:root {
  --bg: #0b0b0b;
  --surface: #171717;
  --surface-strong: #222222;
  --surface-soft: #111111;
  --text: #f4f4f4;
  --muted: #bdbdbd;
  --red: #dd0000;
  --gold: #e6b800;
  --gold-light: #f5d45c;
  --border: rgba(255,255,255,.12);
  --grid: rgba(255,255,255,.09);
  --shadow: 0 22px 54px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html {
  scrollbar-color: #e6b800 rgba(0,0,0,.42);
  scrollbar-width: thin;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,.42); }
::-webkit-scrollbar-thumb {
  border: 2px solid rgba(0,0,0,.42);
  border-radius: 999px;
  background: #e6b800;
}
::-webkit-scrollbar-thumb:hover { background: #f5d45c; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(221,0,0,.16) 0%, transparent 34%),
    radial-gradient(circle at top right, rgba(230,184,0,.12) 0%, transparent 32%),
    var(--bg);
}

a { color: var(--gold-light); }

button,
input,
select { font: inherit; }

button { cursor: pointer; }

.archive-top-links {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.archive-top-links a,
.page-nav a,
.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(230,184,0,.42);
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.26);
  backdrop-filter: blur(8px);
}

.archive-top-links a:hover,
.archive-top-links a:focus-visible,
.page-nav a:hover,
.page-nav a:focus-visible,
.pill-button:hover,
.pill-button:focus-visible {
  border-color: var(--red);
  color: #fff;
  outline: none;
  box-shadow: 0 0 18px rgba(221,0,0,.22), 0 8px 22px rgba(0,0,0,.3);
}

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 72px 0 28px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

h1,
h2,
h3 { letter-spacing: 0; }

h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(32px, 5.5vw, 62px);
  line-height: 1.02;
}

h1::after {
  content: "";
  display: block;
  width: 96px;
  height: 3px;
  margin-top: 15px;
  border-radius: 999px;
  background: var(--red);
}

.lead {
  max-width: 830px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.page-nav a[aria-current="page"] {
  border-color: var(--red);
  color: #fff;
  background: rgba(221,0,0,.14);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(34,34,34,.97), rgba(20,20,20,.97));
  box-shadow: var(--shadow);
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.filter-panel.single-field {
  grid-template-columns: minmax(220px, .75fr) minmax(260px, 1.25fr);
}

.state-picker { margin-bottom: 16px; }

.state-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 20px;
}

.state-tile {
  display: grid;
  align-content: center;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 11px;
  min-height: 104px;
  padding: 15px;
  border: 1px solid rgba(230,184,0,.28);
  border-radius: 13px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(12,12,12,.98), rgba(30,30,30,.98));
  text-decoration: none;
  text-align: left;
  box-shadow: 0 10px 24px rgba(0,0,0,.24);
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.state-tile:hover,
.state-tile:focus-visible {
  border-color: var(--gold);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(230,184,0,.12), 0 12px 28px rgba(0,0,0,.28);
}

.state-tile[aria-pressed="true"] {
  border-color: var(--red);
  background: linear-gradient(145deg, rgba(74,8,8,.68), rgba(26,26,26,.98));
  box-shadow: 0 0 24px rgba(221,0,0,.18), 0 12px 28px rgba(0,0,0,.3);
}

.state-code {
  grid-column: 1;
  grid-row: 1 / 4;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(230,184,0,.45);
  border-radius: 10px;
  color: var(--gold-light);
  background: rgba(230,184,0,.07);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
}

.state-tile strong {
  grid-column: 2;
  align-self: end;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.15;
}

.state-tile > span:not(.state-code) {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.state-prompt {
  display: grid;
  gap: 6px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.state-prompt strong { color: var(--text); font-size: 18px; }

.selected-state {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 46px;
}

.selected-state span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.selected-state strong { font-size: 22px; }

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field select,
.field input[type="search"],
.field input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(0,0,0,.42);
}

.field select:focus,
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(230,184,0,.12);
}

