/* ============================================================================
   THE MARVIN CONSOLE — design system (Epic 9, Story 9.1 foundation)
   A calm, precise instrument panel for a thinking being. Dark-first, warm ink,
   signal-amber. Serif display (the "person") against monospace data (the
   "machine"). Theme-aware. CSP-safe: system font stacks, no external assets.
   9.2-9.4 extend these tokens + components; do not fork them.
   ============================================================================ */

:root {
  /* type — the signature pairing */
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua",
    Palatino, "URW Palladio L", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code",
    "Roboto Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  /* dark "cockpit at night" — the default */
  --ink: #0e0d0b;
  --panel: #15120e;
  --panel-2: #1c1811;
  --line: #2b2519;
  --line-soft: #201b13;
  --text: #ece6d8;
  --muted: #9a927f;
  --dim: #675f50;
  --amber: #e6a53a;
  --amber-dim: #a97d2e;
  --amber-glow: rgba(230, 165, 58, 0.16);
  --teal: #67b3a3;
  --red: #d6725e;
  --violet: #b49ad6;      /* Story 20.4: self-observation badge (dark) */
  --violet-dim: #8f74bd;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 18px 40px -24px rgba(0, 0, 0, 0.8);

  --rail-w: 232px;
  --bar-h: 52px;
  --radius: 3px;
  --tap: 0.14s cubic-bezier(0.2, 0, 0, 1);
}

:root[data-theme="light"] {
  /* light "daylight almanac" — warm paper */
  --ink: #efe9db;
  --panel: #f6f1e6;
  --panel-2: #ede6d5;
  --line: #d6ccb6;
  --line-soft: #e2d9c6;
  --text: #211d16;
  --muted: #6f6754;
  --dim: #9a917b;
  --amber: #9c6410;
  --amber-dim: #b98a3a;
  --amber-glow: rgba(156, 100, 16, 0.12);
  --teal: #2f7d6e;
  --red: #a8442f;
  --violet: #6d4fa8;      /* Story 20.4: self-observation badge (light) */
  --violet-dim: #8a6dc0;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.5), 0 16px 34px -26px rgba(60, 44, 20, 0.5);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #efe9db; --panel: #f6f1e6; --panel-2: #ede6d5; --line: #d6ccb6;
    --line-soft: #e2d9c6; --text: #211d16; --muted: #6f6754; --dim: #9a917b;
    --amber: #9c6410; --amber-dim: #b98a3a; --amber-glow: rgba(156,100,16,0.12);
    --teal: #2f7d6e; --red: #a8442f;
    --violet: #6d4fa8; --violet-dim: #8a6dc0;
    --shadow: 0 1px 0 rgba(255,255,255,0.5), 0 16px 34px -26px rgba(60,44,20,0.5);
  }
}

* { box-sizing: border-box; }
/* Story 18.9: the `hidden` attribute MUST win over component display rules (e.g. `.pending { display: flex }`),
   otherwise JS toggling the `hidden` attribute has no visual effect — the "thinking…" pending strip was never
   actually cleared after a turn. An author-stylesheet reset (with !important) fixes this for every hidden-attr
   element in one rule. Elements that toggle via a `.hidden` CLASS (.gate, .restart-overlay) are unaffected. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--ink);
  /* atmosphere: a faint amber vignette + a hairline dot-grid (the instrument texture) */
  background-image:
    radial-gradient(120% 80% at 82% -10%, var(--amber-glow), transparent 60%),
    radial-gradient(var(--line-soft) 0.6px, transparent 0.6px);
  background-size: auto, 22px 22px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* grain overlay — subtle machined texture */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.025; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- primitives ---------------------------------------------------------- */
