:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --rule: #e4e4e4;
  --wash: #f4f4f2;
  --mark: #ffe14d;

  --alp: #d11f35;
  --coa: #2a6bd1;
  --grn: #1b7f45;
  --on: #ee9a1f;
  --ind: #12a3b4;
  --oth: #8a8f98;

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--display);
  font-variation-settings: "wdth" 100;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { background: var(--mark); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* Masthead */
.masthead { border-bottom: 4px solid var(--ink); }
.masthead-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 12px; }
.brand {
  font-weight: 900; font-size: 26px; letter-spacing: -0.02em; text-decoration: none;
  font-variation-settings: "wdth" 68;
}
.brand:hover { background: none; }
.elections { display: flex; gap: 4px; flex-wrap: wrap; }
.elections a, .modes a {
  font: 500 13px/1 var(--mono); color: var(--ink); text-decoration: none;
  border: 1px solid transparent; padding: 8px 10px; border-radius: 2px;
}
.elections a:hover, .modes a:hover { border-color: var(--ink); background: none; }
.elections a[aria-current="true"], .modes a[aria-current="true"] { background: var(--mark); border-color: var(--ink); }
.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding-bottom: 0; }
.views { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: -10px; }
.views::-webkit-scrollbar { display: none; }
.views a {
  font-weight: 700; font-size: 16px; font-variation-settings: "wdth" 84; text-decoration: none; white-space: nowrap;
  padding: 10px 10px 9px; border-bottom: 5px solid transparent; margin-bottom: -4px;
}
.views a:hover { background: none; border-bottom-color: var(--ink-3); }
.views a[aria-current="page"] { border-bottom-color: var(--mark); box-shadow: inset 0 -1px 0 var(--ink); }
.statusbar { border-bottom: 1px solid var(--rule); font: 400 13px/1 var(--mono); color: var(--ink-2); }
.statusbar .wrap { display: flex; align-items: center; gap: 6px; padding-top: 9px; padding-bottom: 9px; min-height: 32px; flex-wrap: wrap; }
.statusbar .sw { margin-left: 8px; }
.statusbar .sw:first-child { margin-left: 0; }
.view[hidden], [data-slot][hidden] { display: none; }
.view > section:first-child:not(.hero), .view > [data-slot]:first-child > section:first-child, #seats-index > [data-slot]:first-child > section:first-child, [data-slot="seat"] > section:first-child { border-top: 0; margin-top: 28px; }
body.loading main { opacity: .55; transition: opacity .2s .15s; }
table.seats td.name a { font-weight: 700; }

/* Hero */
.hero { padding: 36px 0 8px; }
.dateline { font: 400 13px/1.4 var(--mono); color: var(--ink-2); margin: 0 0 14px; }
h1 {
  font-weight: 900; font-size: clamp(38px, 6.4vw, 76px); line-height: 0.96; letter-spacing: -0.025em;
  font-variation-settings: "wdth" 70; margin: 0 0 18px; max-width: 13em; text-wrap: balance;
}
.deck { font-size: clamp(18px, 2.2vw, 22px); line-height: 1.4; max-width: 30em; margin: 0 0 22px; color: var(--ink); }
.deck b { font-weight: 700; }
.modes { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px 0; }

.sims { display: grid; grid-template-rows: repeat(4, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; max-width: 900px; }
.sims i { display: block; aspect-ratio: 1; border-radius: 50%; }
.sims-caption { font: 400 13px/1.4 var(--mono); color: var(--ink-2); margin: 10px 0 14px; }
.outcome-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 6px 24px; margin: 0; padding: 0; list-style: none; max-width: 900px; }
.outcome-list li { display: flex; align-items: baseline; gap: 8px; font-size: 15px; border-top: 1px solid var(--rule); padding-top: 6px; }
.outcome-list .n { font: 500 15px/1 var(--mono); margin-left: auto; }
.sw { width: 11px; height: 11px; border-radius: 50%; flex: none; display: inline-block; transform: translateY(1px); }

