:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f3f0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --up: #2a78d6;
  --down: #eb6834;
  --up-text: #1c5cab;
  --down-text: #b2461b;
  --y2024: #86b6ef;
  --y2025: #2a78d6;
  --y2026: #104281;
  --seq-lo: #cde2fb;
  --seq-hi: #0d366b;
  --spark-dim: #c3c2b7;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #222220;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --up: #3987e5;
    --down: #d95926;
    --up-text: #86b6ef;
    --down-text: #f0956d;
    --y2024: #184f95;
    --y2025: #3987e5;
    --y2026: #9ec5f4;
    --seq-lo: #1d2a3a;
    --seq-hi: #9ec5f4;
    --spark-dim: #52514e;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --up: #3987e5;
  --down: #d95926;
  --up-text: #86b6ef;
  --down-text: #f0956d;
  --y2024: #184f95;
  --y2025: #3987e5;
  --y2026: #9ec5f4;
  --seq-lo: #1d2a3a;
  --seq-hi: #9ec5f4;
  --spark-dim: #52514e;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-muted); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text-primary); white-space: nowrap; }
.brand svg { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--text-secondary); padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn:hover { color: var(--text-primary); }

/* hero */
.hero { padding-top: 48px; padding-bottom: 8px; }
.eyebrow { color: var(--accent-ink); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 10px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 700; letter-spacing: -0.02em; max-width: 820px; }
.lede { color: var(--text-secondary); font-size: 17px; max-width: 780px; margin: 14px 0 28px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }
.tile .delta { font-size: 13px; margin-top: 2px; color: var(--text-muted); }
.delta-up { color: var(--up-text); }
.delta-down { color: var(--down-text); }

