/* fraudvae ui. one file, no build step. */

:root {
  --paper: #f2f4f7;
  --panel: #ffffff;
  --ink: #15212e;
  --ink-2: #566879;
  --ink-3: #8a98a8;
  --line: #d6dde5;
  --line-2: #e7ebf0;
  --accent: #0b6e79;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f2;
  --alarm: #c8102e;
  --alarm-soft: #fbe6e9;
  --calm: #1f7a4d;
  --calm-soft: #e3f3ea;
  --amber: #b8730a;
  --amber-soft: #fbf0dc;
  --receipt: #fffdf7;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --rail: 232px;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.9rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
code, pre, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--line-2); padding: 0 0.3em; border-radius: 3px; }
pre code { background: none; padding: 0; }
.dim { color: var(--ink-2); }
.small { font-size: 0.86rem; }
.hidden { display: none !important; }
b { font-weight: 600; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  background: var(--ink); color: #c9d3de;
  display: flex; flex-direction: column; padding: 1.4rem 1rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 0.55rem; margin-bottom: 2rem; }
.brand-mark { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--accent) 0 70%, var(--alarm) 70% 100%); box-shadow: 0 0 0 3px rgba(255,255,255,0.12); }
.rail-link { display: block; color: #c9d3de; text-decoration: none; padding: 0.5rem 0.65rem; border-radius: var(--radius); margin-bottom: 2px; }
.rail-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.rail-link.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
.rail-foot { margin-top: auto; font-size: 0.82rem; color: #8ea0b3; }
.rail-model { white-space: pre-line; margin-bottom: 0.8rem; line-height: 1.4; }
.rail-dim { color: #8ea0b3; }
.content { padding: 2.2rem 2.6rem 4rem; max-width: 1380px; min-width: 0; }
.page-head { margin-bottom: 1.6rem; max-width: 72ch; }
.lede { color: var(--ink-2); font-size: 1.05rem; margin: 0.5rem 0 0; }
.tab > section, .card-like { margin-top: 2rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }

/* ---------- buttons & fields ---------- */
.btn {
  font: inherit; font-weight: 500; padding: 0.45rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { font: inherit; padding: 0.38rem 0.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); max-width: 100%; }
.field select, .field input { width: 100%; min-width: 0; }
input[type=number] { font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field > span { font-weight: 500; }
.field small { color: var(--ink-2); }
.inline-field { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-2); }
.inline-field input, .inline-field select { color: var(--ink); }
.row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* ---------- score tab ---------- */
.score-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 2rem; align-items: start; }
.score-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.6rem; }
.form-top { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 1rem; }
.example-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; color: var(--ink-2); padding: 0.6rem 0 1rem; border-bottom: 1px solid var(--line-2); }
.fgroup { margin-top: 1.3rem; }
.fgroup-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.fgroup-head h3 { font-size: 0.98rem; }
.fgroup-head .dim { font-size: 0.82rem; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.65rem 1rem; }
.fgrid label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9rem; }
.fgrid label span { color: var(--ink-2); }
.fgrid label.unused span { color: var(--ink-3); }
.fgrid label.unused input, .fgrid label.unused select { background: var(--paper); }
.fgrid small { color: var(--ink-3); font-size: 0.75rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 1rem; align-items: center; }
details.batch { margin-top: 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1.2rem; max-width: 72ch; }
details.batch summary { cursor: pointer; font-weight: 500; }
.batch-form { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* the receipt */
.receipt-col { position: sticky; top: 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; }
.receipt {
  background: var(--receipt); font-family: var(--mono); font-size: 0.84rem; color: var(--ink);
  padding: 1.3rem 1.3rem 1.6rem; position: relative; border: 1px solid var(--line);
  box-shadow: 0 10px 30px -18px rgba(21,33,46,0.35);
}
.receipt::before, .receipt::after {
  content: ""; position: absolute; left: 0; right: 0; height: 8px;
  background: radial-gradient(circle at 6px 0, transparent 5px, var(--receipt) 5.5px) repeat-x;
  background-size: 12px 8px;
}
.receipt::before { top: -8px; transform: scaleY(-1); }
.receipt::after { bottom: -8px; }
.receipt.empty { color: var(--ink-2); }
.receipt-empty p { margin: 0 0 0.6rem; }
.rc-head { text-align: center; border-bottom: 1px dashed var(--ink-3); padding-bottom: 0.7rem; margin-bottom: 0.7rem; }
.rc-head .rc-title { font-weight: 600; letter-spacing: 0.08em; }
.rc-verdict { text-align: center; padding: 0.8rem 0.4rem; margin: 0.6rem 0; border: 2px solid currentColor; font-weight: 600; letter-spacing: 0.04em; }
.rc-verdict.flag { color: var(--alarm); background: var(--alarm-soft); }
.rc-verdict.ok { color: var(--calm); background: var(--calm-soft); }
.rc-verdict.na { color: var(--amber); background: var(--amber-soft); }
.rc-verdict .big { font-size: 1.6rem; display: block; line-height: 1.1; }
.rc-line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.15rem 0; }
.rc-line .k { color: var(--ink-2); }
.rc-sep { border-top: 1px dashed var(--ink-3); margin: 0.6rem 0; }
.rc-sub { font-weight: 600; letter-spacing: 0.06em; margin: 0.2rem 0 0.3rem; }
.rc-sub .dim { font-weight: 400; letter-spacing: 0; }
.rc-bar > i.calm { background: var(--calm); opacity: 0.55; }
.rc-items { margin-top: 0.4rem; }
.rc-item { padding: 0.3rem 0; }
.rc-item .top { display: flex; justify-content: space-between; gap: 0.6rem; }
.rc-item .top .z { font-weight: 600; min-width: 4.2ch; text-align: right; }
.rc-item .z.hot { color: var(--alarm); }
.rc-item .z.warm { color: var(--amber); }
.rc-item .z.cold { color: var(--ink-3); }
.rc-item .sub { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 0.78rem; }
.rc-bar { height: 4px; background: var(--line-2); margin-top: 3px; }
.rc-bar > i { display: block; height: 100%; background: var(--ink-3); }
.rc-bar > i.hot { background: var(--alarm); }
.rc-bar > i.warm { background: var(--amber); }
.rc-foot { text-align: center; color: var(--ink-2); margin-top: 0.8rem; font-size: 0.76rem; }
.rc-more { text-align: center; margin-top: 0.4rem; }
.rc-more button { font: inherit; background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; }
.latent-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }

/* ---------- data tab ---------- */
.corpus-summary { display: flex; gap: 2.5rem; flex-wrap: wrap; padding: 1rem 0 1.4rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.corpus-summary .stat b { display: block; font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.corpus-summary .stat span { color: var(--ink-2); }
.data-layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.source-list { display: flex; flex-direction: column; gap: 0.4rem; }
.source-row { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 1rem; }
.source-row:hover { border-color: var(--ink-3); }
.source-row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.source-row .name { font-weight: 600; }
.source-row .rows { font-variant-numeric: tabular-nums; text-align: right; }
.source-row .meta { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.86rem; }
.source-row.missing { opacity: 0.6; }
.source-row .pill { font-size: 0.74rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.source-row .pill.ok { color: var(--calm); border-color: var(--calm); }
.source-row .pill.no { color: var(--amber); border-color: var(--amber); }
.source-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.5rem; min-height: 300px; }
.source-detail h2 { margin-bottom: 0.3rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.8rem 0; font-size: 0.92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-top: 1rem; }
.chart-box { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0.6rem 0.8rem; }
.chart-box h4 { margin: 0 0 0.3rem; font-size: 0.86rem; color: var(--ink-2); font-weight: 500; }
/* chart.js needs a fixed-height box or it grows forever with maintainAspectRatio off */
.chart-wrap { position: relative; width: 100%; }
.chart-box .chart-wrap { height: 200px; }
.coverage-grid { overflow-x: auto; }
.coverage-grid table { border-collapse: collapse; font-size: 0.8rem; }
.coverage-grid th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 0.2rem 0.5rem; white-space: nowrap; }
.coverage-grid th.rot { writing-mode: vertical-rl; transform: rotate(180deg); padding: 0.4rem 0.2rem; }
.coverage-grid td { padding: 0; }
.coverage-grid td.cell { width: 26px; height: 20px; border: 1px solid #fff; }
.coverage-grid td.lbl { padding: 0 0.6rem 0 0; white-space: nowrap; color: var(--ink-2); }
.coverage-grid td.grp { padding-top: 0.6rem; font-weight: 600; color: var(--ink); }
.pipeline-row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.log {
  background: var(--ink); color: #d5dee8; padding: 0.9rem 1.1rem; border-radius: var(--radius);
  max-height: 340px; overflow: auto; white-space: pre-wrap; font-size: 0.8rem; margin: 0.8rem 0 0; line-height: 1.45;
}
.log:empty { display: none; }

/* ---------- model tab ---------- */
.runs-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.runs-list { display: flex; flex-direction: column; gap: 0.4rem; }
.run-row { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; cursor: pointer; }
.run-row:hover { border-color: var(--ink-3); }
.run-row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.run-row .top { display: flex; justify-content: space-between; gap: 0.5rem; }
.run-row .name { font-weight: 600; word-break: break-all; }
.run-row .auc { font-variant-numeric: tabular-nums; text-align: right; display: flex; flex-direction: column; }
.run-row .auc .generic { color: var(--ink-2); font-size: 0.78rem; }
.run-row .meta { color: var(--ink-2); font-size: 0.84rem; margin-top: 0.15rem; }
.run-row .state { font-size: 0.74rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.run-row .state.running { color: var(--amber); border-color: var(--amber); }
.run-row .state.loaded { color: var(--accent); border-color: var(--accent); }
.run-row.stale { opacity: 0.6; }
.generic-row td { border-top: 2px solid var(--line); }
.imp-list { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.5rem 0 1rem; font-size: 0.82rem; font-family: var(--mono); }
.imp-list .imp { position: relative; padding: 0.1rem 0.4rem; }
.imp-list .imp i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); opacity: 0.12; }
.run-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.5rem; overflow-x: auto; }
.metric-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 0.6rem 0 1rem; }
.metric-table th, .metric-table td { text-align: right; padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.metric-table th:first-child, .metric-table td:first-child { text-align: left; }
.metric-table th { color: var(--ink-2); font-weight: 500; }
.train-form { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }

/* ---------- compute tab ---------- */
.compute-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.advisor, .keybox, .remote { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.5rem; }
.advisor .verdict { font-size: 1.15rem; font-weight: 600; margin: 0.4rem 0 0.8rem; }
.advisor .verdict.remote { color: var(--alarm); }
.advisor .verdict.local { color: var(--calm); }
.tier-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.tier-table th, .tier-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line-2); text-align: right; font-variant-numeric: tabular-nums; }
.tier-table th:first-child, .tier-table td:first-child { text-align: left; }
.tier-table th { color: var(--ink-2); font-weight: 500; }
.req-list { margin: 0.8rem 0 0; padding-left: 1.1rem; font-size: 0.92rem; }
.req-list li { margin-bottom: 0.2rem; }
.pubkey { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; white-space: pre-wrap; word-break: break-all; font-size: 0.78rem; margin: 0 0 0.6rem; }
.host-form { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.probe { margin-top: 0.8rem; }
.probe .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.5rem 1rem; font-size: 0.9rem; }
.probe .grid b { display: block; font-weight: 600; }
.probe .warn { color: var(--amber); }
.probe .okline { color: var(--calm); }
.probe .err { color: var(--alarm); }
.remote-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; margin-top: 1.4rem; }
.step { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.step h3 { font-size: 0.95rem; }
.step .dim { font-size: 0.86rem; margin: 0; }
.remote-status { margin-top: 1rem; font-size: 0.92rem; }
.remote-status .bar { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; margin: 0.4rem 0; max-width: 480px; }
.remote-status .bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------- explain ---------- */
.explain { max-width: 74ch; font-size: 1.02rem; line-height: 1.65; }
.explain h1 { margin-bottom: 0.4rem; }
.explain h2 { margin: 2.4rem 0 0.7rem; font-size: 1.35rem; }
.explain h3 { margin: 1.6rem 0 0.4rem; }
.explain p { margin: 0.7rem 0; }
.explain figure { margin: 1.4rem 0; }
.explain figcaption { color: var(--ink-2); font-size: 0.9rem; margin-top: 0.4rem; }
.explain .katex-display { margin: 1rem 0; overflow-x: auto; }
.explain table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 0.8rem 0; }
.explain th, .explain td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.explain th { color: var(--ink-2); font-weight: 500; }
.explain .aside { border-left: 3px solid var(--accent); padding: 0.4rem 1rem; color: var(--ink-2); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; }
.explain .toc { columns: 2; font-size: 0.92rem; padding-left: 1.1rem; margin: 0.8rem 0 1.4rem; }
.explain svg text { font-family: var(--sans); }

