:root {
  --paper: #faf7f1;
  --ink: #16130f;
  --muted: #6b6157;
  --rule: #d9d2c6;
  --safe-d: #123c74;
  --likely-d: #1c58a6;
  --lean-d: #6a97d6;
  --tossup: #9b84bd;
  --lean-r: #d98a8a;
  --likely-r: #ab272c;
  --safe-r: #78191d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, -apple-system, Segoe UI, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.masthead {
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
}

.masthead-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.edition {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}

.datestamp {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.board {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.lede h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 4px 0 8px;
  line-height: 1.05;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.caveat {
  max-width: 60ch;
  color: var(--muted);
  margin: 0 0 12px;
}

.board-read {
  font-size: 1.15rem;
  border-left: 4px solid var(--ink);
  padding-left: 14px;
  margin: 18px 0 0;
}

.chamber-read {
  color: var(--muted);
  margin: 10px 0 0;
  padding-left: 18px;
}

.toggles {
  display: flex;
  gap: 0;
  margin: 26px 0 18px;
  border: 1px solid var(--ink);
  width: fit-content;
}

.toggles button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
}

.toggles button:last-child {
  border-right: 0;
}

.toggles button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.toggles button:focus-visible,
.clear-filter:focus-visible,
.table-scroll:focus-visible {
  outline: 2px solid var(--likely-d);
  outline-offset: 2px;
}

.map-card,
.tally-card,
.trend-card,
.changelog-card,
.table-card {
  border-top: 1px solid var(--rule);
  padding: 20px 0;
}

.map {
  height: 460px;
  border: 1px solid var(--rule);
  background: #e9e4da;
}

.map-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 8px 0 0;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 12px 0 0;
  margin: 0;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  display: inline-block;
}

/* Race detail pages: the Money and Coverage figure lists. */
.tally {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 0;
  margin: 0;
}

.tally li {
  font-variant-numeric: tabular-nums;
}

.tally .tally-strong {
  font-size: 1.6rem;
  font-weight: 700;
  display: block;
}

/* Board exposure bar: one flex segment per rating band, D to R left to
   right, each grown in proportion to its seat count. */
.tally-caption {
  margin: 0 0 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tally-caption .tally-strong {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}

.tally-totals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.tally-total {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.tally-total-dem {
  justify-content: flex-start;
}

.tally-total-tossup {
  justify-content: center;
}

.tally-total-rep {
  justify-content: flex-end;
}

.tally-total-count {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tally-bar {
  position: relative;
  display: flex;
  height: 56px;
  border: 1px solid var(--rule);
  background: var(--paper);
}

/* Marker at the even split of the seats on the board. */
.tally-midline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 1px);
  width: 2px;
  background: rgba(22, 19, 15, 0.75);
}

.tally-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.tally-seg + .tally-seg {
  box-shadow: inset 1px 0 0 var(--paper);
}

.tally-seg-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tally-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  padding: 0;
  margin: 12px 0 0;
}

.tally-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.tally-legend-item.is-empty {
  color: var(--muted);
}

.tally-legend-item.is-empty .swatch {
  opacity: 0.35;
}

.tally-legend-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trend svg {
  width: 100%;
  height: auto;
  max-height: 200px;
}

.trend .trend-caption {
  color: var(--muted);
  font-size: 0.9rem;
}

.changelog {
  list-style: none;
  padding: 0;
  margin: 0;
}

.changelog li {
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}

.changelog .band {
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  color: #fff;
  font-size: 0.82rem;
  white-space: nowrap;
}

.clear-filter {
  appearance: none;
  border: 1px solid var(--ink);
  background: transparent;
  font: inherit;
  padding: 6px 12px;
  margin-bottom: 10px;
  cursor: pointer;
}

.site-footer {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.empty {
  color: var(--muted);
  padding: 24px 0;
}

.race-panel {
  border-top: 1px solid var(--rule);
  padding: 18px 0;
}

.race-band {
  display: inline-block;
  border-left: 4px solid;
  padding-left: 10px;
  font-weight: 600;
  margin: 6px 0 12px;
}

.candidates {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.candidate {
  border: 1px solid var(--rule);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.candidate-party {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
}

.candidate-money {
  font-size: 0.85rem;
  color: var(--muted);
}

.evidence {
  list-style: none;
  padding: 0;
  margin: 0;
}

.evidence li {
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}

.race-empty,
.muted {
  color: var(--muted);
}

#race-table a {
  color: inherit;
}

@media (max-width: 720px) {
  .map {
    height: 320px;
  }
  .toggles {
    width: 100%;
  }
  .toggles button {
    flex: 1;
    padding: 10px 8px;
  }
  /* A strip with fewer pixels per seat drops in-segment labels; the legend
     below always carries the numbers. */
  .tally-bar {
    height: 36px;
  }
  /* Three narrow columns wrap the group names; one line each reads better. */
  .tally-totals {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .tally-total-dem,
  .tally-total-tossup,
  .tally-total-rep {
    justify-content: flex-start;
  }
}
