/* Stefan OS – eigene Layout-Regeln.
   Farben, Typo, Knöpfe, Tags und Felder kommen aus ds/bundle.css (Exportlab-Design-System).
   Hier steht nur, was das Design an Aufbau verlangt und keine Komponente abdeckt.
   Keine Hex-Werte: alles über Tokens. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--shell-bg);
  color: var(--color-text);
  font-family: "Inter", var(--font-sans, system-ui), sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* Schriftart erben, Farbe NICHT: die Knöpfe des Design-Systems setzen ihre eigene
   (btn-primary hat weiße Schrift auf dunklem Verlauf). Eine pauschale
   `color: inherit`-Regel hier überschreibt sie, weil app.css nach bundle.css lädt —
   der Primärknopf wurde dadurch weiß auf weiß und war unlesbar. */
button, input, textarea, select { font: inherit; }
input, textarea, select { color: inherit; }

/* ---------- Gerüst ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; align-items: stretch; }

.sidebar {
  flex: 0 0 220px; display: flex; flex-direction: column; gap: 16px;
  padding: 14px 10px; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.brand__name { font-size: 14px; font-weight: 600; color: var(--color-text-strong); flex: 1; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px;
  border-radius: 8px; color: var(--nav-text); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav__item:hover { background: var(--color-hover); }
.nav__item[aria-current="page"] { background: var(--nav-active); color: var(--color-text-strong); }
.nav__item svg { width: 16px; height: 16px; flex: none; stroke: var(--nav-icon); }
.nav__item[aria-current="page"] svg { stroke: currentColor; }
.nav__count {
  margin-left: auto; font-size: 12px; color: var(--color-subtle);
  font-variant-numeric: tabular-nums;
}
.nav__group { display: flex; flex-direction: column; gap: 1px; }
.nav__sub { padding-left: 26px; font-size: 13px; }

.sidebar__foot { margin-top: auto; padding: 0 6px; display: flex; flex-direction: column; gap: 10px; }
.quota { display: flex; flex-direction: column; gap: 6px; }
.quota__row { display: flex; justify-content: space-between; font-size: 12px; color: var(--color-muted); }
.quota__row b { font-weight: 400; font-variant-numeric: tabular-nums; }
.foot__row { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-subtle); }
.foot__row span { flex: 1; }

.panel {
  flex: 1 1 560px; min-width: 0; margin: 8px; display: flex; flex-direction: column;
  background: var(--shell-panel); border: 1px solid var(--shell-line);
  border-radius: 12px; overflow: hidden;
}
.panel__body { flex: 1; overflow: auto; }
/* Kapitel 06: Seiten nutzen die volle Breite. Kein max-width hier —
   Ordnung entsteht durch Abstände, nicht durch eine Spaltenbegrenzung. */
.pad { padding: 48px 48px 40px; display: flex; flex-direction: column; gap: 24px; }

/* ---------- Überschriften ---------- */
.head { display: flex; flex-direction: column; gap: 6px; }
.head__date { font-size: 13px; color: var(--color-subtle); }
.head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--color-text-strong); }
.head p { margin: 0; font-size: 13px; color: var(--color-muted); }
h2.sub { margin: 0; font-size: 13px; font-weight: 600; color: var(--color-text-strong); }

/* ---------- Listen und Zeilen ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--row-line); flex-wrap: wrap; cursor: pointer;
  background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--color-surface-hover); }
.row[aria-selected="true"] { background: var(--color-hover); }
.row__icon {
  width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--color-border); color: var(--color-text-strong);
}
.row__icon svg { width: 16px; height: 16px; }
.row__main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-size: 14px; font-weight: 500; color: var(--color-text-strong); }
.row__title--unread { font-weight: 600; }
.row__sub { font-size: 13px; color: var(--color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__side { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.row__chevron { width: 16px; height: 16px; color: var(--color-subtle); flex: none; }

/* ---------- Aufklappen ---------- */
.fold { border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.fold__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; width: 100%;
  background: none; border: 0; cursor: pointer; color: var(--color-muted); font-size: 13px; text-align: left;
}
.fold__head:hover { background: var(--color-surface-hover); }
.fold__head svg { width: 14px; height: 14px; transition: transform .15s; }
.fold__head[aria-expanded="true"] svg { transform: rotate(90deg); }
.fold__body { border-top: 1px solid var(--row-line); }

