/* ---------- tokens ---------- */

:root {
  color-scheme: light;
  --page: #f1efe9;
  --page-raised: #ebe8e0;
  --surface: #fcfcfb;
  --surface-2: #f5f3ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.16);
  --accent: #6250d6;
  --accent-ink: #4a3aa7;
  --accent-wash: rgba(98, 80, 214, 0.10);
  --glow: rgba(98, 80, 214, 0.12);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-other: #898781;
  /* Categorical order for the per-lab view (validated on the adjacent pairlist, for lines). */
  --lab-1: #2a78d6;
  --lab-2: #eb6834;
  --lab-3: #1baf7a;
  --lab-4: #eda100;
  --lab-5: #e87ba4;
  --lab-6: #008300;
  --lab-7: #6250d6;
  --lab-8: #e34948;
  --frontier: #0b0b0b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.06);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
/* Anchor targets clear the sticky bars. (Not scroll-padding: that also makes focusing a control inside the bars scroll the page.) */
section[id] { scroll-margin-top: 130px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
h1, h2, h3 { letter-spacing: -0.015em; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
h3 { font-size: 15px; margin: 22px 0 6px; }
a { color: var(--accent-ink); }
code { font: 500 13px "JetBrains Mono", ui-monospace, monospace; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 500; font-size: 0.92em;
  background: var(--accent-wash); color: var(--accent-ink); padding: 1px 6px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text-primary); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--text-secondary); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text-primary); background: var(--accent-wash); }

/* ---------- hero ---------- */

.hero {
  position: relative; overflow: hidden;
  padding: 72px 0 56px;
  background:
    radial-gradient(900px 380px at 15% -10%, var(--glow), transparent 70%),
    radial-gradient(700px 300px at 95% 0%, color-mix(in srgb, var(--series-1) 14%, transparent), transparent 70%);
}
.hero::after {
  /* faint tick marks along the bottom, like a clock rim */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 24px);
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  opacity: 0.7;
}
.eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent-ink); }
.hero h1 { font-size: clamp(30px, 4.6vw, 52px); line-height: 1.08; font-weight: 700; margin: 0 0 18px; letter-spacing: -0.03em; max-width: 19ch; text-wrap: balance; }
.lede { margin: 0; max-width: 64ch; color: var(--text-secondary); font-size: 17px; }

/* ---------- control bar ---------- */