.state-election-control {
  display: grid;
  grid-template-columns: minmax(180px, .55fr) minmax(0, 1.8fr);
  gap: 16px 22px;
  align-items: end;
  padding: 18px;
  margin-bottom: 16px;
}

.election-navigation {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.election-picker {
  display: grid;
  grid-template-columns: minmax(92px, .36fr) minmax(220px, 1.64fr) auto;
  gap: 10px;
  align-items: end;
}

.election-counter {
  min-width: 58px;
  padding-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.year-feedback {
  grid-column: 1 / -1;
  min-height: 1.35em;
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.year-feedback:empty { display: none; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  min-height: 105px;
  padding: 17px;
}

.stat span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  font-size: clamp(21px, 3vw, 31px);
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 20px 0;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: clamp(20px, 3vw, 29px);
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.source-link {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover,
.source-link:focus-visible { text-decoration: underline; }

.result-chart {
  --plot-top: 30px;
  --plot-right: 16px;
  --plot-bottom: 138px;
  --plot-left: 58px;
  position: relative;
  height: 540px;
  margin: 18px 20px 20px;
  padding: var(--plot-top) var(--plot-right) var(--plot-bottom) var(--plot-left);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.result-chart-grid {
  position: absolute;
  top: var(--plot-top);
  right: var(--plot-right);
  bottom: var(--plot-bottom);
  left: var(--plot-left);
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(to top, var(--grid) 1px, transparent 1px) 0 0 / 100% 25%;
}

.result-chart-grid span {
  position: absolute;
  top: var(--grid-position);
  left: -49px;
  width: 42px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  transform: translateY(-50%);
}

.result-chart-scroll {
  position: relative;
  z-index: 1;
  height: calc(100% + 124px);
  margin-bottom: -124px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: #e6b800 rgba(0,0,0,.42);
  scrollbar-width: thin;
}

.result-chart-scroll:focus-visible {
  outline: 2px solid rgba(230,184,0,.72);
  outline-offset: 3px;
}

.result-chart-scroll::-webkit-scrollbar { height: 11px; }
.result-chart-scroll::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(0,0,0,.42);
}
.result-chart-scroll::-webkit-scrollbar-thumb {
  border: 1px solid rgba(230,184,0,.28);
  border-radius: 999px;
  background: #e6b800;
}
.result-chart-scroll::-webkit-scrollbar-thumb:hover { background: #f5d45c; }

.result-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: clamp(7px, 1vw, 14px);
  width: max-content;
  min-width: 100%;
  height: calc(100% - 124px);
  padding-bottom: 2px;
}

.result-bar-box {
  position: relative;
  display: flex;
  flex: 1 0 132px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 132px;
  height: 100%;
  gap: 7px;
}

.result-bar-number {
  min-height: 35px;
  color: var(--text);
  font-size: clamp(11px, 1.05vw, 14px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(7px);
  animation: resultValueIn .42s ease forwards;
  animation-delay: calc(var(--result-delay) + .5s);
}

.result-bar-column {
  width: min(64px, 70%);
  height: 0;
  min-height: 2px;
  border-radius: 10px 10px 0 0;
  background: var(--party-color, var(--gold));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), inset 0 10px 16px rgba(255,255,255,.14), 0 8px 18px rgba(0,0,0,.28);
  animation: resultGrowUp .82s cubic-bezier(.2,.85,.2,1) forwards;
  animation-delay: var(--result-delay);
}

.result-bar-caption {
  position: absolute;
  bottom: -122px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: column;
  width: min(132px, 100%);
  min-height: 112px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.result-bar-caption strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.result-bar-caption span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

@keyframes resultGrowUp {
  from { height: 0; }
  to { height: var(--result-height); }
}

@keyframes resultValueIn {
  to { opacity: 1; transform: translateY(0); }
}

.table-wrap {
  max-height: 660px;
  overflow: auto;
  margin: 18px 20px 20px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255,255,255,.075);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--gold-light);
  background: #191919;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

td:not(:first-child),
th:not(:first-child) { text-align: right; }

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

.party-name {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
}

.party-label-copy {
  display: grid;
  gap: 2px;
}

.party-label-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

.party-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.42);
  background: var(--party-color);
}

.history-panel,
.method-panel { margin-top: 16px; }

.chart-scroller {
  overflow-x: auto;
  padding: 10px 18px 18px;
}

.line-chart {
  min-width: 900px;
  min-height: 390px;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: rgba(255,255,255,.23); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 12px; }
.axis-title { fill: var(--muted); font-size: 13px; font-weight: 700; }
.series-line {
  fill: none;
  stroke: var(--party-color);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.68));
}
.series-point {
  fill: var(--party-color);
  stroke: rgba(255,255,255,.72);
  stroke-width: 1.5;
}
.event-marker { stroke: rgba(230,184,0,.38); stroke-width: 1.5; stroke-dasharray: 5 5; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 4px;
}

