/* ===== Jarvis Dashboard – Design Tokens ===== */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222221;
  --surface-3: #2a2a28;
  --border: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);
  --grid: #2c2c2a;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #898781;
  --accent: #3987e5;
  --accent-soft: rgba(57,135,229,0.16);
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-soft: rgba(12,163,12,0.16);
  --warning-soft: rgba(250,178,25,0.16);
  --serious-soft: rgba(236,131,90,0.16);
  --critical-soft: rgba(208,59,59,0.16);
  --series-1: #3987e5;
  --series-1-dim: #184f95;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --drawer-w: 420px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f4f4f1;
  --surface-3: #ebebe7;
  --border: rgba(11,11,11,0.10);
  --border-strong: rgba(11,11,11,0.18);
  --grid: #e1e0d9;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --text-3: #898781;
  --accent: #2a78d6;
  --accent-soft: rgba(42,120,214,0.12);
  --good: #006300;
  --good-soft: rgba(12,163,12,0.14);
  --warning-soft: rgba(250,178,25,0.22);
  --serious-soft: rgba(236,131,90,0.20);
  --critical-soft: rgba(208,59,59,0.12);
  --series-1: #2a78d6;
  --series-1-dim: #9ec5f4;
  --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--text-3); }
.sec { color: var(--text-2); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }
svg.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.icon.sm { width: 14px; height: 14px; }
svg.icon.lg { width: 22px; height: 22px; }

/* ===== App Shell ===== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #9085e9);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text-1); }
.nav a.active { background: var(--accent-soft); color: var(--text-1); }
.nav a.active svg { color: var(--accent); }
.nav .badge { margin-left: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 16px 10px 6px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--border); font-size: 12.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.off { background: var(--text-3); box-shadow: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; }

/* ===== Buttons, Badges, Chips ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-1);
  font-weight: 500; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn.danger { color: var(--critical); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn.icon-only { padding: 7px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.6;
  background: var(--surface-3); color: var(--text-2);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.serious { background: var(--serious-soft); color: var(--serious); }
.badge.critical { background: var(--critical-soft); color: var(--critical); }
:root[data-theme="light"] .badge.warning { color: #7a5200; }
:root[data-theme="light"] .badge.serious { color: #9a3d16; }
.badge.count { background: var(--critical); color: #fff; padding: 0 7px; min-width: 20px; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); background: var(--surface-1); }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--text-1); }
.chip:hover { border-color: var(--border-strong); }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text-3); }

/* ===== Cards & Grids ===== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { flex: 1; }
.card-head .link { font-size: 12.5px; color: var(--accent); font-weight: 500; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ===== Hero / Greeting ===== */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.hero h1 { font-size: 26px; }
.hero .sub { color: var(--text-2); margin-top: 4px; }

/* ===== Stat tiles ===== */
.stat { padding: 16px 18px; }
.stat .label { font-size: 12.5px; color: var(--text-2); }
.stat .value { font-size: 28px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; }
.stat .delta { font-size: 12px; margin-top: 2px; color: var(--text-3); }
.stat .delta.up { color: var(--good); }
.stat .delta.down { color: var(--critical); }
.sparkline { width: 100%; height: 36px; margin-top: 8px; display: block; }
.sparkline .line { fill: none; stroke: var(--series-1); stroke-width: 2; }
.sparkline .area { fill: var(--series-1); opacity: 0.12; }
.sparkline .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }

/* ===== Bar chart (7 Tage) ===== */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 120px; padding-top: 8px; border-bottom: 1px solid var(--grid); }
.bar { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar i { display: block; background: var(--series-1-dim); border-radius: 4px 4px 0 0; min-height: 3px; transition: background .15s; }
.bar.today i { background: var(--series-1); }
.bar:hover i { background: var(--series-1); }
.bar .tip { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border-strong); padding: 4px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; }
.bar:hover .tip { opacity: 1; }
.bar-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; font-size: 11.5px; color: var(--text-3); text-align: center; margin-top: 6px; }