.mono-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
}
.serif { font-family: var(--font-display); }
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* the live "heartbeat" — the thinking machine's pulse */
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--dim);
  box-shadow: 0 0 0 0 transparent; flex: none;
}
.pulse.ok { background: var(--teal); animation: beat 2.6s ease-in-out infinite; }
.pulse.warn { background: var(--amber); animation: beat 1.4s ease-in-out infinite; }
.pulse.err { background: var(--red); }
@keyframes beat {
  0%, 100% { box-shadow: 0 0 0 0 var(--amber-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none !important; } }

/* ---- app shell ----------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--bar-h) 1fr; height: 100vh; }

.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 18px;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--panel), var(--ink));
}
.wordmark { font-family: var(--font-display); font-size: 20px; letter-spacing: 0.01em;
  color: var(--text); font-weight: 600; }
.wordmark b { color: var(--amber); font-weight: 600; }
.topbar .spacer { flex: 1; }
.status-chip { display: flex; align-items: center; gap: 8px; }
.status-chip .txt { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

.rail {
  border-right: 1px solid var(--line); background: var(--panel);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.rail .group { margin: 14px 8px 6px; }
.nav {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: var(--radius); color: var(--muted); cursor: pointer;
  border: 1px solid transparent; transition: background var(--tap), color var(--tap);
  font-size: 13px; letter-spacing: 0.02em; user-select: none;
}
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.active { background: var(--panel-2); color: var(--text); border-color: var(--line);
  box-shadow: inset 2px 0 0 var(--amber); }
.nav .k { font-family: var(--font-mono); font-size: 15px; width: 18px; text-align: center;
  color: var(--amber-dim); }
.nav.active .k { color: var(--amber); }
.nav .soon { margin-left: auto; font-size: 9px; letter-spacing: 0.12em;
  color: var(--dim); text-transform: uppercase; }

.main { overflow-y: auto; padding: 30px 34px 48px; }
.main-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
.main-head h1 { font-family: var(--font-display); font-weight: 600; font-size: 27px;
  margin: 0; letter-spacing: 0.005em; }
.main-head .sub { color: var(--muted); font-size: 12px; }
.lede { color: var(--muted); max-width: 62ch; margin: 10px 0 26px;
  font-size: 13.5px; line-height: 1.6; }

/* ---- panels + rows ------------------------------------------------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft); background: var(--panel-2); }
.panel-head .mono-label { color: var(--muted); }
.panel-body { padding: 6px 16px 14px; }

/* Story 24.2: the read-only "who does what" model-routing table (grouped by vendor). */
.routing-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.routing-table th, .routing-table td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.routing-table thead th { color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em; }
.routing-table th.routing-vendor {
  background: var(--panel-2); color: var(--text); font-weight: 700; font-size: 12px;
  padding-top: 10px;
}
.routing-table td.routing-role { font-weight: 600; white-space: nowrap; }
.routing-table td.routing-purpose { color: var(--muted); }
/* P5 Edge F2: a custom/experimental model id can be long — wrap it within the cell rather than
   clip it (the panel is overflow:hidden), so no id is ever truncated out of view. */
.routing-table td.routing-model { word-break: break-word; }
/* Story 24.4: the per-role model picker (select + reset + state) inside the model cell. */
.routing-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.routing-select { max-width: 260px; font-size: 12px; padding: 3px 6px; }
.routing-reset { font-size: 11px; padding: 2px 8px; }
.routing-state { font-size: 11px; color: var(--muted); }
.routing-state.overridden { color: var(--accent, #b58900); font-weight: 600; }
/* Story 24.5: the smoke-validate verdict badge (✓/✗/⚠) shown when a model is picked. */
.routing-apply-anyway { font-size: 11px; padding: 2px 8px; }
.routing-validity { font-size: 11px; font-weight: 600; }
.routing-validity.pending { color: var(--muted); font-weight: 400; }
.routing-validity.ok { color: var(--ok, #2aa198); }
.routing-validity.warn { color: var(--accent, #b58900); }
.routing-validity.fail { color: var(--bad, #dc322f); }
.routing-validity[hidden], .routing-apply-anyway[hidden] { display: none; }
/* Story 24.6: the unobtrusive "newer available" stay-current badge (honest — "available", not
   "recommended") + its Adopt affordance, which reuses the 24.5 validate gate. */
.routing-newer { font-size: 11px; color: var(--muted); font-style: italic; max-width: 260px; overflow-wrap: anywhere; word-break: break-word; }

/* Story 24.3: the read-only "available models per provider" view (grouped by vendor + freshness). */
.models-bar { margin: 8px 0 4px; }
.models-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.models-vendor { border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; }
.models-vendor-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.models-vendor-name { font-weight: 700; font-size: 13px; color: var(--text); }
.models-count { color: var(--muted); font-size: 12px; }
.models-source { margin-left: auto; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em; }
.models-empty { font-size: 12px; }
.models-ids { display: flex; flex-wrap: wrap; gap: 6px; }
.model-chip {
  font-family: var(--mono, ui-monospace, monospace); font-size: 11px;
  padding: 2px 7px; border-radius: 5px; background: var(--panel-2);
  border: 1px solid var(--line-soft); color: var(--muted); word-break: break-all;
}
.model-chip.chat { color: var(--text); border-color: var(--accent, var(--line)); }

.row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row .name { font-size: 13px; min-width: 130px; color: var(--text); }
.row .probe { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .verdict { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; }
.verdict.ok { color: var(--teal); } .verdict.warn { color: var(--amber); }
.verdict.err { color: var(--red); } .verdict.pending { color: var(--dim); }

/* ---- controls ------------------------------------------------------------ */
.btn {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink); background: var(--amber);
  border: 1px solid var(--amber); border-radius: var(--radius);
  padding: 9px 16px; cursor: pointer; transition: filter var(--tap), transform var(--tap);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); filter: none; }
.input {
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; width: 100%; transition: border-color var(--tap), box-shadow var(--tap);
}
.input:focus { outline: none; border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px var(--amber-glow); }
.input::placeholder { color: var(--dim); }

/* ---- token gate (Fork B: token-paste) ------------------------------------ */
.gate { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 88%, transparent); backdrop-filter: blur(4px); }
.gate.hidden { display: none; }
.gate .card { width: min(460px, 92vw); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 30px 26px; }
.gate h2 { font-family: var(--font-display); font-weight: 600; margin: 6px 0 4px; font-size: 22px; }
.gate p { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 0 0 18px; }
.gate .field { display: flex; gap: 8px; margin-top: 4px; }
.gate .err { color: var(--red); font-size: 11.5px; margin-top: 10px; min-height: 14px;
  font-family: var(--font-mono); }
.gate .note { color: var(--dim); font-size: 10.5px; margin-top: 16px; line-height: 1.6; }

/* ---- boot log (the console reveal) --------------------------------------- */
.bootlog { font-family: var(--font-mono); font-size: 11.5px; color: var(--dim);
  margin: 0 0 22px; white-space: pre-wrap; min-height: 1.2em; }
.bootlog .l { display: block; opacity: 0; animation: fadein 0.4s forwards; }
/* staggered reveal via nth-child (NOT inline JS styles → strict CSP, no 'unsafe-inline') */
.bootlog .l:nth-child(1) { animation-delay: 0s; }
.bootlog .l:nth-child(2) { animation-delay: 0.09s; }
.bootlog .l:nth-child(3) { animation-delay: 0.18s; }
.bootlog .l:nth-child(4) { animation-delay: 0.27s; }
.bootlog .l:nth-child(5) { animation-delay: 0.36s; }
.bootlog .l:nth-child(6) { animation-delay: 0.45s; }
@keyframes fadein { to { opacity: 1; } }

/* utility classes (replace inline style attrs → strict style-src 'self') */
.self-center { align-self: center; }
.btn-sm { padding: 6px 12px; }

.theme-toggle { cursor: pointer; color: var(--muted); background: none; border: 0;
  font-family: var(--font-mono); font-size: 15px; padding: 4px 6px; line-height: 1; }
.theme-toggle:hover { color: var(--amber); }

/* ---- chat surface (Story 9.2) -------------------------------------------- */
.chat-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 20px;
  height: calc(100vh - var(--bar-h) - 92px); }
.sessions { border-right: 1px solid var(--line-soft); padding-right: 16px; overflow-y: auto; }
.sessions-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; }
.session-list { display: flex; flex-direction: column; gap: 3px; }
.session-item { padding: 9px 11px; border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: background var(--tap), border-color var(--tap); }
.session-item:hover { background: var(--panel-2); }
.session-item.active { background: var(--panel-2); border-color: var(--line);
  box-shadow: inset 2px 0 0 var(--amber); }
.session-item .sid { font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Story 22.2: the topic title (prominent) + the summary subtitle. The id fallback re-uses the
   mono face via `.title.mono` so an un-titled session still reads as a store id. */
.session-item .title { font-size: 12.5px; color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .title.mono { font-family: var(--font-mono); font-size: 11.5px; font-weight: 400; }
.session-item .summary { font-size: 11px; color: var(--dim); margin-top: 2px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.session-item .meta { font-size: 10px; color: var(--dim); margin-top: 3px; letter-spacing: 0.04em; }
.session-list .empty { color: var(--dim); font-size: 11px; padding: 8px 4px; }

.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* Story 19.1: min-height:0 lets the flex/grid chain bound the transcript so overflow-y:auto scrolls
   INTERNALLY (else it grows to full content, the page overflows, and marvin.js's scrollTop=scrollHeight
   is a no-op → long chats don't auto-scroll to the newest message). */
.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 4px 12px; display: flex;
  flex-direction: column; gap: 14px; }
.empty-note { color: var(--muted); font-size: 15px; margin: auto; max-width: 44ch;
  text-align: center; line-height: 1.6; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 9px; font-size: 13.5px;
  line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--amber); color: #14100a;
  border-bottom-right-radius: 2px; font-family: var(--font-mono); font-size: 13px; }
.msg.marvin { align-self: flex-start; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-bottom-left-radius: 2px; font-family: var(--font-display);
  font-size: 15px; }
.msg .who { display: block; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); margin-bottom: 5px; }
.msg.user .who { color: #5c4a22; }
/* Story 22.3: the optional compact per-message time (+ response duration on replies) — small,
   muted, mono, consistent with .who. Only present when the chat_show_timestamps toggle is ON. */
.msg .msg-meta { display: block; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.08em; color: var(--dim); margin-top: 5px; }
.msg.user .msg-meta { color: #5c4a22; }
/* Story 49.3: the neutral "⏳ awaiting approval" note (CLI-free; the Approve/Deny buttons are the
   actionable control on a live turn, this line keeps the signal on history). */
.msg .pending-note { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.findings-banner { border: 1px solid var(--amber-dim); background: var(--amber-glow);
  border-radius: var(--radius); padding: 9px 13px; margin-bottom: 12px; font-size: 12px;
  color: var(--text); display: flex; align-items: center; gap: 10px;
  overflow-wrap: anywhere; word-break: break-word; }
.findings-banner .tag { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--amber); }

.pending { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 12px;
  border-top: 1px solid var(--line-soft); }
.composer .input { resize: none; max-height: 160px; font-family: var(--font-mono); }
.composer .btn { flex: none; }
/* Epic 49 (operator ask): the Stop-speaking control — red-tinted so it reads as an interrupt while
   Marvin is talking; only shown (JS unhides it) for the duration of an utterance. */
.stop-speak { color: var(--red); border-color: var(--red); }
.stop-speak:hover { background: var(--red); color: #fff; }
/* Story 50.1: the Auto-read toggle. ON is stated by COLOUR AND by aria-pressed + the label text —
   Epic 15's P5 caught a colour inversion, and a control whose only "on" signal is a tint is a
   control an operator misreads. Disabled carries its reason in the title attribute, never silence. */
.voice-toggle { flex: none; color: var(--muted); }
.voice-toggle[aria-pressed="true"] { color: var(--teal); border-color: var(--teal); }
.voice-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.temp-toggle { flex: none; display: flex; align-items: center; gap: 5px; cursor: pointer;
  color: var(--muted); user-select: none; white-space: nowrap; }
.temp-toggle input { accent-color: var(--amber); cursor: pointer; }
.chat-foot { min-height: 14px; margin-top: 8px; color: var(--dim); }
.chat-foot .err { color: var(--red); }
/* Story 22.4: the staged-image attach preview under the composer. */
#attach-wrap { flex: none; }
#attach-btn { font-size: 16px; line-height: 1; padding: 6px 10px; }
.upload-preview { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); }
.upload-preview[hidden] { display: none; }
.upload-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line-soft); }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.upload-remove { flex: none; padding: 2px 9px; line-height: 1; }

/* ---- operate surfaces (Story 9.3) ---------------------------------------- */
.op-toolbar { display: flex; gap: 9px; margin: 4px 0 16px; align-items: center; flex-wrap: wrap; }
.op-toolbar .input { flex: 1; min-width: 140px; }
.input.sel { flex: none; width: auto; min-width: 130px; }
.op-list { display: flex; flex-direction: column; gap: 1px; }
.op-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  transition: border-color var(--tap); }
.op-row:hover { border-color: var(--line); }
.op-row .rid { font-family: var(--font-mono); font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-row .rmeta { font-size: 10.5px; color: var(--dim); letter-spacing: 0.03em; }
.op-row .grow { flex: 1; min-width: 0; }
.op-row .tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 2px; border: 1px solid var(--line);
  color: var(--muted); }
.op-row .tag.amber { color: var(--amber); border-color: var(--amber-dim); }
.op-row .tag.red { color: var(--red); border-color: var(--red); }
.op-row .tag.teal { color: var(--teal); border-color: var(--teal); }
/* Story 20.4: the self-observation source badge — a maintenance / reasoning-quality row reads as
   Marvin's own operational finding, distinct from ordinary findings. Theme-aware via --violet. */
.op-row .tag.violet { color: var(--violet); border-color: var(--violet-dim); }
.op-actions { display: flex; gap: 6px; flex: none; }
.op-actions .btn { padding: 6px 11px; font-size: 10.5px; }
.op-list .empty { color: var(--dim); font-size: 12px; padding: 14px 6px; font-style: italic; }
.op-detail { margin-top: 16px; }
.op-detail .md { font-family: var(--font-display); font-size: 15px; line-height: 1.65;
  white-space: pre-wrap; color: var(--text); }
.op-detail .obs { font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  padding: 5px 0; border-bottom: 1px solid var(--line-soft); }

/* Story 26.3: legible finding rows (title + urgency + summary + affects) that expand INLINE. */
.finding-item { display: flex; flex-direction: column; }
.finding-item .op-row { align-items: flex-start; cursor: pointer; }   /* multi-line → top-align */
.finding-item.unread .op-row { border-left: 2px solid var(--amber); } /* unread cue on the row */
.op-row .ftitle-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.op-row .ftitle { font-family: var(--font-display); font-size: 14px; color: var(--text);
  font-weight: 600; }
.finding-item:not(.unread) .op-row .ftitle { font-weight: 500; color: var(--muted); } /* read=quieter */
.op-row .fsummary { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
/* urgency badge — only HIGH draws the eye; MEDIUM (the default) stays neutral so it isn't noise. */
.op-row .urg { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 2px; border: 1px solid var(--line);
  color: var(--muted); }
.op-row .urg-high { color: var(--red); border-color: var(--red); }
.op-row .urg-medium { color: var(--muted); border-color: var(--line); }
.op-row .urg-low { color: var(--dim); border-color: var(--line-soft); }
.op-row .faffects { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.op-row .faff-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--dim); }
.op-row .chip { font-family: var(--font-mono); font-size: 10px; padding: 2px 7px; border-radius: 10px;
  background: var(--line-soft); color: var(--muted); }
.finding-detail { margin: 2px 0 8px; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line-soft); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); }
.finding-detail .finding-ctl { margin-top: 12px; }
.rate-pill { cursor: pointer; }
.rate-pill.on { background: var(--amber); color: #14100a; border-color: var(--amber); }

/* Story 31.3: the Files vault — legible upload rows that expand INLINE (mirrors the findings rows). */
.file-item { display: flex; flex-direction: column; }
.file-item .op-row { align-items: flex-start; cursor: pointer; }   /* multi-line → top-align */
/* Story 26.9: the generic inline-detail wrapper (Memory) — row + expandable detail stacked, no
   shared bottom panel. Mirrors .file-item; .op-detail carries the spacing. */
.op-item { display: flex; flex-direction: column; }
.op-item .op-row { cursor: pointer; }
.op-item .memory-detail { margin-top: 8px; }
.op-row .fglyph { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.file-detail { margin: 2px 0 8px; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line-soft); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); }
.file-meta { display: flex; flex-direction: column; gap: 4px; }
.file-meta-row { display: flex; gap: 12px; font-size: 12px; }
.file-meta-k { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--dim); flex: none; width: 120px; padding-top: 2px; }
.file-meta-v { color: var(--muted); word-break: break-word; min-width: 0; }
.op-flash { font-family: var(--font-mono); font-size: 11px; color: var(--teal); margin: 8px 2px;
  min-height: 14px; }
.op-flash.err { color: var(--red); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--teal); color: var(--text);
  font-family: var(--font-mono); font-size: 12px; padding: 10px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 600; animation: fadein 0.25s; }
.toast.err { border-color: var(--red); }

/* Story 33.4 (prod bug #4/#5): a calm, non-modal "changes need a restart" tray — replaces the
   jarring per-toggle confirm()+immediate-restart so setting a restart-required knob no longer reads
   as an error+reload. Saved changes queue here; the operator restarts once, deliberately. */
.restart-tray { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: min(680px, 94vw);
  background: var(--panel); border: 1px solid var(--teal); color: var(--text);
  font-family: var(--font-mono); font-size: 12px; padding: 10px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 601; animation: fadein 0.25s; }
.restart-tray-msg { font-weight: 600; }
.restart-tray-names { color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  max-width: 320px; white-space: nowrap; }

/* Story 33.6: the chat "Read aloud" control — compact, sits under a marvin reply body. */
.speak-btn { margin-top: 6px; font-size: 11px; align-self: flex-start; }
/* Story 35.2 (hands-free voice): the mic button pulses red while recording so the "listening" state
   is unmistakable; motion respects prefers-reduced-motion (falls back to a static red). */
#mic-btn.recording { color: #e5484d; border-color: #e5484d; animation: micpulse 1.1s ease-in-out infinite; }
@keyframes micpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { #mic-btn.recording { animation: none; } }
/* Story 35.3 (show Marvin): the camera capture modal — a centered live preview + Capture/Cancel. */
.cam-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); }
.cam-modal[hidden] { display: none; }
.cam-panel { background: var(--panel, #14161a); border: 1px solid var(--border, #2a2d33); border-radius: 10px; padding: 12px; max-width: 92vw; display: flex; flex-direction: column; gap: 10px; }
#cam-video { max-width: 80vw; max-height: 60vh; width: 480px; background: #000; border-radius: 6px; }
.cam-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* Story 50.2: the Live Air consent dialog (AC2) and the always-on listening bar (AC3). The bar is
   deliberately loud — red, pulsing, and never collapsible: an open microphone the operator has
   forgotten about is the one failure mode this feature must not have. */
.consent-panel { width: 520px; max-width: 92vw; }
.consent-panel p, .consent-panel li { color: var(--muted); line-height: 1.5; }
.consent-panel ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.live-air-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 8px 0;
  border: 1px solid var(--red); border-radius: 8px; background: rgba(214, 114, 94, 0.10);
  color: var(--red); }
.live-air-bar[hidden] { display: none; }
.live-air-bar .btn { margin-left: auto; }
/* Story 50.3: the hold-SPACE affordance — quiet until the key is held, then the countdown. */
.ptt-hint { margin-left: 4px; white-space: nowrap; }
.ptt-hint.arming { color: var(--amber); }

/* Epic 34.2: the B2 bucket picker under the b2_bucket setting. */
.b2-picker { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.b2-picker-list { display: flex; flex-wrap: wrap; gap: 6px; }
.b2-bucket-chip { font-size: 11px; }
/* Epic 49 (operator ask): the "Hear it" voice-preview control next to the tts_voice dropdown. */
.voice-preview { display: inline-flex; margin-left: 8px; }

/* ---- settings / persona / status (Story 9.4) ----------------------------- */
/* Story 19.2 — topical, collapsible settings sections (theme-aware via tokens) */
.set-section { margin-bottom: 14px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel-2); overflow: hidden; }
.set-section-head { display: flex; align-items: center; gap: 9px; padding: 11px 13px;
  cursor: pointer; user-select: none; border-bottom: 1px solid var(--line-soft);
  transition: background var(--tap); }
.set-section-head:hover { background: color-mix(in srgb, var(--amber) 6%, var(--panel-2)); }
.set-section-head .chev { color: var(--amber-dim); font-size: 11px; width: 12px; text-align: center;
  transition: transform var(--tap); }
.set-section-title { font-family: var(--font-display); font-size: 14px; color: var(--text);
  letter-spacing: 0.01em; flex: 1; }
.set-section-count { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--muted); }
.set-section-rows { padding: 10px 12px; display: grid; gap: 2px; }
.set-section.collapsed .set-section-rows { display: none; }
.set-section.collapsed .set-section-head { border-bottom-color: transparent; }
.set-section.collapsed .chev { transform: rotate(-90deg); }
.set-field { display: grid; grid-template-columns: 240px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 2px; }
.set-field .sk { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.set-field .sk .desc { display: block; font-size: 10px; color: var(--dim); margin-top: 3px;
  white-space: normal; letter-spacing: 0; }
.set-field .sv { font-family: var(--font-mono); font-size: 12px; }
.set-field .ro { color: var(--muted); }
.set-field input, .set-field select { font-family: var(--font-mono); font-size: 12px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 2px; color: var(--text);
  padding: 6px 9px; width: 100%; }
.set-field .save { padding: 5px 12px; font-size: 10px; }
.set-field.locked { opacity: 0.62; }
.set-badge { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 2px; border: 1px solid var(--line);
  color: var(--dim); }

/* Story 16.8 — start-fresh "Danger zone" (red-accented, keyed off --red) */
.danger-zone { margin-top: 30px; padding: 18px; border-radius: var(--radius);
  border: 1px solid var(--red); background: color-mix(in srgb, var(--red) 8%, var(--panel)); }
.dz-head { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--red); font-weight: 600; margin-bottom: 6px; }
.dz-note { color: var(--muted); font-size: 12px; line-height: 1.6; max-width: 68ch; margin: 0 0 14px; }
.dz-scopes { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.dz-scope { font-family: var(--font-mono); font-size: 12px; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; }
.dz-summary:not(:empty) { border-left: 2px solid var(--red); padding: 8px 0 8px 12px; margin: 8px 0 14px;
  display: grid; gap: 6px; }
.dz-wipes { font-size: 12px; color: var(--text); line-height: 1.55; }
.dz-keeps { font-size: 12px; color: var(--muted); line-height: 1.55; }
.dz-confirm { font-family: var(--font-mono); font-size: 13px; color: var(--text); background: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; width: min(340px, 100%);
  display: block; margin-bottom: 10px; }
.dz-confirm:focus { outline: none; border-color: var(--red); }
.dz-ack { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text);
  line-height: 1.5; margin-bottom: 14px; max-width: 64ch; cursor: pointer; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.dz-msg:not(:empty) { margin-top: 12px; font-size: 12px; line-height: 1.55; }
.dz-msg.err { color: var(--red); }
.dz-msg.info { color: var(--muted); }

.restart-overlay { position: fixed; inset: 0; z-index: 550; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 90%, transparent); backdrop-filter: blur(4px); }
.restart-overlay.hidden { display: none; }
.restart-overlay .card { width: min(440px, 92vw); background: var(--panel);
  border: 1px solid var(--amber-dim); border-radius: var(--radius); padding: 28px; text-align: center;
  box-shadow: var(--shadow); }