/* Sections */
.view section:not(.hero) { margin-top: 56px; border-top: 4px solid var(--ink); padding-top: 14px; }
h2 { font-weight: 800; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.05; letter-spacing: -0.015em; font-variation-settings: "wdth" 76; margin: 0 0 8px; }
.sub { color: var(--ink-2); max-width: 44em; margin: 0 0 18px; font-size: 16px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 400 12px var(--mono); fill: var(--ink-2); }
.chart text.strong { fill: var(--ink); font-weight: 500; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--ink); stroke-width: 1; }
.chart text.ref-label { fill: var(--ink); stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; }
.notice { font: 400 14px/1.5 var(--mono); color: var(--ink-2); background: var(--wash); padding: 14px 16px; margin: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); margin: 12px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Hero pendulum */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); gap: 16px 24px; align-items: center; }
.pendulum svg { display: block; width: 100%; height: auto; overflow: visible; }
.pendulum text { font: 400 17px var(--mono); fill: var(--ink-2); }
.pendulum text.strong { fill: var(--ink); font-weight: 500; font-size: 20px; }
.pendulum .axis { stroke: var(--ink); stroke-width: 1.5; }
.swing { transform-box: view-box; transform-origin: 210px 26px; transform: rotate(var(--a)); animation: settle 3.2s cubic-bezier(.37,0,.63,1) both; }
@keyframes settle {
  0% { transform: rotate(var(--s)); }
  26% { transform: rotate(calc(var(--a) + (var(--a) - var(--s)) * 0.42)); }
  46% { transform: rotate(calc(var(--a) - (var(--a) - var(--s)) * 0.2)); }
  64% { transform: rotate(calc(var(--a) + (var(--a) - var(--s)) * 0.09)); }
  80% { transform: rotate(calc(var(--a) - (var(--a) - var(--s)) * 0.035)); }
  100% { transform: rotate(var(--a)); }
}
@media (prefers-reduced-motion: reduce) { .swing { animation: none; } .seat-dot { transition: none !important; } }

/* Sandbox */
h3 { font-weight: 800; font-size: 19px; line-height: 1.15; font-variation-settings: "wdth" 80; margin: 0 0 12px; }
.play-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.play-bar button { font: 700 16px/1 var(--display); padding: 13px 18px; border: 2px solid var(--ink); border-radius: 2px; cursor: pointer; color: var(--ink); }
.play-bar .go { background: var(--mark); box-shadow: 4px 4px 0 var(--ink); }
.play-bar .go:hover { transform: translate(1px, 1px); box-shadow: 3px 3px 0 var(--ink); }
.play-bar .go:active { transform: translate(4px, 4px); box-shadow: none; }
.play-bar .ghost { background: var(--paper); font-weight: 500; }
.play-bar .ghost:hover { background: var(--wash); }
.result { min-height: 3em; margin: 0 0 8px; font-size: 16px; max-width: 46em; }
.result b { font-weight: 800; }
.muted { color: var(--ink-2); }
.snake-wrap { position: relative; }
.tongue { animation: flick 4s steps(1) infinite; }
@keyframes flick { 0%, 86% { opacity: 0; } 88%, 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tongue { animation: none; } }
.seat-dot { cursor: pointer; stroke: #fff; stroke-width: 1.5; transition: fill .28s ease; outline: none; }
.seat-dot:hover, .seat-dot:focus-visible { stroke: var(--ink); stroke-width: 3; }
.seat-dot.picked { stroke: var(--ink); stroke-width: 3.5; }
.sw.ring { background: none; border: 1.5px dashed var(--ink); }
.sw.lock { background: var(--oth); border: 3px solid var(--ink); }
.pick { position: absolute; z-index: 5; width: 232px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 10px; }
.pick-title { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); }
.pick-title b { display: block; font-size: 17px; font-weight: 800; color: var(--ink); }
.pick button { display: flex; align-items: center; gap: 8px; width: 100%; font: 400 15px var(--display); background: none; border: 1px solid var(--rule); border-radius: 2px; padding: 8px 9px; margin-top: 4px; cursor: pointer; color: var(--ink); text-align: left; }
.pick button span { margin-left: auto; font: 400 13px var(--mono); color: var(--ink-2); }
.pick button:hover { border-color: var(--ink); }
.pick button[aria-pressed="true"] { background: var(--mark); border-color: var(--ink); }
.pick-foot { display: flex; gap: 4px; }
.pick-foot button { font-size: 13px; justify-content: center; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 48px; margin-top: 30px; }
.odd { display: grid; grid-template-columns: minmax(0, 1fr) 62px; gap: 2px 10px; align-items: center; margin-bottom: 11px; }
.odd-label { grid-column: 1 / -1; font-size: 15px; }
.odd-track { position: relative; height: 16px; background: var(--wash); border-radius: 2px; }
.odd-track i { display: block; height: 100%; border-radius: 2px; min-width: 2px; transition: width .35s ease; }
.odd-track b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.odd-n { font: 500 15px var(--mono); white-space: nowrap; }
.odd-n .was { display: block; font-size: 11px; font-weight: 400; color: var(--ink-2); }
.fine { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); max-width: 52em; margin: 14px 0 0; }

