:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5a5f6b;
  --line: #d9d6cf;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --left: #1e40af;
  --left-bg: #e8eefc;
  --flag: #b91c1c;
  --flag-bg: #fdecec;
  --head: #14213d;
  --head-ink: #f4f1ea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1a1d24;
    --text: #e8e6e1;
    --muted: #a3a7b1;
    --line: #2e323c;
    --accent: #6d8ff5;
    --accent-ink: #0b0d12;
    --left: #9bb5ff;
    --left-bg: #1b2440;
    --flag: #ff8a8a;
    --flag-bg: #3a1a1c;
    --head: #0b1022;
    --head-ink: #e8e6e1;
  }
}
:root[data-theme="dark"] {
  --bg: #111318; --surface: #1a1d24; --text: #e8e6e1; --muted: #a3a7b1; --line: #2e323c;
  --accent: #6d8ff5; --accent-ink: #0b0d12; --left: #9bb5ff; --left-bg: #1b2440;
  --flag: #ff8a8a; --flag-bg: #3a1a1c; --head: #0b1022; --head-ink: #e8e6e1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

header.site { background: var(--head); color: var(--head-ink); padding: 28px 0 22px; }
header.site h1 { margin: 0; font-size: 2rem; letter-spacing: -0.01em; }
header.site .lede { margin: 10px 0 0; font-size: 1.35rem; font-weight: 700; line-height: 1.3; max-width: 34em; }
header.site .tag { margin: 8px 0 0; opacity: 0.85; }

h2 { font-size: 1.3rem; margin: 28px 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.fine { font-size: 0.85rem; color: var(--muted); }
.msg { min-height: 1.2em; margin: 6px 0 0; font-size: 0.95rem; }
.msg.err { color: var(--flag); }

.mapnote { background: var(--left-bg); border-left: 4px solid var(--left); border-radius: 8px; padding: 2px 16px 6px; margin-top: 20px; }
.mapnote h2 { font-size: 1.05rem; margin: 12px 0 4px; }
.mapnote p { margin: 0 0 8px; font-size: 0.95rem; }
.finder { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px 18px 16px; margin-top: 20px; }
.privacy { margin: -4px 0 12px; font-weight: 600; color: var(--left); }
label { display: block; font-weight: 600; font-size: 0.95rem; }
.row { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
select { max-width: 100%; width: 100%; text-overflow: ellipsis; }
input[type=text], select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); min-width: 0;
}
.row input { flex: 1 1 260px; }
button {
  font: inherit; font-weight: 600; padding: 10px 16px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 10px 0 12px; }
.grid select { width: 100%; margin-top: 4px; font-weight: 400; }

.districts { color: var(--muted); font-size: 0.95rem; margin: 4px 0 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }

table.sheet { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sheet th, .sheet td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.sheet th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.sheet td.box { width: 28px; font-size: 1.1rem; color: var(--muted); }
.sheet td.pick { font-weight: 700; color: var(--left); white-space: nowrap; }
.sheet td.why { font-size: 0.9rem; }
.why-m { display: none; font-size: 0.85rem; color: var(--text); margin-top: 3px; }
.sheet .flagged { color: var(--flag); font-weight: 600; }
.sheet .endorsed { color: var(--left); }
.sheet tr.group td { background: var(--bg); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.race { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px 10px; margin: 12px 0; break-inside: avoid; }
.race .meta { font-size: 0.85rem; color: var(--muted); margin: -2px 0 6px; }
.cand { padding: 8px 0; border-top: 1px solid var(--line); }
.cand:first-of-type { border-top: 0; }
.cand .name { font-weight: 700; }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }
.badge.left { background: var(--left-bg); color: var(--left); }
.badge.flag { background: var(--flag-bg); color: var(--flag); }
.badge.end { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.flag-inline { color: var(--flag); font-weight: 700; }
.yn { font-size: 0.95rem; margin: 6px 0; }
.pickline { font-weight: 700; color: var(--left); }
.about { margin-top: 36px; }
.early { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px 18px 8px; }
.early h2 { margin-top: 14px; }
.early ul { padding-left: 20px; margin: 8px 0; }
.early li { margin: 6px 0; }
footer.site { border-top: 1px solid var(--line); margin-top: 36px; padding: 16px 0 28px; }

@media (max-width: 560px) {
  header.site h1 { font-size: 1.6rem; }
  .sheet td.pick { white-space: normal; }
  .sheet th.why, .sheet td.why { display: none; }
  .why-m { display: block; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #bbb; --left: #0b3a9e; --flag: #a00; --left-bg: #fff; --flag-bg: #fff; }
  body { font-size: 10pt; }
  header.site { background: none; color: #000; padding: 0 0 4px; }
  header.site .tag { display: none; }
  header.site .lede { display: none; }
  .mapnote, .finder, .actions, .about, footer.site, .noprint { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .race { border: 0; padding: 0; margin: 6px 0; }
  .sheet th.why, .sheet td.why { display: table-cell !important; }
  .why-m { display: none !important; }
  .sheet { font-size: 9.2pt; }
  .sheet td, .sheet th { padding: 1px 6px; }
  .sheet td.why { font-size: 8.4pt; }
  .sheet { table-layout: fixed; line-height: 1.25; }
  .sheet th:nth-child(1) { width: 4%; }
  .sheet th:nth-child(2) { width: 38%; }
  .sheet th:nth-child(3) { width: 21%; }
  .sheet td { font-size: 8.8pt; }
  .districts { margin: 0 0 4px; }
  h2 { margin: 8px 0 4px; }
  #details { break-before: page; }
  a { color: inherit; text-decoration: none; }
  @page { size: letter; margin: 0.4in; }
  header.site h1 { font-size: 16pt; }
}
.plain { font-weight: 400; }
