/* GroundCheck design system.
   Light, instrument-grade, calibrated to Vercel Geist: a near-white canvas, a
   single near-black ink, a deep neutral gray scale, hairline borders, stacked
   subtle shadows, and no decorative accent colour. Colour means status only. */

:root {
  /* surfaces (Geist light) */
  --bg:            #ffffff;   /* Background 1 */
  --bg-subtle:     #fafafa;   /* Background 2 / accents-1 */
  --bg-inset:      #f6f8fa;   /* code / audit blocks */
  --bg-hover:      #f2f2f2;   /* component hover */

  /* hairline borders (Geist gray scale) */
  --border:        #eaeaea;   /* accents-2, default hairline */
  --border-strong: #d4d4d4;

  /* text (single ink + neutral grays) */
  --text:          #171717;   /* near-black ink */
  --text-secondary:#171717;
  --text-muted:    #1f1f1f;
  --text-faint:    #2b2b2b;   /* near-black: all body text reads black */

  /* the only strong resting colour is ink itself (Geist primary button) */
  --ink:           #171717;
  --ink-press:     #000000;

  /* severity (status meaning only, calibrated for white backgrounds) */
  --ok:        #1a7f37;  --ok-bg:     #e8f6ec;  --ok-border:    #aceebb;
  --warn:      #9a6700;  --warn-bg:   #fff8c5;  --warn-border:  #eac54f;
  --danger:    #cf222e;  --danger-bg: #ffebe9;  --danger-border:#ffb3ad;
  --info:      #0969da;  --info-bg:   #ddf4ff;  --info-border:  #b6e3ff;

  /* type */
  --font-sans:  "Inter",system-ui,-apple-system,sans-serif;
  --font-mono:  "JetBrains Mono",ui-monospace,"SF Mono",monospace;
  --font-serif: "Newsreader",Georgia,serif;

  /* scale (8px grid) */
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-6:24px; --space-8:32px; --space-12:48px;
  --radius:10px; --radius-sm:6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(16,24,40,0.05);
  --maxw: 980px;
}

* { box-sizing: border-box; }
/* The hidden attribute must always win, even over components that set their own
   display (flex/grid). Without this, a hidden refusal box or results grid stays
   visible with stale content. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}

/* ---------- Header ---------- */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--text); }
.brand-mark { display: inline-flex; color: var(--ink); }
.brand-mark svg { display: block; }
.brand-word { font-family: var(--font-mono); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.header-right { display: flex; align-items: center; gap: var(--space-2); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.tag-synthetic {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Disclaimer ---------- */
.disclaimer {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: 13px;
  text-align: center;
  padding: var(--space-2) var(--space-6);
}

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: var(--space-12) var(--space-6); }

.hero { margin-bottom: var(--space-8); }
.hero-line {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
  color: var(--text);
}
.hero-sub { color: var(--text-secondary); max-width: 64ch; margin: 0; font-size: 16px; }
.hero-dataset { margin: var(--space-3) 0 0; font-size: 12.5px; color: var(--text-muted); max-width: 70ch; }
.hero-dataset a { color: var(--info); text-decoration: none; }
.hero-dataset a:hover { text-decoration: underline; }

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.panel-title { margin: 0 0 var(--space-4); }

/* ---------- Ask panel ---------- */
.ask-form { display: flex; flex-direction: column; gap: var(--space-3); }
.ask-row { display: flex; gap: var(--space-3); }
.ask-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ask-input::placeholder { color: var(--text-faint); }
.ask-input:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(23,23,23,0.10);
}

.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,23,23,0.18); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-press); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }
.btn-ghost { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-hover); }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--ink); color: var(--text); background: var(--bg-hover); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,23,23,0.15); }

