@font-face { font-family: 'Heros Cond'; src: url('/fonts/heroscn-regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Heros Cond'; src: url('/fonts/heroscn-bold.woff') format('woff'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  --plane: #131a24;
  --surface: #18212e;
  --raised: #202b3a;
  --hair: #2b384a;
  --base: #3a4a60;
  --ink: #e9eef5;
  --ink-2: #aeb9c8;
  --muted: #8593a7;
  --a: #3987e5;
  --b: #d95926;
  --a-wash: rgba(57, 135, 229, 0.14);
  --b-wash: rgba(217, 89, 38, 0.14);
  --up: #3ec46d;
  --down: #f07a7a;
  --focus: #9cc4ff;
  --cond: 'Heros Cond', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --r: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--ink); font: 15px/1.5 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--ink); text-decoration-color: var(--base); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink-2); }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; letter-spacing: 0.005em; margin: 0; line-height: 1.1; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- brand & buttons */
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 20px/1 var(--cond); letter-spacing: 0.01em; }
.brand-lg { font-size: 26px; margin-bottom: 28px; }
.brand-mark { width: 22px; height: 14px; border-radius: 3px; background: linear-gradient(90deg, var(--a) 0 62%, var(--plane) 62% calc(62% + 2px), var(--b) calc(62% + 2px)); position: relative; }
.brand-mark::after { content: ''; position: absolute; left: 44%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.brand-lg .brand-mark { width: 28px; height: 18px; }

.btn { border: 1px solid transparent; border-radius: 6px; padding: 8px 14px; cursor: pointer; line-height: 1.2; }
.btn-primary { background: var(--ink); color: var(--plane); font-weight: 600; width: 100%; padding: 11px 14px; }
.btn-primary:hover { background: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost { background: none; color: var(--ink-2); width: 100%; margin-top: 8px; }
.btn-ghost:hover { color: var(--ink); }
.btn-quiet { background: transparent; border-color: var(--hair); color: var(--ink-2); font-size: 14px; }
.btn-quiet:hover { border-color: var(--base); color: var(--ink); }

/* ---------- gate (setup / login / passcode) */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 380px; }
.gate-form h1 { font-size: 34px; margin-bottom: 18px; }
.gate-note { color: var(--ink-2); margin: -6px 0 18px; font-size: 14px; }
.gate-form label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 14px; }
.gate-form input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--hair); border-radius: 6px; color: var(--ink); }
.gate-form input:focus { border-color: var(--base); }
.gate-form small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.passcode-input { font-family: var(--cond) !important; letter-spacing: 0.35em; font-size: 20px; }
.passcode-lg { font-size: 40px !important; text-align: center; padding: 14px 12px !important; margin: 4px 0 14px; letter-spacing: 0.4em; }
.gate-error { color: var(--down); min-height: 1.5em; margin: 4px 0 10px; font-size: 14px; }

/* ---------- app shell */
.app { max-width: 1320px; margin: 0 auto; padding: 0 24px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0 14px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.freshness { color: var(--muted); font-size: 13px; }

.collecting { display: grid; gap: 8px; padding: 14px 16px; background: var(--surface); border-radius: var(--r); margin-bottom: 16px; }
.collecting-text { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.collecting-text span { color: var(--ink-2); font-size: 14px; }
.meter { height: 8px; border-radius: 4px; background: rgba(57, 135, 229, 0.22); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--a); border-radius: 4px; transition: width 0.6s ease; }

/* ---------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; padding: 14px 0 18px; border-top: 1px solid var(--hair); position: sticky; top: 0; z-index: 5; background: var(--plane); }
.filter { display: grid; gap: 6px; font-size: 14px; }
.filter-label { color: var(--muted); font-size: 12px; }
.filter select, .filter input[type=search] { background: var(--surface); border: 1px solid var(--hair); border-radius: 6px; padding: 7px 10px; min-width: 136px; color: var(--ink); }
.filter input[type=range] { width: 128px; accent-color: var(--a); }
.filter output { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.filter-check { display: flex; align-items: center; gap: 8px; color: var(--ink-2); padding-bottom: 8px; }
.filter-check input { accent-color: var(--a); width: 16px; height: 16px; }
.filter-search { flex: 1 1 200px; max-width: 320px; }
.filter-search input { width: 100%; }
.seg { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, auto); gap: 0; }
.seg legend { padding: 0; margin-bottom: 6px; float: left; width: 100%; grid-column: 1 / -1; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 12px; border: 1px solid var(--hair); font-size: 14px; color: var(--ink-2); background: var(--plane); }
.seg label:first-of-type span { border-radius: 6px 0 0 6px; }
.seg label:last-of-type span { border-radius: 0 6px 6px 0; }
.seg label + label span { border-left: 0; }
.seg input:checked + span { background: var(--raised); color: var(--ink); border-color: var(--base); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- panels */
.panel { padding: 22px 0 26px; border-top: 1px solid var(--hair); }
.panel-head { margin-bottom: 14px; max-width: 72ch; }
.panel-head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; max-width: none; }
.panel-sub { color: var(--ink-2); margin: 6px 0 0; font-size: 14px; max-width: 70ch; }

.hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 0; background: var(--surface); border-radius: 12px; margin-bottom: 8px; }
.hero .panel { border-top: 0; padding: 22px 24px 24px; }
.hero .gaps-panel { border-left: 1px solid var(--hair); }
.hero h2 { font-size: 30px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.key { display: inline-flex; align-items: center; gap: 7px; }
.key-muted { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-a, .swatch-a { background: var(--a); }
.dot-b, .swatch-b { background: var(--b); }
.swatch { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.tick-key { width: 2px; height: 16px; background: var(--ink); display: inline-block; border-radius: 1px; }

/* ---------- scatter */
.scatter-wrap { position: relative; width: 100%; aspect-ratio: 1.25 / 1; max-height: 560px; }
.scatter-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.axis text, .chart-text { fill: var(--muted); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.grid line { stroke: var(--hair); stroke-width: 1; }
.diag { stroke: var(--base); stroke-width: 1.5; }
.diag-label { fill: var(--muted); font: italic 12px var(--sans); }
.region-label { fill: var(--ink-2); font: 13px var(--sans); }
.pt { stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: opacity 0.15s; }
.pt.dim { opacity: 0.25; }
.pt.hot { stroke: var(--ink); }
.empty-note { color: var(--muted); font-size: 14px; padding: 24px 0; }

/* ---------- gap list */
.gap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: gap; }
.gap-item button { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; width: 100%; padding: 10px 10px; border-radius: 6px; cursor: pointer; }
.gap-item button:hover, .gap-item button:focus-visible { background: var(--raised); }
.gap-item button:focus-visible { outline: 2px solid var(--focus); }
.gap-title { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gap-num { font: 700 26px/1 var(--cond); text-align: right; white-space: nowrap; }
.gap-num small { display: block; font: 12px var(--sans); color: var(--muted); margin-top: 3px; }
.gap-meta { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 2px 14px; }
.gap-meta b { color: var(--ink); font-weight: 600; }
.gap-item .mini-tug { grid-column: 1 / -1; margin-top: 4px; }

/* ---------- tug-of-war rows */
.tug-list { display: grid; gap: 4px; }
.tug { all: unset; box-sizing: border-box; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 46%); gap: 6px 28px; align-items: center; padding: 12px 10px; border-radius: 6px; cursor: pointer; }
.tug:hover, .tug:focus-visible { background: var(--surface); }
.tug:focus-visible { outline: 2px solid var(--focus); }
.tug-title { font-size: 15px; line-height: 1.35; }
.tug-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--muted); margin-top: 3px; }
.tug-bar-wrap { display: grid; gap: 5px; }
.tug-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); }
.tug-labels b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tug-labels .r { text-align: right; }
.bar { position: relative; height: 12px; }
.bar-a, .bar-b { position: absolute; top: 0; bottom: 0; }
.bar-a { left: 0; background: var(--a); border-radius: 4px 0 0 4px; }
.bar-b { right: 0; background: var(--b); border-radius: 0 4px 4px 0; }
.bar-a.full { border-radius: 4px; }
.bar-b.full { border-radius: 4px; }
.bar-tick { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; box-shadow: 0 0 0 2px var(--plane); }
.tug:hover .bar-tick, .tug:focus-visible .bar-tick { box-shadow: 0 0 0 2px var(--surface); }
.mini-tug .bar { height: 8px; }
.mini-tug .bar-tick { top: -4px; bottom: -4px; box-shadow: 0 0 0 2px var(--surface); }
.gap-item button:hover .bar-tick { box-shadow: 0 0 0 2px var(--raised); }
.more-btn { margin: 10px 10px 0; }

/* ---------- stats strip */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 22px 0; }
.stat { padding: 0 20px; border-left: 1px solid var(--hair); }
.stat:first-child { border-left: 0; padding-left: 0; }
.stat-label { color: var(--ink-2); font-size: 13px; }
.stat-value { font: 700 40px/1.05 var(--cond); margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- split row */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; border-top: 1px solid var(--hair); }
.split .panel { border-top: 0; }
.line-wrap { position: relative; height: 240px; }
.line-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { opacity: 0.12; }
.crosshair { stroke: var(--base); stroke-width: 1; }