.legend-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-scroll {
  max-height: 240px;
  overflow-y: auto;
  padding-bottom: 12px;
}

.legend button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  color: var(--text);
  background: rgba(0,0,0,.3);
  font-size: 13px;
  font-weight: 700;
}

.legend button[aria-pressed="false"] { opacity: .42; }

.legend button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.42);
  background: var(--party-color);
}

.legend-full-name {
  color: var(--muted);
  font-weight: 400;
}

.event-control {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 18px;
  margin-bottom: 16px;
}

.event-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--red);
}

.model-event-control .year-feedback { grid-column: 1 / -1; }

.event-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 20px;
  margin-bottom: 16px;
}

.event-context h2 { margin: 0; font-size: clamp(23px, 4vw, 36px); }
.event-context p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }

.event-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(230,184,0,.4);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(230,184,0,.08);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.method-copy {
  padding: 4px 20px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.58;
}

.method-copy ol {
  margin: 12px 0 0;
  padding-left: 22px;
}

.method-copy li + li { margin-top: 8px; }

.notice {
  margin: 0 20px 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--gold);
  border-radius: 4px 10px 10px 4px;
  background: rgba(230,184,0,.07);
  color: #e8e0bc;
  line-height: 1.5;
}

.empty-state {
  padding: 38px 20px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.site-footer a { text-decoration: none; }
.site-footer a:hover,
.site-footer a:focus-visible { color: var(--red); outline: none; }

@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr; }
  .page-nav { justify-content: flex-start; }
  .state-election-control { grid-template-columns: 1fr; align-items: stretch; }
}