/* ---------- Zwei Spalten (Liste + Detail) ---------- */
.split { display: flex; flex: 1; min-height: 0; }
.split__list { flex: 0 0 380px; border-right: 1px solid var(--shell-line); overflow: auto; min-width: 0; }
.split__detail { flex: 1; overflow: auto; min-width: 0; padding: 32px 36px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Board ---------- */
.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; }
.board__col { flex: 1 1 0; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.board__head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--color-text-strong); }
.board__head span { color: var(--color-subtle); font-weight: 400; font-variant-numeric: tabular-nums; }
.sos-card {
  border: 1px solid var(--color-border); border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--color-bg);
}
.sos-card__title { font-size: 13px; font-weight: 500; color: var(--color-text-strong); }
.sos-card__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- Text und Protokolle ---------- */
.prose { font-size: 14px; line-height: 1.65; color: var(--color-text); white-space: pre-wrap; word-break: break-word; }
.prose--muted { color: var(--color-muted); font-size: 13px; }
.boxed {
  border: 1px solid var(--color-border); border-radius: 10px; padding: 16px 18px;
  background: var(--color-surface-alt);
}
.boxed--warn { border-color: var(--tag-amber-bd); background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.boxed--error { border-color: var(--tag-red-bd); background: var(--tag-red-bg); color: var(--tag-red-fg); }
.boxed--info { border-color: var(--tag-blue-bd); background: var(--tag-blue-bg); color: var(--tag-blue-fg); }

/* Fremder Text (Mails, Agenten-Protokolle) — nur über textContent gefüllt */
.log {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6;
  background: var(--shell-bg); border: 1px solid var(--color-border); border-radius: 10px;
  padding: 14px 16px; max-height: 420px; overflow: auto;
}
.log__line { display: flex; gap: 10px; padding: 1px 0; }
.log__line time { color: var(--color-subtle); flex: none; font-variant-numeric: tabular-nums; }
.log__line b { flex: none; width: 62px; font-weight: 400; color: var(--color-muted); }
.log__line.tool b { color: var(--color-info); }
.log__line.fehler b, .log__line.fehler span { color: var(--color-danger); }
.log__line.nachricht b { color: var(--tag-purple-fg); }
.log__line.ergebnis b { color: var(--color-success-text); }
.log__line span { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 680px; }
.form__label { font-size: 13px; color: var(--color-muted); }
.ta {
  width: 100%; min-height: 120px; padding: 12px 14px; border-radius: var(--radius-control, 8px); resize: vertical;
  background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text);
}
.ta:focus, .inp:focus { outline: none; border-color: var(--color-border-hover); box-shadow: var(--field-ring); }
/* Höhe und Radius aus dem Token-Satz (field-h 36, radius-control 8) */
.inp {
  height: var(--field-h, 36px); padding: 0 12px; width: 100%;
  border-radius: var(--radius-control, 8px);
  background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions--end { justify-content: flex-end; }
.sendrow { display: flex; gap: 8px; align-items: flex-end; }
.sendrow .inp { flex: 1; }

/* ---------- Leerzustände ---------- */
.empty { padding: 56px 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; color: var(--color-muted); font-size: 13px; }
.empty h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--color-text-strong); }   /* Stufe Title */

/* ---------- Meldung ---------- */
.sos-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--color-tooltip); color: var(--color-text-strong);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: var(--z-toast, 10100);
  box-shadow: var(--shadow-overlay);
}
.sos-toast.show { opacity: 1; }

/* ---------- Mobil: Aufbau wie die Claude-App ---------- */
.mhead {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  position: sticky; top: 0; background: var(--shell-bg); z-index: var(--z-overlay, 10000);
}
.mhead__title { flex: 1; text-align: center; font-size: 13px; color: var(--color-subtle); }
.mbar {
  position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--shell-bg); border-top: 1px solid var(--shell-line);
  display: flex; gap: 8px; align-items: flex-end;
}
.drawer {
  position: fixed; inset: 0; z-index: var(--z-overlay, 10000); display: none;
  background: color-mix(in srgb, var(--shell-bg) 70%, transparent);
}
.drawer.open { display: block; }
.drawer__panel {
  width: min(300px, 86vw); height: 100%; padding: 14px 10px;
  background: var(--shell-panel); border-right: 1px solid var(--shell-line);
  display: flex; flex-direction: column; gap: 16px;
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .panel { margin: 0; border: 0; border-radius: 0; min-height: 100dvh; }
  .pad { padding: 20px 16px 32px; gap: 24px; max-width: none; }
  /* Mobil eine Stufe kleiner: Headline 22 -> Title 17, statt eines Zwischenwerts */
  .head h1 { font-size: 17px; letter-spacing: -0.01em; }
  .split { flex-direction: column; }
  .split__list { flex: none; border-right: 0; border-bottom: 1px solid var(--shell-line); max-height: 45vh; }
  .split__detail { padding: 20px 16px; }
  .board { flex-direction: column; }
  /* Tippflächen mindestens 44 px, wie im Design gefordert */
  .row, .nav__item, .fold__head { min-height: 44px; }
}
@media (min-width: 861px) { .mhead, .mbar, .drawer { display: none !important; } }