/* Sandbox controls */
.find { margin-left: auto; font: 400 13px var(--mono); color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.find input { font: 400 16px var(--display); padding: 10px 12px; border: 2px solid var(--ink); border-radius: 2px; width: 190px; background: var(--paper); color: var(--ink); }
.swinger { margin: 6px 0 14px; max-width: 640px; }
.swinger label { font-weight: 700; font-size: 15px; }
.swing-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; font: 400 13px var(--mono); color: var(--ink-2); white-space: nowrap; }
.swing-row input { flex: 1; min-width: 0; height: 32px; accent-color: var(--ink); cursor: grab; }
.swing-note { font-size: 14px; color: var(--ink-2); margin: 2px 0 0; min-height: 1.5em; }
.tally { margin: 0 0 14px; }
.tally-label { display: flex; font: 400 12px var(--mono); color: var(--ink-2); margin-bottom: 4px; }
.tally-label span { margin: 0 auto; transform: translateX(-50%); color: var(--ink); font-weight: 500; }
.tally-bar { position: relative; display: flex; gap: 2px; height: 30px; }
.tally-bar i { display: flex; align-items: center; justify-content: center; min-width: 3px; border-radius: 2px; color: #fff; font: 500 13px var(--mono); font-style: normal; transition: flex-grow .3s ease; overflow: hidden; }
.tally-bar b { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--ink); }
.run-dot { cursor: pointer; }
.run-dot:hover { stroke: var(--ink); stroke-width: 2; opacity: 1; }
.found { animation: pulse 1.2s ease-in-out 3; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .found { animation: none; } .tally-bar i, .odd-track i { transition: none; } }
.seat-card { border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 14px 16px; margin: 18px 0 0; max-width: 640px; }
.seat-card h3 { margin: 0 0 2px; font-size: 22px; }
.seat-card p { margin: 0 0 10px; font-size: 15px; }
.card-odds { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; font-size: 15px; }
.card-odds span { display: inline-flex; align-items: center; gap: 6px; }
.card-odds b { font: 500 14px var(--mono); }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-actions button { font: 500 14px var(--display); padding: 9px 12px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); cursor: pointer; }
.card-actions button:hover { background: var(--mark); }
.play-bar button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Seat table */
.controls { display: flex; gap: 12px 20px; flex-wrap: wrap; align-items: center; margin: 14px 0 12px; }
.controls input[type="search"] { font: 400 16px var(--display); padding: 9px 12px; border: 1px solid var(--ink); border-radius: 2px; min-width: min(320px, 100%); flex: 1 1 260px; max-width: 420px; background: var(--paper); color: var(--ink); }
.select { font: 400 13px var(--mono); color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.select select { font: 400 15px var(--display); padding: 8px 10px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); }
.table-scroll { overflow-x: auto; }
table.seats { width: 100%; border-collapse: collapse; min-width: 620px; }
table.seats th { font: 400 12px var(--mono); color: var(--ink-2); text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--ink); }
table.seats td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; font-size: 15px; }
table.seats tr.seat { cursor: pointer; }
table.seats tr.seat:hover td { background: var(--wash); }
table.seats td.name button { font: 700 16px var(--display); background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; text-align: left; }
table.seats td.held, table.seats td.fav { white-space: nowrap; }
table.seats .num { font: 400 13px var(--mono); color: var(--ink-2); }
table.seats td.bar { width: 42%; min-width: 200px; }
.stack { display: flex; gap: 2px; height: 14px; }
.stack i { display: block; height: 100%; border-radius: 2px; min-width: 2px; }
table.seats tr.detail > td { background: var(--wash); padding: 14px 16px 16px; }
.detail-body { position: sticky; left: 16px; max-width: calc(100vw - 72px); overflow-x: auto; }
.cands { width: 100%; border-collapse: collapse; max-width: 760px; }
.cands th { font: 400 12px var(--mono); color: var(--ink-2); text-align: left; padding: 0 12px 6px 0; border: 0; }
table.seats .cands td { padding: 5px 16px 5px 0; border: 0; border-top: 1px solid var(--rule); font-size: 15px; background: none; }
table.seats .cands th { border: 0; padding: 0 16px 6px 0; }
table.seats .cands td.r, table.seats .cands th.r { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; padding-right: 0; padding-left: 16px; }
.cands .muted { color: var(--ink-2); }
.detail-note { font-size: 14px; color: var(--ink-2); margin: 10px 0 0; max-width: 46em; }
.empty { color: var(--ink-2); }

