:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #121212;
  --ink-2: #4a4a4a;
  --ink-3: #727272;
  --rule: #e2e2e2;
  --rule-strong: #121212;
  --chip: #f3f3f1;
  --nodata: #ececea;
  --map-stroke: #ffffff;

  --dem: #2e6db4;
  --dem-mid: #6f9fd6;
  --dem-light: #bcd3ee;
  --rep: #d2463a;
  --rep-mid: #e5867c;
  --rep-light: #f2c3bd;
  --oth: #c9a227;
  --oth-light: #eedfa6;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Libre Franklin", "Franklin Gothic Medium", Arial, sans-serif;
}
/* Dark mode is opt-in via the masthead toggle, not the OS setting. */
:root[data-theme="dark"] {
  --bg: #121314; --surface: #1a1b1d; --ink: #ececec; --ink-2: #b9b9b9; --ink-3: #8d8d8d;
  --rule: #2e3033; --rule-strong: #ececec; --chip: #24262a; --nodata: #2a2c30; --map-stroke: #121314;
  --dem: #4f8fd8; --dem-mid: #3a6aa3; --dem-light: #263f5e;
  --rep: #e2584b; --rep-mid: #a8473e; --rep-light: #5a2a26;
  --oth: #d9b440; --oth-light: #4d4220;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 56px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); }
a { color: inherit; }
button { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--bg); padding: 4px 8px; z-index: 10; }
.num, td, .bal-figs, .cand-votes { font-variant-numeric: tabular-nums; }