/* ---------- tabs & tables */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--hair); }
.tab { background: none; border: 0; padding: 8px 14px 10px; color: var(--ink-2); cursor: pointer; font: 700 20px/1 var(--cond); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }
.table-search { max-width: 360px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.data th button { all: unset; cursor: pointer; }
table.data th button:focus-visible { outline: 2px solid var(--focus); }
table.data th[aria-sort] button { color: var(--ink); }
table.data th.r, table.data td.r { text-align: right; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--hair); font-variant-numeric: tabular-nums; vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover, table.data tbody tr:focus-visible { background: var(--surface); }
table.data td.t { min-width: 260px; max-width: 460px; }
.side { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.side::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--a); }
.side.b::before { background: var(--b); }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.table-foot { color: var(--muted); font-size: 13px; padding: 10px; }

/* ---------- drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 18, 0.6); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); z-index: 21; overflow-y: auto; padding: 26px 28px 40px; border-left: 1px solid var(--hair); animation: slidein 0.22s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-close { position: sticky; top: 0; float: right; margin: -6px -8px 0 12px; background: var(--surface); }
.drawer h2 { font-size: 28px; margin: 0 0 8px; padding-right: 60px; }
.drawer .lede { color: var(--ink-2); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 18px; }
.drawer section { margin-top: 26px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--hair); }
.kv > div { padding: 12px 0; border-bottom: 1px solid var(--hair); }
.kv > div:nth-child(odd) { padding-right: 16px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 2px 0 0; font: 700 24px/1.1 var(--cond); }
.kv dd small { font: 13px var(--sans); color: var(--ink-2); margin-left: 6px; }
.holders { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.holders h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.holders ol { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.holders li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--hair); }
.holders li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.holders li span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ext { font-size: 14px; }

/* ---------- tooltip */
.tooltip { position: fixed; z-index: 30; pointer-events: none; background: var(--raised); border: 1px solid var(--base); border-radius: 6px; padding: 9px 11px; font-size: 13px; max-width: 320px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
.tooltip .tt-title { color: var(--ink-2); margin-bottom: 6px; line-height: 1.3; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; color: var(--ink); }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; background: var(--ink); }
.tooltip .tt-key.a { background: var(--a); }
.tooltip .tt-key.b { background: var(--b); }

.foot { border-top: 1px solid var(--hair); margin-top: 8px; padding-top: 18px; color: var(--muted); font-size: 13px; max-width: 90ch; }

.loading { opacity: 0.55; transition: opacity 0.2s; }

/* ---------- responsive */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; }
  .hero .gaps-panel { border-left: 0; border-top: 1px solid var(--hair); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 20px; }
  .stat:nth-child(4) { border-left: 0; padding-left: 0; }
  .split { grid-template-columns: 1fr; gap: 0; }
  .split .panel + .panel { border-top: 1px solid var(--hair); }
}
@media (max-width: 720px) {
  .app { padding: 0 16px 40px; }
  .filters { position: static; }
  .tug { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 0 14px; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat:nth-child(4) { border-left: 1px solid var(--hair); padding-left: 14px; }
  .stat-value { font-size: 32px; }
  .hero .panel { padding: 18px 16px; }
  .holders { grid-template-columns: 1fr; }
  .drawer { padding: 20px 16px 32px; }
  .scatter-wrap { aspect-ratio: 1 / 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- chart series classes */
:root { --neutral: #8aa2c2; }
.pt-a { fill: var(--a); }
.pt-b { fill: var(--b); }
.line.neutral { stroke: var(--neutral); }
.area.neutral { fill: var(--neutral); }
.pt-end.neutral { fill: var(--neutral); }
.line.series-a { stroke: var(--a); }
.pt-end.series-a { fill: var(--a); }
.line.series-ink { stroke: var(--ink-2); }
.pt-end.series-ink { fill: var(--ink-2); }
.pt-end { stroke: var(--plane); stroke-width: 2; }
.drawer .pt-end { stroke: var(--surface); }
.swatch-ink { background: var(--ink-2); }
.drawer .line-wrap { height: 220px; margin-top: 6px; }

/* ---------- category bars (one hue: categories are nominal, so length carries the value) */
.cat-bars { display: grid; gap: 8px; }
.cat-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 64px; gap: 12px; align-items: center; font-size: 14px; padding: 2px 0; border-radius: 4px; }
.cat-row:focus-visible { outline: 2px solid var(--focus); }
.cat-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-track { height: 12px; }
.cat-fill { display: block; height: 100%; background: var(--neutral); border-radius: 0 4px 4px 0; }
.cat-val { text-align: right; font-variant-numeric: tabular-nums; }

.holders { margin-top: 12px; }
.drawer table.data td.t { min-width: 0; }
.drawer table.data td.r, .drawer table.data th.r { white-space: nowrap; }
