/* Console – Stil nach ~/Desktop/API/DESIGN.md (shadcn-Monochrom, hell)
   plus rein schwarzer Dark Mode nach Taygers Vorgabe (wie Space). */
:root {
  --color-canvas: #f5f5f5;
  --color-paper: #ffffff;
  --color-surface-alt: #fafafa;
  --color-ink: #0a0a0a;
  --color-ink-soft: #171717;
  --color-mid: #737373;
  --color-hairline: #e5e5e5;
  --color-ember: #e7000b;
  --color-grau-a: #a3a3a3;
  --color-grau-b: #d4d4d4;
  --color-grau-c: #e5e5e5;
  --font-geist: 'Geist', 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-card: 0 0 0 1px rgba(23, 23, 23, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --radius-card: 24px;
  --radius-pill: 18px;
  --radius-nested: 10px;
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-border: rgba(255, 255, 255, 0.55);
  --shadow-dock: 0 1px 1px rgba(23, 23, 23, 0.06), 0 12px 32px rgba(23, 23, 23, 0.14), 0 4px 12px rgba(23, 23, 23, 0.08);
}

/* Dunkel per Systemeinstellung, wenn nicht ausdrücklich "Hell" gewählt.
   Reines Schwarz: Karten teilen die Fläche mit dem Canvas und leben von der Hairline. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-canvas: #000000;
    --color-paper: #000000;
    --color-surface-alt: #050505;
    --color-ink: #ffffff;
    --color-ink-soft: #f2f2f2;
    --color-mid: #8f8f8f;
    --color-hairline: rgba(255, 255, 255, 0.14);
    --color-ember: #ff3b30;
    --color-grau-a: #6b6b6b;
    --color-grau-b: #3a3a3a;
    --color-grau-c: #222222;
    --glass-bg: rgba(10, 10, 10, 0.62);
    --glass-border: rgba(255, 255, 255, 0.12);
    --shadow-dock: 0 1px 1px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.4);
  }
  :root:not([data-theme="light"]) .search { border-color: var(--color-hairline); }
}
:root[data-theme="dark"] {
  --color-canvas: #000000;
  --color-paper: #000000;
  --color-surface-alt: #050505;
  --color-ink: #ffffff;
  --color-ink-soft: #f2f2f2;
  --color-mid: #8f8f8f;
  --color-hairline: rgba(255, 255, 255, 0.14);
  --color-ember: #ff3b30;
  --color-grau-a: #6b6b6b;
  --color-grau-b: #3a3a3a;
  --color-grau-c: #222222;
  --glass-bg: rgba(10, 10, 10, 0.62);
  --glass-border: rgba(255, 255, 255, 0.12);
  --shadow-dock: 0 1px 1px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.4);
}
:root[data-theme="dark"] .search { border-color: var(--color-hairline); }

/* ── Grundlagen ─────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-geist);
  font-size: 14px;
  line-height: 1.43;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.2; font-weight: 600; letter-spacing: -0.75px; }
h2 { font-size: 18px; line-height: 1.56; font-weight: 600; }
.mid { color: var(--color-mid); }
.klein { font-size: 12px; line-height: 1.33; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Bildschirme (Laden, Anmelden) ──────────── */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .lede { margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; line-height: 1.33; letter-spacing: 0.6px; text-transform: uppercase; color: var(--color-mid); }
.auth-msg { min-height: 20px; margin: 8px 0 12px; color: var(--color-mid); }
.auth-msg.error { color: var(--color-ember); }
.auth-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--color-hairline); border-top-color: var(--color-ink);
  animation: dreh 0.8s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

/* ── Karten, Knöpfe, Eingaben, Badges ───────── */
.card {
  background: var(--color-paper);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; font-weight: 500; }

.btn, .btn-ghost, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500; border: none; white-space: nowrap;
  text-decoration: none;
}
.btn { background: var(--color-ink); color: var(--color-canvas); }
.btn-ghost { background: var(--color-canvas); color: var(--color-ink); }
.btn-outline { background: transparent; color: var(--color-ink); border: 1px solid var(--color-hairline); }
.btn[disabled], .btn-ghost[disabled], .btn-outline[disabled] { opacity: 0.5; cursor: default; }
.btn-text { background: none; border: none; padding: 0; color: var(--color-mid); font-size: 14px; }
.btn-text:hover { color: var(--color-ink); }
.btn-destructive { background: none; border: none; padding: 0; color: var(--color-ember); font-size: 14px; font-weight: 500; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-pill); border: none;
  background: transparent; color: var(--color-mid); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--color-canvas); color: var(--color-ink); }
.icon-btn svg, .btn svg, .btn-ghost svg { width: 18px; height: 18px; }

.search {
  width: 100%; height: 36px; padding: 8px 12px;
  background: var(--color-canvas); color: var(--color-ink);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font: inherit; outline: none; -webkit-appearance: none;
}
.search::placeholder { color: var(--color-mid); }
.search:focus { border-color: var(--color-hairline); }

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 2px 8px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge-solid { background: var(--color-ink-soft); color: var(--color-canvas); }
.badge-soft { background: var(--color-canvas); color: var(--color-ink-soft); }
.badge-outline { background: transparent; color: var(--color-ink); border: 1px solid var(--color-hairline); }
.badge-ember { color: var(--color-ember); border: 1px solid var(--color-hairline); }

