/* Layout: sticky header with nav, then one view at a time; races board is a dense table,
   race detail is a two-column card grid that stacks under 1000px. Tokens come from tokens.css. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text-1);
  font: 400 var(--fs-body)/var(--lh-body) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.num, .tab { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border-subtle); }
.top-inner { display: flex; align-items: center; gap: var(--space-4); padding: 14px var(--header-pad); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--space-4); }
.logo { height: 14px; width: auto; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.nav { display: flex; gap: var(--space-1); background: var(--surface-sunken); padding: 3px; border-radius: var(--radius-pill); }
.nav button, .seg button {
  border: 1px solid transparent; background: none; border-radius: var(--radius-pill);
  padding: 6px 14px; cursor: pointer; color: var(--text-2); white-space: nowrap;
}
.nav button.active, .seg button.active { background: var(--surface); border-color: var(--border); color: var(--text-1); font-weight: 500; }
.nav button:hover, .seg button:hover { color: var(--text-1); }
/* contextual race tab: named for the open race, closes with × */
.nav-race { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; }
.nav-race-label { overflow: hidden; text-overflow: ellipsis; }
.nav-x { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-3); font-size: 14px; line-height: 1; }
.nav-x:hover { background: var(--surface-sunken); color: var(--text-1); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.sources { display: flex; gap: var(--space-3); font-size: var(--fs-sm); color: var(--text-3); }
.src { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); flex: none; }
.dot.ok { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.live { background: var(--live); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-pill);
  padding: 5px 12px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-2);
}
.icon-btn[aria-pressed="true"] { background: var(--text-1); color: var(--surface); }
.health-chip { background: var(--warn-soft); border-color: var(--warn); color: #3F2A00; font-weight: 600; cursor: default; }
.update-chip { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.banner { background: var(--warn-soft); color: #3F2A00; padding: 6px var(--header-pad); font-size: var(--fs-sm); font-weight: 500; }

main { padding: var(--space-5) var(--header-pad) var(--space-10); max-width: 1680px; margin: 0 auto; }
.view, .stack { display: flex; flex-direction: column; gap: var(--space-4); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); min-width: 0; }
.card h3 { margin: 0 0 var(--space-2); font-size: var(--fs-h3); font-weight: 600; text-wrap: balance; }
.kicker { font-size: var(--fs-caption); font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-caption); color: var(--text-3); margin: 0 0 var(--space-1); }
.kpi { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-kpi); line-height: var(--lh-tight); font-variant-numeric: tabular-nums; }
.kpi-sm { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: var(--lh-tight); font-variant-numeric: tabular-nums; }
.d-ink { color: var(--party-d-ink); }
.r-ink { color: var(--party-r-ink); }
.o-ink { color: var(--party-other-ink); }
.muted { color: var(--text-3); }

/* top strip on the board */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-4); }
.strip .card { display: flex; flex-direction: column; gap: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.seg { display: flex; gap: 2px; background: var(--surface-sunken); padding: 3px; border-radius: var(--radius-pill); flex-wrap: wrap; }
input[type="search"] { flex: 1 1 220px; max-width: 420px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
.seg.sub { align-self: flex-start; }
.filters.pad, .card-head.pad { padding: var(--space-4) var(--space-5) 0; }
.table-card .filters.pad { padding-bottom: var(--space-3); }
select { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }

/* ---------- races table ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: left;
  font-size: var(--fs-caption); font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-caption);
  color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.race-name { font-weight: 600; font-size: var(--fs-body); white-space: nowrap; }
.cands { color: var(--text-1); max-width: 280px; font-size: var(--fs-body); }
.cands span { white-space: nowrap; }
.pin { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.pin.d { background: var(--party-d); } .pin.r { background: var(--party-r); } .pin.o { background: var(--party-other); }
.pct-in { color: var(--text-3); font-size: var(--fs-caption); display: block; }
/* series markers: ○ Vantage pre-election · ● our live model · ◆ Polymarket (same shapes on every view) */
.mk { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: 0; flex: none; box-sizing: border-box; }
.mk-live { border-radius: 50%; background: var(--series-1); }
.mk-pre { border-radius: 50%; border: 2px solid var(--series-2); background: var(--surface); }
.mk-market { width: 9px; height: 9px; background: var(--series-3); transform: rotate(45deg); margin-right: 7px; }
.kpi-sm .mk, .stat-label .mk { margin-right: 6px; }
.kpi-sm .mk { width: 12px; height: 12px; vertical-align: 2px; }

/* chance strip: one 0–100% scale, D on the left, R on the right, 50/50 in the middle */
.chance { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.pstrip { position: relative; width: 128px; height: 18px; flex: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--party-d) var(--pstrip-tint), transparent), transparent 50%, color-mix(in srgb, var(--party-r) var(--pstrip-tint), transparent));
  box-shadow: inset 0 0 0 1px var(--pstrip-edge); border-radius: 9px; }
