/* Layout: a registry ledger. Summary band, substance-by-stage matrix, start-year chart, then a filterable list of trial records. */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #5a6872;
  --line: #d9e0e4;
  --accent: #0b6e72;
  --accent-soft: #dcefef;
  --s-alcohol: #b5651d;
  --s-tobacco: #6b5b95;
  --s-opioid: #2a6f97;
  --s-cocaine: #a23b52;
  --s-meth: #3d8c40;
  --s-cannabis: #8a7a12;
  --st-finished: #2c6e49;
  --st-underway: #0b6e72;
  --st-planned: #7a6a9a;
  --st-stopped: #8a8f94;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f171c; --surface: #16222a; --ink: #e4ecef; --muted: #98a8b1; --line: #26363f;
    --accent: #5cc3c4; --accent-soft: #173a3d;
    --s-alcohol: #e0954f; --s-tobacco: #a796d6; --s-opioid: #6fb3dc; --s-cocaine: #e07a92; --s-meth: #7cc47f; --s-cannabis: #d4c45a;
    --st-finished: #6fc48f; --st-underway: #5cc3c4; --st-planned: #b3a4d6; --st-stopped: #8d979e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f171c; --surface: #16222a; --ink: #e4ecef; --muted: #98a8b1; --line: #26363f;
  --accent: #5cc3c4; --accent-soft: #173a3d;
  --s-alcohol: #e0954f; --s-tobacco: #a796d6; --s-opioid: #6fb3dc; --s-cocaine: #e07a92; --s-meth: #7cc47f; --s-cannabis: #d4c45a;
  --st-finished: #6fc48f; --st-underway: #5cc3c4; --st-planned: #b3a4d6; --st-stopped: #8d979e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-body); margin: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 32px 56px; display: grid; gap: 36px; }
h1, h2 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.1; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
p { margin: 0; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eyebrow { font: 600 0.72rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.lede { max-width: 66ch; color: var(--muted); font-size: 1.02rem; }
header { display: grid; gap: 12px; }
.meta { font: 0.8rem var(--font-mono); color: var(--muted); }

/* Stage summary */
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stage { background: var(--surface); padding: 14px 16px; display: grid; gap: 4px; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.stage:hover { background: var(--accent-soft); }
.stage[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--accent); }
.stage .n { font: 600 1.9rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.stage .lbl { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* Matrix */
section { display: grid; gap: 14px; min-width: 0; }
.section-note { color: var(--muted); font-size: 0.9rem; max-width: 70ch; }
.scroll { overflow-x: auto; }
table.matrix { border-collapse: collapse; width: 100%; min-width: 560px; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix th { font: 600 0.75rem var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix td.sub { font-weight: 600; white-space: nowrap; }
.cell { min-width: 2.4em; padding: 4px 8px; border-radius: 6px; border: 0; font: 600 0.95rem var(--font-body); color: var(--ink); cursor: pointer; background: transparent; }
.cell:hover { outline: 1px solid var(--accent); }
.cell.zero { color: var(--line); cursor: default; }
.cell.zero:hover { outline: none; }

/* Chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font-mono); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters label { display: grid; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.filters input, .filters select { font: inherit; font-size: 0.92rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; min-width: 0; }
.filters input { width: min(280px, 100%); }
.filters .count { margin-left: auto; font: 0.85rem var(--font-mono); color: var(--muted); }
.reset { font: inherit; font-size: 0.85rem; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 7px; padding: 7px 12px; cursor: pointer; }

/* Trial records */
.list { display: grid; gap: 12px; }
.trial { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.trial-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.chip { font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.pill { font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: var(--surface); white-space: nowrap; }
.nct { font: 0.8rem var(--font-mono); color: var(--muted); margin-left: auto; }
.trial h3 { margin: 0; font: 600 1.05rem/1.35 var(--font-body); text-wrap: balance; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.85rem; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 600; }
.outcome { font-size: 0.88rem; }
.outcome span { color: var(--muted); }
.finding { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; font-size: 0.92rem; }
.verdict { font: 600 0.72rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.pubs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; }
.pubs a { text-decoration: none; }
.pubs a:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 24px 0; }
footer { color: var(--muted); font-size: 0.85rem; display: grid; gap: 8px; max-width: 80ch; border-top: 1px solid var(--line); padding-top: 18px; }
@media (max-width: 560px) { .nct { margin-left: 0; width: 100%; } .filters .count { margin-left: 0; width: 100%; } }
