/* KQ Lab: restrained monochrome, one quiet accent, generous spacing, subtle motion. */
:root {
  --bg: #f7f7f5; --panel: #ffffff; --ink: #1b1b19; --ink-2: #4a4a46; --ink-3: #8a8a84; --line: #e6e6e1; --line-2: #d6d6d0;
  --chip: #f1f1ed; --chip-ink: #2c2c29; --accent: #3a5bd9; --good: #2f7d4f; --bad: #b4452f; --warn: #a7731b;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 20, 18, .04), 0 4px 16px rgba(20, 20, 18, .04);
  color-scheme: light;
}
/* Theme: the system's choice unless the header switch pinned one (html[data-theme], set before first paint by the
   pages' inline script); the dark tokens are therefore written twice, once per way of asking for them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --panel: #1a1a19; --ink: #ececea; --ink-2: #b9b9b4; --ink-3: #7c7c77; --line: #2a2a28; --line-2: #3a3a37;
    --chip: #242422; --chip-ink: #dededa; --accent: #8ea2ff; --good: #6fc192; --bad: #e98a75; --warn: #e0b45e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --panel: #1a1a19; --ink: #ececea; --ink-2: #b9b9b4; --ink-3: #7c7c77; --line: #2a2a28; --line-2: #3a3a37;
  --chip: #242422; --chip-ink: #dededa; --accent: #8ea2ff; --good: #6fc192; --bad: #e98a75; --warn: #e0b45e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* min-height, not height: a body fixed to the viewport would end the sticky header's containing block at one screen. */