/* ---------- misc ---------- */
.notice { padding: 0.7rem 1rem; border-radius: var(--radius); margin: 0.8rem 0; font-size: 0.92rem; }
.notice.warn { background: var(--amber-soft); color: #6b4300; }
.notice.err { background: var(--alarm-soft); color: #7a0a1b; }
.notice.ok { background: var(--calm-soft); color: #0f4d2e; }
.spin::after { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-left: 0.5em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin::after { animation: none; } }

@media (max-width: 1100px) {
  .score-grid, .data-layout, .runs-layout, .compute-grid { grid-template-columns: 1fr; }
  .receipt-col { position: static; }
  .remote-steps { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 0.2rem; align-items: center; }
  .brand { margin: 0 1rem 0 0; }
  .rail-foot { display: none; }
  .content { padding: 1.2rem 1rem 3rem; }
  .form-top, .chart-pair { grid-template-columns: 1fr; }
}


/* v5: customer history box on the score form */
.history-box { margin: 10px 0 4px; border: 1px dashed var(--line, #d7d9de); border-radius: 6px; padding: 6px 10px; }
.history-box summary { cursor: pointer; font-weight: 600; }
.history-box label { display: block; margin: 8px 0; }
.history-box label span { display: block; font-size: 12px; margin-bottom: 3px; }
.history-box textarea { width: 100%; font-family: var(--mono, monospace); font-size: 12px; box-sizing: border-box; }
.history-box input[type=text] { width: 260px; }
.rc-line.dim span { color: var(--dim, #777); font-size: 12px; }

/* v5 public demo: the model picker, the comparison strip and the timeline */
.field.check .checkline { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; color: var(--ink-1); }
.field.check input[type="checkbox"] { width: 1rem; height: 1rem; }
.rc-compare { margin: 0.4rem 0 0.2rem; border-top: 1px dashed var(--line); padding-top: 0.4rem; }
.rc-compare .rc-line.head .k, .rc-compare .rc-line.head span { color: var(--ink-2); }
.rc-compare .rc-line.me span:first-child { font-weight: 600; }
.timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.7rem; margin: 0 0 1.2rem; }
.timeline .tl-card { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.8rem; background: var(--paper); position: relative; }
.timeline .tl-card.best { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.timeline .tl-card .tl-v { font-size: 0.8rem; color: var(--ink-2); letter-spacing: 0.04em; text-transform: uppercase; }
.timeline .tl-card .tl-name { font-weight: 600; margin: 0.1rem 0 0.3rem; }
.timeline .tl-card .tl-num { font-family: var(--mono); font-size: 0.95rem; }
.timeline .tl-card .tl-meta { color: var(--ink-2); font-size: 0.8rem; margin-top: 0.3rem; line-height: 1.35; }
.timeline .tl-card .tl-changed { font-size: 0.85rem; margin-top: 0.35rem; }
.timeline .tl-card .tl-tag { position: absolute; top: 0.55rem; right: 0.6rem; font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 999px; background: var(--accent); color: white; }
.timeline .tl-card .tl-tag.legacy { background: var(--ink-3, #888); }
.story-switch { display: flex; gap: 0.5rem; align-items: center; margin: 0 0 1rem; color: var(--ink-2); }
.story-switch .btn.small { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.story-switch .btn.active { background: var(--accent-soft); border-color: var(--accent); }
.explain .callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 0.6rem 0.9rem; margin: 1rem 0; border-radius: 4px; }
.explain table.metric-table td, .explain table.metric-table th { vertical-align: top; }

/* right / wrong against a labelled example */
.receipt .call.ok { color: var(--calm); font-weight: 600; }
.receipt .call.bad { color: var(--alarm); font-weight: 600; }

/* ---------- glossary: a word's definition on demand ---------- */
/* terms carry no mark at all; the box is plain monospace text */
.term { cursor: inherit; }
#term-box {
  display: none; position: absolute; z-index: 50; max-width: 380px;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.45; color: var(--ink);
  background: var(--panel); border: 1px solid var(--ink-3); padding: 0.5rem 0.65rem; white-space: pre-wrap;
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  html { font-size: 14.5px; }
  .rail { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0.6rem 0.8rem; gap: 0.1rem; scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .brand { margin: 0 0.8rem 0 0; font-size: 1.05rem; flex: 0 0 auto; }
  .rail-link { flex: 0 0 auto; padding: 0.4rem 0.55rem; white-space: nowrap; font-size: 0.92rem; }
  .content { padding: 1rem 0.9rem 3rem; }
  h1 { font-size: 1.5rem; }
  .page-head { margin-bottom: 1rem; }
  .score-form { padding: 1rem 0.9rem; }
  .fgrid { grid-template-columns: 1fr 1fr; gap: 0.5rem 0.7rem; }
  .example-row { gap: 0.4rem; }
  .receipt { font-size: 0.8rem; padding: 1rem 0.9rem 1.3rem; }
  .rc-line { gap: 0.6rem; }
  .corpus-summary { gap: 1.2rem 1.8rem; }
  .corpus-summary .stat b { font-size: 1.35rem; }
  .source-detail, .run-detail { padding: 1rem 0.9rem; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 0.4rem; }
  .kv dd { overflow-wrap: anywhere; }
  .explain { font-size: 0.98rem; }
  .explain .toc { columns: 1; }
  .explain table, .metric-table, .tier-table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }
  .explain table td, .explain table th { white-space: normal; min-width: 7rem; }
  pre, .log { overflow-x: auto; }
  .timeline { grid-template-columns: 1fr; }
  .history-box input[type=text] { width: 100%; }
  .batch-form input[type=file] { max-width: 100%; }
  .chart-box .chart-wrap { height: 170px; }
  .latent-card .chart-wrap { height: 240px !important; }
  #term-box { font-size: 0.78rem; }
}
@media (max-width: 480px) {
  .fgrid { grid-template-columns: 1fr; }
  .corpus-summary .stat { flex: 1 1 40%; }
}

/* "in detail" folds on the how-it-works page */
.explain details { margin: 0.3rem 0 1.2rem; }
.explain summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
.explain summary:hover { color: var(--ink); }
.explain details[open] summary { margin-bottom: 0.3rem; }