/* ===== Lists ===== */
.list { display: flex; flex-direction: column; }
.list > li { padding: 11px 0; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.list .time { color: var(--text-3); font-size: 12px; min-width: 44px; font-variant-numeric: tabular-nums; }
.list .body { flex: 1; min-width: 0; }
.list .title { font-weight: 500; }
.list .meta { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.ev-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.ev-icon.good { background: var(--good-soft); color: var(--good); }
.ev-icon.warning { background: var(--warning-soft); color: var(--warning); }
.ev-icon.accent { background: var(--accent-soft); color: var(--accent); }
.ev-icon.critical { background: var(--critical-soft); color: var(--critical); }

/* ===== Agenda ===== */
.agenda li { display: grid; grid-template-columns: 56px 3px 1fr; gap: 12px; padding: 8px 0; }
.agenda .t { color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.agenda .bar-mark { background: var(--accent); border-radius: 2px; }
.agenda .bar-mark.alt { background: var(--series-1-dim); }

/* ===== Approvals ===== */
.approval { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.approval + .approval { margin-top: 10px; }
.approval .head { display: flex; align-items: center; gap: 8px; }
.approval .head strong { flex: 1; }
.approval .action { font-family: var(--mono); font-size: 12.5px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text-2); white-space: pre-wrap; }
.approval .reason { font-size: 13px; color: var(--text-2); }
.approval .foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.approval .foot .muted { margin-left: auto; font-size: 12px; }
.approval.done { opacity: .5; }

/* ===== Area status row ===== */
.areas-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.area-pill { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.area-pill .name { font-weight: 500; font-size: 13px; }
.area-pill .perm { font-size: 11.5px; color: var(--text-3); }
.area-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }

/* ===== Area cards (Zugriffe) ===== */
.area-card { display: flex; flex-direction: column; gap: 12px; }
.area-card .top { display: flex; align-items: center; gap: 12px; }
.area-card .top h3 { font-size: 15px; }
.area-card .desc { color: var(--text-2); font-size: 13px; }
.area-card .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12.5px; }
.area-card .kv dt { color: var(--text-3); }
.area-card .kv dd { margin: 0; }
.area-card .foot { display: flex; gap: 8px; margin-top: auto; }
.area-card.add { border-style: dashed; align-items: center; justify-content: center; text-align: center; color: var(--text-3); min-height: 220px; gap: 8px; }
.area-card.add:hover { border-color: var(--accent); color: var(--text-1); }

/* ===== Segment control ===== */
.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segment button { padding: 6px 14px; border-radius: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.segment button.active { background: var(--accent); color: var(--accent-ink); }
.segment.lg button { padding: 10px 18px; }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .title { font-weight: 500; }
.table .sub { font-size: 12px; color: var(--text-3); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .toolbar { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-3); min-width: 240px; }
.search input { background: none; border: 0; outline: 0; flex: 1; color: var(--text-1); }
.search input::placeholder { color: var(--text-3); }

/* ===== Status indicator ===== */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.running { color: var(--accent); }
.status.running::before { animation: pulse 1.2s infinite; }
.status.warning { color: var(--warning); }
.status.critical { color: var(--critical); }
.status.muted { color: var(--text-3); }
:root[data-theme="light"] .status.warning { color: #7a5200; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ===== Run detail / timeline ===== */
.run-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.run-head .crumbs { font-size: 12.5px; color: var(--text-3); }
.run-head .crumbs a:hover { color: var(--text-1); }
.run-head h1 { font-size: 22px; }
.kv-row { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; }
.kv-row div span { display: block; color: var(--text-3); font-size: 11.5px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 6px; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: 12px; position: relative; }
.step .node { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); z-index: 1; }
.step .node.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.step .node.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.step .node.warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 15.5px; top: 32px; bottom: -6px; width: 1px; background: var(--border); }
.step .box { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.step .box > summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.step .box > summary::-webkit-details-marker { display: none; }
.step .box > summary .t { font-weight: 500; flex: 1; }
.step .box > summary .d { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.step .box > summary .chev { transition: transform .15s; color: var(--text-3); }
.step .box[open] > summary .chev { transform: rotate(90deg); }
.step .box .inner { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.io { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.io pre, .step .box pre { margin: 0; font-family: var(--mono); font-size: 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 10px; white-space: pre-wrap; color: var(--text-2); max-height: 220px; overflow: auto; }
.io .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 4px; }
.thought { font-size: 13px; color: var(--text-2); font-style: italic; }

/* ===== Chat ===== */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - var(--topbar-h) - 56px); min-height: 520px; }
.conv-list { display: flex; flex-direction: column; overflow: auto; }
.conv-list .conv { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.conv-list .conv:hover { background: var(--surface-2); }
.conv-list .conv.active { background: var(--accent-soft); }
.conv-list .conv .t { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-list .conv .m { font-size: 12px; color: var(--text-3); }
.chat { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.chat .messages { flex: 1; overflow: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 760px; display: flex; gap: 10px; }
.msg .avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.msg.ai .avatar { background: linear-gradient(135deg, var(--accent), #9085e9); color: #fff; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; line-height: 1.55; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg .bubble p + p { margin-top: 8px; }
.msg .bubble ul { list-style: disc; padding-left: 18px; margin: 6px 0; }
.tool-call { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); margin: 8px 0; overflow: hidden; }
.tool-call summary { list-style: none; cursor: pointer; padding: 7px 10px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary .name { font-family: var(--mono); color: var(--text-1); }
.tool-call summary .dur { margin-left: auto; color: var(--text-3); font-size: 11.5px; }
.tool-call .inner { padding: 0 10px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-call pre { margin: 0; font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border-radius: 6px; padding: 8px; white-space: pre-wrap; color: var(--text-2); }
.composer { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; resize: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; outline: 0; min-height: 44px; }
.composer textarea:focus { border-color: var(--accent); }
.composer .actions { display: flex; align-items: center; gap: 6px; }
.composer .actions .spacer { flex: 1; }

/* ===== Chat Drawer ===== */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: var(--drawer-w); max-width: 100vw; background: var(--surface-1); border-left: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(100%); transition: transform .22s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer .drawer-head { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.drawer .drawer-head h2 { flex: 1; font-size: 15px; }
.drawer .chat { flex: 1; border: 0; border-radius: 0; background: transparent; }
.drawer .messages { padding: 16px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ===== Memory ===== */
.mem { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); align-items: start; }
.mem:first-child { border-top: 0; }
.mem .text { font-size: 14px; }
.mem .meta { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.mem .acts { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.mem:hover .acts { opacity: 1; }
.mem-type { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ===== Settings ===== */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.settings-nav a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); }
.settings-nav a.active, .settings-nav a:hover { background: var(--surface-2); color: var(--text-1); }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); align-items: center; }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting .lbl { font-weight: 500; }
.setting .help { font-size: 12.5px; color: var(--text-3); margin-top: 2px; max-width: 520px; }
.select { padding: 7px 32px 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.toggle { width: 40px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s; }
.toggle.on { background: var(--accent); border-color: transparent; }
.toggle.on::after { transform: translateX(18px); background: #fff; }
.autonomy { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.autonomy .opt { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; cursor: pointer; background: var(--surface-2); }
.autonomy .opt.active { border-color: var(--accent); background: var(--accent-soft); }
.autonomy .opt strong { display: block; margin-bottom: 4px; }
.autonomy .opt span { font-size: 12.5px; color: var(--text-2); }
.rule { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.rule:first-child { border-top: 0; }
.rule .txt { flex: 1; }

/* ===== Toast ===== */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-1); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: all .2s; z-index: 50; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 45; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .conv-list { display: none; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: flex; gap: 4px; overflow: auto; }
  .autonomy { grid-template-columns: 1fr; }
  .io, .tool-call .inner { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .topbar .hide-sm { display: none; }
}

/* ===================== App-spezifisch (Jarvis v1) ===================== */
.chat-page { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - var(--topbar-h) - 40px); min-height: 480px; }
.content.chat-content { padding: 20px 24px; max-width: none; }
.conv-list .conv { display: flex; align-items: center; gap: 8px; }
.conv-list .conv .t { flex: 1; }
.conv-list .conv .del { opacity: 0; color: var(--text-3); }
.conv-list .conv:hover .del { opacity: 1; }
.chat .messages { scroll-behavior: smooth; }
.msg .bubble { max-width: 100%; word-wrap: break-word; }
.msg.ai .bubble { background: transparent; border-color: transparent; padding: 4px 2px; font-size: 15px; line-height: 1.6; }
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3 { font-size: 15px; margin: 10px 0 4px; }
.msg .bubble ol { padding-left: 20px; margin: 6px 0; }
.msg .bubble code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.msg .bubble pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow: auto; margin: 8px 0; }
.msg .bubble pre code { background: none; padding: 0; }
.msg .bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg.user .bubble { white-space: pre-wrap; }
.msg .meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; display: flex; gap: 10px; align-items: center; }
.msg.user .meta { justify-content: flex-end; }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: -2px; margin-left: 2px; border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0 } }
.thinking-dots { display: inline-flex; gap: 4px; padding: 6px 2px; }
.thinking-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .15s } .thinking-dots i:nth-child(3) { animation-delay: .3s }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity: .4 } 40% { transform: translateY(-4px); opacity: 1 } }

/* Tool-Karten im Chat */
.tool-cards { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.tool-card { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; max-width: 560px; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tool-card .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tool-card .ic.ok { background: var(--good-soft); color: var(--good); }
.tool-card .ic.err { background: var(--critical-soft); color: var(--critical); }
.tool-card .ic.run svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.tool-card .nm { font-family: var(--mono); font-size: 12.5px; color: var(--text-1); }
.tool-card .sm { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.tool-card .st { margin-left: auto; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.tool-card .body { min-width: 0; flex: 1; }

/* Modal / Pop-up */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); display: none; place-items: center; z-index: 60; padding: 20px; }
.modal-scrim.show { display: grid; }
.modal { width: min(720px, 100%); max-height: 86vh; overflow: auto; background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0 } to { transform: none; opacity: 1 } }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-1); }
.modal .mh h2 { flex: 1; font-size: 15px; }
.modal .mb { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal pre { margin: 0; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; color: var(--text-2); }
.modal .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 4px; }
.modal.approval .mh { border-bottom-color: var(--warning); }

/* Composer */
.composer { gap: 10px; }
.composer textarea { min-height: 48px; max-height: 200px; font-size: 15px; }
.composer .mic { position: relative; }
.composer .mic.rec { background: var(--critical); border-color: transparent; color: #fff; }
.composer .mic.rec::after { content: ""; position: absolute; inset: -4px; border-radius: 10px; border: 2px solid var(--critical); animation: ring 1s ease-out infinite; }
@keyframes ring { from { opacity: .8; transform: scale(1) } to { opacity: 0; transform: scale(1.25) } }
.voice-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); background: var(--surface-2); }
.voice-bar .lvl { width: 90px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.voice-bar .lvl i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s; }
.voice-bar .state { font-weight: 500; color: var(--text-1); min-width: 90px; }
.voice-bar .state.listen { color: var(--critical); }
.voice-bar .state.speak { color: var(--accent); }
.voice-bar .spacer { flex: 1; }
.voice-bar .toggle { width: 34px; height: 20px; }
.voice-bar .toggle::after { width: 14px; height: 14px; }
.voice-bar .toggle.on::after { transform: translateX(14px); }
.notice { align-self: center; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; }
.empty-state { margin: auto; text-align: center; color: var(--text-3); max-width: 420px; }
.empty-state h2 { color: var(--text-1); font-size: 20px; margin-bottom: 6px; }
.empty-state .sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.conn .status-dot { width: 7px; height: 7px; }
.conn.off .status-dot { background: var(--critical); box-shadow: none; }
@media (max-width: 860px) {
  .chat-page { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 32px); }
  .conv-list { display: none; }
}