.restart-overlay h2 { font-family: var(--font-display); margin: 8px 0; }
.restart-overlay p { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
/* Story 18.8: restart-recovery failure state (bounded poll timed out → visible failure, not an infinite spinner) */
.restart-overlay .card.failed { border-color: var(--red); }
.restart-overlay .rhint { color: var(--dim); font-size: 11px; margin-top: 10px; }
.restart-overlay .rbtns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.restart-overlay .rsub { color: var(--dim); font-size: 11px; margin-top: 8px; }
/* Story 49.5: an HONEST progress indicator so a ~70s configured restart never reads as frozen — a
   real elapsed-seconds ticker + an INDETERMINATE animated bar (motion, NOT a % claim; it never
   "completes" — the overlay hides on the real /healthz 200). */
.restart-overlay .rbar { margin: 16px auto 0; height: 4px; width: 82%; border-radius: 2px;
  background: var(--line); overflow: hidden; }
.restart-overlay .rbar-fill { height: 100%; width: 38%; border-radius: 2px; background: var(--amber);
  animation: rbar-slide 1.5s ease-in-out infinite; }
@keyframes rbar-slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.restart-overlay .relapsed { color: var(--dim); font-size: 11px; margin-top: 8px;
  font-family: var(--font-mono); letter-spacing: 0.04em; }
@media (prefers-reduced-motion: reduce) {
  .restart-overlay .rbar-fill { animation: none; width: 100%; opacity: 0.25; margin-left: 0; } }

/* Story 16.6 — first-run wizard overlay.
   Epic 49 (BUG C): the overlay SCROLLS. It used `display:grid; place-items:center` with NO
   overflow, so on a short window (e.g. 1024x640) a tall card clipped its top/bottom off-screen and
   the Skip/action buttons sat below the fold with no way to reach them (only Escape). Grid +
   `margin:auto` on the card + `overflow-y:auto` on the overlay is the bulletproof scrollable-centered
   pattern (flexbox has the "can't scroll to the top of an overflowing centered child" bug; grid
   doesn't) — the card centers when it fits and scrolls fully into reach when it doesn't. */
.wizard-overlay { position: fixed; inset: 0; z-index: 560; display: grid; overflow-y: auto;
  padding: 24px 12px; background: rgba(0, 0, 0, 0.55); }
.wizard-overlay .card { width: min(460px, 92vw); margin: auto; position: relative; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; text-align: center; }
.wizard-close { position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.wizard-close:hover { color: var(--text); }
.wizard-overlay h2 { font-family: var(--font-display); margin: 4px 0 8px; }
.wizard-overlay .wmsg { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin-bottom: 16px; }
.wizard-presets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
/* Epic 49 (installer LOW): keep the primary "Skip for now" / get-me-out control ON SCREEN at a short
   1024x640 viewport without scrolling. The overlay (not the card) is the scroll container (the grid
   pattern above), so pin Skip to the bottom of that scroller as a full-width panel-backed footer band
   — a hairline separates it from the content scrolling behind, which the panel background masks. */
.wizard-skip { position: sticky; bottom: 0; display: block; width: 100%; margin-top: 10px;
  background: var(--panel); border-top: 1px solid var(--line); padding-top: 10px; }
.wizard-key-get { font-size: 11.5px; color: var(--muted); text-decoration: underline; white-space: nowrap; }
.wizard-key-get:hover { color: var(--text); }

/* Story 18.3: gate break-glass link + wizard/settings set-password controls */
.linklike { background: none; border: none; color: var(--muted); text-decoration: underline;
  cursor: pointer; font-size: 12px; padding: 6px 0; font-family: inherit; }
.linklike:hover { color: var(--text); }
.wizard-pw { display: grid; gap: 8px; margin: 4px 0 14px; text-align: left; }
.wizard-pw-row { display: flex; flex-wrap: wrap; gap: 8px; }
.wizard-pw-row .input { flex: 1 1 130px; min-width: 120px; }
.wizard-pw-done { color: var(--teal); font-size: 13px; }
/* Story 18.4 — the wizard "connect your AI keys" section. */
.wizard-keys { display: grid; gap: 8px; margin: 4px 0 14px; text-align: left; }
.wizard-key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wizard-key-label { flex: 0 0 130px; color: var(--muted); font-size: 13px; }
.wizard-key-row .input { flex: 1 1 160px; min-width: 140px; }
.wizard-key-chip { font-size: 12px; min-width: 90px; }
.wizard-key-chip.ok { color: var(--teal); }
.wizard-key-chip.err { color: var(--red); }
.wizard-key-chip.warn { color: var(--amber-dim); }
.wizard-key-chip.pending { color: var(--muted); }
.wizard-keys-save { margin-top: 6px; justify-self: start; }
/* The wizard's "already have a Marvin?" restore step. Sits FIRST in the card and is visually
   separated below, because it is an alternative to the whole setup flow rather than a step in it. */
.wizard-restore {
  display: grid;
  gap: 8px;
  margin: 4px 0 16px;
  padding-bottom: 14px;
  text-align: left;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.12));
}
.wizard-restore select, .wizard-restore input[type="file"] { max-width: 100%; }
.wizard-restore .btn { justify-self: start; }
.dz-msg.ok { color: var(--teal); }
#change-password .panel-body { display: grid; gap: 8px; }
#change-password .panel-body .input { max-width: 340px; }
/* Epic 48.5: Backup & Migration card + the login-gate recovery form */
#backup-migration .panel-body { display: grid; gap: 8px; }
#backup-migration .panel-body .input,
#backup-migration .panel-body select { max-width: 360px; }
#backup-migration .sk { margin-top: 10px; font-weight: 600; }
#gate-recover { display: block; margin-top: 8px; }
.recover-form { display: grid; gap: 8px; margin: 10px 0 4px; text-align: left; }
.recover-form .input { width: 100%; }
.recover-scope { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }

.persona-field { display: grid; grid-template-columns: 160px 1fr 56px auto; gap: 14px;
  align-items: center; padding: 12px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 2px; }
.persona-field .pn { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }
/* Story 39.2: eight dials need a name and a sentence, not a raw field key. The column widens
   because a description that wraps to four lines is not more legible than the snake_case it
   replaced. */
.persona-field { grid-template-columns: 260px 1fr 56px auto; align-items: start; }
.persona-field input[type=range], .persona-field .pv { margin-top: 6px; }
.persona-field .pn-label { font-family: var(--font-sans, inherit); font-size: 13px;
  font-weight: 600; color: var(--text); letter-spacing: 0.01em; }
.persona-field .pn-desc { font-family: var(--font-sans, inherit); font-size: 11px;
  line-height: 1.45; color: var(--muted); margin-top: 3px; }
.persona-group { display: block; margin: 18px 0 8px; color: var(--amber-dim);
  letter-spacing: 0.16em; text-transform: uppercase; }
.persona-group:first-child { margin-top: 0; }
.persona-field input[type=range] { width: 100%; accent-color: var(--amber); }
.persona-field .pv { font-family: var(--font-mono); font-size: 13px; color: var(--amber);
  text-align: right; }
.persona-field .ovr { font-size: 9px; color: var(--teal); }