/* ── App-Rahmen: Sidebar (Desktop) / Dock (Handy) ── */
#app-screen { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.nav {
  display: flex; align-items: center; gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; color: var(--color-mid);
  border-radius: var(--radius-pill); padding: 8px 12px; font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item.active { color: var(--color-ink); background: var(--color-canvas); }
.nav-brand { display: none; }
.nav-foot { display: none; }

.main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px 16px 120px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 40px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-user { display: none; }

.theme-switch { display: inline-flex; gap: 2px; background: var(--color-canvas); border-radius: var(--radius-pill); padding: 2px; }
.theme-switch .icon-btn { width: 32px; height: 32px; }
.theme-switch .icon-btn.active { background: var(--color-paper); color: var(--color-ink); box-shadow: var(--shadow-card); }

/* Handy: Dock unten, Frosted Glass (nur die Navigation bekommt Glas). */
@media (max-width: 767px) {
  .nav {
    position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-50%); z-index: 20;
    padding: 6px; border-radius: 28px;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
    box-shadow: var(--shadow-dock);
  }
  .nav-item { flex-direction: column; gap: 3px; padding: 8px 14px; font-size: 11px; line-height: 1; }
  .nav-item svg { width: 20px; height: 20px; }
}

/* Desktop: Sidebar links (#fafafa), eine Tonstufe über dem Canvas. */
@media (min-width: 768px) {
  #app-screen { grid-template-columns: 240px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--color-surface-alt); padding: 20px 12px;
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; padding: 8px 12px 20px; font-weight: 600; font-size: 16px; letter-spacing: -0.4px; }
  .nav-brand img { width: 28px; height: 28px; border-radius: 8px; }
  .nav-item { width: 100%; text-align: left; }
  .nav-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding: 8px 4px 0; }
  .nav-foot .theme-switch { align-self: flex-start; }
  .main { padding: 32px 32px 48px; }
  .topbar { margin-bottom: 24px; }
  .topbar .theme-switch, .topbar #logout-btn { display: none; }
  .topbar-user { display: block; }
}

/* ── Raster und Kacheln ─────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
@media (min-width: 768px) { .span-2 { grid-column: span 2; } }
.stat-label { font-size: 12px; line-height: 1.33; letter-spacing: 0.6px; text-transform: uppercase; color: var(--color-mid); }
.stat-value { font-size: 36px; line-height: 1.11; font-weight: 600; letter-spacing: -0.9px; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--color-mid); }
.stand-zeile { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 16px; color: var(--color-mid); font-size: 12px; }

/* Listenzeilen (Posts, Kanäle) */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--color-hairline); min-width: 0; }
.row:first-child { border-top: none; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-canvas); object-fit: cover; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--color-mid); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { text-align: right; color: var(--color-mid); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
.row-side strong { display: block; color: var(--color-ink); font-size: 14px; font-weight: 500; }

/* Diagramme: nur Grautöne */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { width: 120px; height: 120px; flex: none; }
.donut circle { fill: none; stroke-width: 14; }
.seg-0 { stroke: var(--color-ink); }
.seg-1 { stroke: var(--color-mid); }
.seg-2 { stroke: var(--color-grau-a); }
.seg-3 { stroke: var(--color-grau-b); }
.seg-4 { stroke: var(--color-grau-c); }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-dot.seg-0 { background: var(--color-ink); }
.legend-dot.seg-1 { background: var(--color-mid); }
.legend-dot.seg-2 { background: var(--color-grau-a); }
.legend-dot.seg-3 { background: var(--color-grau-b); }
.legend-dot.seg-4 { background: var(--color-grau-c); }
.legend-row .legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .legend-val { color: var(--color-mid); font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 56px; display: block; margin-top: 8px; }
.spark polyline { fill: none; stroke: var(--color-ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .spark-area { fill: var(--color-canvas); stroke: none; }

/* Tabellen (Detail) */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: right; padding: 8px 0; border-top: 1px solid var(--color-hairline); white-space: nowrap; }
.table th { font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--color-mid); font-weight: 500; border-top: none; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th + th, .table td + td { padding-left: 14px; }
.table-wrap { overflow-x: auto; }

/* Leerzustände, Hinweise, Toast */
.empty { color: var(--color-mid); padding: 8px 0; }
.hinweis { color: var(--color-mid); font-size: 12px; line-height: 1.5; margin-top: 12px; }
.hinweis code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.verbinden-form { display: flex; gap: 8px; margin-top: 12px; }
.verbinden-form .search { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin-top: 12px; }
.kv dt { color: var(--color-mid); }
.kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; max-width: calc(100vw - 32px);
  background: var(--color-ember); color: #fff; padding: 10px 16px; border-radius: var(--radius-pill);
  font-weight: 500; box-shadow: var(--shadow-dock);
}
.toast-neutral { background: var(--color-ink); color: var(--color-canvas); }
@media (min-width: 768px) { .toast { bottom: 24px; } }