/* Masthead */
.masthead { padding: 28px 0 18px; border-bottom: 1px solid var(--rule); }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.kicker a { text-decoration: none; }
.kicker-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.theme-toggle { font: 600 12px var(--sans); color: var(--ink-2); background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
h1 { font: 700 clamp(30px, 5vw, 46px)/1.05 var(--serif); margin: 0 0 8px; letter-spacing: -.01em; }
.dek { margin: 0 0 16px; font-size: 17px; color: var(--ink-2); max-width: 640px; }
.status { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; font-size: 13px; color: var(--ink-2); }
.status-line { display: flex; gap: 6px; align-items: center; }
.sep { color: var(--ink-3); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live-dot.is-live { background: #d0021b; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot.is-live { animation: none; } }
.reporting { display: flex; gap: 8px; align-items: center; }
.meter { width: 120px; height: 6px; background: var(--nodata); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .6s; }
.banner { flex-basis: 100%; margin: 4px 0 0; padding: 8px 12px; background: var(--chip); border-left: 3px solid var(--ink); color: var(--ink); }

/* Jump nav */
.jump { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--rule); }
.jump .wrap { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.jump a { padding: 12px 0; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; color: var(--ink-2); }
.jump a:hover { color: var(--ink); }

/* Sections */
.section { padding: 32px 0 8px; border-bottom: 1px solid var(--rule); }
.section:last-child { border-bottom: 0; }
h2 { font: 700 24px/1.2 var(--serif); margin: 0 0 6px; }
h3 { font: 700 17px/1.25 var(--sans); margin: 0; }
.section-dek { margin: 0 0 16px; color: var(--ink-2); max-width: 680px; }

/* Balance of power */
.balance-grid { display: grid; gap: 28px; margin-top: 16px; }
.bal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.bal-head h3 { font-size: 16px; }
.bal-sub { font-size: 12px; color: var(--ink-3); }
.bal-figs { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 6px; }
.bal-side { display: flex; flex-direction: column; }
.bal-side.r { align-items: flex-end; text-align: right; }
.bal-big { font: 800 28px/1 var(--sans); }
.bal-side.d .bal-big { color: var(--dem); }
.bal-side.r .bal-big { color: var(--rep); }
.bal-party { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.bal-detail { font-size: 12px; color: var(--ink-3); }
.bal-net { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 3px; font-size: 11px; font-weight: 700; background: var(--chip); color: var(--ink); }
.bal-bar { position: relative; display: flex; height: 22px; gap: 2px; }
.bal-bar > span { height: 100%; min-width: 0; transition: flex-grow .6s; }
.bal-bar > span:first-child { border-radius: 4px 0 0 4px; }
.bal-bar > span:last-of-type { border-radius: 0 4px 4px 0; }
.seg-d-won { background: var(--dem); } .seg-d-lead { background: var(--dem-light); }
.seg-r-won { background: var(--rep); } .seg-r-lead { background: var(--rep-light); }
.seg-o-won { background: var(--oth); } .seg-o-lead { background: var(--oth-light); }
.seg-pending { background: var(--nodata); }
.seg-d-hold { background: repeating-linear-gradient(135deg, var(--dem) 0 3px, var(--dem-mid) 3px 6px); }
.seg-r-hold { background: repeating-linear-gradient(135deg, var(--rep) 0 3px, var(--rep-mid) 3px 6px); }
.bal-majority { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--ink); box-shadow: 0 0 0 1.5px var(--bg); }
.bal-majority-label { display: flex; font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.bal-key { max-width: 460px; margin-top: -6px; font-size: 11px; color: var(--ink-2); }
.bal-key-bar, .bal-key-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.bal-key-bar span { height: 10px; }
.bal-key-bar span:first-child { border-radius: 3px 0 0 3px; }
.bal-key-bar span:last-child { border-radius: 0 3px 3px 0; }
.bal-key-labels span { text-align: center; line-height: 1.2; margin-top: 3px; }
.bal-key-note { margin: 6px 0 0; color: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 5px; }

/* Chips & tabs */
.map-toggle, .filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.chip { border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin: 12px 0 18px; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 16px 8px; font-weight: 700; cursor: pointer; color: var(--ink-3); }
.tab.is-on { color: var(--ink); border-bottom-color: var(--ink); }
.tab-sub { display: block; font-weight: 400; font-size: 12px; }

/* Statewide cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.card { border-top: 2px solid var(--rule-strong); padding-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: .03em; background: var(--chip); color: var(--ink-2); white-space: nowrap; }
.tag.flip-d { background: var(--dem); color: #fff; }
.tag.flip-r { background: var(--rep); color: #fff; }
.tag.called { background: var(--ink); color: var(--bg); }

.cand-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cand-table td { padding: 6px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.cand-name { font-weight: 600; }
.cand-name .party { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.cand-name .check { display: inline-block; width: 15px; height: 15px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; color: #fff; text-align: center; font-size: 10px; line-height: 15px; }
.cand-bar { width: 34%; padding: 0 10px !important; }
.cand-bar span { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.cand-pct { text-align: right; font-weight: 700; width: 56px; }
.cand-votes { text-align: right; color: var(--ink-2); width: 84px; }
.card-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* Maps */
.map { position: relative; }
.map svg { display: block; width: 100%; height: auto; }
.map path.shape { stroke: var(--map-stroke); stroke-width: .6; vector-effect: non-scaling-stroke; cursor: pointer; }
.map path.shape:hover, .map path.shape.is-selected { stroke: var(--ink); stroke-width: 1.6; }
.map path.outline { fill: none; stroke: var(--ink-3); stroke-width: .8; vector-effect: non-scaling-stroke; pointer-events: none; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.map-legend.scale { display: block; max-width: 300px; }
.scale-ends { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 3px; }
.scale-bar, .scale-ticks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.scale-bar i { width: auto; height: 10px; margin: 0; border-radius: 0; }
.scale-bar i:first-child { border-radius: 2px 0 0 2px; }
.scale-bar i:last-child { border-radius: 0 2px 2px 0; }
.scale-ticks span { text-align: center; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.scale-extra { margin-top: 6px; }
.key-grid { border-collapse: collapse; }
.key-grid th { font-weight: 600; text-align: left; padding: 0 10px 2px 0; }
.key-grid tr:first-child th { text-align: center; color: var(--ink-3); font-weight: 500; }
.key-grid td { text-align: center; padding: 1px 6px; }
.key-grid td i { margin: 0; vertical-align: middle; }
.key-grid td.key-gap { width: 18px; padding: 0; }
.key-grid td.key-extra { text-align: left; padding: 1px 0; white-space: nowrap; }
.key-grid td.key-extra i { margin-right: 4px; }
.card .map { max-width: 240px; margin: 12px auto 0; }

/* Chamber layout */
.chamber-grid { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 28px; align-items: start; }
.chamber-map-col { position: sticky; top: 64px; }
.detail { padding: 4px 4px 6px; min-height: 40px; font-size: 14px; }
.hint { color: var(--ink-3); font-size: 13px; }
.race-table tr.detail-row { cursor: default; }
.race-table tr.detail-row > td { background: var(--chip); border-bottom: 2px solid var(--rule-strong); padding: 4px 10px 12px; }
/* Keep the sticky map column within the viewport so the Marion County inset isn't cut off. */
@media (min-width: 760px) {
  .chamber-map-col .map > svg { max-height: calc(100vh - 380px); min-height: 260px; margin: 0 auto; }
  .chamber-map-col .inset svg { max-height: 24vh; min-height: 150px; margin: 0 auto; }
}
.detail .county-list { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.search { border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; min-width: 0; flex: 1 1 140px; max-width: 220px; }

.race-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.race-table > thead > tr > th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 0 6px 6px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.race-table > tbody > tr > td { padding: 7px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.race-table > tbody > tr { cursor: pointer; }
.race-table > tbody > tr:hover > td, .race-table > tbody > tr.is-selected > td { background: var(--chip); }
.race-table .dist { font-weight: 700; width: 40px; }
.race-table .r-num { text-align: right; white-space: nowrap; }
.mini-cands { display: grid; gap: 2px; }
.mini-cand { display: grid; grid-template-columns: 8px 1fr auto; gap: 6px; align-items: center; }
.mini-cand i { width: 8px; height: 8px; border-radius: 50%; }
.mini-cand.is-leader { font-weight: 700; }
.mini-cand .pct { text-align: right; min-width: 42px; }
.lean { font-weight: 600; white-space: nowrap; }
.lean.d { color: var(--dem); } .lean.r { color: var(--rep); }
.muted { color: var(--ink-3); }
.empty { padding: 16px 0; color: var(--ink-3); }

/* Flips */
.flip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding-bottom: 24px; }
.flip { border: 1px solid var(--rule); border-left: 4px solid var(--ink); border-radius: 4px; padding: 10px 12px; font-size: 13px; }
.flip.d { border-left-color: var(--dem); } .flip.r { border-left-color: var(--rep); }
.flip strong { display: block; font-size: 14px; }

/* Tooltip */
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); box-shadow: 0 4px 16px rgba(0,0,0,.14); border-radius: 4px; padding: 8px 10px; font-size: 12px; max-width: 260px; }
.tooltip h4 { margin: 0 0 4px; font-size: 13px; }
.tooltip table { border-collapse: collapse; width: 100%; }
.tooltip td { padding: 1px 0; }
.tooltip td + td { text-align: right; padding-left: 10px; font-variant-numeric: tabular-nums; }
.tooltip .tt-foot { margin-top: 4px; color: var(--ink-3); }

.footer { padding: 24px 16px 48px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--rule); }
.footer p { max-width: 760px; }

@media (min-width: 760px) {
  .balance-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 759px) {
  .chamber-grid { grid-template-columns: 1fr; }
  .chamber-map-col { position: static; max-width: 360px; margin: 0 auto; width: 100%; }
  .race-table .hide-sm { display: none; }
  .cand-votes { display: none; }
}

/* Zoomed inset under legislative maps; the clip keeps neighboring districts tidy. */
.inset { margin-top: 10px; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.inset-label { font-size: 11px; font-weight: 600; color: var(--ink-2); padding: 4px 8px; border-bottom: 1px solid var(--rule); }
.inset svg { display: block; width: 100%; height: auto; }