/* Story 16.2 — persona preset bar */
.persona-presets { margin-bottom: 14px; }
.persona-presets .mono-label { display: block; margin-bottom: 8px; }
.persona-presets .preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-btn { padding: 7px 13px; font-size: 11.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  margin-bottom: 18px; }
.stat-tile { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 15px 16px; }
.stat-tile .label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); }
.stat-tile .val { font-family: var(--font-display); font-size: 25px; margin-top: 6px; color: var(--text); }
.stat-tile .val.ok { color: var(--teal); } .stat-tile .val.warn { color: var(--amber); }
.stat-tile .val.err { color: var(--red); }

@media (max-width: 720px) {
  .set-field { grid-template-columns: 1fr; } .persona-field { grid-template-columns: 1fr auto; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--bar-h) auto 1fr; }
  .rail { grid-row: 2; flex-direction: row; overflow-x: auto; border-right: 0;
    border-bottom: 1px solid var(--line); padding: 8px; }
  .rail .group { display: none; } .nav .soon { display: none; }
  .main { padding: 22px 18px 40px; }
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .sessions { border-right: 0; border-bottom: 1px solid var(--line-soft); padding-right: 0;
    padding-bottom: 12px; max-height: 140px; }
  .op-row { flex-wrap: wrap; }
}