@media (max-width: 920px) {
  .content-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { padding-top: 62px; }
  .archive-top-links { top: 10px; right: 10px; left: 10px; }
  .archive-top-links a { min-height: 32px; padding: 0 10px; font-size: 12px; }
  .page-shell { width: min(100% - 20px, 1280px); padding-top: 22px; }
  .filter-panel,
  .stats-grid { grid-template-columns: 1fr; }
  .filter-panel.single-field { grid-template-columns: 1fr 1fr; }
  .state-grid { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 10px; }
  .state-tile { min-height: 90px; padding: 14px; }
  .state-tile strong { line-height: 1.3; }
  .state-code { width: 34px; height: 34px; }
  .stat { min-height: 88px; }
  .panel-head,
  .event-context { grid-template-columns: 1fr; display: grid; }
  .source-link { justify-self: start; }
  .result-chart {
    --plot-left: 51px;
    height: 500px;
    margin-inline: 10px;
  }
  .result-chart-grid span { left: -44px; width: 38px; }
  .result-bar-box { flex-basis: 116px; min-width: 116px; }
  .result-bar-caption { width: min(116px, 100%); }
  .table-wrap { margin-inline: 10px; }
  th, td { padding: 9px 8px; }
  .event-control { grid-template-columns: 1fr 1fr; }
  .event-control > input { grid-column: 1 / -1; grid-row: 2; }
  .event-control > .election-picker { grid-column: 1 / -1; grid-row: 1; }
  .model-event-control > #previousEvent { grid-column: 1; grid-row: 3; }
  .model-event-control > #nextEvent { grid-column: 2; grid-row: 3; justify-self: end; }
  .model-event-control > .year-feedback { grid-row: 4; }
  .election-navigation { grid-template-columns: 1fr 1fr; }
  .election-picker { grid-column: 1 / -1; grid-row: 1; }
  .election-navigation > button:last-child { justify-self: end; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .legend-toolbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .election-picker { grid-template-columns: 1fr auto; }
  .election-picker .field:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .election-counter { grid-column: 2; grid-row: 1; }
  .election-navigation > .pill-button { justify-self: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .result-bar-column { animation: none; height: var(--result-height); }
  .result-bar-number { animation: none; opacity: 1; transform: none; }
}

/* Einzelseiten: identisches Grundraster wie die bestehenden Wahlseiten. */
body.election-detail-page {
  --bg: #0b0b0b;
  --surface: #181b22;
  --text: #f2f2f2;
  --muted: #b8beca;
  --grid: rgba(255,255,255,.10);
  padding: 20px;
  background:
    radial-gradient(circle at top left, rgba(221,0,0,.16) 0%, transparent 34%),
    radial-gradient(circle at top right, rgba(230,184,0,.12) 0%, transparent 32%),
    var(--bg);
}

.election-app {
  width: min(1280px, 100%);
  margin: 52px auto 0;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.election-header {
  margin-bottom: 18px;
  text-align: center;
}

.election-header h1 {
  max-width: none;
  margin: 0 0 10px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.12;
}

.election-header h1::after { display: none; }

.election-meta {
  color: var(--muted);
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.45;
}

.election-chart-wrap {
  --plot-top: 30px;
  --plot-right: 14px;
  --plot-bottom: 150px;
  --plot-left: 54px;
  position: relative;
  height: 540px;
  padding: var(--plot-top) var(--plot-right) var(--plot-bottom) var(--plot-left);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}

.election-chart-wrap .result-chart-scroll {
  height: calc(100% + 134px);
  margin-bottom: -134px;
}

.election-chart-wrap .result-bars {
  height: calc(100% - 134px);
  gap: clamp(5px, 1vw, 14px);
}

.election-chart-wrap .threshold-line {
  position: absolute;
  right: 0;
  bottom: var(--threshold);
  left: 0;
  z-index: 4;
  border-top: 1px solid #ff3b3b;
  pointer-events: none;
}

.election-chart-wrap .threshold-line span {
  position: absolute;
  bottom: 4px;
  left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #ff6b6b;
  background: rgba(16,18,22,.92);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.threshold-chart-line {
  stroke: #dd0000;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.threshold-chart-label {
  fill: #ff7777;
  font-size: 12px;
  font-weight: 800;
}

.election-chart-wrap .result-bar-box { gap: 8px; }

.election-chart-wrap .result-bar-number {
  min-height: 18px;
  font-size: clamp(10px, 1.15vw, 15px);
}

.election-chart-wrap .result-bar-caption {
  bottom: -126px;
  min-height: 100px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.18;
}

.election-chart-wrap .result-bar-caption strong {
  width: 100%;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.election-chart-nav {
  position: absolute;
  top: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0 0 4px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.35);
  font-size: 30px;
  line-height: 1;
}

.election-chart-nav:hover,
.election-chart-nav:focus-visible {
  filter: brightness(1.2);
  outline: 2px solid rgba(230,184,0,.72);
  outline-offset: 2px;
}

.election-chart-nav-previous { left: 64px; }
.election-chart-nav-next { right: 16px; }

.election-search-box {
  position: absolute;
  top: 14px;
  right: 70px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.election-search-box input,
.election-search-box select {
  width: 120px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  outline: none;
  color: var(--text);
  background: rgba(0,0,0,.35);
  font-size: 16px;
}

.election-search-box select {
  width: 128px;
  cursor: pointer;
  color-scheme: dark;
}

.election-search-box-wide select { width: 220px; }

.election-search-box input:focus,
.election-search-box select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(230,184,0,.12);
}

.election-search-box select option {
  color: var(--text);
  background: var(--surface);
}

.election-search-box input::placeholder { color: var(--muted); }

.election-chart-counter {
  position: absolute;
  top: 62px;
  right: 82px;
  z-index: 5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.election-app > .year-feedback { margin: 10px 0 0; }

.election-source-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.election-source-note a {
  color: var(--text);
  font-weight: 700;
}

.election-night-callout { margin: 20px 0; }

.election-night-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  border: 2px solid var(--gold);
  border-radius: 16px;
  background: linear-gradient(110deg, rgba(230,184,0,.2), rgba(230,184,0,.06));
  color: var(--text);
  text-decoration: none;
}

.election-night-button strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.25;
}

.election-night-button span span { font-size: 16px; line-height: 1.5; }
.election-night-arrow { flex: 0 0 auto; color: var(--gold); font-size: 34px; }
.election-night-button:hover { background: rgba(230,184,0,.25); }
.election-night-button:focus-visible { outline: 3px solid var(--text); outline-offset: 4px; }

.election-result-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 16px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.election-result-legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.election-result-legend-item > span:last-child { min-width: 0; }
.election-result-legend-item strong { color: var(--text); }

.election-result-swatch {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px;
  background: var(--party-color);
}

.election-section,
.election-app .history-panel,
.election-app .method-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.10);
}

.election-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.election-section-head h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 29px);
}

