:root {
  --bg: #070b14;
  --text: #eef2fa;
  --muted: #95a3bc;
  --faint: #71809a;
  --a: #83aaff;
  --b: #ff947b;
  --line: rgba(255, 255, 255, .1);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
html[data-route="home"] .state-layout, html[data-route="state"] .home-slot { display: none; }
.states-page #method { display: none; }
h1, h2, p { margin: 0; }
a:focus-visible, summary:focus-visible, .location-picker select:focus-visible, #chart-svg:focus-visible {
  outline: 2px solid #a3baff;
  outline-offset: 3px;
}

.page {
  max-width: 1480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 148, 123, .25);
  border-radius: 14px;
  background: rgba(255, 148, 123, .08);
  color: #ffc1b3;
  font-size: 13px;
  line-height: 1.4;
}
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.hero h1 {
  margin-top: 6px;
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 680;
  line-height: 1;
  letter-spacing: -.06em;
}
.hero h1 em { color: #98aff4; font-style: normal; }
.location-picker { position: relative; display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; max-width: min(40vw, 220px); }
.location-picker::after { position: absolute; top: 50%; right: 2px; width: 7px; height: 7px; border-right: 1.5px solid #bdc9dd; border-bottom: 1.5px solid #bdc9dd; content: ''; pointer-events: none; transform: translateY(-70%) rotate(45deg); }
.update-indicator { display: grid; place-items: center; flex: none; width: 1em; height: 1em; color: #a3baff; font-size: clamp(36px, 5vw, 64px); line-height: 1; opacity: .65; pointer-events: none; }
.update-indicator.is-updating { opacity: 1; animation: update-spin .8s linear infinite; }
@keyframes update-spin { to { transform: rotate(1turn); } }
.location-picker select {
  display: block;
  flex: 1;
  min-width: 0;
  width: 100%;
  appearance: none;
  height: 44px;
  padding: 0 20px 0 0;
  border: 0;
  background: transparent;
  color: #bdc9dd;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  text-align-last: right;
  text-overflow: ellipsis;
  cursor: pointer;
}
.location-picker select:hover { color: #fff; }
.location-picker select option { background: #151e31; color: var(--text); }

.chart-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; margin-bottom: 12px; }
.series-key { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 11px; font-weight: 550; letter-spacing: .025em; }
.series-key span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.key-line { display: inline-block; width: 18px; height: 3px; border-radius: 3px; background: #fff; }
.key-projected { height: 4px; -webkit-mask: radial-gradient(circle, #000 1.5px, transparent 1.9px) left center / 6px 4px repeat-x; mask: radial-gradient(circle, #000 1.5px, transparent 1.9px) left center / 6px 4px repeat-x; }
.key-first { height: 1.5px; background: rgba(255, 255, 255, .45); }
.chart-wrap { position: relative; width: 100%; }
#chart-svg { display: block; width: 100%; height: clamp(440px, 62dvh, 620px); outline: none; touch-action: pan-y; cursor: crosshair; }
.chart-axis-label { fill: #aebbd0; font-family: inherit; font-size: 11px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.chart-axis-label.major { fill: #f0f3fa; font-weight: 700; }
.chart-axis-label.chart-x-label { fill: #7d8ca6; font-weight: 500; }
.chart-tooltip {
  position: absolute;
  z-index: 5;
  width: 240px;
  max-width: calc(100% - 8px);
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  background: rgba(13, 19, 33, .94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  pointer-events: none;
}
.tooltip-heading { margin-bottom: 6px; color: var(--text); font-size: 12px; font-weight: 650; }
.tooltip-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px 54px; gap: 8px; align-items: center; min-height: 21px; color: var(--muted); font-size: 11px; }
.tooltip-row > span:first-child { white-space: nowrap; }
.tooltip-row strong { color: var(--text); font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.tooltip-columns { min-height: 15px; color: var(--faint); font-size: 10px; font-weight: 600; }
.tooltip-columns span:nth-child(2) { color: var(--a); text-align: right; }
.tooltip-columns span:nth-child(3) { color: var(--b); text-align: right; }
.tooltip-first strong { color: #b4c0d6; }
.tooltip-baseline { margin-top: 3px; padding-top: 3px; border-top: 1px solid var(--line); }

.scoreboard { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.scoreboard-label { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .12em; }
.candidate-rows { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: center; gap: 28px; margin-top: 16px; }
.prediction-candidate { display: flex; align-items: center; min-width: 0; gap: 14px; }
.candidate-photo { flex: none; width: 78px; height: 78px; border: 2px solid var(--candidate-color); border-radius: 50%; object-fit: cover; object-position: center 33%; background: #182239; box-shadow: 0 0 0 6px color-mix(in srgb, var(--candidate-color) 12%, transparent); }
.prediction-identity { display: flex; flex: 1; flex-direction: column; justify-content: center; min-width: 0; gap: 4px; }
.prediction-eyebrow { color: var(--candidate-color); font-size: 10px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.prediction-name { font-size: clamp(17px, 2vw, 23px); font-weight: 700; line-height: 1.15; letter-spacing: -.03em; }
.prediction-value { display: flex; flex: none; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.prediction-value strong { color: #f3f6fc; font-size: clamp(38px, 4vw, 55px); font-weight: 720; line-height: 1; letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.prediction-value span { color: #9aa9c3; font-size: 11px; white-space: nowrap; }
.prediction-secondary { padding-left: 28px; border-left: 1px solid var(--line); opacity: .74; }
.prediction-secondary .candidate-photo { width: 54px; height: 54px; box-shadow: none; }
.prediction-secondary .prediction-name { font-size: 17px; }
.prediction-secondary .prediction-value strong { font-size: 27px; letter-spacing: -.04em; }
.prediction-secondary .prediction-value span { font-size: 10px; }
.candidate-rows:not(.has-favorite) .prediction-primary .candidate-photo { border-color: #7d8da8; box-shadow: none; }
.candidate-rows:not(.has-favorite) .prediction-primary .prediction-eyebrow { color: #b8c5dc; }
.forecast-note, .state-note { display: block; margin-top: 12px; color: var(--faint); font-size: 11px; }

.home-page footer, .state-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }
.home-page .footer-actions { display: flex; align-items: flex-start; gap: 20px; }
.home-page .footer-actions > a, .state-footer a, .home-page .footer-actions summary { color: #9aabc5; }
.home-page .footer-actions details { position: relative; }
.home-page .footer-actions summary { cursor: pointer; list-style: none; }
.home-page .footer-actions summary::-webkit-details-marker { display: none; }
.home-page .method-content { position: absolute; right: 0; bottom: 26px; z-index: 10; width: min(420px, calc(100vw - 32px)); padding: 18px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 15px; background: #111a2b; box-shadow: 0 14px 40px rgba(0, 0, 0, .45); color: #b6c2d6; font-size: 12px; line-height: 1.55; }
.home-page .method-content p { margin-bottom: 11px; }
.home-page .method-content p:last-child { margin-bottom: 0; }
.home-page .method-content a { color: #b1c6ff; text-decoration: underline; text-underline-offset: 2px; }

.tour-spotlight { position: relative; z-index: 25; border-radius: 16px; box-shadow: 0 0 0 2px rgba(163, 186, 255, .72), 0 0 0 9999px rgba(2, 5, 12, .84); }
.chart-tour { position: fixed; z-index: 40; inset: 0; pointer-events: none; }
.tour-guard { position: absolute; inset: 0; pointer-events: auto; }
.tour-card { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); width: min(370px, calc(100vw - 24px)); padding: 14px; border: 1px solid rgba(163, 186, 255, .22); border-radius: 16px; background: #151e31; box-shadow: 0 18px 56px rgba(0, 0, 0, .55); transform: translateX(-50%); pointer-events: auto; }
.tour-card h2 { font-size: 18px; font-weight: 680; letter-spacing: -.035em; }
.tour-card p { margin-top: 5px; color: #c0cbde; font-size: 12px; line-height: 1.35; }
.tour-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 10px; }
.tour-actions button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; }
.tour-next { background: #9eb8ff; color: #0b1222; }
.tour-actions button:focus-visible { outline: 1px solid #e5edff; outline-offset: 2px; }

@media (min-width: 720px) {
  .page { padding: calc(32px + env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left)); }
  #chart-svg { height: clamp(520px, 62dvh, 680px); }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .chart-top { min-height: 31px; }
}
@media (max-width: 700px) {
  html, body { height: 100%; overflow: hidden; }
  .page { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .hero { align-items: center; gap: 8px; flex: none; margin-bottom: 10px; }
  .hero h1 { margin-top: 0; font-size: clamp(25px, 7.4vw, 31px); white-space: nowrap; }
  .location-picker { gap: 4px; max-width: min(38vw, 160px); }
  .location-picker::after { right: 2px; width: 6px; height: 6px; }
  .update-indicator { font-size: clamp(25px, 7.4vw, 31px); }
  .location-picker select { height: 32px; padding-right: 16px; font-size: 11px; }
  .visualization { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  .home-slot, .state-slot { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  .chart-top { flex: none; min-height: 31px; margin-bottom: 2px; }
  .series-key { gap: 4px 12px; font-size: 9px; }
  .chart-wrap { flex: 1; min-height: 0; width: calc(100% + 12px); margin-left: -6px; }
  #chart-svg { height: 100%; touch-action: none; }
  .scoreboard { flex: none; margin-top: 7px; padding-top: 8px; }
  .scoreboard-label { font-size: 9px; }
  .candidate-rows { grid-template-columns: 1fr; gap: 5px; margin-top: 7px; }
  .prediction-candidate { gap: 10px; }
  .prediction-identity { gap: 2px; }
  .prediction-primary .candidate-photo { width: 44px; height: 44px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--candidate-color) 12%, transparent); }
  .prediction-primary .prediction-name { font-size: 15px; }
  .prediction-primary .prediction-value strong { font-size: 29px; }
  .prediction-secondary { padding: 0; border: 0; }
  .prediction-secondary .candidate-photo { width: 26px; height: 26px; margin: 0 9px; }
  .prediction-secondary .prediction-name { font-size: 12px; }
  .prediction-secondary .prediction-value strong { font-size: 18px; }
  .prediction-secondary .prediction-value span { display: none; }
  .prediction-eyebrow { font-size: 8px; }
  .prediction-value span { font-size: 9px; }
  .forecast-note, .state-note { margin-top: 5px; font-size: 9px; }
  .home-page footer, .state-footer { flex: none; align-items: center; gap: 8px; margin-top: 9px; padding-top: 8px; font-size: 9px; white-space: nowrap; }
  .home-page .footer-actions { gap: 10px; }
  .tour-card { bottom: calc(10px + env(safe-area-inset-bottom)); padding: 12px; }
  .tour-card h2 { font-size: 17px; }
  .tour-card p { font-size: 11px; }
}
@media (max-width: 390px) {
  .prediction-eyebrow { line-height: 1.2; white-space: normal; }
}
@media (max-width: 350px) {
  .series-key { gap: 4px 7px; font-size: 8px; }
  .series-key span { gap: 4px; }
  .key-line { width: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
