:root {
  --bg: #0d1117; --card: #161b22; --line: #2a313c; --text: #e6edf3; --muted: #8b949e;
  --dem: #2f74e0; --rep: #d6363f; --ind: #9a6fd6; --oth: #6e7681; --yes: #2da44e; --no: #b5651d;
  --gold: #e3b341;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
h2 { margin: 0 0 10px; font-size: 15px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.live { color: var(--rep); font-size: 12px; font-weight: 700; margin-left: 4px; vertical-align: middle; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rep);
  vertical-align: middle; margin-left: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.tools { display: flex; gap: 12px; align-items: center; }
#election, #search { width: 260px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); }
.toggle { color: var(--muted); font-size: 13px; white-space: nowrap; }
.errors { margin: 10px 20px 0; padding: 8px 12px; border: 1px solid #6e3b00; background: #2b1d0e;
  color: var(--gold); border-radius: 6px; font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.bop-row { display: grid; grid-template-columns: repeat(var(--chart-cols, 3), minmax(0, 1fr)); gap: 16px; padding: 16px 20px 0; }
.bop-row .card { background: #000; padding: 12px 14px 14px; }
.hemi-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 24px; }
.hemi-head .d { color: #1d9bf0; } .hemi-head .r { color: #f4212e; }
.hemi-head .t { text-align: center; font-size: 15px; font-weight: 700; color: var(--text); }
.hemi-head .t small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.hemi { display: block; width: 100%; height: auto; margin-top: 6px; }
.hemi circle { stroke: #000; stroke-width: 1; }
.hemi.labelled circle { stroke: #fff; stroke-width: 3; }
.hemi text { text-anchor: middle; dominant-baseline: central; font-weight: 800; fill: #fff; pointer-events: none; }
.s-d-won circle { fill: #1d9bf0; } .s-r-won circle { fill: #f4212e; } .s-i-won circle { fill: #7856ff; }
.s-d-lead circle { fill: #b9ecff; } .s-r-lead circle { fill: #ffc4cb; } .s-i-lead circle { fill: #c7b8ff; }
.hemi.labelled .s-d-lead circle, .hemi.labelled .s-r-lead circle, .hemi.labelled .s-i-lead circle { stroke: none; }
.s-d-lead text, .s-r-lead text, .s-i-lead text { fill: #0d1117; }
.s-none circle { fill: #6e6e6e; } .hemi.labelled .s-none circle { stroke: none; }
.hemi-bar { position: relative; display: flex; gap: 2px; height: 20px; margin-top: 12px; border-radius: 4px; overflow: visible; }
.hemi-bar span { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 12px; }
.hemi-bar .p-dem { background: #1d9bf0; border-radius: 4px 0 0 4px; } .hemi-bar .p-rep { background: #f4212e; border-radius: 0 4px 4px 0; }
.hemi-bar .p-ind { background: #7856ff; }
.hemi-mark { position: absolute; left: 50%; top: -9px; bottom: -9px; width: 0;
  border-left: 1px dashed #8b949e; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px 20px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button { background: var(--card); color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font: inherit; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--dem); background: #1c2a40; }
.tabs .n { color: var(--muted); font-size: 11px; margin-left: 4px; }
.races { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.race { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--oth);
  border-radius: 6px; padding: 10px 12px; }
.race.w-dem { border-left-color: var(--dem); } .race.w-rep { border-left-color: var(--rep); }
.race.w-ind { border-left-color: var(--ind); } .race.w-yes { border-left-color: var(--yes); }
.race.w-no { border-left-color: var(--no); }
.race-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: #30363d;
  color: var(--muted); white-space: nowrap; align-self: center; }
.badge.called { background: #1f3b26; color: #7ee787; } .badge.flip { background: #3d2a00; color: var(--gold); }
.cand { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; font-size: 13px; margin-top: 4px; align-items: center; }
.cand .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.cand .votes { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 70px; text-align: right; }
.cand.win .nm::after { content: " ✓"; color: #7ee787; }
.chip { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--oth); }
.p-dem { background: var(--dem); } .p-rep { background: var(--rep); } .p-ind { background: var(--ind); }
.p-yes { background: var(--yes); } .p-no { background: var(--no); }
.mini { height: 4px; display: flex; border-radius: 2px; overflow: hidden; margin-top: 8px; background: #30363d; }
.foot-line { color: var(--muted); font-size: 11px; margin-top: 6px; }
.state-group { margin-bottom: 14px; }
.state-group > h3 { font-size: 14px; margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
.state-group > h3 small { color: var(--muted); font-weight: 400; }
table.leg { width: 100%; border-collapse: collapse; font-size: 13px; }
table.leg th, table.leg td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.leg th { color: var(--muted); font-weight: 600; position: sticky; top: 64px; background: var(--bg); }
.rt-D { color: #79b0ff; } .rt-R { color: #ff8a8f; } .rt-T { color: var(--gold); }
.calls { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; }
.calls ol { list-style: none; margin: 0; padding: 0; }
.calls li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.calls li time { color: var(--muted); font-size: 11px; display: block; }
.calls li.new { animation: flash 3s ease-out; }
@keyframes flash { from { background: #3d2a00; } to { background: transparent; } }
.empty { color: var(--muted); padding: 20px; }
.foot { color: var(--muted); font-size: 12px; padding: 0 20px 24px; }
@media (max-width: 1400px) { .bop-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .bop-row, .grid-main { grid-template-columns: 1fr; }
  .calls { position: static; max-height: 360px; }
  #search { width: 100%; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#election { width: 230px; padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.hemi-bar .hemi-gap { background: #3a3f47; }
.hemi-stamp { margin: 6px 0 0; text-align: right; color: var(--muted); font-size: 11px; }
.seat { cursor: pointer; outline: none; }
.seat:hover circle, .seat:focus circle { stroke: var(--gold) !important; stroke-width: 3 !important; }
.race-dialog { width: min(720px, 94vw); max-height: 88vh; overflow: auto; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.race-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.race-close { position: sticky; top: 0; float: right; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.rp-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rp-head h2 { font-size: 20px; margin: 0; }
.rp-stats { color: var(--muted); }
.rp-stats b { color: var(--text); }
.rp-cand { margin: 10px 0; }
.rp-cand.win b::after { content: " ✓"; color: #7ee787; }
.rp-line { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.rp-line a, .rp-posts a, .rp-out { color: #58a6ff; text-decoration: none; }
.rp-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-track { height: 8px; background: #30363d; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.rp-track span { display: block; height: 100%; }
.rp-out { display: inline-block; margin-top: 4px; font-weight: 600; }
.race-dialog h3 { font-size: 14px; margin: 18px 0 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.rp-posts { list-style: none; margin: 0; padding: 0; }
.rp-posts li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.rp-posts p { margin: 4px 0; white-space: pre-wrap; word-break: break-word; }
.rp-post-head { color: var(--muted); font-size: 12px; }
.rp-post-head b { color: var(--text); }

.hemi .s-d-rated circle { fill: #0d1117; stroke: #1d9bf0 !important; stroke-width: 3 !important; }
.hemi .s-r-rated circle { fill: #0d1117; stroke: #f4212e !important; stroke-width: 3 !important; }
.hemi .s-i-rated circle { fill: #0d1117; stroke: #7856ff !important; stroke-width: 3 !important; }
.hemi .s-d-rated text, .hemi .s-r-rated text, .hemi .s-i-rated text { fill: #e6edf3; }
.hemi-note { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.rp-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.rp-table th, .rp-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.rp-table th { color: var(--muted); font-weight: 600; width: 40%; }

.navlink { color: #58a6ff; text-decoration: none; }
.history { padding: 16px 20px; }
.history h2 { font-size: 16px; margin: 22px 0 8px; }
.htools { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; color: var(--muted); }
.htools select, .htools input[type=search] { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.htable td { vertical-align: top; }
.htable .mini { max-width: 160px; }
.mc { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.empty-cell { color: var(--muted); }
.rt-Tie, .rt-Coal { color: #c7b8ff; }
.so-far { display: block; color: var(--gold); font-size: 10px; }
.seat-bar { display: flex; height: 12px; margin-top: 8px; border-radius: 3px; overflow: hidden; background: #3a3f47; }
.seat-bar span { display: block; height: 100%; }
.seat-bar .s-lead-d { background: #b9ecff; } .seat-bar .s-lead-r { background: #ffc4cb; } .seat-bar .hemi-gap { background: #3a3f47; }
.notes { max-width: 900px; line-height: 1.6; } .notes li { margin: 6px 0; } .notes h2 { margin-top: 26px; }