/* ---- Story 15.1: Status key→value tree, markdown detail, Documentation ---- */
/* AC1: readable Status — labelled rows instead of a raw JSON.stringify wall */
.panel-body.kv { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; }
.kv-row { display: flex; gap: 12px; padding: 2px 0; align-items: baseline; }
.kv-k { color: var(--muted); min-width: 150px; flex-shrink: 0; letter-spacing: 0.02em; }
.kv-v { color: var(--text); word-break: break-word; }
.kv-v.ok { color: var(--teal); } .kv-v.err { color: var(--red); }
.kv-branch .kv-k { color: var(--text); font-weight: 600; }
.kv-nest { margin: 2px 0 6px 16px; padding-left: 12px; border-left: 1px solid var(--line-soft); }
.kv-scalar { color: var(--text); padding: 1px 0; white-space: pre-wrap; }
.kv-scalar.dim, .dim { color: var(--dim); }
/* AC2: findings detail rendered as markdown, not a collapsed raw line */
.op-detail .md-h { font-family: var(--font-display); color: var(--text); margin: 10px 0 4px; }
.op-detail .md-h1 { font-size: 19px; } .op-detail .md-h2 { font-size: 16px; }
.op-detail .md-h3, .op-detail .md-h4 { font-size: 14px; color: var(--muted); }
.op-detail .md-p { font-family: var(--font-display); font-size: 15px; line-height: 1.65;
  color: var(--text); margin: 6px 0; white-space: pre-wrap; }