.controlbar {
  position: sticky; top: 56px; z-index: 20;
  background: color-mix(in srgb, var(--page-raised) 90%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.controlbar-inner { display: flex; flex-wrap: wrap; gap: 10px 44px; align-items: center; padding-top: 10px; padding-bottom: 10px; }
.control { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Min. benchmarks and the CI switch wrap as one unit, so neither is left alone on a row. */
.control-pair { display: flex; align-items: center; gap: 10px 44px; }
.control-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.status { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* benchmark dropdown */
.dropdown { position: relative; }
.dd-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 190px; justify-content: space-between; }
.dd-btn svg { width: 12px; height: 12px; color: var(--text-muted); transition: transform 120ms; }
.dd-btn[aria-expanded="true"] { border-color: var(--accent); }
.dd-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.dd-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40;
  width: min(440px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(11, 11, 11, 0.14); padding: 8px;
}
.dd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dd-actions { display: inline-flex; gap: 10px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 500; color: var(--accent-ink); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.dd-domain { border-radius: 10px; }
.dd-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; font-size: 14px; color: var(--text-primary); }
.dd-row:hover { background: var(--surface-2); }
.dd-row label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.dd-row input, .dd-bench input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
.dd-row .n { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dd-expand { border: 0; background: none; color: var(--text-muted); cursor: pointer; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; }
.dd-expand:hover { background: var(--border); color: var(--text-primary); }
.dd-expand svg { width: 12px; height: 12px; transition: transform 120ms; }
.dd-expand[aria-expanded="true"] svg { transform: rotate(90deg); }
.dd-benches { padding: 2px 8px 8px 33px; display: grid; gap: 1px; }
.dd-bench { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-secondary); padding: 3px 0; cursor: pointer; }
.dd-bench .n { margin-left: auto; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* intervals switch */
.switch { cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background 150ms; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(11, 11, 11, 0.25); transition: transform 150ms; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.segmented button {
  border: 0; border-radius: 7px; background: transparent; color: var(--text-muted);
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(11, 11, 11, 0.12); }
.seg-sm { margin-top: 10px; }
.head-row { display: flex; align-items: center; gap: 10px 18px; margin-top: 4px; }
.head-row .segmented { flex: none; margin-left: auto; }
.section-head .head-row p { margin: 0; max-width: 112ch; } /* beside the view toggle, wider than other descriptions */

select, .btn, .search, input[type="search"] {
  font: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; padding: 6px 11px; height: 34px;
}
select { padding-right: 28px; }
.btn { cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* ---------- sections ---------- */

main.wrap { padding-top: 40px; padding-bottom: 64px; }
.section { padding: 28px 0; border-top: 1px solid var(--border); }
.section:first-child { border-top: 0; padding-top: 8px; }
.section-head { margin-bottom: 10px; }
.section-head p { margin: 0; color: var(--text-secondary); font-size: 14px; max-width: 76ch; }
.section-head.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-kicker { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; border-top: 1px solid var(--border); }
.grid-2 > .section { border-top: 0; min-width: 0; }

.chart { width: 100%; height: 400px; }
.chart-tall { height: 520px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-secondary); margin: 8px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend svg { overflow: visible; }
.legend button { display: inline-flex; align-items: center; gap: 7px; font: inherit; color: inherit; background: none;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.legend button[aria-pressed="false"] { color: var(--text-muted); }
.legend button[aria-pressed="false"] svg { opacity: 0.25; }
.footnote { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; }

/* ---------- headline gaps (hero) ---------- */

.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: center; }
.hero-stats { display: grid; gap: 22px; }
.hero-stats:empty { display: none; }
.hero-stats .item { border-left: 3px solid; padding: 2px 0 2px 16px; }
.hero-stats .lead { font-size: 14px; color: var(--text-secondary); }
.hero-stats .value { font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stats .muted { font-size: 12px; color: var(--text-muted); }.key-line { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; align-self: center; }

/* ---------- table ---------- */

.search { width: 280px; max-width: 100%; }
.table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }
th:hover { color: var(--text-primary); }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent-ink); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent-ink); }
tbody tr:hover td { background: var(--accent-wash); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
td .ci { color: var(--text-muted); font-size: 12px; }
tr.record td:first-child { font-weight: 600; }
td.reading-cell { font-weight: 600; color: var(--text-primary); }

/* ---------- prose ---------- */

.prose { font-size: 14px; color: var(--text-secondary); }
.prose h2, .prose h3, .prose strong { color: var(--text-primary); }
.prose li { margin-bottom: 8px; max-width: 90ch; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .section + .section { border-top: 1px solid var(--border); }
  /* Controls wrap onto two rows: benchmarks and curve, then min. benchmarks and CI. */
  /* Two classes, so the small-screen .wrap padding reset can't zero the top and bottom. */
  .controlbar .controlbar-inner { gap: 10px 16px; padding-top: 14px; padding-bottom: 14px; }
  #domain-dd { flex: 0 1 260px; }
  /* The curve buttons move to their own row rather than squeeze or wrap. */
  .control:has(#mode-seg) { min-width: auto; }
  #mode-seg { flex-wrap: nowrap; }
  .control-pair { gap: 10px 16px; }
  .dd-btn { min-width: 0; width: 100%; }
  .control { gap: 8px; }
}
@media (max-width: 640px) {
  .head-row { flex-wrap: wrap; }
  .wrap { padding: 0 16px; }
  .nav { display: none; }
  .icon-btn { margin-left: auto; }
  .hero { padding: 44px 0 36px; }
  .hero-stats .value { font-size: 32px; }
  .br-wide { display: none; }
  .controlbar { position: static; }
  section[id] { scroll-margin-top: 64px; }
  .chart { height: 340px; }
  .chart-tall { height: 400px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
