:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --warning-bg: #fff6df;
  --warning-border: #f0d48a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --good-text: #0ca30c;
    --warning-bg: #2a2412;
    --warning-border: #5c4a17;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --good-text: #0ca30c;
  --warning-bg: #2a2412;
  --warning-border: #5c4a17;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, select, input {
  font: inherit;
  color: inherit;
}

/* ---------------- Top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #2a78d6, #6250d6);
  display: grid; place-items: center;
  color: white; font-size: 13px;
}

.data-source {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.data-source label { color: var(--text-muted); font-size: 12px; }
.data-source select,
.data-source input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  max-width: 420px;
  min-width: 0;
}
.data-source input { width: 300px; }

.btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }

/* ---------------- Layout ---------------- */

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
}
.card .sub {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0 0 10px;
}

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 1000px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
}

.section-title {
  margin: 28px 0 10px;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.section-title .hint { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.banner .icon { font-size: 15px; line-height: 1.3; }
.banner .close { margin-left: auto; }

.loading, .error {
  padding: 60px 0;
  text-align: center;
  color: var(--text-muted);
}
.error { color: var(--critical); }

/* ---------------- Controls ---------------- */

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.control-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 8px;
}
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-secondary);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); margin: 0; }

/* ---------------- Overview ---------------- */

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}
@media (max-width: 1100px) {
  .overview-layout { grid-template-columns: minmax(0, 1fr); }
}
.scatter-card { padding: 8px 8px 4px; }
#scatter { width: 100%; height: min(70vh, 720px); min-height: 440px; }

.side-column { display: flex; flex-direction: column; gap: 16px; }

.task-strip { display: grid; gap: 6px 24px; margin-bottom: 14px; padding: 12px 16px; }
.task-strip.multi { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.task-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.task-row { display: flex; gap: 8px; align-items: baseline; }
.task-row .swatch { flex: none; transform: translateY(2px); }
.task-quote { color: var(--text-primary); }
.task-quote.big { font-size: 15px; font-style: italic; color: var(--text-secondary); margin-top: 4px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  background: var(--text-primary);
  color: var(--page);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }

.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-section + .legend-section { margin-top: 8px; }
.legend-head {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px 2px;
}
.legend-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}
.legend-item:hover { background: var(--surface-2); }
.legend-item.off { opacity: 0.4; }
.legend-item .swatch { flex: none; }
.legend-item .name { flex: 1; font-size: 13px; color: var(--text-primary); }
.legend-item .count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------- Chips & badges ---------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.chip b { color: var(--text-primary); font-weight: 600; }
.chip.picked { border-color: var(--accent); background: var(--accent-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.good { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 13%, transparent); }
.badge.neutral { color: var(--text-secondary); background: var(--surface-2); }
.badge.partial { color: #9a6a00; background: rgba(237, 161, 0, 0.16); }
:root[data-theme="dark"] .badge.partial, :root[data-theme="dark"] .matrix.decisions td.partial { color: #f2c04d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.partial, :root:not([data-theme="light"]) .matrix.decisions td.partial { color: #f2c04d; }
}
.badge.accent { color: var(--accent); background: var(--accent-soft); }
.badge.solid { color: #fff; }
.badge.accent.solid { background: var(--accent); }
.badge.good.solid { background: #0a8a0a; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12px;
}
.chip-btn:hover { border-color: var(--axis); }
.chip-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------------- Paradigm page ---------------- */

.crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-header h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-header .params { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.nav-arrows { display: flex; gap: 6px; align-items: flex-start; }

.kpi .label { font-size: 12px; color: var(--text-muted); }
.kpi .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2px 0;
}
.kpi .value .unit { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.kpi .foot { font-size: 12px; color: var(--text-secondary); }
.meter {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.pipeline {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.pipeline .step {
  flex: 1 1 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  font-size: 13px;
}
.pipeline .step .n { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pipeline .arrow { align-self: center; color: var(--text-muted); }
.prompt-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chart { width: 100%; height: 260px; }

/* Matrices: accuracy (overview) and decisions (paradigm page) */
.matrix { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 12px; }
.matrix th { color: var(--text-muted); font-weight: 500; padding: 4px; text-align: center; white-space: nowrap; }
.matrix th.group { color: var(--text-secondary); border-bottom: 1px solid var(--grid); }
.matrix th.row { text-align: right; padding-right: 8px; width: 1%; }
.matrix th.row a { color: var(--text-primary); }
.matrix th.model-col { text-align: left; width: 1%; padding-right: 10px; }
.matrix th.model-col .swatch { vertical-align: -2px; }
.matrix td {
  text-align: center;
  padding: 7px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  border: 2px solid transparent;
  transition: transform 0.08s;
}
.matrix td:hover { transform: scale(1.05); }
.matrix td .v { font-weight: 650; }
.matrix td .t { font-size: 11px; opacity: 0.8; }
.matrix td.pooled { background: var(--surface-2); cursor: default; }
.matrix td.pooled:hover, .matrix td.empty:hover, .matrix td.stat:hover { transform: none; }
.matrix td.empty { color: var(--text-muted); cursor: default; }

.decision-card h3 { margin-bottom: 8px; }
.matrix.decisions td.dcell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 650; }
.matrix.decisions td.ok { color: var(--good-text); background: color-mix(in srgb, var(--good) 16%, transparent); }
.matrix.decisions td.bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 14%, transparent); }
.matrix.decisions td.partial { color: #9a6a00; background: rgba(237, 161, 0, 0.16); }
.matrix.decisions td.failed { color: var(--text-secondary); background: var(--surface-2); }
.pips { display: flex; justify-content: center; gap: 2px; margin-top: 3px; }
.pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--grid); }
.pips i.ok { background: var(--good); }
.pips i.bad { background: var(--critical); }
.pips i.failed { background: var(--axis); }
.matrix.decisions td.current { border-color: var(--text-primary); }
.matrix.decisions td.stat { cursor: default; color: var(--text-secondary); font-size: 11px; }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--axis);
  white-space: nowrap;
}
table.data th.num { text-align: right; }
table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-secondary);
  max-width: 620px;
}

