:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #e3e6eb;
  --text: #14171c;
  --muted: #6b7280;
  --accent: #0f9f6e;
  --accent-soft: rgba(15, 159, 110, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.12);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.14);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.12);
  --me: #14171c;
  --me-text: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e12;
    --panel: #14171d;
    --panel-2: #1b1f27;
    --line: #262b35;
    --text: #e8ebf0;
    --muted: #8b93a1;
    --accent: #3ddc97;
    --accent-soft: rgba(61, 220, 151, 0.14);
    --blue: #60a5fa;
    --blue-soft: rgba(96, 165, 250, 0.15);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.14);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.14);
    --me: #e8ebf0;
    --me-text: #0c0e12;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login form {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.login .brand { justify-content: center; font-size: 18px; margin-bottom: 4px; }
.login input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login .error { color: var(--red); font-size: 13px; min-height: 18px; }
.login .hint { color: var(--muted); font-size: 12.5px; text-align: center; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px;
  padding: 7px 12px;
  font-weight: 500;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: 0.9; }
.btn.small { padding: 3px 9px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Grundgeruest ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100dvh; }
.nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; padding: 4px 8px 14px; }
.brand img { width: 26px; height: 26px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); font-weight: 650; }
.nav-item .grow { flex: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 4px; }
.nav-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; font-size: 12.5px; color: var(--muted); }
.nav-foot .btn { justify-self: start; white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--accent); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }
.dot.busy { background: var(--blue); animation: puls 1.2s ease-in-out infinite; }
@keyframes puls { 50% { opacity: 0.35; } }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.top h1 { font-size: 18px; margin: 0; font-weight: 650; }
.top .meta { color: var(--muted); font-size: 12.5px; }
.seg { display: none; margin-left: auto; background: var(--panel-2); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 500; }
.seg button.active { background: var(--panel); box-shadow: var(--shadow); }

.body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); min-height: 0; }
.body.nur-chat { grid-template-columns: minmax(0, 1fr); }
.status { overflow: auto; padding: 20px; display: grid; gap: 20px; align-content: start; }
.chat { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.body.nur-chat .chat { border-left: 0; }
.body.nur-chat .chat-inner { max-width: 820px; width: 100%; margin: 0 auto; }

/* ---------- Karten ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 20px; font-weight: 650; margin-top: 2px; overflow-wrap: anywhere; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }

.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.project {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
}
.project:hover { border-color: var(--muted); }
.project .t { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.project .s { color: var(--muted); font-size: 12.5px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > h2 { font-size: 14px; margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.card > h2 .right { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; font-weight: 400; }
.card .empty { padding: 14px; color: var(--muted); }

.row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.card > h2 + .row, .card > h2 + div > .row:first-child { border-top: 0; }
.row .main-col { flex: 1; min-width: 0; }
.row .title { font-weight: 550; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.row-dot { margin-top: 6px; }
.sub.err { color: var(--red); }
.sub.logname { margin-bottom: 4px; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--panel-2); color: var(--muted); }
.chip.ok { background: var(--accent-soft); color: var(--accent); }
.chip.info { background: var(--blue-soft); color: var(--blue); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }

.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.pill.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.alt { color: var(--muted); font-size: 12.5px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.titles { margin-top: 4px; font-size: 12.5px; display: grid; gap: 1px; }
.titles span { color: var(--muted); margin-right: 4px; }

.cmd { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.cmd code { background: var(--panel-2); padding: 3px 7px; border-radius: 6px; overflow-wrap: anywhere; }

details.logs { padding: 0 14px 12px; }
details.logs summary { cursor: pointer; padding: 10px 0; color: var(--muted); }
pre.log { margin: 0 0 10px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; max-height: 180px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Chat ---------- */
.chat-inner { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.chat-head .right { margin-left: auto; }
.msgs { flex: 1; overflow: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.msg.du { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 5px; white-space: pre-wrap; }
.msg.claw { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.msg.fehler { align-self: flex-start; background: var(--red-soft); color: var(--red); }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow: auto; white-space: pre-wrap; margin: 6px 0; }
.msg code { background: var(--bg); padding: 0 4px; border-radius: 4px; }
.msg pre code { background: none; padding: 0; }
.msg ul { margin: 4px 0; padding-left: 20px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: puls 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 280px; }
.chat-empty .big { font-size: 28px; margin-bottom: 6px; }
.composer { display: flex; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 180px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.composer .btn.primary { height: 42px; padding: 0 16px; border-radius: 12px; }

/* ---------- Anmeldung, Formulare, Speicher ---------- */
.login-box { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; display: grid; gap: 6px; background: var(--panel-2); }
.code-line { display: flex; align-items: center; gap: 10px; }
.code { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 1px; }
.ok-text { color: var(--accent); }
.inline-form { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 180px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
.inline-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.bar-row { border-top: 0; padding-top: 6px; padding-bottom: 6px; }
.bar-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.bar i.w1 { width: 5%; }
.bar i.w2 { width: 10%; }
.bar i.w3 { width: 15%; }
.bar i.w4 { width: 20%; }
.bar i.w5 { width: 25%; }
.bar i.w6 { width: 30%; }
.bar i.w7 { width: 35%; }
.bar i.w8 { width: 40%; }
.bar i.w9 { width: 45%; }
.bar i.w10 { width: 50%; }
.bar i.w11 { width: 55%; }
.bar i.w12 { width: 60%; }
.bar i.w13 { width: 65%; }
.bar i.w14 { width: 70%; }
.bar i.w15 { width: 75%; }
.bar i.w16 { width: 80%; }
.bar i.w17 { width: 85%; }
.bar i.w18 { width: 90%; }
.bar i.w19 { width: 95%; }
.bar i.w20 { width: 100%; }
.nav-item .ext { color: var(--muted); font-size: 12px; }
a.nav-item { color: inherit; text-decoration: none; }

/* ---------- Handy ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nav {
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    overflow-x: auto;
    gap: 2px;
    align-items: center;
  }
  .brand { padding: 0 8px 0 2px; font-size: 15px; }
  .brand span { display: none; }
  .nav-sep, .nav-foot .server-line { display: none; }
  .nav-item { width: auto; padding: 7px 10px; }
  .nav-foot { margin: 0 0 0 auto; padding: 0 0 0 6px; }
  .top { padding: 10px 14px; }
  .seg { display: flex; }
  .body, .body.nur-chat { grid-template-columns: 1fr; }
  .body[data-ansicht="status"] .chat { display: none; }
  .body[data-ansicht="chat"] .status { display: none; }
  .body.nur-chat .status { display: none; }
  .chat { border-left: 0; }
  .status { padding: 14px; gap: 14px; }
  .row { flex-wrap: wrap; }
  .row .actions { width: 100%; justify-content: flex-start; }
}
