:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #16202e;
  --ink-2: #4a5568;
  --ink-3: #718096;
  --line: #e2e6ec;
  --line-2: #cfd6df;
  --accent: #0f2a4a;
  --accent-ink: #ffffff;
  --focus: #2b6cdf;
  --na: #e3e7ec;
  --empty: #fcfcfd;
  --pend: #c5ccd6;
  --stroke: #ffffff;
  --st-n: #edf0f3;
  --st-p: #f2b84b;
  --st-f: #1f7a5a;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e27;
    --ink: #e8edf3;
    --ink-2: #b4bfcc;
    --ink-3: #8794a5;
    --line: #26303c;
    --line-2: #35414f;
    --accent: #0b1f37;
    --focus: #6ea0ff;
    --na: #1f2730;
    --empty: #3a4656;
    --pend: #59667a;
    --stroke: #0f141b;
    --st-n: #27313d;
    --st-p: #c9922c;
    --st-f: #2f9d76;
    --warn-bg: #3a2f12;
    --warn-ink: #f6dca0;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--focus); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* Masthead */
.masthead { background: var(--accent); color: var(--accent-ink); }
.masthead-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 32px; padding-top: 16px; padding-bottom: 16px; }
.brand h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.sub { margin: 2px 0 0; font-size: 14px; opacity: .85; display: flex; gap: 8px; align-items: center; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: #f2b84b; color: #2a1d00; padding: 2px 7px; border-radius: 4px; }
.pulse { display: flex; gap: 28px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; opacity: .75; }

@media (max-width: 600px) {
  .brand h1 { font-size: 21px; }
  .pulse { display: grid; grid-template-columns: repeat(4, auto); gap: 12px; width: 100%; justify-content: space-between; }
  .stat-num { font-size: 17px; }
  .stat-label { font-size: 11px; }
}

.banner { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 16px; text-align: center; font-size: 14px; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 20px; padding-top: 20px; padding-bottom: 8px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* Picker */
.picker { display: grid; gap: 10px; margin-bottom: 14px; }
.year-wrap { display: flex; align-items: center; gap: 10px; }
.year-wrap[hidden] { display: none; }
.year-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.year-wrap select { flex: 1; max-width: 360px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); font-weight: 700; }
.seg[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; cursor: pointer; }
.chip[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { opacity: .6; font-weight: 400; margin-left: 4px; }
.picker-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search { flex: 1 1 240px; }
.search input, .select-wrap select, .county-pick select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface);
}
.check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.select-wrap select { font-weight: 600; }

/* Map */
.map-card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-card { padding: 14px 14px 10px; }
.map-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.map-head h2 { margin: 2px 0 0; font-size: 17px; font-weight: 700; line-height: 1.3; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; flex: none; }
.seg-btn { border: 0; background: transparent; padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg-btn.is-on { background: var(--ink); color: var(--surface); }
.map-wrap { position: relative; margin-top: 8px; }
#map { width: 100%; height: auto; display: block; outline: none; }
#map path.county { fill: var(--na); stroke: var(--stroke); stroke-width: .8; cursor: pointer; transition: fill .25s; outline: none; }
#map path.county.is-quiet { stroke: var(--line-2); }
#map path.county:hover, #map path.county.is-hover { stroke: var(--ink); stroke-width: 1.6; }
#map path.county.is-selected { stroke: var(--ink); stroke-width: 2.4; }
#map path.county.is-out { cursor: default; }
#map .outline { fill: none; stroke: var(--ink-3); stroke-width: 1; pointer-events: none; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 200px; max-width: 280px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 10px 12px; font-size: 13px;
}
.tip h4 { margin: 0 0 4px; font-size: 14px; }
.tip .row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.tip .row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 2px 4px; font-size: 13px; color: var(--ink-2); align-items: center; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; border: 1px solid rgba(0,0,0,.08); }
.ramp { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.ramp .sw { width: 16px; border-radius: 2px; }

/* Side cards */
.side-col { display: grid; gap: 16px; }
.card { padding: 16px; }
.card h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.meta { margin: 10px 0 12px; font-size: 13px; color: var(--ink-2); }
.progress { height: 6px; border-radius: 3px; background: var(--st-n); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--st-f); }