/* ---------- Tuning panel ---------- */
.tuning-panel { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.toggle-icon {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--text-faint);
  position: relative;
  flex: none;
}
.toggle-icon::before, .toggle-icon::after {
  content: ""; position: absolute; background: var(--text-faint);
}
.toggle-icon::before { width: 6px; height: 1.5px; top: 5px; left: 3px; }
.toggle-icon::after { width: 1.5px; height: 6px; top: 3px; left: 5px; }
.tuning-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tuning-status.modified { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }

.tuning-body { margin-top: var(--space-4); }
.tuning-hint { margin: 0 0 var(--space-6); color: var(--text-secondary); font-size: 13.5px; max-width: 70ch; }

.tuning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.control-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-2); }
.control-head label { font-size: 13px; font-weight: 600; color: var(--text); }
.control-val { font-family: var(--font-mono); font-size: 13px; color: var(--text); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 8px; }
.control-note { margin: var(--space-2) 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.45; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: var(--border-strong);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--bg);
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--bg); box-shadow: var(--shadow-sm);
}
input[type="range"]:focus-visible { box-shadow: 0 0 0 3px rgba(23,23,23,0.15); }

.toggles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3) var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--border-strong);
  position: relative; flex: none;
  transition: background 0.15s ease;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(23,23,23,0.15); }
.switch-label { font-size: 13.5px; color: var(--text); }
.switch.disabled { opacity: 0.5; cursor: not-allowed; }

.tuning-actions { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-6); }
.tuning-applies { font-size: 12px; color: var(--text-faint); }

