:root {
  --bg: #1a1f27;
  --surface: #222935;
  --surface-2: #2a3340;
  --line: #333d4b;
  --text: #e9edf2;
  --muted: #96a1b1;
  --faint: #6b7686;
  --dem: #5b93e8;
  --gop: #e3604f;
  --oth: #a3adbb;
  --dem-soft: rgba(91, 147, 232, 0.18);
  --gop-soft: rgba(227, 96, 79, 0.18);
  --called: #d7e4f5;
  --focus: #ffd166;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --line: #d9dee6;
    --text: #1b2230;
    --muted: #596577;
    --faint: #8a94a3;
    --dem: #2f6fd1;
    --gop: #c8463a;
    --oth: #7c8696;
    --dem-soft: rgba(47, 111, 209, 0.14);
    --gop-soft: rgba(200, 70, 58, 0.14);
    --called: #1b2230;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  padding: 0 16px 48px;
}
button, select { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 0 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .top { grid-template-columns: 260px 1fr; align-items: start; }
}
.feed { color: var(--muted); font-size: 13px; margin-top: 4px; }
.feed .err { color: var(--gop); }

/* Control of chamber bars */
.controls { display: grid; gap: 10px; }
.bar {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
}
.bar .name { font-weight: 600; font-size: 14px; }
.bar .name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.track {
  position: relative;
  height: 22px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.track .seg { height: 100%; }
.track .seg + .seg { margin-left: 2px; }
.track .seg.d { background: var(--dem); border-radius: 4px 0 0 4px; }
.track .seg.r { background: var(--gop); border-radius: 0 4px 4px 0; margin-left: auto; }
.track .mid {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--text); opacity: 0.8;
}
.tally {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 3px;
}
.tally b { color: var(--text); font-weight: 600; }
.tally .dn { color: var(--dem); }
.tally .rn { color: var(--gop); }

.warn {
  max-width: 1180px; margin: 0 auto 10px;
  padding: 8px 12px; border-radius: 6px;
  background: var(--gop-soft); color: var(--text); font-size: 13px;
}

/* Filters */
.filters {
  max-width: 1180px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  padding: 10px 0 14px;
  border-top: 1px solid var(--line);
}
.chips { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: transparent;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  color: var(--muted); font-size: 14px;
}
.chip:hover { color: var(--text); }
.chip[aria-selected="true"], .chip.on { background: var(--surface-2); color: var(--text); border-color: var(--surface-2); }
.offices .chip { padding: 5px 10px; font-size: 13px; }
.sel { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sel select {
  font-size: 16px; padding: 5px 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* Board */
main { max-width: 1180px; margin: 0 auto; }
.group { margin-bottom: 22px; }
.group h2 {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 0 0 6px; padding: 0 10px;
}
.row {
  display: grid;
  grid-template-columns: 88px 70px minmax(136px, 1fr) 160px minmax(136px, 1fr) 56px 96px 92px 136px;
  gap: 0 12px;
  align-items: center;
  padding: 9px 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: 48px;
}
.group .row:first-of-type { border-top: 0; border-radius: 8px 8px 0 0; }
.group .row:last-of-type { border-radius: 0 0 8px 8px; }
.group .row:only-of-type { border-radius: 8px; }
.row.called { background: color-mix(in srgb, var(--surface) 85%, var(--surface-2)); }
.seat { font-weight: 600; }
.seat small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.seat a { color: inherit; text-decoration: none; }
.seat a:hover { text-decoration: underline; }
.rating { font-size: 12px; color: var(--muted); }
.rating.tossup { color: var(--text); font-weight: 600; }
.cand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cand.right { justify-content: flex-end; text-align: right; }
.cand .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .nm i { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 4px; }
.cand .pct { font-weight: 600; width: 52px; flex: none; }
.cand.right .pct { text-align: right; }
.cand .v { color: var(--faint); font-size: 12px; flex: none; }
.cand.won .nm::after { content: " ✓"; color: var(--called); font-weight: 700; }
.cand.won .nm { font-weight: 600; }
.cand .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.dot.DEM { background: var(--dem); } .dot.GOP { background: var(--gop); } .dot.OTH { background: var(--oth); }

/* Margin bar: the one thing meant to be read at a glance */
.mbar {
  position: relative; height: 14px;
  background: var(--surface-2); border-radius: 4px;
}
.mbar::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px;
  margin-left: -1px; background: var(--faint); opacity: 0.6;
}
.mbar .fill { position: absolute; top: 2px; bottom: 2px; }
.mbar .fill.d { right: 50%; background: var(--dem); border-radius: 4px 0 0 4px; margin-right: 1px; }
.mbar .fill.r { left: 50%; background: var(--gop); border-radius: 0 4px 4px 0; margin-left: 1px; }
.mbar .lbl {
  position: absolute; top: -1px; font-size: 11px; color: var(--muted); line-height: 16px;
}
.mbar .lbl.d { right: calc(50% + 4px); }
.mbar .lbl.r { left: calc(50% + 4px); }

.mbar .tick {
  position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px;
  background: var(--text); opacity: 0.9; z-index: 1;
}
.prev, .swing { font-size: 13px; line-height: 1.2; }
.prev b, .swing b { display: block; font-weight: 600; }
.prev small, .swing small { color: var(--faint); font-size: 11px; }
.prev.alt small { color: var(--muted); }
.prev .D, .swing .D { color: var(--dem); } .prev .R, .swing .R { color: var(--gop); }
.swing.empty::before { content: "–"; color: var(--faint); }
.note { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; line-height: 1.35; padding-top: 2px; max-width: 72ch; }
.in { text-align: right; color: var(--muted); font-size: 13px; }
.in b { color: var(--text); font-weight: 600; font-size: 14px; }
.status { font-size: 13px; color: var(--muted); }
.status.won { color: var(--text); font-weight: 600; }
.status .flip { color: var(--focus); font-weight: 600; }
.status .D { color: var(--dem); } .status .R { color: var(--gop); }

@media (max-width: 860px) {
  .row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "seat status"
      "dem gop"
      "bar bar"
      "prev swing";
    gap: 4px 10px;
    padding: 10px;
  }
  .seat { grid-area: seat; display: flex; gap: 8px; align-items: baseline; }
  .seat small { display: inline; }
  .rating { display: none; }
  .seat .rt { color: var(--muted); font-weight: 400; font-size: 12px; }
  .cand.left { grid-area: dem; }
  .cand.right { grid-area: gop; }
  .mbar { grid-area: bar; margin-top: 4px; }
  .prev { grid-area: prev; }
  .swing { grid-area: swing; text-align: right; }
  .prev b, .swing b { display: inline; margin-right: 4px; }
  .in { grid-area: status; text-align: right; }
  .in b { font-size: 13px; }
  .status { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; }
  .in { display: none; }
  .status .inm { display: inline; }
  .cand .v { display: none; }
}
@media (min-width: 861px) { .status .inm { display: none; } .seat .rt { display: none; } }

footer {
  max-width: 1180px; margin: 28px auto 0;
  color: var(--faint); font-size: 12px;
  border-top: 1px solid var(--line); padding-top: 12px;
}
.stamp { margin-top: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .mbar .fill { transition: width 400ms ease; }
}