.cands { width: 100%; border-collapse: collapse; }
.cands td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.cands tr:first-child td { border-top: 0; }
.cands .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cands .nm { font-weight: 600; }
.cands .pty { font-size: 12px; color: var(--ink-3); margin-left: 4px; font-weight: 500; }
.cands .lead { font-size: 11px; font-weight: 700; color: var(--st-f); text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }
.cands .num { text-align: right; white-space: nowrap; padding-left: 10px; }
.cands .pct { font-weight: 700; display: block; }
.cands .votes { font-size: 12px; color: var(--ink-3); }
.bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; }
.split { margin-top: 12px; font-size: 12px; color: var(--ink-3); }

.county-pick { display: grid; gap: 6px; margin-bottom: 12px; }
.county-pick label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.county-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 14px; }
.county-stats div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.county-stats b { display: block; font-size: 17px; }
.county-stats span { font-size: 12px; color: var(--ink-3); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; }
.cat-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 18px 0 6px; }
.mini { border-top: 1px solid var(--line); padding: 10px 0; }
.mini h5 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.mini h5 button { all: unset; cursor: pointer; }
.mini h5 button:hover, .mini h5 button:focus-visible { text-decoration: underline; }
.mini .r { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 1px 0; }
.mini .r .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mini .r.is-lead { font-weight: 700; }
.office-list { max-height: 520px; overflow: auto; margin-top: 6px; }
.office-list .r { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.office-list .r:hover { background: var(--bg); }

.foot { padding-top: 12px; padding-bottom: 40px; font-size: 13px; color: var(--ink-2); max-width: 1320px; }
.foot p { margin: 6px 0; }

/* ---------- Comparison maps ---------- */
.seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn { white-space: nowrap; }
.seg-btn[hidden] { display: none; }
.cmp { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.cmp[hidden] { display: none; }
.cmp-pick { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
.cmp-pick select { padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); max-width: 100%; }
.cmp-note { flex: 1 1 260px; }
#map #arrows line { stroke-width: 1.7; stroke-linecap: round; pointer-events: none; }
#map.is-zoomed { cursor: grab; touch-action: none; }
.zoom { position: absolute; right: 6px; bottom: 6px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.zoom button[hidden] { display: none; }

/* ---------- Race card tools, tags ---------- */
.card-tools { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.btn-link { all: unset; cursor: pointer; color: var(--focus); font-size: 13px; font-weight: 600; padding: 4px 0; }
.btn-link:hover, .btn-link:focus-visible { text-decoration: underline; }
.btn { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--bg); }
.tag-hold { background: transparent; }
.tag-gain { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.tag-seat { background: transparent; text-transform: none; letter-spacing: 0; font-weight: 500; }
.cand-hint { font-size: 13px; }
.cand-hint[hidden] { display: none; }
.unc-line { margin: -6px 0 10px; }

/* ---------- County history chart ---------- */
.hist { margin-top: 6px; }
.hist-svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 4px 0 6px; overflow: visible; }
.hist-svg .axis { stroke: var(--line-2); stroke-width: 1; }
.hist-svg .lbl { font-size: 9px; fill: var(--ink-3); }
.hist-svg .cty-line { fill: none; stroke: var(--ink-3); stroke-width: 1.2; }
.hist-svg .state-line { fill: none; stroke: var(--line-2); stroke-width: 1.2; stroke-dasharray: 3 3; }
.hist-svg .turn { fill: var(--st-f); opacity: .55; }

/* ---------- Insights card ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: -4px 0 10px; }
.tab { border: 0; background: transparent; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.ins-body p { margin: 4px 0 10px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; padding: 4px 6px 4px 0; }
.mini-table td { padding: 6px 6px 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.mini-table td.num { text-align: right; white-space: nowrap; }
.mini-table tr[data-county], .mini-table tr[data-open] { cursor: pointer; }
.mini-table tr[data-county]:hover, .mini-table tr[data-open]:hover { background: var(--bg); }
.mini-table .lead { font-size: 10px; font-weight: 700; color: var(--st-f); text-transform: uppercase; letter-spacing: .05em; margin-left: 4px; }

/* ---------- Candidate dialog ---------- */
.cand-dlg { border: 1px solid var(--line-2); border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 900px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.cand-dlg::backdrop { background: rgba(10, 16, 24, .45); }
.dlg-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 17px; }
#candBody { padding: 6px 16px 16px; }
.cand-group { margin-top: 14px; }
.cand-group h4 { margin: 0; font-size: 16px; }
.cand-table { margin-top: 6px; }
.sheet-x { border: 0; background: transparent; color: var(--ink-2); font-size: 24px; line-height: 1; width: 40px; height: 40px; cursor: pointer; border-radius: 8px; }
.sheet-x:hover { background: var(--bg); }

/* ---------- Phone sheet ---------- */
.sheet { position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 20; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 14px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.28); max-height: 50vh; overflow: auto; }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.sheet-body { margin: 8px 0 12px; font-size: 14px; }
.sheet-body .row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.sheet-body .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sheet .btn { width: 100%; }

@media (max-width: 960px) {
  .map-head { flex-wrap: wrap; }
  .map-head .seg { width: 100%; }
  .seg-btn { flex: 1 0 auto; padding: 9px 12px; font-size: 14px; }
  .chip { padding: 8px 14px; }
  .search input, .select-wrap select, .county-pick select, .year-wrap select, .cmp-pick select { padding: 11px 12px; font-size: 16px; }
  .cmp-pick { flex: 1 1 100%; }
  .cmp-pick select { flex: 1; }
  .btn-link { padding: 8px 0; }
  .zoom button { width: 40px; height: 40px; }
  .tip { display: none !important; }
  .office-list { max-height: none; }
  .mini .r { padding: 3px 0; }
  .cand-dlg { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100%; margin: 0; border-radius: 0; border: 0; }
  .foot { padding-bottom: 120px; }
}

/* ---------- Precinct map ---------- */
.pct-open { margin: 10px 0 4px; }
.pct-dlg { width: min(900px, calc(100vw - 32px)); }
#pctBody { padding: 10px 16px 16px; }
.pct-wrap { margin-top: 10px; }
#pctMap { width: 100%; height: auto; max-height: 56vh; display: block; }
#pctMap path { fill: var(--na); stroke: var(--stroke); stroke-width: .6; cursor: pointer; }
#pctMap path:hover, #pctMap path.is-on { stroke: var(--ink); stroke-width: 1.6; }
.pct-info { min-height: 64px; margin-top: 6px; font-size: 13px; }
.pct-info .row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.pct-info .nm { display: flex; align-items: center; gap: 6px; }
.pct-warn { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 10px; border-radius: 8px; margin: 10px 0 0; }
#pctMap .hatch-bg { fill: var(--na); }
#pctMap .hatch-ln { stroke: var(--line-2); stroke-width: 2.5; }
.sw-hatch { background: repeating-linear-gradient(45deg, var(--na) 0 3px, var(--line-2) 3px 5px); }
.cmp-pick { max-width: 100%; }
.cmp-pick select { min-width: 0; text-overflow: ellipsis; }
#pctBody .cmp-pick { display: flex; }
#pctBody .cmp-pick select { flex: 1; }

/* ---------- Registration & scores (county panel) ---------- */
.scores { margin-top: 6px; }
.reg-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 8px; background: var(--line); }
.reg-bar span { display: block; height: 100%; }
.reg-rows .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 2px 0; }
.reg-rows .nm { display: flex; align-items: center; gap: 6px; }
.score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 6px; }
.score-grid div { background: var(--bg); border-radius: 8px; padding: 7px 8px; text-align: center; }
.score-grid b { display: block; font-size: 15px; }
.score-grid span { font-size: 11px; color: var(--ink-3); }
.score-tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line-2); margin-bottom: 6px; }
@media (max-width: 600px) { .score-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Districts (map layer, panel, card) ---------- */
#distG path { fill: none; stroke: var(--ink); stroke-opacity: .55; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
#distG.is-fill path { stroke: var(--surface); stroke-opacity: 1; stroke-width: .9; pointer-events: auto; cursor: pointer; }
#distG.is-fill path:hover, #distG.is-fill path:focus-visible { stroke: var(--ink); stroke-width: 2.2; outline: none; }
#distG path.dist-halo { stroke: var(--surface); stroke-opacity: .9; stroke-width: 5.5; pointer-events: none; }
#distG path.dist-hi { stroke: var(--ink); stroke-opacity: 1; stroke-width: 2.4; pointer-events: none; }
#distG text { font: 700 12px system-ui, sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.dist-bar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 13px; color: var(--ink-2); padding: 2px 2px 4px; }
.dist-bar select { font: inherit; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
.dist-h { margin: 0 0 10px !important; font-size: 16px !important; }
.dist-race .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
.dist-race .nm { display: flex; align-items: center; gap: 6px; }
#distBody .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; border-top: 1px solid var(--line); }
#distBody .btn, .money + .btn { margin: 6px 0 4px; }
.money { margin-top: 6px; }
.money .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.money td:not(:first-child), .money th:not(:first-child) { text-align: right; white-space: nowrap; }

/* ---------- People (demographics) ---------- */
.people-table td:not(:first-child), .people-table th:not(:first-child) { text-align: right; white-space: nowrap; }
.people-rel { flex-basis: 100%; color: var(--ink); font-weight: 600; }
/* Phones: let the map-mode buttons wrap instead of hiding modes off-screen. */
@media (max-width: 600px) {
  .map-head .seg { flex-wrap: wrap; overflow: visible; }
  .map-head .seg .seg-btn { flex: 1 0 auto; }
}

/* =====================================================================
   Update 14: Emerge Kentucky colors (deep blue + golden yellow) for the page itself;
   party colors on the map are unchanged. Compact header, two-row race picker, map views
   grouped into three, folding banner, accessibility fixes, comparison plot, donor map.
   ===================================================================== */
:root {
  --brand: #03425d; --brand-2: #0a5a7c; --gold: #f6bb71; --gold-ink: #3d2700;
  --accent: var(--brand); --focus: #0a5a7c; --ink-3: #5c6878;
  --warn-bg: #fdf1dc; --warn-ink: #4a3200;
}
@media (prefers-color-scheme: dark) {
  :root { --brand: #03425d; --brand-2: #8fd0e6; --accent: #022c3f; --focus: #f6bb71; --ink-3: #9aa6b6; --warn-bg: #3a2f12; --warn-ink: #f6dca0; }
}
a { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 30; background: var(--gold); color: var(--gold-ink); padding: 8px 14px; border-radius: 6px; font-weight: 700; text-decoration: none; }
.skip:focus { left: 12px; }

/* Header: one compact band; the status banner folds to a line. */
.masthead-inner { padding-top: 10px; padding-bottom: 10px; gap: 8px 28px; }
.brand h1 { font-size: 20px; }
.sub { font-size: 13px; margin-top: 1px; }
.badge { background: var(--gold); color: var(--gold-ink); }
.stat-num { font-size: 18px; }
.stat-label { font-size: 11.5px; opacity: .85; }
.masthead .banner { position: relative; font-size: 13.5px; padding: 8px 16px; }
.banner a { color: var(--brand); font-weight: 600; }
.banner.is-folded { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 84px; }
.banner-more { position: absolute; right: 12px; top: 6px; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 6px; padding: 1px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer; }

/* Race picker: race list (and year) on one row; type chips, search and the contested switch on the next. */
.layout { padding-top: 14px; }
.picker { gap: 8px; margin-bottom: 12px; }
.picker-top { display: flex; gap: 10px; align-items: center; }
.picker-top .year-wrap { flex: 0 1 300px; }
.picker-top .year-wrap select { max-width: none; width: 100%; padding: 9px 12px; }
.picker-top .select-wrap { flex: 1 1 320px; min-width: 0; }
.picker-toggle { display: none; }
.picker-row { gap: 8px 12px; }
.picker-row .chips { flex: 1 1 auto; }
.picker-row .search { flex: 0 1 260px; }
.chip[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Map views: three groups, then the chosen group's views. */
.map-head { flex-wrap: wrap; }
.modes { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-left: auto; }
.seg-main .grp-btn { border: 0; background: transparent; padding: 6px 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg-main .grp-btn.is-on { background: var(--brand); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.seg-sub { border: 0; gap: 4px; flex-wrap: wrap; justify-content: flex-end; overflow: visible; }
.seg-sub .seg-btn { border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 11px; }
.seg-sub .seg-btn.is-on { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 600; }
.seg-sub .seg-btn.is-other, .seg-sub.is-single { display: none; }
.cands .lead.is-won { color: var(--brand-2); }

/* County-by-county comparison (Vs. past race / Two races). */
.cmp-plot { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.cmp-plot[hidden] { display: none; }
.cmp-plot > summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 4px 0; }
.cp-read { margin: 4px 0 6px; color: var(--ink-2); }
.cp-svg { width: 100%; max-width: 480px; display: block; }
.cp-grid line { stroke: var(--line); stroke-width: 1; }
.cp-grid line.zero { stroke: var(--line-2); }
.cp-grid text, .cp-axis { font-size: 10px; fill: var(--ink-3); }
.cp-axis { font-size: 11px; fill: var(--ink-2); font-weight: 600; }
.cp-even { stroke: var(--ink-3); stroke-width: 1.2; }
.cp-shift { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 5 4; }
.cp-dots circle { fill-opacity: .72; stroke: var(--surface); stroke-width: .8; cursor: pointer; }
.cp-dots circle:hover { fill-opacity: 1; stroke: var(--ink); }
.cmp-lists { margin-top: 4px; }

/* Campaign money: where it comes from. */
.money-more { margin: 6px 0 2px; }
.money-more > summary { cursor: pointer; font-weight: 600; color: var(--brand-2); font-size: 13.5px; padding: 4px 0; }
.mini-tabs { margin: 4px 0 6px; }
.donor-map { width: 100%; display: block; margin: 4px 0; }
.donor-map path { stroke: var(--surface); stroke-width: .7; }
.donor-map .dm0 { fill: var(--na); }
.donor-map .dm1 { fill: #cfe0e8; }
.donor-map .dm2 { fill: #8fb4c6; }
.donor-map .dm3 { fill: #4f86a1; }
.donor-map .dm4 { fill: #03425d; }

/* Phones: map near the top. Race list + Filters button; full-width map. */
@media (max-width: 600px) {
  .masthead-inner { padding-top: 8px; padding-bottom: 8px; }
  .brand h1 { font-size: 18px; }
  .pulse { gap: 8px; }
  .stat-num { font-size: 15px; }
  .stat-label { font-size: 10.5px; }
  .picker-top { flex-wrap: wrap; }
  .picker-top .year-wrap { flex: 1 1 100%; order: 3; }
  .picker-top .select-wrap { flex: 1 1 0; }
  .picker-toggle { display: inline-flex; align-items: center; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-weight: 600; }
  .picker-toggle[aria-expanded="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
  .picker:not(.is-open) .picker-top .year-wrap, .picker:not(.is-open) .picker-row { display: none; }
  .picker-row .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; }
  .picker-row .search { flex: 1 1 0; }
  .map-card { margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; padding: 10px 6px 8px; }
  .map-head { padding: 0 6px; }
  .modes { width: 100%; align-items: stretch; margin-left: 0; }
  .seg-main { display: flex; width: 100%; }
  .seg-main .grp-btn { flex: 1 1 0; padding: 8px 6px; }
  .seg-sub { justify-content: flex-start; }
  .seg-sub .seg-btn { flex: 0 0 auto; }
  .legend, .dist-bar, .cmp, .cmp-plot { padding-left: 6px; padding-right: 6px; }
}
.chip .n { opacity: 1; color: var(--ink-3); }
.chip[aria-selected="true"] .n { color: #fff; opacity: .85; }
@media (max-width: 600px) {
  .picker-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .picker-top .select-wrap, .picker-top .year-wrap { min-width: 0; }
  .picker-top .year-wrap { grid-column: 1 / -1; }
  .picker-top select, .picker-row .search input { width: 100%; min-width: 0; max-width: 100%; }
  .picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .picker-row .chips { grid-column: 1 / -1; }
  .picker-row .search { min-width: 0; }
}

/* =====================================================================
   Update 16: three views (Results / Explore / Strategy) in a bar that stays at the top,
   each with its own map colorings and side panel; the county panel folds into tabs.
   ===================================================================== */
.views { position: sticky; top: 0; z-index: 20; background: var(--accent); color: var(--accent-ink, #fff); border-top: 1px solid rgba(255,255,255,.14); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.views-inner { display: flex; gap: 2px; }
.views .grp-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 8px 16px 9px; opacity: .78; box-shadow: inset 0 -3px 0 transparent; text-align: left; }
.views .grp-btn b { font-size: 15px; font-weight: 700; }
.views .grp-btn span { font-size: 12px; font-weight: 500; }
.views .grp-btn:hover { opacity: 1; }
.views .grp-btn.is-on { opacity: 1; box-shadow: inset 0 -4px 0 var(--gold); }
.views .grp-btn:focus-visible { outline-color: var(--gold); outline-offset: -3px; }
.modes { gap: 0; }
/* Each view's side panel: Results = race + county; Explore adds Insights; Strategy leads with Districts & money. */
body[data-view="results"] #insightsCard, body[data-view="results"] #distCard,
body[data-view="explore"] #distCard, body[data-view="strategy"] #insightsCard { display: none; }
body[data-view="strategy"] #distCard { order: -1; }
/* County panel: summary, then Ballot / Voters / People / History. */
.cty-head .pct-open { margin: 8px 0 2px; }
.cty-tabs { margin: 14px 0 0; }
.cty-tab .n { color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.cty-pane[hidden], .ballot-focus[hidden], .ballot-all[hidden] { display: none; }
.cty-pane > .scores > .cat-h:first-child, .cty-pane > .people > .cat-h:first-child, .cty-pane > .hist > .cat-h:first-child { margin-top: 12px; }
.ballot-focus .cat-h:first-child, .ballot-all > .cat-h:first-child { margin-top: 12px; }
.ballot-more { margin: 10px 0 4px; width: 100%; }
.card, .map-card { scroll-margin-top: 64px; } /* clear of the view bar */
@media (max-width: 600px) {
  .views-inner { padding: 0; }
  .views .grp-btn { flex: 1 1 0; align-items: center; text-align: center; padding: 10px 4px 11px; }
  .views .grp-btn span { display: none; }
}

/* =====================================================================
   Update 17: Strategy becomes the target board; the district map and the seat and money lists
   move to Explore; one race finder replaces the chips, list and search box; plain names + glossary.
   ===================================================================== */
body[data-view="strategy"] .picker, body[data-view="strategy"] #raceCard, body[data-view="strategy"] #countyCard,
body:not([data-view="strategy"]) #targetCard { display: none; }
.mode-note { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.mode-note:empty { display: none; }
.q { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; margin-left: 2px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--ink-2); font: 700 12px/1 inherit; letter-spacing: 0; text-transform: none; vertical-align: middle; cursor: pointer; }
.q:hover { border-color: var(--brand-2); color: var(--brand-2); }
.foot-tools { display: flex; gap: 8px 18px; flex-wrap: wrap; margin: 8px 0; }
/* Race finder */
.finder { position: relative; flex: 1 1 360px; min-width: 0; }
.finder input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); font: inherit; font-weight: 600;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c6878' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 12px center; }
.finder input:focus { font-weight: 500; }
.finder-panel { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); display: flex; flex-direction: column; max-height: min(70vh, 560px); background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.finder-panel[hidden] { display: none; }
.finder-filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.finder-filters button { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.finder-filters button .n { color: var(--ink-3); margin-left: 2px; }
.finder-filters button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.finder-filters button[aria-pressed="true"] .n { color: #fff; opacity: .85; }
.finder-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1 1 auto; }
.finder-h { padding: 10px 12px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.finder-list [role="option"] { display: block; padding: 7px 12px; cursor: pointer; box-shadow: inset 3px 0 0 transparent; }
.finder-list [role="option"]:hover, .finder-list [role="option"].is-active { background: var(--bg); box-shadow: inset 3px 0 0 var(--gold); }
.finder-list .ft { display: block; font-size: 14px; font-weight: 600; }
.finder-list [aria-selected="true"] .ft::after { content: " ✓"; color: var(--brand-2); }
.finder-list .fs { display: block; font-size: 12.5px; color: var(--ink-3); }
.finder-none { padding: 12px; font-size: 14px; color: var(--ink-2); }
.finder-foot { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.finder-foot #finderHist { margin-left: auto; }
/* Glossary */
.gloss { margin: 0; padding: 4px 16px 16px; }
.gloss > div { padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.gloss > div.is-on { background: color-mix(in srgb, var(--gold) 22%, transparent); }
.gloss dt { font-weight: 700; }
.gloss dd { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
/* Target board */
.side-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.side-pick span { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-right: 2px; }
.side-pick button { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.side-pick button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.seat-bar { position: relative; display: flex; height: 14px; margin: 20px 0 4px; border-radius: 4px; background: var(--na); }
.seat-bar span { display: block; height: 100%; }
.seat-bar span:first-child { border-radius: 4px 0 0 4px; }
.seat-bar span:last-of-type { border-radius: 0 4px 4px 0; }
.seat-bar i { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); }
.seat-bar i::after { content: attr(data-l); position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: 11px; font-style: normal; font-weight: 700; color: var(--ink-2); }
.seat-count { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.tier-h { display: flex; align-items: center; gap: 6px; }
.tier-h .sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.tier-h .n { color: var(--ink-3); font-weight: 600; letter-spacing: 0; }
#targetCard .tier-h + p { margin: 0 0 4px; }
@media (max-width: 600px) {
  .picker-top { grid-template-columns: minmax(0, 1fr); }
  .picker-top .year-wrap { grid-column: auto; order: 2; }
  .finder { order: 1; }
  .finder-panel { max-height: 62vh; }
  .mode-note { padding: 0 6px; }
}
@media (max-width: 600px) { .picker .picker-top .year-wrap:not([hidden]) { display: flex; } }
.ins-more { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.ins-more > summary { cursor: pointer; padding: 6px 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.ins-more > summary .n { letter-spacing: 0; font-weight: 600; margin-left: 2px; }

/* Update 19: candidate profiles. */
.prof-link { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }
.prof-link:hover { color: var(--brand-2); text-decoration-color: var(--brand-2); }
.prof-dlg #profBody { padding: 4px 18px 18px; }
.prof-meta { margin: 6px 0 4px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.prof-list { margin: 4px 0 8px; padding-left: 18px; }
.prof-list li { margin: 6px 0; line-height: 1.45; }
.prof-list .cite, .prof-src a { color: var(--brand-2); }
.prof-list .cite { font-size: 12px; text-decoration: none; margin-left: 2px; }
.prof-src { margin: 4px 0 10px; padding-left: 22px; font-size: 13.5px; }
.prof-src li { margin: 3px 0; }

/* =====================================================================
   Update 20: no masthead. The site name sits at the left of the view bar; the status banner
   only appears for problems (a page that failed to load).
   ===================================================================== */
.views { border-top: 0; }
.views-inner { display: flex; align-items: stretch; gap: 0 18px; }
.views-brand { margin: 0; align-self: center; padding: 10px 18px 10px 0; border-right: 1px solid rgba(255,255,255,.2);
  font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; }
.views-nav, .views-tabs { display: flex; }
.views-tabs { gap: 2px; }
.banner { text-align: left; }
.banner:not([hidden]) { padding: 10px max(16px, calc((100% - 1320px) / 2 + 16px)); }
@media (max-width: 760px) {
  .views-brand { font-size: 15px; padding-right: 14px; }
  .views-inner { gap: 0 10px; }
}
@media (max-width: 600px) {
  .views-inner { padding: 0 0 0 12px; gap: 0 4px; }
  .views-brand { width: 74px; padding: 6px 8px 6px 0; font-size: 12.5px; line-height: 1.12; white-space: normal; }
  .views-nav, .views-tabs { flex: 1 1 auto; min-width: 0; }
  .views .grp-btn { padding: 12px 2px 13px; }
  .views .grp-btn b { font-size: 14px; }
}