.pstrip .mid { position: absolute; left: 50%; top: 3px; bottom: 3px; border-left: 1px dashed var(--zero-line); }
.pstrip .mk { position: absolute; top: 50%; margin: 0; transform: translate(-50%, -50%); transition: left .6s ease; }
.pstrip .mk-pre { width: 13px; height: 13px; }
.pstrip .mk-live { width: 11px; height: 11px; box-shadow: 0 0 0 2px var(--surface); }
.pstrip .mk-market { transform: translate(-50%, -50%) rotate(45deg); }
.chance-num { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 56px; }
.chance-key { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.chance-key .mk { margin-left: 8px; margin-right: 4px; }
@media (prefers-reduced-motion: reduce) { .pstrip .mk { transition: none; } }
.table-foot button { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-pill); padding: 4px 12px; cursor: pointer; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--radius-pill); padding: 2px 8px; font-size: var(--fs-caption); font-weight: 500; white-space: nowrap; }
.b-wait { background: var(--surface-sunken); color: var(--text-3); }
.b-ok { background: var(--good-soft); color: #00513A; }
.b-miss { background: var(--miss); color: var(--surface); }
.b-live { background: var(--good-soft); color: #00513A; }
.b-warn { background: var(--warn-soft); color: #5A3A00; }
.b-d { background: var(--party-d); color: #fff; }
.b-r { background: var(--party-r); color: #fff; }
.b-o { background: var(--party-other); color: #fff; }

/* ---------- race detail ---------- */
.race-pick { display: flex; gap: var(--space-3); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-4); }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
/* Avatar: Figma Avatar/Container — 40px rounded square (14px), party tint underlay, faint shadow */
.avatar { display: inline-block; flex: none; width: 40px; height: 40px; border-radius: 14px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-avatar); vertical-align: middle; }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; display: block; }
/* party frame: the border is the only place a photo carries party color */
.avatar { border: 2px solid var(--party-other); }
.avatar.av-d { background: #EFF6FF; border-color: var(--party-d); }
.avatar.av-r { background: #FEF4F2; border-color: var(--party-r); }
.avatar.sm { width: 32px; height: 32px; border-radius: 11px; border-width: 2px; margin-right: 10px; }
.avatar.md { width: 28px; height: 28px; border-radius: 10px; margin-right: 8px; }
.cand-chip { display: inline-flex; align-items: center; white-space: nowrap; }
.cand-stack { display: flex; flex-direction: column; gap: 6px; }
.cand-name { font-weight: 600; }
.bar-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; margin-top: 6px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.bar-proj { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-1); border-radius: 1px; }
.map-wrap { position: relative; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-caption); color: var(--text-3); margin-top: var(--space-2); flex-wrap: wrap; }
.legend .ramp { width: 180px; height: 8px; border-radius: 4px; }
.county-table { max-height: 520px; overflow: auto; }
.empty { padding: var(--space-8); text-align: center; color: var(--text-3); }

/* ---------- chamber control ---------- */
.clickable { cursor: pointer; }
.clickable:hover { border-color: var(--border-strong); }
.seatbar-wrap { margin-top: var(--space-8); }
.card > .grid2, .card > .table-wrap { margin-top: var(--space-5); }
.seatbar { position: relative; display: flex; height: 28px; border-radius: var(--radius-xs); overflow: visible; gap: 1px; }
.seg-bar { min-width: 2px; border: 0; padding: 0; cursor: pointer; }
.seg-bar.fixed { cursor: default; }
.seg-bar:not(.fixed):hover { filter: brightness(1.1); }
.seg-bar.on { box-shadow: inset 0 0 0 2px var(--text-1); }
.seg-bar:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
.seg-bar:nth-last-child(2) { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.majority { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--text-1); transform: translateX(-1px); }
.majority span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: var(--fs-caption); font-weight: 600; white-space: nowrap; color: var(--text-1); }
.seatbar-wrap .legend { gap: var(--space-3); }

/* ---------- stats: label + value pairs (the only labels the UI carries) ---------- */
.stats { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-top: var(--space-2); }
/* big stat rows fill the card: equal cells with hairline dividers, the hero cell a bit wider */
.stats-lg { gap: 0; align-items: stretch; margin: 0; }
.stats-lg .stat { flex: 1 1 0; min-width: 130px; padding: var(--space-1) var(--space-5); border-left: 1px solid var(--border-subtle); justify-content: flex-end; }
.stats-lg .stat:first-child { border-left: 0; padding-left: 0; }
.stats-lg .stat.hero { flex: 1.5 1 0; }
.card.stats.stats-lg { padding: var(--space-5) var(--space-6); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--fs-caption); font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-caption); color: var(--text-3); }
.stat-value { font-size: var(--fs-body); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-value small { font-size: var(--fs-caption); font-weight: 400; color: var(--text-3); margin-left: 6px; }
.stats-lg .stat-value { font-family: var(--font-display); font-size: 1.6rem; line-height: var(--lh-tight); }
.stats-lg .stat.hero .stat-value { font-size: var(--fs-kpi); }
.card.stats { margin: 0; }
.card-title { margin: 0 0 var(--space-3); font-size: var(--fs-h2); font-weight: 600; }
.key-line { display: inline-block; width: 16px; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
.key-line.dash { border-top-style: dotted; }
.call-line { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); padding: 2px 0; }
.call-line span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.proxy { text-decoration: underline dotted var(--text-4); text-underline-offset: 3px; }
td.status { white-space: nowrap; }
td.status .badge + .badge { margin-left: 4px; }
.table-foot { padding: 10px 16px; display: flex; justify-content: center; }
.race-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.race-head h2 { margin: 0 var(--space-2) 0 0; font-size: var(--fs-h1); font-weight: 600; letter-spacing: -0.01em; }
.pct-big { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cand-head, .cand-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 64px 64px; gap: var(--space-3); align-items: center; }
.cand-head { font-size: var(--fs-caption); font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-caption); color: var(--text-3); padding-bottom: var(--space-1); border-bottom: 1px solid var(--border); }
.cand-head span:nth-child(n+3) { text-align: right; }
.cand-row { padding: var(--space-2) 0; }
/* candidate card stretches to the chart beside it; rows spread over the height */
.cand-card { display: flex; flex-direction: column; }
.cand-list { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; gap: var(--space-2); padding-top: var(--space-2); }
.cand-card .cand-row .avatar { width: 48px; height: 48px; border-radius: 16px; }
.cand-card .cand-head, .cand-card .cand-row { grid-template-columns: 48px minmax(0, 1fr) 72px 72px; }
.cand-card .bar-track { height: 12px; border-radius: 6px; margin-top: 8px; }
.cand-card .bar-fill { border-radius: 6px; }
.cand-card .cand-name { font-size: 1rem; }
.cand-card .cand-share { font-size: 1.25rem; }
.cand-main { min-width: 0; }
.cand-share, .cand-proj { font-variant-numeric: tabular-nums; text-align: right; }
.cand-share { font-size: 1rem; font-weight: 600; }
.cand-proj { color: var(--text-3); }
.tick-key { display: inline-block; width: 2px; height: 10px; background: var(--text-1); margin-right: 5px; vertical-align: -1px; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-head .card-title { margin: 0; margin-right: auto; }
.card-head > .seg:first-child { margin-right: auto; }

/* info (i) popovers */
.info { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-3); font: 600 11px/1 var(--font-sans); cursor: help; padding: 0; }
.info:hover, .info:focus-visible { color: var(--text-1); border-color: var(--text-3); }