html, body { margin: 0; }
body { min-height: 100vh; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 56px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; letter-spacing: .02em; display: flex; align-items: baseline; gap: 8px; }
.brand small { color: var(--ink-3); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; }
nav.tabs button:hover { background: var(--chip); color: var(--ink); }
nav.tabs button.on { background: var(--ink); color: var(--bg); }
.status { margin-left: auto; display: flex; gap: 10px; align-items: center; color: var(--ink-3); font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 6px; }
.dot.busy { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { padding: 20px 24px 40px; max-width: 1680px; margin: 0 auto; }
.page { display: none; } .page.on { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.grid-play { display: grid; grid-template-columns: 240px minmax(0, 1fr) minmax(420px, 560px); gap: 16px; align-items: start; }
@media (max-width: 1280px) { .grid-play { grid-template-columns: 220px minmax(0, 1fr) 420px; } }
@media (max-width: 1050px) { .grid-play { grid-template-columns: 1fr; } .sticky { position: static; max-height: none; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > .head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel > .head h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.panel > .body { padding: 12px 14px; }
.sticky { position: sticky; top: 72px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; }
.sticky > .body { overflow: auto; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.row { display: flex; gap: 8px; align-items: center; } .grow { flex: 1; } .wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 8px; }

.btn { border: 1px solid var(--line-2); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--chip); }
.btn:disabled { opacity: .45; cursor: default; }
input.field, textarea.field, select.field { width: 100%; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 8px 10px; outline: none; transition: border-color .15s; }
input.field:focus, textarea.field:focus, select.field:focus { border-color: var(--ink-3); }
textarea.field { resize: vertical; min-height: 120px; font: 13px/1.5 var(--mono); }

.doc-item { padding: 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; transition: background .15s; }
.doc-item:hover { background: var(--chip); }
.doc-item.on { border-color: var(--line-2); background: var(--chip); }
.doc-item .title { font-weight: 550; font-size: 13px; }
.bar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ink); transition: width .3s ease; }

.stats { display: flex; gap: 22px; flex-wrap: wrap; }
.stat b { display: block; font-size: 18px; font-weight: 620; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.chunk { padding: 14px 0; border-bottom: 1px solid var(--line); }
.chunk:last-child { border-bottom: 0; }
.chunk .idx { font: 600 11px var(--mono); color: var(--ink-3); width: 48px; flex: none; padding-top: 2px; }
.chunk .text { color: var(--ink-2); white-space: pre-wrap; overflow: hidden; max-height: 4.5em; position: relative; font-size: 13px; }
.chunk .text.open { max-height: none; }
.chunk .text:not(.open)::after { content: ""; position: absolute; inset: auto 0 0; height: 1.6em; background: linear-gradient(transparent, var(--panel)); }
.chunk.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--accent) 12%, transparent); } 100% { background: transparent; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 12px/1.35 var(--mono); background: var(--chip); color: var(--chip-ink); padding: 4px 8px; border-radius: 6px; }
.chip.raw { background: none; border: 1px dashed var(--line-2); color: var(--ink-3); }
.chip.q { background: var(--ink); color: var(--bg); }
.chip.pending { color: var(--ink-3); background: none; border: 1px dashed var(--line); }
.badge { font: 600 10px var(--sans); letter-spacing: .05em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--ink-2); }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.chat { display: flex; flex-direction: column; gap: 14px; }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--ink); color: var(--bg); padding: 9px 12px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; }
.answer { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.answer h4 { margin: 0 0 6px; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.answer + .answer { margin-top: 0; }
.hit { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; }
.hit:first-of-type { border-top: 0; }
.hit .rank { font: 600 12px var(--mono); color: var(--ink-3); width: 22px; flex: none; }
.hit .snip { color: var(--ink-2); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hit.gold .rank { color: var(--good); }
.hit .via { font: 11px var(--mono); color: var(--ink-3); margin-top: 3px; }
.timing { font: 11px var(--mono); color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 42px; max-height: 160px; font: 14px/1.4 var(--sans); }
.suggest { display: flex; flex-direction: column; gap: 4px; }
.suggest button { text-align: left; border: 1px solid var(--line); background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); transition: border-color .15s; }
.suggest button:hover { border-color: var(--ink-3); color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { padding: 18px; }
.card h3 { margin: 0 0 6px; font-size: 15px; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 520px; }
table.data tr:hover td { background: var(--chip); cursor: pointer; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.subtabs button { border: 0; background: none; padding: 8px 12px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 94vw); background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(0, 0, 0, .08); transform: translateX(100%); transition: transform .22s ease; z-index: 20; display: flex; flex-direction: column; }
.drawer.on { transform: none; }
.drawer .body { overflow: auto; padding: 18px 22px; }
.field-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.field-row .k { font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 4px; }
.field-row .v { white-space: pre-wrap; word-break: break-word; }
pre.json { font: 12px/1.5 var(--mono); background: var(--chip); padding: 10px; border-radius: 8px; overflow: auto; margin: 0; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 6px 16px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--ink-3); }
.empty { padding: 40px; text-align: center; color: var(--ink-3); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 13px; z-index: 30; }

/* ---- clarity pass (2026-10-05): dialogs, verdicts, highlights ---------------------------------------------------- */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lead { color: var(--ink-2); max-width: 760px; margin: 4px 0 18px; }
.hint { font-size: 11px; color: var(--ink-3); padding: 0 14px 10px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 340px); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 22px; width: min(760px, 94vw);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .18); }
dialog::backdrop { background: rgba(10, 10, 9, .35); backdrop-filter: blur(2px); }
dialog[open] { animation: fade .18s ease; }
dialog textarea.field { min-height: 260px; font: 13px/1.55 var(--sans); }
.drop { display: block; border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 18px; text-align: center; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, background .15s; font-size: 13px; }
.drop:hover, .drop.over { border-color: var(--ink-3); background: var(--chip); }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: none; padding: 6px 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line-2); }
.segmented button.on { background: var(--ink); color: var(--bg); }
#question-list { max-height: 56vh; overflow: auto; }
.doc-item { position: relative; }
.doc-item .del { position: absolute; top: 6px; right: 6px; opacity: 0; border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.doc-item:hover .del { opacity: 1; }
.doc-item .del:hover { background: var(--line); color: var(--ink); }
.explain { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.chunk .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.chunk .more { border: 0; background: none; color: var(--ink-3); font-size: 12px; cursor: pointer; padding: 0; margin-top: 2px; }
.chunk .more:hover { color: var(--ink); }
.chip.hl { outline: 2px solid var(--accent); outline-offset: 1px; background: color-mix(in srgb, var(--accent) 12%, var(--chip)); }
.verdict { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; font-size: 12.5px; }
.verdict.good { background: color-mix(in srgb, var(--good) 10%, transparent); color: var(--good); }
.verdict.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.verdict b { font-weight: 650; }
.label { font: 600 10.5px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 6px; }
.hit .key { font: 11.5px var(--mono); color: var(--ink-2); background: var(--chip); padding: 1px 6px; border-radius: 4px; }
.hit .tag { font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--good); margin-left: 6px; }
.showmore { border: 0; background: none; color: var(--ink-2); font-size: 12.5px; cursor: pointer; padding: 8px 0 0; }
.showmore:hover { color: var(--ink); }
.steps { counter-reset: step; display: grid; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: flex; gap: 10px; align-items: baseline; color: var(--ink-2); }
.steps li::before { content: counter(step); font: 600 11px var(--mono); width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1px solid var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); }
.welcome { padding: 28px; }
.welcome h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.01em; }

