:root {
  --ink: #172231;
  --ink-soft: #596574;
  --paper: #f3f5f7;
  --panel: #ffffff;
  --line: #d9dee5;
  --accent: #a43f69;
  --accent-dark: #7e3155;
  --shadow: 0 8px 24px rgba(18, 36, 60, 0.06);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --ink: #eaf0f7;
  --ink-soft: #aebccc;
  --paper: #10151c;
  --panel: #18212c;
  --line: #344151;
  --accent: #d66d99;
  --accent-dark: #f0a7c4;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 3px;
}

.shell {
  width: min(1380px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid rgba(18, 36, 60, 0.13);
}

.nav {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  object-fit: contain;
}

.brand-name {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
}

.brand-name small {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 13px;
}

.theme-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.theme-toggle-state {
  padding: 2px 5px;
  color: var(--ink-soft);
  background: rgba(18, 36, 60, 0.07);
  border-radius: 4px;
  font-size: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #1f9d61;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(31, 157, 97, 0.13);
}

.hero {
  padding: 54px 0 34px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 860px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 52px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.94;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 720px) auto;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

.hero-copy {
  margin: 0;
  color: var(--ink-soft);
  font-size: 17px;
  overflow-wrap: anywhere;
}

.countdown {
  min-width: 220px;
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

.countdown strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
}

.countdown span {
  display: block;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard {
  padding-bottom: 80px;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(18, 36, 60, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .site-header {
  border-bottom-color: var(--line);
}

:root[data-theme="dark"] .panel {
  background: rgba(25, 37, 52, 0.97);
  border-color: var(--line);
}

:root[data-theme="dark"] .support-slot {
  color: var(--ink-soft);
  background: rgba(25, 37, 52, 0.72);
  border-color: #496178;
}

:root[data-theme="dark"] .support-slot span {
  color: var(--ink-soft);
}


.support-slot {
  display: grid;
  min-height: 58px;
  place-items: center;
  margin: 18px 0;
  padding: 13px 18px;
  color: #687586;
  background: rgba(255, 255, 255, 0.68);
  border: 1px dashed rgba(18, 36, 60, 0.22);
  border-radius: var(--radius);
  box-shadow: none;
}

.support-slot span {
  color: #5f6c7b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.support-slot strong {
  color: var(--ink);
  font-size: 13px;
}

.support-slot p {
  margin: 0;
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
}

.stat {
  min-width: 0;
  min-height: 128px;
  padding: 22px 24px;
  border-right: 1px solid var(--line);
}

.stat:last-child {
  border-right: 0;
}

.stat-label {
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-value {
  font-family: Georgia, serif;
  font-size: 38px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stat:last-child .stat-value {
  font-size: 30px;
  line-height: 1.05;
}

.stat-note {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.chart-panel {
  overflow: hidden;
}

.chart-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 26px 28px 22px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  margin-bottom: 5px;
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0;
}

.section-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.toolbar-actions {
  display: grid;
  grid-template-columns:
    minmax(180px, 1.15fr)
    minmax(190px, 1fr)
    minmax(160px, 0.85fr)
    minmax(160px, 0.85fr)
    auto;
  align-items: end;
  gap: 12px;
}

.toolbar-commands {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-commands .ghost-button {
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.range-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(48px, 1fr));
  gap: 2px;
  padding: 3px;
  background: #e9edf1;
  border: 1px solid #d3d8df;
  border-radius: 7px;
}

:root[data-theme="dark"] .range-control {
  background: #213145;
  border-color: #40566f;
}

.range-button {
  min-width: 48px;
  height: 34px;
  padding: 0 10px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.range-button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(18, 36, 60, 0.12);
}

select,
.ghost-button {
  min-height: 42px;
  padding: 0 14px;
  background: var(--panel);
  border: 1px solid #c9c7c1;
  border-radius: 6px;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.ghost-button {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.slider-field {
  min-width: 0;
}

.slider-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid #c9c7c1;
  border-radius: 6px;
}

.slider-wrap input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent-dark);
}

.slider-value {
  min-width: 48px;
  color: var(--ink-soft);
  text-align: right;
  font-size: 11px;
  font-weight: 750;
}

.ghost-button:hover {
  background: #eef5f1;
  border-color: #9cb7aa;
}

:root[data-theme="dark"] select,
:root[data-theme="dark"] .ghost-button {
  border-color: #4b6075;
}

:root[data-theme="dark"] .ghost-button:hover {
  background: #263b4a;
  border-color: #618071;
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(217, 75, 53, 0.22);
  outline-offset: 2px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 22px;
  padding: 18px 28px;
  background: #f8fafb;
  border-bottom: 1px solid var(--line);
}

:root[data-theme="dark"] .filters {
  background: #162231;
}

.filter-block {
  min-width: 0;
}

.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.filter-head h3 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-count {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.text-button {
  min-height: 28px;
  padding: 0 8px;
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.text-button:hover {
  background: #edf1f4;
  border-color: #d5dce3;
}

.text-button[hidden] {
  display: none;
}

:root[data-theme="dark"] .text-button:hover {
  background: #26364a;
  border-color: #3f556b;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 116px;
  overflow-y: auto;
  padding-right: 4px;
}

.chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #c5ced7;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition:
    color 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease;
}

:root[data-theme="dark"] .chip {
  background: #1d2b3b;
  border-color: #4a6077;
}

:root[data-theme="dark"] .chip:hover {
  background: #26384b;
  border-color: #62809b;
}

:root[data-theme="dark"] .chip[aria-pressed="true"] {
  background: #2a4056;
  border-color: #7794af;
}

:root[data-theme="dark"] .chip[aria-pressed="false"] {
  color: var(--ink-soft);
  background: #172230;
  border-color: #31465b;
}

:root[data-theme="dark"] .chip-check {
  background: #132031;
  border-color: #6b8197;
}

.chip:hover {
  color: var(--ink);
  border-color: #b8c4ce;
  background: #f7fafb;
}

.chip[aria-pressed="true"] {
  color: var(--ink);
  background: #eaf0f5;
  border-color: #6f879c;
  box-shadow: inset 0 0 0 1px rgba(18, 36, 60, 0.05);
}

.chip[aria-pressed="false"] {
  color: #687586;
  background: #f4f6f8;
  border-color: #dce1e6;
  opacity: 0.62;
}

.chip-check {
  display: grid;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  place-items: center;
  color: transparent;
  background: white;
  border: 1px solid #aeb9c3;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.chip[aria-pressed="true"] .chip-check {
  color: white;
  background: var(--ink);
  border-color: var(--ink);
}

.chip[aria-pressed="false"] .chip-dot {
  filter: saturate(0.25);
  opacity: 0.55;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.plot-wrap {
  position: relative;
  min-height: 0;
  padding: 8px 12px 10px;
}

#poll-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  overflow: visible;
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
}

.grid-line {
  stroke: #e3e6e9;
  stroke-width: 1;
}

:root[data-theme="dark"] .grid-line {
  stroke: #33465a;
}

:root[data-theme="dark"] .axis-label {
  fill: #afc0d2;
}

:root[data-theme="dark"] .election-line {
  stroke: #8292a3;
}

:root[data-theme="dark"] .year-line {
  stroke: #263748;
}

:root[data-theme="dark"] .election-label {
  fill: #aebdcb;
}

:root[data-theme="dark"] .coverage-gap {
  fill: #141d27;
}

:root[data-theme="dark"] .coverage-gap-label {
  fill: #718294;
}

.axis-label {
  fill: #6f7884;
  font-size: 11px;
}

.election-line {
  stroke: #687481;
  stroke-width: 1;
  opacity: 0.52;
}

.year-line {
  stroke: #edf0f3;
  stroke-width: 1;
  pointer-events: none;
}

.election-label {
  fill: #687583;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0;
}

.coverage-gap {
  fill: #f5f7f9;
  opacity: 0.86;
  pointer-events: none;
}

.coverage-gap-label {
  fill: #929ca7;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0;
  pointer-events: none;
}

.zoom-hit-area {
  fill: transparent;
  cursor: crosshair;
  pointer-events: all;
  touch-action: pan-y;
}

.trend-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.poll-point {
  cursor: pointer;
  stroke: var(--panel);
  stroke-width: 0.8;
  transition: opacity 120ms ease;
}

.poll-point.is-muted {
  stroke-width: 0.55;
}

.zoom-selection {
  fill: rgba(18, 36, 60, 0.13);
  stroke: rgba(18, 36, 60, 0.45);
  stroke-width: 1;
  pointer-events: none;
}

.zoom-selection[hidden] {
  display: none;
}

.zoom-reset {
  border-color: #70869a;
}

.zoom-reset[hidden] {
  display: inline-block;
  visibility: hidden;
  pointer-events: none;
}

.poll-point:focus {
  outline: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.tooltip {
  position: absolute;
  z-index: 3;
  width: max-content;
  max-width: 260px;
  padding: 11px 13px;
  color: white;
  background: #12243cee;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(18, 36, 60, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 100ms ease;
  font-size: 12px;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.chart-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 28px 24px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.archive-status {
  color: var(--ink);
  font-weight: 700;
}

.coverage-note {
  flex-basis: 100%;
  max-width: 88ch;
  line-height: 1.5;
}

.coverage-notes {
  padding: 28px 2px 10px;
  border-bottom: 1px solid var(--line);
}

.coverage-notes h2 {
  margin: 0;
  font-size: 20px;
}

.coverage-notes-intro {
  max-width: 82ch;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.coverage-notes-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.coverage-notes-list li {
  display: grid;
  grid-template-columns: minmax(150px, 0.24fr) minmax(0, 1fr);
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.coverage-dates {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.coverage-explanation strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.coverage-explanation p {
  max-width: 82ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.coverage-explanation a {
  display: inline-block;
  margin-top: 7px;
  color: var(--accent);
  font-size: 12px;
  text-underline-offset: 3px;
}

.table-panel {
  margin-top: 18px;
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 25px 28px 20px;
  border-bottom: 1px solid var(--line);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.source-picker {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.source-picker select {
  width: min(310px, 32vw);
  min-width: 180px;
  min-height: 38px;
  font-size: 12px;
}

#compiled-source {
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

#source-note {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

#toggle-table-rows[hidden] {
  display: none;
}

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

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #e6e3dc;
  text-align: right;
  white-space: nowrap;
}

:root[data-theme="dark"] th,
:root[data-theme="dark"] td {
  border-bottom-color: #314255;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink-soft);
  background: #f8fafb;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:root[data-theme="dark"] th {
  background: #162231;
}

.table-party-heading {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--ink-soft);
}

.table-party-swatch {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
}

th:first-child,
th:nth-child(2),
td:first-child,
td:nth-child(2) {
  text-align: left;
}

tbody tr:hover {
  background: #fffaf3;
}

:root[data-theme="dark"] tbody tr:hover {
  background: #202f40;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.source-link {
  color: var(--ink);
  font-weight: 700;
  text-decoration-color: #bebbb4;
}

.method {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  padding: 62px 4px 18px;
}

.method h2 {
  max-width: 520px;
  font-family: Georgia, serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.03;
}

.method-copy {
  color: var(--ink-soft);
  font-size: 14px;
}

.method-copy p {
  margin-bottom: 14px;
}

.update-note {
  margin-top: 20px;
  padding: 16px 18px;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.65);
  border: 1px solid var(--line);
  border-radius: 8px;
}

:root[data-theme="dark"] .update-note {
  background: rgba(25, 37, 52, 0.72);
}

footer {
  padding: 0;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

footer .shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  padding: 26px 0 38px;
}

.empty-state {
  display: grid;
  min-height: 440px;
  place-items: center;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 900px) {
  .zoom-reset[hidden] {
    display: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .chart-toolbar,
  .filters,
  .method {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .toolbar-commands {
    grid-column: 1 / -1;
  }

  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-actions {
    width: 100%;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .source-picker {
    flex: 1 1 420px;
  }

  .source-picker select {
    width: 100%;
  }

  .method {
    gap: 14px;
  }

  .support-slot {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 22px, 1380px);
  }

  .nav {
    min-height: 64px;
  }

  .header-meta > span:not(.live-dot) {
    display: none;
  }

  .theme-toggle,
  .range-button,
  .chip,
  .text-button,
  select,
  .ghost-button,
  .slider-wrap {
    min-height: 44px;
  }

  .range-button {
    height: 44px;
  }

  .hero {
    padding-top: 42px;
  }

  .hero-row {
    grid-template-columns: 1fr;
  }

  .countdown {
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    min-height: 122px;
    padding: 19px 16px;
  }

  .stat-value {
    font-size: 26px;
  }

  .stat:last-child .stat-value {
    font-size: 24px;
  }

  .chart-toolbar,
  .filters,
  .table-head {
    padding-inline: 18px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .range-field {
    grid-column: 1 / -1;
  }

  .slider-field,
  .toolbar-commands {
    grid-column: 1 / -1;
  }

  .toolbar-commands {
    align-items: stretch;
    flex-direction: column;
  }

  .source-picker {
    flex-basis: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .plot-wrap {
    min-height: 0;
    overflow-x: hidden;
    padding-inline: 6px;
  }

  #poll-chart {
    width: 100%;
    min-height: 0;
  }

  .chart-note {
    flex-direction: column;
  }

  .coverage-notes-list li {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  footer .shell {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 46px;
  }

  .method h2 {
    font-size: 34px;
  }
}