/* watchlist stars */
.star { border: 0; background: none; padding: 0 2px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-4); }
.star:hover { color: var(--text-2); }
.star.me { color: var(--accent); }
.star.team { color: var(--warn); }
.star-cell { width: 28px; padding-right: 0 !important; text-align: center; }
.race-head .star { font-size: 22px; }

/* charts (Chart.js canvases size to these boxes) */
.chart-box { position: relative; min-width: 0; } /* height comes from the chart's opts.height (js/charts.js) */

/* inline bars inside tables */
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.hbar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }

/* closings timeline */
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
@media (max-width: 1000px) { .grid-side { grid-template-columns: minmax(0, 1fr); } }
.side-sticky { position: sticky; top: 90px; }
.wave.done { opacity: .72; }
.wave.soon { border-color: var(--accent); }
.chip { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); font-size: var(--fs-caption); font-weight: 600; }
.wave .table-wrap { margin-top: var(--space-3); }

/* ---------- scorecard ---------- */
.score-table td, .score-table th { padding: 10px 12px; }
.score-table tr.sub td:first-child { padding-left: 28px; color: var(--text-2); }
.score-table tr.total td { font-weight: 600; border-top: 1px solid var(--border); }
.score-table tbody tr { cursor: default; }

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-inverse); color: var(--text-on-dark);
  padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-tooltip); font-size: var(--fs-sm);
  max-width: 260px; line-height: 1.35;
}
.tooltip { max-width: 320px; }
.tooltip b { font-weight: 600; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-extra { margin-top: 6px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--text-on-dark) 18%, transparent); }
.tooltip .tt-dim { opacity: .7; margin-top: 6px; font-size: var(--fs-caption); }
.tooltip .tt-table { margin-top: 6px; font-size: var(--fs-sm); }
.tooltip .tt-table td { padding: 1px 12px 1px 0; border: 0; }
.tooltip .tt-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
/* the tooltip sits on the inverse surface, so it takes the other theme's party inks */
.tooltip .d-ink { color: var(--tt-d-ink); }
.tooltip .r-ink { color: var(--tt-r-ink); }

/* race field (js/swarm.js) */
.field-card { padding: var(--space-4) var(--space-5); }
.swarm { position: relative; width: 100%; }
.swarm-svg { display: block; overflow: visible; font-family: var(--font-sans); }
.swarm-svg text.head { font-size: 12px; }
.swarm-svg text.foot { font-size: 11px; font-variant-numeric: tabular-nums; }
.swarm-svg g.node { cursor: pointer; }
.swarm-svg g.node:hover circle { stroke-width: 2.5px; }
.swarm-svg g.node.lit circle { stroke-width: 2px; }
html.demo .banner { background: var(--accent-soft); color: var(--text-1); }