/* ---------- Decision ---------- */
.decision-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.status-chip {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status-chip.answer { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.status-chip.refuse { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.decision-reason { color: var(--text-secondary); font-size: 14px; }

.answer-body { font-size: 16px; line-height: 1.7; color: var(--text); }
.answer-body:empty { display: none; }

.citation {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 1px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.citation:hover { background: var(--bg-hover); border-color: var(--ink); }

.refuse-callout {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.refuse-callout p { margin: 0; font-family: var(--font-mono); font-size: 14px; color: var(--text); }
.routed { color: var(--text-secondary); font-size: 13px; }

/* ---------- Grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); margin-bottom: var(--space-6); }
.grid-2 .panel { margin-bottom: 0; }

/* ---------- Sources ---------- */
.sources { display: flex; flex-direction: column; gap: var(--space-3); }
.source-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  background: var(--bg-subtle);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.source-card.cited { border-color: var(--ink); background: var(--bg); box-shadow: var(--shadow-sm); }
.source-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-1); }
.source-id { font-family: var(--font-mono); font-size: 12px; color: var(--text); font-weight: 600; }
.source-title { font-size: 13px; color: var(--text-secondary); font-weight: 500; text-align: right; }
.source-snippet { font-size: 13px; color: var(--text-muted); margin: var(--space-1) 0 var(--space-2); line-height: 1.5; }
.score-row { display: flex; align-items: center; gap: var(--space-2); }
.score-bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.score-bar-fill { height: 100%; background: var(--text-faint); border-radius: 2px; }
.source-card.cited .score-bar-fill { background: var(--ink); }
.score-num { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

/* ---------- Trace ----------
   (clickable, explained trace styles live in the dedicated block lower down) */
@keyframes traceIn { to { opacity: 1; transform: translateY(0); } }

/* ---------- Collapsible ---------- */
.collapsible-toggle {
  width: 100%; background: none; border: none; color: inherit; cursor: pointer;
  display: flex; align-items: center; gap: var(--space-3); padding: 0; text-align: left;
}
/* Keep the eyebrow and the summary text on one cleanly-centred line. */
.collapsible-toggle > * { line-height: 1.4; display: inline-flex; align-items: center; }
.collapsible-toggle .eyebrow { margin: 0; }
.how-summary, .eval-summary, .corpus-summary { color: var(--text-secondary); }
.collapsible-toggle .chevron { margin-left: auto; color: var(--text-faint); transition: transform 0.15s ease; }
.collapsible-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.audit-controls { display: flex; gap: var(--space-2); margin: var(--space-4) 0 var(--space-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.audit-tree {
  margin: var(--space-2) 0 0;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px; line-height: 1.6; color: var(--text);
  overflow: auto; max-height: 460px;
}
.j-node { margin-left: 2px; }
.j-body { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 10px; }
.j-summary { cursor: pointer; list-style: none; }
.j-summary::-webkit-details-marker { display: none; }
.j-summary::before { content: "▸"; display: inline-block; width: 12px; color: var(--text-faint); }
details[open] > .j-summary::before { content: "▾"; }
.j-line { padding-left: 12px; }
.j-key { color: #8250df; }
.j-meta { color: var(--text-faint); }
.j-val.j-string { color: #0a7d33; }
.j-val.j-number { color: #0969da; }
.j-val.j-boolean { color: #b5320b; }
.j-val.j-null { color: var(--text-faint); }

/* ---------- Evaluation ---------- */
.eval-summary { font-size: 13px; color: var(--text-secondary); }
.eval-body { margin-top: var(--space-4); }
.eval-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: var(--space-2); }
.eval-bar-fill { height: 100%; background: var(--ok); width: 0; transition: width 0.5s ease; }
.eval-caption { margin: 0 0 var(--space-3); font-size: 12px; color: var(--text-faint); }
.eval-cases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.eval-case { display: flex; align-items: center; gap: var(--space-3); font-size: 13px; }
.eval-case .glyph { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.eval-case .glyph.ok { background: var(--ok); }
.eval-case .glyph.bad { background: var(--danger); }
.eval-case .q { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eval-case .verdict { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-left: auto; white-space: nowrap; }
.eval-foot { margin: var(--space-3) 0 0; font-size: 12px; color: var(--text-faint); }
.adversarial-block { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.adv-head { display: flex; align-items: baseline; gap: var(--space-3); }
.adv-score { font-size: 13px; color: var(--text-secondary); }
.adv-note { margin: var(--space-2) 0 var(--space-3); font-size: 12.5px; color: var(--text-faint); line-height: 1.5; max-width: 76ch; }

/* ---------- Example chip groups ---------- */
.chip-group { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.chip-group-label { color: var(--text-faint); }
.chips-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- How it works ---------- */
.how-summary { font-size: 13px; color: var(--text-secondary); }
.how-body { margin-top: var(--space-4); }
.how-intro { margin: 0 0 var(--space-6); color: var(--text-secondary); font-size: 14.5px; max-width: 74ch; }
.how-stages { list-style: none; margin: 0 0 var(--space-6); padding: 0; display: flex; flex-direction: column; }
.how-stage { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.how-stage:last-child { border-bottom: none; }
.how-stage-num { color: var(--text-faint); font-size: 12px; }
.how-stage-name { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.how-stage-desc { font-size: 13px; color: var(--text-muted); }
.how-judge { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.how-judge-title { margin: 0 0 var(--space-2); font-size: 15px; font-weight: 600; }
.how-judge p { margin: 0; color: var(--text-secondary); font-size: 14px; max-width: 74ch; }
.how-judge code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* ---------- Richer source cards ---------- */
.source-id-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.source-rank { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.source-score-tag { font-family: var(--font-mono); font-size: 12px; color: var(--text); font-weight: 600; }
.src-badge { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 999px; }
.cited-badge { background: var(--ink); color: #fff; }
.below-gate { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.source-title-row { font-size: 13.5px; color: var(--text); font-weight: 500; margin: var(--space-2) 0; }
.source-meta { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-bottom: var(--space-2); }
.meta-tag { font-family: var(--font-mono); font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); background: var(--bg); }
.tag-kind { color: var(--text); border-color: var(--border-strong); }
.tag-section { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
.tag-topic { color: var(--text-muted); }
.score-row .score-num { text-transform: lowercase; }
.source-card.flash { animation: flashPulse 0.8s ease; }
@keyframes flashPulse { 0% { box-shadow: 0 0 0 0 rgba(23,23,23,0.35); } 100% { box-shadow: 0 0 0 6px rgba(23,23,23,0); } }

/* ---------- Clickable trace ---------- */
.trace { list-style: none; margin: 0; padding: 0; }
.trace-item {
  border-bottom: 1px solid var(--border);
  opacity: 0; transform: translateY(4px);
  animation: traceIn 0.28s ease forwards;
}
.trace-item:last-child { border-bottom: none; }
.trace-row {
  width: 100%; background: none; border: none; cursor: pointer;
  display: grid; grid-template-columns: 16px 1fr auto;
  align-items: baseline; gap: var(--space-3);
  padding: var(--space-3) 0; text-align: left; color: inherit;
}
.trace-row:hover .trace-name { color: var(--ink); }
.trace-row:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(23,23,23,0.18); border-radius: 4px; }
.trace-glyph { width: 9px; height: 9px; border-radius: 50%; align-self: center; background: var(--text-faint); }
.trace-glyph.pass { background: var(--ok); }
.trace-glyph.warn { background: var(--warn); }
.trace-glyph.fail { background: var(--danger); }
.trace-glyph.info { background: var(--info); }
.trace-glyph.skip { background: var(--border-strong); }
.trace-main { min-width: 0; }
.trace-name { font-family: var(--font-mono); font-size: 13px; color: var(--text); transition: color 0.12s ease; }
.trace-item.skip .trace-name { color: var(--text-faint); }
.trace-item.fail .trace-name { color: var(--danger); }
.trace-detail { font-size: 12px; color: var(--text-muted); }
.trace-item.skip .trace-detail { color: var(--text-faint); }
.trace-right { display: flex; align-items: center; gap: var(--space-2); }
.trace-ms { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.trace-caret { color: var(--text-faint); font-size: 11px; transition: transform 0.15s ease; }
.trace-item.open .trace-caret { transform: rotate(90deg); }

.trace-expand { padding: 0 0 var(--space-4) var(--space-6); }
.stage-explain { margin: 0 0 var(--space-3); font-size: 13px; color: var(--text-secondary); line-height: 1.55; max-width: 70ch; }
.stage-data { background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.data-line { display: flex; align-items: center; gap: var(--space-3); font-size: 12.5px; }
.data-line .data-muted { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-score { color: var(--text); }
.data-note { margin: 0 0 var(--space-1); font-size: 12px; color: var(--text-faint); }
.data-muted { color: var(--text-muted); font-size: 12.5px; margin: 0; }
.data-muted.small { font-size: 11.5px; }
.mono { font-family: var(--font-mono); }
.mono.strong { font-weight: 600; color: var(--text); }

.claim-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); background: var(--bg); display: flex; flex-direction: column; gap: var(--space-2); }
.claim-text { margin: 0; font-size: 13px; color: var(--text); line-height: 1.5; }
.claim-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.claim-stat { font-family: var(--font-mono); font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.claim-stat.ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }
.claim-stat.bad { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.judge-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); padding-top: var(--space-1); border-top: 1px dashed var(--border); }
.judge-verdict { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.judge-verdict.ok { color: var(--ok); }
.judge-verdict.bad { color: var(--danger); }
.judge-reason { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ---------- Corpus map ---------- */
.corpus-summary { font-size: 13px; color: var(--text-secondary); }
.corpus-body { margin-top: var(--space-4); }
.corpus-hint { margin: 0 0 var(--space-4); color: var(--text-secondary); font-size: 13.5px; max-width: 74ch; }
.corpus-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); margin-bottom: var(--space-6); }
.corpus-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); background: var(--bg-subtle); }
.tile-value { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.tile-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.corpus-map-wrap { display: flex; flex-direction: column; gap: var(--space-3); }
.corpus-canvas-wrap { position: relative; }
.corpus-canvas {
  width: 100%; aspect-ratio: 1 / 1; max-width: 520px; margin: 0 auto;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: block;
  cursor: grab; touch-action: none;
}
.corpus-canvas:active { cursor: grabbing; }
.corpus-drag-hint {
  position: absolute; top: var(--space-2); left: var(--space-2);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 8px; pointer-events: none; transition: opacity 0.3s ease;
}
.corpus-fs-btn {
  position: absolute; top: var(--space-2); right: var(--space-2);
  width: 30px; height: 30px; line-height: 1; font-size: 16px;
  background: var(--bg); color: var(--text-secondary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.corpus-fs-btn:hover { background: var(--bg-hover); color: var(--text); }
.corpus-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  max-width: 220px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: var(--space-2) var(--space-3);
}
.corpus-tooltip .tt-head { display: flex; align-items: baseline; gap: var(--space-2); justify-content: space-between; }
.corpus-tooltip .tt-id { font-size: 11px; font-weight: 600; color: var(--text); }
.corpus-tooltip .tt-kind { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.corpus-tooltip .tt-title { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.35; }
.corpus-tooltip .tt-section { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.corpus-tooltip .tt-retrieved { font-size: 10.5px; color: var(--ink); font-weight: 600; margin-top: 3px; }
.corpus-canvas-wrap.fullscreen {
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.corpus-canvas-wrap.fullscreen .corpus-canvas {
  width: 92vmin; height: 92vmin; max-width: 92vmin; aspect-ratio: auto;
}

/* Clickable topics tile + topic list */
.corpus-tile.clickable { cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.corpus-tile.clickable:hover { border-color: var(--ink); background: var(--bg-hover); }
.corpus-tile.clickable:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,23,23,0.15); }
.topic-list-panel {
  margin: 0 0 var(--space-6); border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-subtle); padding: var(--space-4);
}
.topic-list-head { margin-bottom: var(--space-3); color: var(--text-faint); }
.topic-list-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-1) var(--space-4); max-height: 320px; overflow-y: auto;
}
.topic-item { display: flex; align-items: center; gap: var(--space-2); font-size: 12.5px; padding: 2px 0; }
.topic-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.topic-name { color: var(--text-secondary); text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-count { margin-left: auto; color: var(--text-faint); }
.corpus-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.corpus-section-bars { margin-top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); }
.section-bars-title { margin-bottom: var(--space-1); }
.section-bar-row { display: grid; grid-template-columns: 200px 1fr 48px; align-items: center; gap: var(--space-3); }
.section-bar-label { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.section-bar-fill { height: 100%; background: var(--text-faint); border-radius: 3px; }
.section-bar-num { font-size: 11px; color: var(--text-faint); text-align: right; }

/* ---------- Refusal explain ---------- */
.refuse-explain { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- Dataset provenance ---------- */
.dataset-note { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.dataset-note p { margin: var(--space-2) 0 0; font-size: 13px; color: var(--text-secondary); line-height: 1.55; max-width: 78ch; }
.dataset-note a { color: var(--info); text-decoration: none; }
.dataset-note a:hover { text-decoration: underline; }
.dataset-note code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* ---------- Footer ---------- */
.footer { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); text-align: center; padding-top: var(--space-8); }
.footer-note { margin-top: var(--space-2); max-width: 70ch; margin-left: auto; margin-right: auto; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .tuning-grid { grid-template-columns: 1fr; gap: var(--space-4); }
}
@media (max-width: 760px) {
  .container { padding: var(--space-8) var(--space-4); }
  .grid-2 { grid-template-columns: 1fr; }
  .header-inner { padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
  .ask-row { flex-direction: column; }
  .btn-primary { justify-content: center; }
  .toggles { grid-template-columns: 1fr; }
  .corpus-pill, .tag-synthetic { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .trace-row { animation: none; opacity: 1; transform: none; }
  .spinner { animation: none; }
  .eval-bar-fill, .switch-thumb, .chevron { transition: none; }
}