/* ---- sign-in page ------------------------------------------------------------------------------------------------ */
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card { width: min(380px, 100%); padding: 28px; }
.signin-card .brand { font-size: 18px; }
.signin-card label { color: var(--ink-2); font-weight: 550; margin-bottom: -2px; }
.signin-error { min-height: 18px; font-size: 12.5px; color: var(--bad); }

/* ---- exact timings and per-slot tables -------------------------------------------------------------------------- */
.timebar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); margin: 8px 0 8px; }
.timebar i { display: block; height: 100%; }
.timebar i + i { box-shadow: inset 1px 0 0 var(--panel); }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 3px 14px; font-size: 11.5px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend b { font: 600 11.5px var(--mono); color: var(--ink); margin-left: auto; font-variant-numeric: tabular-nums; }
.legend .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tokens-line { font: 11px var(--mono); color: var(--ink-3); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.total { font: 650 13px var(--sans); }
.total small { font-weight: 500; color: var(--ink-3); }
table.slots { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
table.slots td { padding: 5px 8px; border-top: 1px solid var(--line); vertical-align: top; }
table.slots td:first-child { font: 600 11px var(--mono); color: var(--ink-3); width: 38px; }
table.slots td.out { font: 12px/1.4 var(--mono); word-break: break-word; }
table.slots tr.served td.out { color: var(--ink); }
table.slots tr.dropped td.out { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
table.slots tr.stopped td.out { color: var(--ink-3); font-style: italic; }
table.slots td.why { width: 150px; text-align: right; }
.outcome { font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.outcome.served { color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.outcome.dropped { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.outcome.stopped { color: var(--ink-3); background: var(--chip); }
.linkbtn { border: 0; background: none; color: var(--ink-2); font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.linkbtn:hover { color: var(--ink); }
.slot-summary { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
/* Written answer (lab/answer.py): a quiet box above the evidence; [n] citations are small mono buttons. */
.reply { border-left: 2px solid var(--line-2); padding: 2px 0 2px 12px; margin: 0 0 14px; }
.reply.live { border-left-color: var(--ink-3); }
.reply-text { font-size: 13.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.cite { font: 600 10.5px var(--mono); border: 1px solid var(--line-2); background: var(--chip); color: var(--ink-2); border-radius: 4px; padding: 0 4px; margin: 0 1px; cursor: pointer; vertical-align: 1px; }
.cite:hover { border-color: var(--ink-3); color: var(--ink); }
label.label { display: block; } /* a form label in the .label style sits on its own line (the answer dialog) */