@media (max-width: 720px) {
  .top-inner { gap: var(--space-3); }
  .sources { display: none; }
  /* the tab row scrolls sideways on its own instead of widening the page */
  .nav { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { flex: none; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  /* phone header: logo and buttons on one row, the tabs on their own full-width row below */
  .top-inner { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); row-gap: 10px; }
  .brand { order: 1; } .top-right { order: 2; gap: 6px; } .nav { order: 3; width: 100%; }
  .top-right .icon-btn { padding: 5px 10px; font-size: var(--fs-caption); }
  .logo { height: 16px; }
  .brand { width: 124px; overflow: hidden; flex: none; } /* the logo file has blank space after the wordmark */
  /* filter pills scroll sideways in one row instead of wrapping into a block */
  .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .filters { gap: var(--space-2); }
  .filters select, .filters input[type="search"] { flex: 1 1 140px; min-width: 0; }
  /* Races table: race, candidates, result, chance and status fit; the starting point and % in drop out */
  table.races th:nth-child(3), table.races td:nth-child(3), table.races th:nth-child(4), table.races td:nth-child(4), table.races th:nth-child(6), table.races td:nth-child(6) { display: none; }
  table.races .race-name { white-space: normal; }
  #demo-toggle { display: none; }
  .top-inner { flex-wrap: wrap; } .top-right { flex-wrap: nowrap; }
  table.races .chance-key { display: none; }
  table.races td, table.races th { padding-left: 6px; padding-right: 6px; }
  .card { padding: var(--space-4); }
  .strip .card { min-height: 0; }
  .card.stats.stats-lg { padding: var(--space-4); row-gap: var(--space-3); flex-wrap: wrap; }
  .stats-lg .stat { flex: 1 1 40%; min-width: 0; padding: 0 var(--space-3); }
  .stats-lg .stat.hero { flex: 1 1 100%; padding-left: 0; border-left: 0; }
  .sub-pop { bottom: 64px; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; }
  .sub-pop .substack-frame { height: 250px; }
  .needle-key { flex-direction: row !important; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
  .field-card .swarm { margin-top: 30px; } /* room for the share icon in the corner */
  .field-card .xport.btn-corner { top: 6px; right: 6px; }
}

/* ---------- news (Perigon story clusters) ---------- */
.news-meta { margin-left: auto; font-size: var(--fs-sm); color: var(--text-3); }
.newsline { width: 100%; }
.newsline-svg { display: block; width: 100%; height: auto; overflow: visible; }
.newsline-svg g.st:hover circle.bub { stroke: var(--text-1); stroke-width: 2px; }
.newsline-svg line.stem { opacity: 0; transition: opacity .2s; pointer-events: none; }
.newsline-svg g.st.on line.stem { opacity: .7; }
.newsline-svg g.st.hover line.stem { opacity: .45; }
.news-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--space-4); align-items: start; }
@media (max-width: 1000px) { .news-grid { grid-template-columns: minmax(0, 1fr); } }
.news-detail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 120px); display: flex; flex-direction: column; gap: var(--space-3); }
.nd-title { margin: 0; font-size: var(--fs-h2); line-height: 1.25; text-wrap: balance; }
.nd-sum { margin: 0; color: var(--text-2); line-height: 1.6; max-width: 68ch; }
.nd-pts { margin: 0; padding-left: 1.1em; color: var(--text-2); line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
.nd-links { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border-subtle); padding-top: var(--space-3); }
.src-link { display: flex; gap: var(--space-3); align-items: baseline; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-sm); color: var(--text-1); min-width: 0; }
.src-link:hover { background: var(--surface-2); }
.src-host { font-size: var(--fs-sm); color: var(--accent); flex: none; min-width: 110px; }
.src-title { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.news-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.race-chip { border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px 10px; font-size: var(--fs-caption); color: var(--text-1); cursor: pointer; background: var(--surface-2); white-space: nowrap; }
.race-chip:hover, .race-chip:focus-visible { border-color: var(--accent); }
.bad-ink { color: var(--bad); }

/* the feed: a vertical timeline (time · rail with a dot sized by articles · headline) */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 720px; overflow: auto; }
.feed-row { display: grid; grid-template-columns: 64px 28px minmax(0, 1fr); align-items: start; cursor: pointer; border-radius: var(--radius-sm); padding-right: var(--space-2); }
.feed-row:hover { background: var(--surface-2); }
.feed-row.on { background: color-mix(in srgb, var(--series-1) 14%, transparent); }
.feed-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.feed-time { font-size: var(--fs-sm); color: var(--text-3); font-variant-numeric: tabular-nums; text-align: right; padding: 12px 0; }
.feed-rail { position: relative; align-self: stretch; display: flex; justify-content: center; }
.feed-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--border); }
.feed-row:first-child .feed-rail::before { top: 18px; }
.feed-row:last-child .feed-rail::before { bottom: calc(100% - 18px); }
.feed-dot { position: relative; margin-top: 14px; border-radius: 50%; background: var(--text-4); border: 2px solid var(--surface); box-sizing: content-box; }
.feed-dot.matched { background: var(--series-1); }
.feed-dot.sm { width: 7px; height: 7px; margin-top: 16px; } .feed-dot.md { width: 10px; height: 10px; margin-top: 14px; }
.feed-dot.lg { width: 13px; height: 13px; margin-top: 13px; } .feed-dot.xl { width: 16px; height: 16px; margin-top: 11px; }
.feed-row.on .feed-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-1) 35%, transparent); }
.feed-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 0 12px; min-width: 0; }
.feed-title { font-weight: 600; line-height: 1.35; color: var(--text-1); }
.feed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--fs-sm); color: var(--text-3); }
.race-news { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
@media (max-width: 1000px) { .race-news { grid-template-columns: minmax(0, 1fr); } }
.feed-compact { max-height: none; }
.feed-compact .feed-title { font-weight: 500; font-size: var(--fs-body); }
.card-head-link { margin-left: auto; font-size: var(--fs-sm); color: var(--accent); cursor: pointer; }
.card-head-link + .card-head-link { margin-left: var(--space-3); }

/* ---------- then vs. now (race page): diverging bars from a baseline ---------- */
.bl-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.bl-hero { display: flex; flex-direction: column; gap: 2px; }
.bl-hero-label { font-size: var(--fs-caption); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.bl-hero-val { font-size: var(--fs-kpi); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bl-chart { display: flex; flex-direction: column; gap: 10px; }
.bl-axis { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; margin-left: 170px; margin-right: 130px; font-size: var(--fs-caption); font-weight: 600; }
.bl-axis > :last-child { text-align: right; }
.bl-base-lab { color: var(--text-1); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px 10px; white-space: nowrap; }
.bl-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) 120px; align-items: center; gap: 10px; }
.bl-name { font-size: var(--fs-sm); color: var(--text-2); text-align: right; }
.bl-live .bl-name { color: var(--series-1); font-weight: 600; }
.bl-track { position: relative; height: 22px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--party-r) var(--pstrip-tint), transparent), transparent 50%, color-mix(in srgb, var(--party-d) var(--pstrip-tint), transparent)); }
.bl-zero { position: absolute; left: 50%; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text-1); opacity: .7; border-radius: 1px; }
.bl-bar { position: absolute; top: 5px; bottom: 5px; border-radius: 3px; background: var(--text-4); transition: left .9s cubic-bezier(.2, .8, .2, 1), width .9s cubic-bezier(.2, .8, .2, 1); }
.bl-bar.to-d { background: var(--party-d); } .bl-bar.to-r { background: var(--party-r); }
.bl-past .bl-bar { opacity: .55; }
.bl-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text-2); transition: left .9s cubic-bezier(.2, .8, .2, 1); }
.bl-pre .bl-dot { border-color: var(--series-2); }
.bl-live .bl-dot { width: 16px; height: 16px; margin: -8px 0 0 -8px; background: var(--series-1); border-color: var(--surface); box-shadow: 0 0 0 5px color-mix(in srgb, var(--series-1) 25%, transparent); }
.bl-val { display: flex; flex-direction: column; line-height: 1.2; font-variant-numeric: tabular-nums; }
.bl-val b { font-size: var(--fs-body); }
.bl-val span { font-size: var(--fs-caption); color: var(--text-3); }
@media (prefers-reduced-motion: reduce) { .bl-bar, .bl-dot { transition: none; } }
@media (max-width: 700px) { .bl-row { grid-template-columns: 90px minmax(0, 1fr) 76px; } .bl-axis { margin-left: 100px; margin-right: 86px; } }
.tn-foot { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--fs-sm); color: var(--text-3); padding-top: var(--space-3); margin-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.tn-foot:empty { display: none; }
.tn-k { color: var(--text-3); }
.tn-shift { color: var(--text-1); font-weight: 600; }
.tn-note { flex-basis: 100%; }