.banner { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 20px; font-size: 14px; color: var(--text-secondary); }
.banner b { color: var(--text-primary); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.insights { margin-top: 16px; padding: 18px 20px; }
.insights h2 { font-size: 15px; font-weight: 650; margin-bottom: 8px; }
.insights ul { margin: 0; padding-left: 18px; color: var(--text-secondary); }
.insights li { margin: 4px 0; }
.insights li b { color: var(--text-primary); font-weight: 600; }

/* sections */
.section { padding-top: 56px; }
.section-head { margin-bottom: 16px; max-width: 820px; }
.section-head h2 { font-size: 26px; font-weight: 680; letter-spacing: -0.01em; }
.section-head p { color: var(--text-secondary); margin: 8px 0 0; }
.sub-h { font-size: 16px; font-weight: 650; margin: 24px 0 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.grid-wide-left { grid-template-columns: 3fr 2fr; }
@media (max-width: 880px) { .grid-2, .grid-wide-left { grid-template-columns: 1fr; } }

/* segmented tabs */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.seg button {
  border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 14px;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.seg button:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* chart cards */
.chart-card { padding: 16px 18px 12px; margin-top: 16px; min-width: 0; }
.grid-2 > .chart-card { margin-top: 0; }
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cc-title { font-size: 15px; font-weight: 650; }
.cc-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.cc-toggle {
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; cursor: pointer; flex: none;
}
.cc-toggle:hover { color: var(--text-primary); }
.cc-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
.cc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cc-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cc-body { margin-top: 8px; }
.cc-chart { width: 100%; }
.cc-table { max-height: 420px; overflow: auto; }
.cc-table table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cc-table th, .cc-table td, .data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.cc-table th, .data-table th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
.cc-table td.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cc-note { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

/* sparkline grid */
.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.spark {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: end;
}
.spark .name { grid-column: 1 / -1; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark .val { font-size: 20px; font-weight: 650; }
.spark .val small { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 4px; }
.spark .chg { font-size: 12px; }
.spark svg { grid-row: 2 / 4; grid-column: 2; }

/* explorer */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; align-items: center; }
.filters input[type="search"], .filters select {
  font: inherit; font-size: 14px; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.filters input[type="search"] { flex: 1 1 260px; }
.filters select { flex: 0 1 auto; max-width: 220px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--text-secondary); padding: 0 6px; }
#count { margin: 12px 2px; font-size: 14px; }
.paper-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.paper { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.paper .pt { font-weight: 600; color: var(--text-primary); }
.paper .pa { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.paper .pm { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap; }
.chip.venue { color: var(--text-primary); font-weight: 600; }
.paper .links { display: flex; gap: 12px; margin-left: auto; font-size: 13px; }
.pager { display: flex; justify-content: center; margin-top: 14px; }
.btn { font: inherit; font-size: 14px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }

.about h2 { font-size: 22px; }
.about h3 { font-size: 15px; margin: 18px 0 6px; }
.about p { color: var(--text-secondary); margin: 0; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 48px; padding-bottom: 40px; font-size: 13px; color: var(--text-secondary); }

/* tooltip for sparklines */
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

@media (max-width: 600px) {
  .brand span { display: none; }
  .tile .value { font-size: 26px; }
  .paper .links { margin-left: 0; width: 100%; }
}

/* topic briefing */
.brief-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 980px) { .brief-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .brief-grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel h3 { font-size: 14px; font-weight: 650; margin: 0 0 10px; }
.panel .empty { color: var(--text-muted); font-size: 13px; }
.panel.wide { grid-column: 1 / -1; }

/* single-colour horizontal bar list (label, bar, value) */
.barlist { display: grid; gap: 6px; }
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 13px; color: var(--text-secondary); }
.barrow .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barrow .num { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.barrow .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.barrow .fill { height: 100%; border-radius: 0 3px 3px 0; background: var(--accent); }
.barrow.clickable { cursor: pointer; }
.barrow.clickable:hover .lbl { color: var(--text-primary); text-decoration: underline; }

.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.mini-list li { line-height: 1.35; }
.mini-list .meta { color: var(--text-muted); font-size: 12px; }

/* cluster & community lists */
.pick-list { display: grid; gap: 6px; max-height: 560px; overflow: auto; padding-right: 4px; }
.pick {
  text-align: left; font: inherit; font-size: 13px; color: var(--text-secondary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px;
}
.pick:hover { border-color: var(--axis); color: var(--text-primary); }
.pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); color: var(--text-primary); }
.pick b { color: var(--text-primary); font-weight: 600; }
.pick .meta { color: var(--text-muted); font-size: 12px; }

/* research gaps */
.gap-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; cursor: pointer; }
.gap-row:hover .gap-name { text-decoration: underline; }
.gap-name { color: var(--text-primary); }
.gap-bars { position: relative; height: 14px; }
.gap-bars .exp { position: absolute; inset: 0 auto 0 0; border: 1px solid var(--axis); border-radius: 0 4px 4px 0; }
.gap-bars .obs { position: absolute; top: 3px; bottom: 3px; left: 0; background: var(--accent); border-radius: 0 3px 3px 0; }
.gap-val { color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .gap-row { grid-template-columns: 1fr; } }

/* ask the field */
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.ask-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ask-examples button { font: inherit; font-size: 12px; color: var(--text-secondary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.ask-examples button:hover { color: var(--text-primary); border-color: var(--axis); }
.ask-status { font-size: 13px; margin: 10px 2px 0; }
.ask-summary { margin-top: 14px; padding: 16px 18px; }
.ask-summary h3 { font-size: 15px; margin: 0 0 6px; }
.ask-summary p { margin: 4px 0; color: var(--text-secondary); }
.ask-summary p b { color: var(--text-primary); }
.yearbars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; height: 110px; margin-top: 6px; }
.yearbars .yb { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; font-size: 12px; color: var(--text-secondary); }
.yearbars .yb .bar { width: 22px; align-self: end; border-radius: 4px 4px 0 0; background: var(--accent); }
.yearbars .yb .v { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.sim { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.sim .track { width: 60px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.sim .fill { height: 100%; background: var(--accent); }
.ai-answer { border-left: 3px solid var(--accent); }
.ai-answer > p:not(.muted):not(.cc-note) { color: var(--text-primary); line-height: 1.6; }