.op-detail .md-ul { margin: 4px 0 8px 18px; } .op-detail .md-li { font-size: 14px; line-height: 1.55;
  color: var(--muted); list-style: disc; margin: 2px 0; }
/* AC5: Documentation surface */
.docs { max-width: 760px; }
.docs .doc-h { font-size: 20px; color: var(--text); margin: 22px 0 8px; }
.docs .doc-p { font-family: var(--font-display); font-size: 15px; line-height: 1.7; color: var(--muted);
  margin: 6px 0 14px; }
/* Install guide (Documentation surface): sub-headings, copyable command blocks, and a callout. */
.docs .doc-h3 { font-size: 15px; color: var(--text); margin: 18px 0 6px; font-weight: 600; }
.docs .doc-code { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin: 6px 0 12px; overflow-x: auto; }
.docs .doc-code code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  color: var(--text); white-space: pre; }
.docs .doc-note { border-left: 3px solid var(--amber); background: var(--panel); border-radius: 4px;
  padding: 8px 12px; margin: 6px 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.docs .doc-dl { margin: 10px 0 14px; }
.docs .doc-dl .btn { font-size: 14px; padding: 8px 14px; }
.doc-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px;
  margin: 8px 0 6px; }
.doc-feature { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 12px 14px; }
.doc-feature-name { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.doc-feature-desc { font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.doc-mut { display: block; margin: 18px 0 6px; color: var(--dim); }
.doc-knob { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.doc-knob-name { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.doc-knob-desc { font-size: 13px; line-height: 1.5; color: var(--muted); margin-top: 3px; }

/* Story 15.2: inline explainer under an operator form (e.g. Attention → Findings flow) */
.op-hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 2px 0 14px;
  max-width: 68ch; }
.op-hint strong { color: var(--text); font-weight: 600; }

/* Story 16.1: collapsible "what I recalled" chip atop a chat reply (replaces the raw fence) */
.msg .recall-chip { margin: 2px 0 6px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel-2); overflow: hidden; }
.msg .recall-chip > summary { cursor: pointer; list-style: none; padding: 4px 10px; font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.msg .recall-chip > summary::before { content: "▸ "; color: var(--dim); }
.msg .recall-chip[open] > summary::before { content: "▾ "; }
.msg .recall-chip > summary::-webkit-details-marker { display: none; }
/* Story 26.4: the structured recall list (replaces the raw .recall-body blob). Each memory's content
   reads as a line with quiet entity · provenance · time meta beneath it. */
.msg .recall-list { padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.msg .recall-item { border-left: 2px solid var(--line); padding-left: 10px; }
.msg .recall-content { font-size: 12.5px; line-height: 1.5; color: var(--text);
  word-break: break-word; }
.msg .recall-meta { margin-top: 2px; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.04em; color: var(--dim); word-break: break-word; }
.msg .msg-body { white-space: pre-wrap; }

/* Story 16.5 — read-only tools catalog rows */
.tool-row { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 4px; }
.tool-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-name { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.tool-tag { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; padding: 1px 6px;
  border-radius: 4px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-soft); }
.tool-tag.generated { color: var(--amber); }
.tool-tag.skill { color: var(--teal); }
.tool-cat { font-family: var(--font-mono); font-size: 10px; color: var(--dim); }
.tool-desc { margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.5; word-break: break-word; }
/* Story 28.1 — catalog controls, summary, source groups, enabled-state pill */
.tools-controls { margin-bottom: 8px; }
.tools-filter { width: 100%; max-width: 360px; }
.tools-summary { font-family: var(--font-mono); font-size: 11px; color: var(--dim);
  margin-bottom: 10px; }
.tools-summary:empty { display: none; }
.tool-group-head { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; }
.tool-group-head:first-child { margin-top: 0; }
.tool-group-label { color: var(--muted); }
.tool-group-count { font-size: 10px; color: var(--dim); }
.tool-state { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; padding: 1px 6px;
  border-radius: 4px; border: 1px solid var(--line-soft); margin-left: auto; }
.tool-state.on { color: var(--teal); }
.tool-state.off { color: var(--red); }
/* Story 28.2 — the "Create a capability" panel (generate a tool / learn a skill) */
.tools-create { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.tools-create-h { font-size: 15px; margin-bottom: 10px; }
.tools-create-row { margin-bottom: 14px; }
.tools-create-label { color: var(--muted); margin-bottom: 6px; }
.tools-create-input { display: flex; gap: 8px; flex-wrap: wrap; }
.tools-create-input .input { flex: 1; min-width: 200px; }
.tools-create-input .btn { flex: none; }
.tools-create-hint { margin-top: 6px; font-size: 12px; color: var(--dim); line-height: 1.5; }
.tools-create-hint code { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
/* Story 30.1 — Cogent Bridge config fields */
.cogent-field { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cogent-field .tools-create-label { margin-bottom: 0; min-width: 110px; }
.cogent-field .input { flex: 1; min-width: 180px; max-width: 360px; }
.cogent-field input[type="checkbox"] { width: 16px; height: 16px; }

/* Story 16.4 — the "how I got here" trace panel (mirrors the recall-chip idiom) */
.msg .trace-panel { margin: 6px 0 2px; border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel-2); overflow: hidden; }
.msg .trace-panel > summary { cursor: pointer; list-style: none; padding: 4px 10px; font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.msg .trace-panel > summary::before { content: "▸ "; color: var(--dim); }
.msg .trace-panel[open] > summary::before { content: "▾ "; }
.msg .trace-panel > summary::-webkit-details-marker { display: none; }
.msg .trace-body { padding: 6px 12px 10px; }
.msg .trace-timeline { margin-top: 8px; }
.msg .trace-timeline > .mono-label { display: block; margin-bottom: 4px; }
.msg .trace-step { display: flex; gap: 8px; padding: 2px 0; font-family: var(--font-mono); font-size: 11.5px; }
.msg .trace-step .step-kind { color: var(--teal); min-width: 84px; flex: none; }
/* min-width:0 defeats a flex item's default min-content floor so a long unbreakable id WRAPS
   inside the bubble instead of forcing horizontal overflow (P5 Edge #2). */
.msg .trace-step .step-detail { color: var(--muted); min-width: 0; word-break: break-word; }

/* Story 25.6: interactive memory graph surface (theme-aware; canvas + node detail). */
.graph-wrap { position: relative; width: 100%; height: 62vh; min-height: 320px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
#graph-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#graph-canvas:active { cursor: grabbing; }
.graph-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-style: italic; pointer-events: none; }
.graph-detail { position: absolute; top: 10px; right: 10px; max-width: 260px; max-height: calc(100% - 20px);
  overflow-y: auto; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.25); font-size: 0.85rem; }
.graph-detail .gd-title { font-weight: 600; word-break: break-word; }
.graph-detail .gd-meta { color: var(--muted); margin: 2px 0 6px; }
.graph-detail .gd-edges { margin: 0; padding-left: 1.1em; }
.graph-detail .gd-edges li { color: var(--ink); word-break: break-word; margin: 1px 0; }

/* Story 25.6 P5: CSP-safe utility classes replacing 3 inline styles in the 25.7 secret-candidates
   header (style-src 'self' blocked the inline attrs → console CSP errors). */
.mt-lg { margin-top: 1.5rem; }
.h2-sm { font-size: 1.1rem; }
.push-right { margin-left: auto; }

/* Story 27.1: the Memory→Danger-zone deep-link affordance + the transient highlight on arrival. */
.btn.danger-link { color: #c0563a; border-color: rgba(192,86,58,0.4); }
.btn.danger-link:hover { background: rgba(192,86,58,0.12); }
#memory-start-fresh-hint { margin: 0.15rem 0 0.4rem; }
.dz-flash { animation: dzFlash 1.6s ease-out; border-radius: 8px; }
@keyframes dzFlash {
  0% { box-shadow: 0 0 0 3px rgba(192,86,58,0.55); }
  100% { box-shadow: 0 0 0 3px rgba(192,86,58,0); }
}

/* Story 40C.1: why a pinned memory is NOT actually in context — persistent, beside the memory it
   is about. The transient toast alone was the defect: it self-removes after 4.2s and the panel
   behind it asserted "always in context" regardless. */
.warn-note { color: var(--accent, #b58900); font-size: 12px; line-height: 1.5; margin: 6px 0 4px;
  border-left: 2px solid var(--accent, #b58900); padding-left: 10px; max-width: 68ch; }

/* Story 51.1: the Life OS surface — five kind groups, read-only lists. Reuses op-list/op-row;
   only the group scaffolding is new. */
.lifeos-group { margin-top: 1.25rem; }
.lifeos-group-head { display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.35rem; }
.lifeos-count { opacity: 0.7; }

/* Story 51.2: the Life OS inline create/edit form — reuses .input/.btn; only layout is new. */
.lifeos-head-right { display: flex; align-items: baseline; gap: 0.6rem; }
.lifeos-form { margin: 0.4rem 0 0.6rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line, #333);
  border-radius: 8px; }
.lifeos-field { margin: 0.4rem 0; }
.lifeos-field-label { margin-bottom: 0.15rem; }
.lifeos-field .input { width: 100%; }

/* Story 51.4: a Life OS reference chip in Findings is a link into the Life OS view. The
   dotted underline is the AT-REST affordance (P5: hover-only made links indistinguishable). */
.chip.link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.chip.link:hover { text-decoration: underline solid; }

/* Story 36.5 R7/AC2 — local-backend readiness. Read-only status shown ABOVE the backend selectors
   so an operator knows a backend cannot run BEFORE switching to it, which is the stated purpose of
   the route behind it. Mirrors the .models-* layout idiom rather than inventing a second one. */
.lb-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.lb-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px;
}
.lb-skill { font-weight: 600; min-width: 8.5rem; }
.lb-backend { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.lb-badge { font-size: 11px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); }
/* teal = it runs; red = it cannot. Deliberately NOT amber: "cannot run" is a definite state, not a
   warning to be squinted at. */
.lb-badge.ok  { color: var(--teal); border-color: var(--teal); }
.lb-badge.bad { color: var(--red);  border-color: var(--red); }
.lb-reason { color: var(--muted); font-size: 12px; flex: 1 1 14rem; }
/* The fix command is selectable and verbatim — an operator must copy exactly what works. */
.lb-fix {
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  background: var(--ink); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 2px 6px; user-select: all; flex-basis: 100%;
}
.lb-size { color: var(--dim); font-size: 11px; font-family: var(--font-mono); }