/* ---------- replay bar (Field) ---------- */
.replay { display: flex; align-items: center; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); flex-wrap: wrap; }
.replay input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.replay-cap { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 260px; }

/* ---------- what-if (Control) ---------- */
.whatif-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--space-6); }
@media (max-width: 900px) { .whatif-grid { grid-template-columns: 1fr; } }
.whatif-controls { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.whatif-label { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--text-2); }
.whatif-label b { color: var(--text-1); }
.whatif input[type="range"] { width: 100%; accent-color: var(--accent); }
.whatif-locks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 6px var(--space-4); max-height: 300px; overflow: auto; }
.lock-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); min-width: 0; }
.lock-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock-p { color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg-sm button { padding: 2px 8px; font-size: var(--fs-caption); }
.seg-sm button.lk-d.active { background: var(--party-d); color: #fff; }
.seg-sm button.lk-r.active { background: var(--party-r); color: #fff; }
.whatif-out { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
#w-reset { margin-left: auto; }

/* ---------- needles (Control) ---------- */
.needles { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: var(--space-6); }
@media (max-width: 700px) { .needles { grid-template-columns: 1fr 1fr; } .needle-key { grid-column: 1 / -1; } }
.needle { display: flex; flex-direction: column-reverse; align-items: center; opacity: .72; transition: opacity .2s; }
.needle.on { opacity: 1; }
.needle-svg { width: 100%; max-width: 280px; height: auto; display: block; }
.needle-hand { transition: transform 1.2s cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: reduce) { .needle-hand { transition: none; } }
.needle-ticks line { stroke-width: 3; stroke-linecap: round; }
.needle-ticks .tick-pre { stroke: var(--series-2); stroke-dasharray: 3 3; }
.needle-ticks .tick-mkt { stroke: var(--series-3); }
.needle-cap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.needle-title { font-size: var(--fs-sm); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.needle-val { font-size: var(--fs-h2); font-weight: 600; font-variant-numeric: tabular-nums; }
.needle-key { font-size: var(--fs-sm); color: var(--text-3); display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--space-4); }
.cmap { position: relative; }
.cmap-svg { display: block; width: 100%; height: auto; max-height: 640px; margin: 0 auto; }
.cmap-unit { stroke: var(--surface); stroke-width: .4; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .6s, opacity .3s; }
.cmap-unit:hover { stroke: var(--text-1); stroke-width: 1.5; }
.cmap-unit.dim { opacity: .25; }
.cmap-unit.none { cursor: default; opacity: .55; }
.cmap-borders { fill: none; stroke: var(--text-1); stroke-width: 1; stroke-opacity: .55; vector-effect: non-scaling-stroke; pointer-events: none; }
.cmap-nation { fill: none; stroke: var(--text-3); stroke-width: .8; vector-effect: non-scaling-stroke; pointer-events: none; }
#c-map-back { margin-left: auto; }

/* ---------- money (FEC) on the race page ---------- */
.tug { display: flex; flex-direction: column; gap: 10px; }
.tug-labels { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; font-size: var(--fs-sm); }
.tug-labels b { font-size: var(--fs-h2); font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 4px; }
.tug-share { color: var(--text-2); font-weight: 600; }
.tug-bar { position: relative; display: flex; height: 16px; border-radius: 8px; overflow: visible; background: var(--surface-2); }
.tug-d, .tug-r { position: relative; display: flex; height: 100%; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.tug-d { background: var(--party-d); border-radius: 8px 0 0 8px; justify-content: flex-end; }
.tug-r { background: var(--party-r); border-radius: 0 8px 8px 0; flex: 1; }
.tug-out { display: block; height: 100%; background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--surface) 55%, transparent) 4px 7px); }
.tug-d .tug-out { border-radius: 0; } .tug-r .tug-out { border-radius: 0; }
.tug-mid { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--text-1); opacity: .5; }
.tug-vote { position: absolute; top: -7px; bottom: -7px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--series-1); box-shadow: 0 0 0 2px var(--surface); transition: left .9s cubic-bezier(.2, .8, .2, 1); }
.tug-key { display: flex; flex-wrap: wrap; gap: 6px var(--space-4); font-size: var(--fs-caption); color: var(--text-3); align-items: center; }
.tug-key i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.tug-key .k-camp { background: var(--text-3); }
.tug-key .k-out { background: var(--text-3); background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--surface) 3px 5px); }
.tug-key .k-vote { width: 4px; height: 12px; background: var(--series-1); }
.tug-total { margin-left: auto; }
.mcols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
@media (max-width: 700px) { .mcols { grid-template-columns: minmax(0, 1fr); } }
.mcol { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mcol-name { font-weight: 600; font-size: var(--fs-h3); }
.mstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.mstats span { display: block; font-size: var(--fs-caption); color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.mstats b { font-size: var(--fs-h3); font-weight: 600; font-variant-numeric: tabular-nums; }
.mix { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.mix i { display: block; height: 100%; min-width: 2px; }
.mix-key { display: flex; flex-wrap: wrap; gap: 4px var(--space-3); font-size: var(--fs-caption); color: var(--text-2); }
.mix-key i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.mout { font-size: var(--fs-sm); color: var(--text-3); }
.mout b { color: var(--text-1); font-weight: 600; }
.vpd { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--space-3); }
.vpd-head { display: flex; align-items: center; gap: 8px; }
.vpd-title { font-weight: 600; font-size: var(--fs-h3); }
.vpd-ratio { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
.vpd-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: var(--space-5); align-items: center; }
@media (max-width: 700px) { .vpd-body { grid-template-columns: minmax(0, 1fr); } }
.vpd-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.vpd-c { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vpd-name { font-size: var(--fs-sm); font-weight: 600; }
.vpd-num { font-size: var(--fs-h1, 32px); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.vpd-d .vpd-num { color: var(--party-d-ink, var(--party-d)); } .vpd-r .vpd-num { color: var(--party-r-ink, var(--party-r)); }
.vpd-i .vpd-num { color: var(--text-1); }
.vpd-sub { font-size: var(--fs-caption); color: var(--text-3); font-variant-numeric: tabular-nums; min-height: 1em; }
.vpd-chart { min-width: 0; }

/* ---------- Scorecard: model and forecaster comparison (Kalshi-style race + ranked board) ---------- */
.cmp-head { flex-wrap: wrap; gap: var(--space-3); }
.cmp-ctl { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.cmp-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: var(--space-5); align-items: start; }
@media (max-width: 900px) { .cmp-body { grid-template-columns: minmax(0, 1fr); } }
.cmp-chart { min-width: 0; }
.cmp-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cmp-item { display: grid; grid-template-columns: 18px 12px minmax(0, 1fr) auto 36px; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); transition: background .3s; }
.cmp-item.ours { box-shadow: inset 0 0 0 1.5px var(--series-1); }
.cmp-rank { font-size: var(--fs-caption); color: var(--text-3); font-variant-numeric: tabular-nums; text-align: right; }
.cmp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.cmp-item .cmp-dot { margin: 0; }
.cmp-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-val { font-size: var(--fs-h2); font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-n { font-size: var(--fs-caption); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.cmp-table { margin-top: var(--space-4); }
.cmp-us { color: var(--series-1); font-weight: 600; }
.cmp-them { color: var(--text-2); }
#s-model-chip { margin-left: 8px; }

/* stepped map legends (race map: vs. model, % in) */
.steps { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.step { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-caption); color: var(--text-2); font-variant-numeric: tabular-nums; }
.step i { width: 18px; height: 10px; border-radius: 3px; display: inline-block; }

/* Analysis: Counties vs. model (js/countyscatter.js) */
.cs-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
@media (max-width: 700px) { .cs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cscatter { position: relative; }
.cscatter-svg { display: block; width: 100%; }
.cscatter circle { transition: opacity .2s; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.cs-chips button { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-1); font: inherit; font-size: var(--fs-caption); cursor: pointer; font-variant-numeric: tabular-nums; }
.cs-chips button.on { border-color: var(--text-1); background: var(--surface); }
.cs-chips button span { font-weight: 600; }

/* "PNG" export buttons on chart cards */
.btn-export { margin-left: auto; padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: var(--fs-caption); font-weight: 600; cursor: pointer; }
.btn-export:hover { color: var(--text-1); border-color: var(--text-3); }
.card-head .seg + .btn-export, .card-head .seg ~ .btn-export { margin-left: 8px; }

/* race page: Forecasters (each forecaster's margin on one R-D axis, plus its chance) */
.fc { display: flex; flex-direction: column; gap: 6px; }
.fc-head, .fc-row { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) 80px 76px 76px; gap: 12px; align-items: center; }
.fc-head { font-size: var(--fs-caption); color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.fc-axis { display: flex; justify-content: space-between; text-transform: none; letter-spacing: 0; }
.fc-row { padding: 6px 0; border-top: 1px solid var(--border-subtle); }
.fc-row.live { border-top: 0; }
.fc-row.avg { font-weight: 600; }
.fc-name { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-track { position: relative; height: 18px; border-radius: 9px; background: linear-gradient(90deg, color-mix(in srgb, var(--party-r) 14%, transparent), transparent 50%, color-mix(in srgb, var(--party-d) 14%, transparent)); }
.fc-zero { position: absolute; left: 50%; top: 2px; bottom: 2px; width: 1px; background: var(--zero-line); }
.fc-line { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text-3); border-radius: 1px; transition: left .9s cubic-bezier(.2,.8,.2,1); }
.fc-line.final { background: var(--text-1); width: 3px; margin-left: -1.5px; }
.fc-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--surface); transition: left .9s cubic-bezier(.2,.8,.2,1); }
.fc-dot.pre { background: var(--surface); border: 2.5px solid var(--series-2); }
.fc-dot.live { background: var(--series-1); }
.fc-m, .fc-p, .fc-miss { text-align: right; font-variant-numeric: tabular-nums; }
.fc-foot { font-size: var(--fs-caption); color: var(--text-3); margin-top: 4px; }
@media (max-width: 700px) { .fc-head, .fc-row { grid-template-columns: 90px minmax(0, 1fr) 64px 60px; } .fc-miss, .fc-head > :last-child { display: none; } }

.card.rel { position: relative; }
.btn-corner { position: absolute; top: 12px; right: 12px; z-index: 2; margin: 0; }
.card-tools { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.btn-export.busy { opacity: .6; pointer-events: none; }
.race-pick { display: flex; gap: 8px; align-items: center; }
.race-pick #r-overview { margin-left: auto; }

/* export icon on charts: a download glyph that opens PNG / GIF / Video */
.xport { position: relative; margin-left: auto; display: inline-flex; }
.card-head .seg ~ .xport, .card-head .card-title ~ .xport { margin-left: 8px; }
.card-head > .card-title + .xport, .card-head > .info + .xport { margin-left: auto; }
.xport-btn { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-3); cursor: pointer; font: inherit; font-size: var(--fs-caption); font-weight: 600; font-variant-numeric: tabular-nums; }
.xport-btn:hover, .xport.open .xport-btn { color: var(--text-1); background: var(--surface-2); border-color: var(--border); }
.xport.busy .xport-btn { color: var(--series-1); background: var(--surface-2); cursor: progress; }
.xport-menu { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 150px; padding: 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); flex-direction: column; }
.xport.open .xport-menu { display: flex; }
.xport-item { text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-1); font: inherit; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.xport-item:hover { background: var(--surface-2); }
.xport.btn-corner { position: absolute; top: 10px; right: 10px; z-index: 5; }
.race-pick .xport-race { margin-left: auto; }

/* overview image builder (js/overview.js): a dialog, and the off-screen layout it paints */
.ov-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 24px; }
.ov-panel { width: min(1180px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.ov-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.ov-x { border: 0; background: transparent; color: var(--text-2); font-size: 26px; line-height: 1; cursor: pointer; }
.ov-main { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 0; flex: 1; }
@media (max-width: 760px) { .ov-main { grid-template-columns: minmax(0, 1fr); } }
.ov-side { padding: 16px; display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--border-subtle); overflow: auto; }
.ov-grp { display: flex; flex-direction: column; gap: 8px; }
.ov-list { display: flex; flex-direction: column; gap: 6px; }
.ov-item, .ov-toggle { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); cursor: pointer; }
.ov-item.off { opacity: .45; }
.ov-toggle { padding: 10px; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
.ov-save { margin-top: auto; padding: 10px 14px; border-radius: 10px; border: 0; background: var(--accent); color: var(--text-on-dark, #fff); font: inherit; font-weight: 700; cursor: pointer; }
.ov-preview { overflow: auto; padding: 16px; background: var(--bg); }
.ov-preview.busy { opacity: .6; }
.ov-canvas { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 16px rgba(0, 0, 0, .3); }
.ov-stage { position: absolute; left: -20000px; top: 0; width: 1180px; padding: 0; background: var(--bg); color: var(--text-1); display: flex; flex-direction: column; gap: var(--space-4); }
.ov-stage .card { margin: 0; }
.ov-results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: center; }
.ov-results.solo { grid-template-columns: minmax(0, 1fr); }
.ov-cand { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.ov-cand-name { font-size: 24px; font-weight: 700; }
.ov-cand-share { font-size: 34px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.ov-cand-sub { color: var(--text-3); font-size: 16px; }
.ov-bar { grid-column: 1 / -1; height: 14px; border-radius: 7px; background: var(--surface-2); position: relative; overflow: hidden; }
.ov-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; }
.ov-map svg { width: 100%; height: auto; display: block; }
.ov-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--text-3); font-size: 15px; margin-top: 10px; }
.ov-legend i { display: inline-block; width: 16px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.ov-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ov-stats .stat-value { font-size: 30px; }
.ov-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.ov-table th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; }
.ov-table td { padding: 8px; border-top: 1px solid var(--border-subtle); }
.ov-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Desk (views/desk.js): moments feed, draft post and actions */
.d-v { margin-left: auto; }
.feed-head { list-style: none; padding: 10px 4px 4px; font-size: var(--fs-caption); color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.feed-row.upcoming .feed-title { color: var(--text-2); }
.feed-row.upcoming .feed-dot { background: transparent; border: 2px solid var(--text-3); }
.d-draft { position: relative; margin: var(--space-3) 0; }
.d-draft textarea { width: 100%; box-sizing: border-box; resize: vertical; padding: 12px 14px 26px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-1); font: inherit; font-size: var(--fs-sm); line-height: 1.45; }
.d-count { position: absolute; right: 12px; bottom: 10px; font-size: var(--fs-caption); color: var(--text-3); font-variant-numeric: tabular-nums; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-actions .ov-save { margin: 0; }
.d-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.feed-row.upcoming .feed-dot { background: transparent !important; border: 2px solid var(--text-3); }
.d-news-head { margin: var(--space-4) 0 0; }

/* moments bar (views/desk.js h.deskBar): the latest moment along the bottom of every tab but the Desk */
.mbar { --mb-color: var(--series-1); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; gap: var(--space-3);
  padding: 6px var(--header-pad); padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgb(0 0 0 / 6%); font-size: var(--fs-sm); }
.mbar[hidden] { display: none; }
.mbar button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); }
.mbar button:hover { background: var(--surface-2); }
.mbar-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.mbar-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--mb-color); }
.mbar-time { flex: none; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mbar-kind { flex: none; font-size: var(--fs-caption); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-right: 6px; }
.mbar-head { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text-1); }
.mbar-more { flex: none; font-weight: 700; color: var(--accent) !important; }
.mbar-next { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2) !important; border-left: 1px solid var(--border) !important; border-radius: 0 !important; }
.mbar-x { flex: none; color: var(--text-3) !important; font-size: 18px !important; line-height: 1; }
.mbar.min { left: auto; right: var(--space-4); bottom: var(--space-4); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-pill); }
.mbar-pill { display: flex; align-items: center; gap: 4px; padding: 8px 14px !important; border-radius: var(--radius-pill) !important; font-weight: 600; }
.mbar-pill b { margin-left: 4px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--accent); color: var(--surface); font-size: var(--fs-caption); }
.mbar.fresh { animation: mbar-in 1.6s ease-out; }
.mbar.fresh .mbar-dot { animation: mbar-dot 1.4s ease-out 3; }
.mbar.fresh.big { animation: mbar-in 1.6s ease-out 2; }
@keyframes mbar-in { from { background: color-mix(in srgb, var(--mb-color) 30%, var(--surface)); } }
@keyframes mbar-dot { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mb-color) 60%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { .mbar.fresh, .mbar.fresh .mbar-dot { animation: none; } }
body.has-mbar main { padding-bottom: 64px; }
@media (max-width: 700px) { .mbar.has-latest .mbar-next, .mbar-time, .mbar-more { display: none; } .mbar { gap: 4px; } }