.election-section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.history-range-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(108px, 1fr));
  gap: 10px;
  min-width: 244px;
}

.history-range-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-range-field select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  outline: none;
  color: var(--text);
  background: rgba(0,0,0,.35);
  color-scheme: dark;
  font: inherit;
  cursor: pointer;
}

.history-range-field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(230,184,0,.12);
}

.history-range-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.election-section .table-wrap { margin: 18px 0 0; }
.election-section .legend-toolbar { padding: 14px 0 0; }
.election-section .legend { padding-inline: 0; }
.election-section .chart-scroller { padding-inline: 0; }
.election-section .method-copy { padding: 4px 0 0; }
.election-section .notice { margin: 18px 0 0; }

.election-app .site-footer a {
  color: #dce4ff;
  font-weight: 700;
}

@media (max-width: 760px) {
  body.election-detail-page { padding: 12px; padding-top: 62px; }
  .election-app { margin-top: 0; padding: 14px; }
  .election-chart-wrap {
    --plot-bottom: 146px;
    --plot-left: 42px;
    height: 500px;
    padding-left: 42px;
    padding-bottom: 146px;
  }
  .election-chart-wrap .result-bars { gap: 4px; }
  .election-chart-nav {
    width: 36px;
    height: 36px;
    font-size: 26px;
  }
  .election-chart-nav-previous { left: 48px; }
  .election-search-box {
    right: 58px;
    max-width: calc(100% - 116px);
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .election-search-box input,
  .election-search-box select {
    width: 88px;
    height: 36px;
    padding: 0 10px;
    font-size: 14px;
  }
  .election-search-box select { width: 96px; }
  .election-search-box-wide select { width: 150px; }
  .election-chart-counter { top: 56px; right: 66px; }
  .election-result-legend { grid-template-columns: 1fr; }
  .election-section-head { flex-direction: column; }
  .history-range-controls { width: 100%; min-width: 0; }
}

@media (max-width: 520px) {
  .election-chart-wrap {
    --plot-top: 112px;
    height: 550px;
    padding-top: 112px;
  }
  .election-chart-nav-previous { left: 12px; }
  .election-chart-nav-next { right: 12px; }
  .election-search-box,
  .election-search-box-wide {
    top: 58px;
    right: 12px;
    left: 12px;
    max-width: none;
    justify-content: center;
  }
  .election-search-box-wide select { width: 150px; }
  .election-chart-counter {
    top: 25px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
}