.stackbar {
  display: flex;
  height: 10px;
  gap: 2px;
  border-radius: 4px;
  overflow: hidden;
}
.stackbar > span { height: 100%; }
.stackcell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.stackcell .track { flex: 1; }

details.table-view summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 0;
}

/* ---------------- Decision inspector ---------------- */

#inspector { margin-top: 16px; scroll-margin-top: 70px; }
.inspector { display: flex; flex-direction: column; gap: 16px; }
.inspector-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.inspector-head h2 { margin: 2px 0 0; font-size: 18px; }
.inspector-result { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.inspector-result .badge { font-size: 14px; padding: 3px 12px; }
.breakdown { display: flex; flex-direction: column; align-items: flex-end; color: var(--text-secondary); }
.inspector-nav { display: flex; gap: 10px 28px; flex-wrap: wrap; }
.inspector-nav .control-label { display: block; margin-bottom: 4px; }

.reasoning {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px 14px;
}
@media (max-width: 900px) { .reasoning { flex-direction: column; } }
.reasoning .o0 { margin: 0; flex: 0 0 min(420px, 40%); }
.reasoning .o0 img { width: 100%; border-radius: 8px; display: block; cursor: zoom-in; background: #000; }
.reasoning-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.tt-section { color: var(--text-muted); font-size: 11px; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.quote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.quote .ref {
  display: inline-block;
  margin: 0 2px 0 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.error-pre {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--critical);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}
.sim-list { display: flex; flex-direction: column; gap: 4px; max-width: 520px; }
.sim { display: flex; align-items: center; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; padding: 2px 6px; border-radius: 6px; }
.sim.picked { background: var(--accent-soft); font-weight: 600; }
.sim .bar { flex: 1; height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.sim .bar span { display: block; height: 100%; border-radius: 4px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.kv dd { margin: 0; color: var(--text-secondary); }

.cand-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; }
.cand-toolbar h3 { margin: 0; font-size: 14px; }
.frame-slider { width: 180px; accent-color: var(--accent); }
.action-legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.line-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; vertical-align: middle; }
.line-key.sq { width: 10px; height: 10px; border-radius: 2px; }

.cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.cand {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cand.target { box-shadow: 0 0 0 2px var(--good); }
.cand.selected { box-shadow: 0 0 0 3px var(--accent); }
.cand.selected.target { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--good); }
.cand-media { position: relative; cursor: zoom-in; background: #000; }
.cand-media video { width: 100%; aspect-ratio: 8 / 3; object-fit: contain; display: block; }
.cand-missing { aspect-ratio: 8 / 3; display: grid; place-items: center; }
.cand-idx {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 6px; border-radius: 5px;
}
.cand-flags { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.cand-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.cand-label { font-size: 13px; font-weight: 600; }
.cand-narration {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.cand-narration.open { display: block; }

.strip-wrap { display: grid; grid-template-columns: 38px 1fr; gap: 6px; align-items: stretch; }
.strip-labels { display: flex; flex-direction: column; justify-content: space-around; font-size: 10px; text-align: right; }
.action-strip { width: 100%; height: 26px; display: block; }

/* ---------------- Modal ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(1200px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.modal header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal header h3 { margin: 0; font-size: 15px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.modal-scroll { overflow: auto; min-height: 0; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body video { width: 100%; max-height: 72vh; background: #000; border-radius: 8px; }
.modal pre {
  margin: 0;
  padding: 16px 18px;
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.placeholder {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 3px;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  main { padding: 16px 16px 48px; }
  .data-source { margin-left: 0; width: 100%; }
  .data-source input { width: 100%; }
  .cand-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------------------
   VLA command-following explorer
   --------------------------------------------------------------------------- */

a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  display: flex; flex-direction: column; padding: 8px 16px 9px; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550;
}
.tab:hover { text-decoration: none; color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.tab-count { font-size: 11px; font-weight: 400; color: var(--text-muted); }

.scatter-note { padding: 0 8px 6px; min-height: 18px; }
.matrix td.unlabeled { background: var(--surface-2); color: var(--text-muted); }
.matrix td.unlabeled .v { font-weight: 500; }

h1.command { font-size: 22px; font-weight: 650; margin: 4px 0 8px; line-height: 1.3; }

.trial-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.trial-card { display: flex; flex-direction: column; gap: 10px; }
.trial-head { display: flex; gap: 10px; align-items: baseline; }
.plot { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.plot img { display: block; width: 100%; height: auto; }
.no-plot { padding: 40px 16px; text-align: center; color: var(--text-muted); background: var(--surface-2); border-radius: 8px; }
.model-text { margin: 0; font-size: 13px; color: var(--text-secondary); }
.metrics { font-variant-numeric: tabular-nums; }

.label-buttons { display: flex; gap: 8px; }
.label-buttons .btn { flex: 1; }
.btn.label-yes.on { background: color-mix(in srgb, var(--good) 18%, transparent); border-color: var(--good); color: var(--good-text); font-weight: 650; }
.btn.label-no.on { background: color-mix(in srgb, var(--critical) 15%, transparent); border-color: var(--critical); color: var(--critical); font-weight: 650; }

.progress { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 220px; }
.meter.wide { flex: 1; margin: 0; }
.label-card { display: flex; flex-direction: column; gap: 14px; }
.label-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.label-head .params { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.label-actions { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.btn.big { height: 44px; font-size: 15px; font-weight: 600; justify-content: space-between; display: flex; align-items: center; gap: 12px; }
.btn.big.label-yes { border-color: var(--good); color: var(--good-text); }
.btn.big.label-yes:hover { background: color-mix(in srgb, var(--good) 14%, transparent); }
.btn.big.label-no { border-color: var(--critical); color: var(--critical); }
.btn.big.label-no:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
kbd {
  font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
}
.label-nav { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.grid.cols-2.label-views { align-items: start; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.query-header { margin-bottom: 16px; }
.query-header .params { display: flex; gap: 6px; flex-wrap: wrap; }
.controls .segmented { flex-wrap: wrap; }
.card.done { text-align: center; padding: 40px 16px; }

@media (max-width: 640px) {
  .grid.cols-2.label-views { grid-template-columns: 1fr; }
  .progress { margin-left: 0; width: 100%; }
  .label-actions { width: 100%; }
}
