  :root {
    color-scheme: dark;     /* native controls and scrollbars draw dark */
    --bg: #0e1116;
    --panel: #151a22;
    --line: #2a3240;
    --text: #e8ecf2;
    --muted: #9aa5b5;
    --dem: #584cde;         /* party fills: the map's own (colors.js DEM_C[3], REP_C[3]) */
    --rep: #d72f30;
    --dem-ink: #8fa8ff;     /* party text on a dark background */
    --rep-ink: #ff8b8b;
    --oth: #5d6c82;
    --accent: #f2c14e;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
  .app { display: grid; grid-template-columns: clamp(280px, 28vw, 390px) minmax(0, 1fr); height: 100vh; }
  /* the map page: the controls in a bar across the top, the map below them */
  .app main { display: flex; flex-direction: column; }
  .map-area { position: relative; flex: 1; min-height: 0; overflow: hidden; }
  aside { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 22px 22px 32px; }
  main { position: relative; min-width: 0; overflow: hidden; }
  #stage { position: absolute; inset: 0; }
  #stage canvas { display: block; touch-action: none; }
  h1 { font-size: 22px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
  .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
  h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }
  p { margin: 0 0 10px; }
  b.hl { color: var(--accent); font-weight: 650; }
  .bars { display: grid; gap: 12px; }
  .bar-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  .bar { display: flex; height: 22px; border-radius: 4px; overflow: hidden; font-size: 12px; font-weight: 600; }
  .bar span { display: flex; align-items: center; padding: 0 7px; white-space: nowrap; color: #fff; overflow: hidden; }
  .bar .d { background: var(--dem); }
  .bar .r { background: var(--rep); justify-content: flex-end; }
  .bar .o { background: var(--oth); padding: 0; }
  .bar-note { font-size: 12px; color: var(--muted); margin-top: 3px; }
  .legend { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; font-size: 11px; color: var(--muted); text-align: center; }
  .legend i { display: block; height: 12px; border-radius: 2px; margin-bottom: 3px; }
  .legend-title { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
  /* with vote-lead color on: one run from pale to the race's biggest lead, with round numbers marked */
  .legend .lead-ramp { grid-column: 1 / -1; height: 12px; border-radius: 2px; }
  .legend .lead-ticks { grid-column: 1 / -1; position: relative; height: 15px; }
  .legend .lead-ticks span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
  .legend .lead-ticks span:first-child { transform: none; }
  .legend .lead-ticks span:last-child { transform: translateX(-100%); }
  /* with Vote mix on: the split across (all Republican to all Democratic), votes cast down, each cell in the color a
     county like that gets */
  .legend .mix-grid { grid-column: 1 / -1; display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 2px; align-items: center; }
  .legend .mix-grid i { height: 12px; margin: 0; }
  .legend .mix-votes { text-align: right; padding-right: 4px; white-space: nowrap; }
  .legend .mix-note { grid-column: 1 / -1; text-align: left; margin-top: 6px; }
  /* the control bar along the bottom of every map (viewbar.js): Look, By and Color, each with a small label */
  .controls { flex-wrap: wrap; justify-content: center; row-gap: 6px; border-radius: 22px; width: max-content; }
  .vb-group { display: flex; align-items: center; gap: 6px; }
  .vb-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
  @media (max-width: 820px) { .vb-label:not(.keep) { display: none; } }
  .controls select { font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; cursor: pointer; }
  .controls select:disabled { opacity: .5; cursor: default; }
  .controls { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center;
    background: rgba(21,26,34,.88); border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 8px; backdrop-filter: blur(6px);
    max-width: calc(100% - 32px); }
  button { font: inherit; font-weight: 600; color: #111; background: var(--accent); border: 0; border-radius: 999px; padding: 9px 18px; cursor: pointer; white-space: nowrap; }
  button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 8px 14px; }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  input[type=range] { width: 180px; accent-color: var(--accent); }
  /* choices joined together: bar view or dot view (a link to its page); by county, precinct or district */
  .seg { display: inline-flex; }
  .seg[hidden] { display: none; }
  .seg > * { font-size: 13px; font-weight: 600; line-height: 1.3; padding: 5px 11px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-decoration: none; white-space: nowrap; border-radius: 0; }
  .seg > :focus-visible { position: relative; z-index: 1; }
  .seg > :first-child { border-radius: 999px 0 0 999px; }
  .seg > :last-child { border-radius: 0 999px 999px 0; }
  .seg > :not(:first-child) { margin-left: -1px; }
  .seg > :only-child { border-radius: 999px; }
  .seg > :disabled { opacity: .5; cursor: default; }
  .seg > [aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); }
  .seg > a:hover, .seg > a:focus-visible { color: var(--accent); }
  .place-note:not(:first-child)::before { content: " · "; }
  /* first in a state page's top bar (sitenav.js): the site's name, which goes home, and a menu of the other states */
  .site-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .site-home { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
  .site-home:hover, .site-home:focus-visible { text-decoration: underline; }
  .races { flex: none; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 16px 6px; z-index: 4; }
  /* each group wraps as a whole, and the bar always takes as little height as the width allows */
  .bar-groups { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
  .group { display: flex; align-items: center; gap: 6px; min-width: 0; }
  #picker { flex: 1 1 220px; max-width: 320px; }
  #raceSelect { flex: 1; width: 0; min-width: 0; }
  #yearSelect { flex: none; }
  #goRow { flex: 1 1 340px; max-width: 520px; }
  #goRow select { flex: 1; width: 0; min-width: 0; }
  .pick-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
  /* a line kept open under the groups, so the map doesn't jump when something appears in it */
  .info-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 14px; min-height: 18px; margin-top: 5px; font-size: 12.5px; line-height: 18px; color: var(--muted); }
  .place-info b { color: var(--text); }
  .hint { margin-left: auto; font-size: 12px; white-space: nowrap; }
  @media (max-width: 1200px) { .place-info:not(:empty) + .hint { display: none; } }
  .races select { font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
    border-radius: 999px; padding: 5px 10px; cursor: pointer; }
  .races select:disabled { opacity: .5; cursor: default; }
  .races select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .races select option, .races select optgroup { background: var(--panel); color: var(--text); }
  #tip { position: absolute; pointer-events: none; background: rgba(14,17,22,.95); border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; font-size: 13px; min-width: 230px; display: none; z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
  #tip .n { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
  #tip .row { display: flex; justify-content: space-between; gap: 14px; }
  #tip .m { color: var(--muted); }
  /* on a touch screen, a tapped county's card stays in the map's top corner (app.js); tapping it closes it */
  #tip.pinned { left: 8px !important; top: 8px !important; pointer-events: auto; cursor: pointer; padding-right: 30px; max-width: calc(100% - 16px); }
  #tip.pinned::after { content: "×"; position: absolute; top: 4px; right: 10px; font-size: 18px; line-height: 1; color: var(--muted); }
  .label { position: absolute; pointer-events: none; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000;
    transform: translate(-50%, -120%); white-space: nowrap; opacity: 0; }
  .label small { display: block; font-weight: 500; color: #d7dde6; text-align: center; }
  .sources { font-size: 12.5px; color: var(--muted); }
  .sources ol { padding-left: 18px; margin: 0 0 10px; }
  .sources li { margin-bottom: 6px; }
  .sources a { color: #b8c3d4; }
  #loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; padding: 16px; }
  #loading::before, .busy-spin {
    content: ""; display: block; width: 26px; height: 26px; border-radius: 50%; box-sizing: border-box;
    border: 3px solid var(--line); border-top-color: var(--text); animation: busy-spin .9s linear infinite; will-change: transform;
  }
  #loading.failed::before { display: none; }
  /* a change under way, over the map (busy.js) */
  .busy {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; pointer-events: none;
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: calc(100% - 32px); box-sizing: border-box;
    background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: 13px;
    white-space: nowrap; box-shadow: 0 4px 18px rgba(0, 0, 0, .45); animation: busy-in .15s ease-out;
  }
  .busy[hidden] { display: none; }
  .busy-spin { width: 16px; height: 16px; border-width: 2px; flex: none; }
  @keyframes busy-spin { to { transform: rotate(360deg); } }
  @keyframes busy-in { from { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) {
    /* still shows something is happening, more gently */
    #loading::before, .busy-spin { animation: busy-pulse 1.6s ease-in-out infinite; border-top-color: var(--line); }
    @keyframes busy-pulse { 50% { opacity: .35; } }
  }
  @media (max-width: 820px) {
    .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
    main { order: -1; }
    .map-area { flex: none; height: 58vh; min-height: 300px; }
    aside { border-right: 0; border-top: 1px solid var(--line); padding: 18px 16px 28px; }
    input[type=range] { width: 44px; }
    .controls { gap: 6px; padding: 6px 8px 6px 6px; bottom: 12px; }
    .controls button { font-size: 13px; padding: 7px 10px; }
    .controls input[type=range] { width: 36px; }
    .hint { display: none; }
    .races { padding: 8px 12px 6px; }
    #picker, #goRow { flex: none; width: 100%; max-width: none; }
    .site-nav { width: 100%; justify-content: space-between; }
    .seg > * { padding: 5px 9px; font-size: 12px; }
    .controls .seg > * { padding: 7px 8px; }
    #goRow select { padding: 5px 8px; }
    #goRow .pick-label { display: none; }
    .info-row { font-size: 12px; }
    button { padding: 8px 12px; }
  }
/* "How we got there" link on the 2026 page, and the way back on the history page */
.cta { display: block; margin: 4px 0 6px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 10px; color: var(--text);
  text-decoration: none; background: rgba(242,193,78,.08); }
.cta:hover, .cta:focus-visible { background: rgba(242,193,78,.16); }
.cta b { color: var(--accent); display: block; font-size: 15px; }
.cta span { font-size: 12.5px; color: var(--muted); }
.back { display: inline-block; font-size: 13px; color: var(--accent); margin: 0 0 12px; text-decoration: none; }
.back:hover { text-decoration: underline; }
/* the guided flights: set apart from the results, on every page that offers them */
.flights { margin: 14px 0 4px; }
.flights h2 { margin: 0 0 6px; color: var(--accent); }
.flights-note { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }
.flight { display: block; margin-bottom: 8px; padding: 10px 13px; border: 1px solid var(--accent); border-radius: 10px; background: rgba(242,193,78,.08); color: var(--text); text-decoration: none; }
.flight:hover, .flight:focus-visible { background: rgba(242,193,78,.18); }
.flight b { display: block; font-size: 15px; color: var(--accent); }
.flight span { display: block; font-size: 12.5px; color: var(--muted); }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
/* the race tables */
.races-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.races-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 0 3px 4px 0; white-space: nowrap; }
.races-table td { padding: 4px 3px 4px 0; border-top: 1px solid var(--line); white-space: nowrap; }
.races-table td:first-child { white-space: normal; min-width: 92px; }
.races-table .n { text-align: right; }
.races-table a { color: var(--text); }
.races-table tr.cur td, .races-table tr.cur a { color: var(--accent); font-weight: 650; }
.table-wrap { overflow-x: auto; }

/* City and town names on the maps (cities.js): a small dot at the place and its name beside it (cities.js places each
   label with a transform, so these have no margins) */
.city-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; transition: opacity .3s; }
.city { position: absolute; left: 0; top: 0; padding-left: 10px; font-size: 11px; line-height: 14px; box-sizing: border-box;
  color: #dfe5ee; text-shadow: 0 0 3px #000, 0 1px 2px #000, 0 0 1px #000; white-space: nowrap; opacity: 0; transition: opacity .25s; }
.city::before { content: ''; position: absolute; left: 0; top: 4px; width: 6px; height: 6px; border-radius: 50%;
  background: #f4f6f9; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.city.on { opacity: .92; }
.city.city-mid { font-size: 12px; font-weight: 600; line-height: 16px; }
.city.city-mid::before { top: 5px; }
.city.city-big { font-size: 13.5px; font-weight: 700; line-height: 18px; }
.city.city-big::before { top: 6px; }
/* name to the left of the dot, above it, or below it */
.city.l { padding-left: 0; padding-right: 10px; }
.city.l::before { left: auto; right: 0; }
.city.a { padding: 0 0 8px; }
.city.a::before { left: calc(50% - 3px); top: auto; bottom: 0; }
.city.b { padding: 8px 0 0; }
.city.b::before { left: calc(50% - 3px); top: 0; }
/* the details panel's Hide button, at its top right, and the Details button that brings it back, first in the top strip while it's
   hidden (panel.js); on phones the panel is below the map and stays */
.panel-close { float: right; margin: -4px -6px 0 8px; font-size: 12.5px; font-weight: 600; padding: 4px 11px; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.panel-close:hover, .panel-close:focus-visible { color: var(--text); border-color: var(--muted); }
body:not(.panel-hidden) .panel-toggle { display: none; }
.panel-toggle { font-size: 12.5px; font-weight: 600; padding: 4px 11px; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.panel-toggle:hover, .panel-toggle:focus-visible { color: var(--text); border-color: var(--muted); }
@media (min-width: 821px) {
  .panel-hidden .app { grid-template-columns: minmax(0, 1fr); }
  .panel-hidden .app > aside { display: none; }
}
@media (max-width: 820px) { .panel-toggle, .panel-close { display: none; } }
/* the dot tour's card in the dot view is a button that plays it */
button.flight { width: 100%; text-align: left; font: inherit; white-space: normal; }
button.flight + .ghost { margin: -2px 0 8px; font-size: 13px; padding: 5px 12px; }
/* Compare ⇆, last in the top strip of both views: this map beside the other view (compare.html) */
.compare-link { font-size: 12.5px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 4px 11px; text-decoration: none; white-space: nowrap; }
.compare-link:hover, .compare-link:focus-visible { background: var(--accent); color: #111; }
/* a view inside compare.html (panel.js marks it .framed): no panel, no ways out (the compare page has them), and the map fills the frame */
.framed aside, .framed .panel-toggle, .framed .compare-link, .framed .site-home { display: none !important; }
.framed .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; }
.framed .map-area { flex: 1; height: auto; min-height: 0; }
.framed .voters.exploring { height: 100vh; min-height: 0; }
.bar-groups > .compare-link, .nav-row > .compare-link { margin-left: auto; }
@media (max-height: 520px) {
  .framed #goRow, .framed .info-row, .framed #topnav .nav-group[aria-label="Go to a place"], .framed .nav-info > :not(#legend) { display: none; }
}