/* Tooltip */
.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: #fff; padding: 9px 11px; border-radius: 3px; font-size: 13px; line-height: 1.45; max-width: 280px; }
.tip b { font-weight: 700; }
.tip .row { display: flex; align-items: center; gap: 7px; }
.tip .row .v { margin-left: auto; padding-left: 14px; font-family: var(--mono); }
.tip .sw { transform: none; width: 9px; height: 9px; }
.tip .muted { color: #bdbdbd; }

.footer { margin-top: 72px; padding-top: 22px; padding-bottom: 56px; color: var(--ink-2); font-size: 15px; background: linear-gradient(var(--ink), var(--ink)) 20px 0 / calc(100% - 40px) 4px no-repeat; }
.footer p { max-width: 46em; margin: 0 0 10px; }
.footer strong { color: var(--ink); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .sims { grid-template-rows: repeat(5, 1fr); }
  .hero-grid, .play-grid { grid-template-columns: minmax(0, 1fr); }
  .pendulum { max-width: 400px; }
  .find { margin-left: 0; width: 100%; }
  .find input { flex: 1; }
  .view section:not(.hero) { margin-top: 44px; }
}
table.seats .cands td:first-child { min-width: 170px; }
/* Seat table on phones: seat and holder share a cell, the stacked odds bar goes, and the favourite
   stays in view without scrolling sideways. */
table.seats .held-m { display: none; }
@media (max-width: 600px) {
  table.seats { min-width: 0; }
  table.seats > thead th:nth-child(2), table.seats > thead th:nth-child(3), table.seats td.held, table.seats td.bar { display: none; }
  table.seats .held-m { display: block; font: 400 13px/1.3 var(--mono); color: var(--ink-2); margin-top: 2px; }
  table.seats td.fav { white-space: normal; width: 45%; }
  table.seats td.fav .num { display: block; }
}

/* Forecast page reading order: verdict first, then the core charts, then the deep dives.
   The order is real DOM order (app.js moves #forecast-charts into the gap the insights plugin
   leaves after its briefing), so tab order and screen readers follow what is on screen. */
.statusbar span { margin-right: 4px; }
.statusbar .st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin-right: 8px; }
.statusbar .st .sw { margin-left: 0; transform: none; }

/* Skip link: first tab stop, visible only when focused. */
.skip { position: absolute; left: 8px; top: -60px; z-index: 20; background: var(--mark); border: 2px solid var(--ink); padding: 10px 14px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 8px; }
main:focus { outline: none; }

/* Section tabs that scroll sideways on a phone fade at whichever end hides more of them. */
.views.more-right { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 34px); mask-image: linear-gradient(to left, transparent 0, #000 34px); }
.views.more-left { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 34px); mask-image: linear-gradient(to right, transparent 0, #000 34px); }
.views.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%); }
.views a:focus-visible { outline-offset: -3px; }

/* Dark numbers on the paler party colours in the seat bar. */
.tally-bar i.on-on, .tally-bar i.on-ind, .tally-bar i.on-oth { color: var(--ink); }
.run-dot { outline: none; }
.run-dot:focus-visible { stroke: var(--ink); stroke-width: 3; opacity: 1; }
.outcome-list li { cursor: default; }
.subnav { display: flex; gap: 6px; margin: 22px 0 0; }
.subnav a { font: 500 14px/1 var(--mono); text-decoration: none; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 2px; }
.subnav a:hover { background: var(--wash); }
.subnav a[aria-current="true"] { background: var(--mark); }
#seats-index > .subnav + [data-slot] > section:first-child, #seats-index > [data-slot] > section:first-child { border-top: 0; margin-top: 24px; }

/* Visually hidden, still read aloud. */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; font-size: 16px; }

/* Front page: no election is chosen yet, so nothing election-specific shows in the shell. */
body.at-home .statusbar, body.at-home .footer p:nth-of-type(1), body.at-home .footer p:nth-of-type(2) { display: none; }
.subnav { flex-wrap: wrap; }

/* Forecast hero: majority for each side against no majority. The deck already gives the
   headline odds, so the status bar would only repeat them on this page. */
body.at-forecast .statusbar { display: none; }
h1.long { font-size: clamp(34px, 4.6vw, 54px); }
.majbar { max-width: 30em; margin: 0 0 22px; }
.majbar-title { font: 400 13px/1.4 var(--mono); color: var(--ink-2); margin: 0 0 6px; }
.majbar-bar { display: flex; gap: 2px; height: 22px; }
.majbar-bar i { display: block; min-width: 3px; border-radius: 2px; }
.majbar .mb-hung { box-shadow: inset 0 0 0 2px var(--ink); }
.majbar-key { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.majbar-key li { display: inline-flex; align-items: center; gap: 6px; }
.majbar-key b { font: 500 14px var(--mono); }
.majbar-key .sw.mb-hung { box-shadow: inset 0 0 0 2px var(--ink); }

/* Phones: every pill, tab, sub-tab and button is at least a 44px tap target. Zero specificity
   (:where) so any plugin that sets its own size still wins. */
@media (max-width: 600px) {
  :where(.elections a, .modes a, .subnav a, .views a) { min-height: 44px; display: inline-flex; align-items: center; }
  :where(button:not(.link)) { min-height: 44px; }
}

/* Play it out has its own seat search (it rings the seat on the snake), so the global
   find-your-seat strip would be a second search box on the same page. */
body.at-play [data-slot="locate"] { display: none; }