.d-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: var(--fs-caption); font-weight: 700; }
.d-badge.ok { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.d-badge.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }

/* public site (worker/public.js; html.public, and html.pub-nov while Vantage is withheld) */
.pub-only { display: none !important; }
html.public .pub-only { display: block !important; }
html.public .subscribe-btn.pub-only { display: inline-flex !important; }
html.pub-nov .v-only { display: none !important; }
html.public #health-chip { display: none !important; }
html.pub-nov .nav [data-view="score"] { display: none; }
html.public .d-draft, html.public .d-actions, html.public .d-v, html.public .d-badge { display: none !important; }
.subscribe-btn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.sub-frame { display: flex; justify-content: center; }
.substack-frame { width: 100%; max-width: 480px; height: 320px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.sub-panel { max-width: 540px; height: auto; }
.sub-panel .sub-frame { padding: var(--space-4); }
.strip-wide { grid-column: 1 / -1; }
html.pub-nov .cand-card .cand-head, html.pub-nov .cand-card .cand-row { grid-template-columns: 48px minmax(0, 1fr) 72px; }
.sub-pop { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 72px; z-index: 60; width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / 22%); overflow: hidden; animation: sub-in .35s ease-out; }
.sub-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 8px 16px; font-size: var(--fs-sm); }
.sub-pop-head .ov-x { font-size: 22px; }
.sub-pop .substack-frame { display: block; width: 100%; max-width: none; height: 300px; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
@keyframes sub-in { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sub-pop { animation: none; } }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 80; background: var(--text-1); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: var(--fs-sm); box-shadow: 0 8px 24px rgb(0 0 0 / 25%); max-width: calc(100vw - 32px); }
.share-btn { display: inline-flex; align-items: center; gap: 6px; }
.share-btn svg { width: 14px; height: 14px; }
.pub-share { display: none !important; }
html.public .pub-share { display: inline-flex !important; }
.btn-corner2 { position: absolute; top: 12px; right: 12px; z-index: 2; }
html.public #b-group [data-group="legislature"] { display: none; } /* not loaded on the public site */
/* the share menu: Post to X and Copy link first; the downloads below a rule (internal site only) */
.xport-files { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
html.public .xport-files { display: none; }
.d-head { display: flex; align-items: center; gap: 8px; }
.d-head .kicker { margin: 0; }

