/* Texas Polls Tracker — visual system
   Type: Archivo (variable width/weight) for nameplate, headings, figures and tables; Source Serif 4 for running text.
   Chrome is neutral so the data colors (blue D, red R, gray tossup) carry meaning. */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,400..800&family=Source+Serif+4:ital,opsz,wght@0,8..60,400..600;1,8..60,400&display=swap");

:root {
  --paper: #ffffff; --ink: #22252a; --ink-2: #5d626b; --ink-3: #8a8f98; --rule: #d9dce1; --rule-soft: #eceef1; --wash: #f4f5f7;
  --d4: #1e3a8a; --d3: #2563eb; --d2: #60a5fa; --d1: #bfdbfe; --toss: #8b8b8b; --r1: #fecaca; --r2: #f87171; --r3: #c01818; --r4: #6b1010;
  --d-held: #dbeafe; --r-held: #fee2e2; --notup: #ededeb;
  --to-d: #1d4ed8; --to-r: #b91c1c;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --measure: 68ch;
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
a { color: inherit; text-decoration-color: var(--ink-3); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
p.note, .meta, .foot, .sources, .seat-note, .moves-list { font-family: var(--serif); }

/* ---- masthead & hero board ---- */
.masthead { padding: 34px 20px 0; }
.masthead .top { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.masthead h1 { margin: 0; font-size: clamp(28px, 4.6vw, 46px); font-weight: 800; font-stretch: 112%; letter-spacing: -0.02em; line-height: 1; }
.masthead .dek { margin: 10px 0 0; font-family: var(--serif); font-size: 17px; color: var(--ink-2); max-width: var(--measure); }
.asof { margin: 6px 0 0; color: var(--ink-3); font-size: 13.5px; font-family: var(--serif); }
.segmented { display: inline-flex; border: 1px solid var(--ink); border-radius: 6px; padding: 2px; background: var(--paper); }
.segmented button { font: inherit; font-size: 13.5px; font-weight: 600; border: 0; background: transparent; color: var(--ink); padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.segmented button.active { background: var(--ink); color: var(--paper); }
.segmented-label { font-size: 13px; color: var(--ink-2); margin-right: 8px; }
.board { border-top: 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.board { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.board .lead { padding: 18px 22px 18px 0; border-right: 1px solid var(--rule); }
.board .lead:last-child { border-right: 0; padding-right: 0; }
.board .lead + .lead { padding-left: 22px; }
.board .race { font-size: 13.5px; color: var(--ink-2); margin: 0 0 6px; }
.board .race b { color: var(--ink); font-weight: 600; }
.board .big { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-stretch: 105%; }
.board .big small { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-top: 4px; font-stretch: 100%; line-height: 1.3; }
.board .big .delta { display: inline-block; margin-left: 8px; vertical-align: 6px; }
.split { display: flex; height: 12px; margin: 10px 0 6px; background: var(--wash); border-radius: 2px; overflow: hidden; }
.split .d { background: var(--d3); } .split .r { background: var(--r3); } .split .i { background: var(--toss); }
.split .d, .split .r, .split .i { height: 100%; }
.board .sub { font-family: var(--serif); font-size: 13.5px; color: var(--ink-2); margin: 0; }
.board .sub b { color: var(--ink); font-weight: 600; }

/* ---- vote panel ---- */
.vote-button { font: inherit; font-size: 13.5px; font-weight: 700; border: 2px solid var(--ink); background: var(--ink); color: var(--paper); border-radius: 6px; padding: 7px 14px; cursor: pointer; margin-right: 18px; }
.vote-button:hover { background: var(--paper); color: var(--ink); }
.vote-strip { margin-top: 18px; padding: 10px 14px; border: 1px solid var(--ink); border-left-width: 6px; font-family: var(--serif); font-size: 15px; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.vote-strip b { font-family: var(--sans); }
.vote-strip button { font: inherit; font-family: var(--sans); font-size: 13px; font-weight: 600; border: 1px solid var(--ink); background: var(--paper); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.vote-dialog { border: 2px solid var(--ink); border-radius: 8px; padding: 26px 28px 22px; max-width: 860px; width: calc(100% - 32px); color: var(--ink); background: var(--paper); font-family: var(--sans); }
.vote-dialog::backdrop { background: rgba(34, 37, 42, 0.55); }
.vote-dialog h2 { border: 0; padding: 0; margin: 0 0 8px; font-size: 32px; font-stretch: 110%; }
.vote-dialog h3 { margin: 14px 0 8px; font-size: 15px; }
.vote-lede { font-family: var(--serif); font-size: 17px; line-height: 1.5; margin: 0 0 10px; max-width: 70ch; }
.vote-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px 32px; }
.vote-dates { list-style: none; padding: 0; margin: 0; }
.vote-dates li { padding: 7px 0; border-top: 1px solid var(--rule-soft); display: grid; grid-template-columns: 1fr auto; gap: 10px; font-size: 14.5px; }
.vote-dates li:first-child { border-top: 0; }
.vote-dates .when { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.vote-dates li.past { color: var(--ink-3); text-decoration: line-through; }
.vote-dates li.today { font-weight: 700; }
.vote-find { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); }
.vote-select select { font: inherit; font-size: 13.5px; padding: 4px 6px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); max-width: 220px; }
.vote-card { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; font-size: 14px; min-height: 1.5em; }
.vote-card .county { font-weight: 700; font-size: 16px; }
.vote-card a { font-weight: 600; }
.vote-links { margin: 6px 0 0; padding-left: 18px; font-family: var(--serif); font-size: 14.5px; line-height: 1.5; }
.vote-small { font-family: var(--serif); font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }
.vote-close-form { float: right; margin: -6px -8px 0 0; }
.vote-close { font: inherit; font-size: 13px; border: 1px solid var(--rule); background: var(--paper); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.vote-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
@media (max-width: 700px) { .vote-grid { grid-template-columns: 1fr; } .vote-button { margin: 0 0 8px; } .vote-dialog h2 { font-size: 26px; } }

/* ---- tabs & panels ---- */
.tabs { position: sticky; top: 0; z-index: 5; background: var(--paper); display: flex; flex-wrap: wrap; gap: 0 2px; border-bottom: 2px solid var(--ink); margin-top: 22px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; text-decoration: none; padding: 12px 16px 10px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.panel { display: none; }
.panel.active { display: block; }
.panel section:first-child { margin-top: 32px; }
.board { margin-top: 28px; }

.control-strip { margin-top: 0; border-bottom: 1px solid var(--rule); }
.control-strip .figure .v { font-size: 26px; }
.tx-mark { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 5px; border: 1px solid var(--ink); border-radius: 3px; margin-left: 6px; vertical-align: 1px; }

.digest { font-family: var(--serif); max-width: 78ch; font-size: 16px; line-height: 1.55; }
.digest .headline { font-size: 19px; margin: 6px 0 18px; color: var(--ink); }
.digest h4 { font-family: var(--sans); font-size: 15px; margin: 18px 0 6px; font-weight: 600; }
.digest ul { margin: 0; padding-left: 20px; }
.digest li { margin: 4px 0; }
.digest-actions { display: flex; gap: 10px; align-items: center; margin: 6px 0 10px; font-size: 13px; }
.archive { list-style: none; padding: 0; margin: 0; max-width: 78ch; font-family: var(--serif); }
.archive li { padding: 8px 0; border-top: 1px solid var(--rule-soft); display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.archive li a { font-family: var(--sans); font-weight: 600; text-decoration: none; }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px 28px; margin: 12px 0 10px; }
.trend h4 { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; }
.trend .legend { margin: 2px 0 6px; }
.changelog-day { border-top: 1px solid var(--rule-soft); padding: 8px 0; }
.changelog-day .d { font-weight: 600; font-size: 14px; }
.changelog-day ul { margin: 4px 0 0; padding-left: 18px; font-family: var(--serif); }
.lean-d { color: var(--to-d); font-weight: 600; } .lean-r { color: var(--to-r); font-weight: 600; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 24px; margin: 8px 0 14px; align-items: end; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--ink-2); }
.controls output { font-weight: 600; color: var(--ink); font-size: 15px; }
.controls input[type="range"] { width: 100%; accent-color: var(--ink); }
.controls button { justify-self: start; }
.trend-title { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; }

/* ---- sections ---- */
main { padding-bottom: 48px; }
section { margin-top: 56px; }
h2 { margin: 0 0 14px; font-size: 26px; font-weight: 700; font-stretch: 108%; letter-spacing: -0.015em; padding-bottom: 8px; border-bottom: 1px solid var(--ink); }
h3 { margin: 28px 0 8px; font-size: 16px; font-weight: 600; color: var(--ink); }
.note { color: var(--ink-2); font-size: 14.5px; line-height: 1.55; margin: 6px 0 12px; max-width: var(--measure); }
.moves { margin-top: 34px; }
.moves h2 { border-bottom: 0; padding-bottom: 0; }
.moves-list { list-style: none; margin: 0; padding: 0; max-width: 900px; }
.moves-list li { padding: 9px 0; border-top: 1px solid var(--rule-soft); display: grid; grid-template-columns: 110px 1fr; gap: 14px; font-size: 15.5px; }
.moves-list li:first-child { border-top: 0; }
.moves-list .tag { font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); padding-top: 3px; display: flex; align-items: center; gap: 7px; }
.moves-list .tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.moves-list .tag.rating::before { background: #7c3aed; } .moves-list .tag.market::before { background: #0369a1; } .moves-list .tag.poll::before, .moves-list .tag.poll-average::before, .moves-list .tag.poll-model::before { background: #15803d; } .moves-list .tag.control::before { background: #b91c1c; }

/* ---- figures (stat strip) ---- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin: 6px 0 22px; border-bottom: 1px solid var(--rule); }
.figure { padding: 12px 18px 14px 0; border-right: 1px solid var(--rule); }
.figure + .figure { padding-left: 18px; }
.figure:last-child { border-right: 0; }
.figure .k { font-size: 13px; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; }
.figure .v.text { font-size: 20px; line-height: 1.2; margin-top: 8px; }
.figure .v { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; font-stretch: 104%; }
.figure .s { font-family: var(--serif); font-size: 12.5px; color: var(--ink-3); margin-top: 4px; line-height: 1.35; }
.figure.primary .v { color: var(--ink); } .figure.primary .k { color: var(--ink); font-weight: 600; }
.delta { font-size: 12px; font-weight: 600; margin-left: 6px; font-stretch: 100%; letter-spacing: 0; }
.delta.to-d { color: var(--to-d); } .delta.to-r { color: var(--to-r); } .delta.flat { color: var(--ink-3); font-weight: 400; }

/* ---- charts & maps ---- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.chart { width: 100%; min-height: 220px; }
.chart.chart-small { min-height: 160px; max-width: 760px; }
.zoom-controls { margin-left: auto; display: inline-flex; gap: 4px; }
.zoom-controls button { min-width: 32px; }
.map.zoomable { border: 1px solid var(--rule-soft); overflow: hidden; touch-action: none; cursor: grab; }
.map.zoomable:active { cursor: grabbing; }
.hint { font-size: 13px; color: var(--ink-3); }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid line { stroke: var(--rule-soft); }
.chart .axis text { fill: var(--ink-2); font-size: 11.5px; font-family: var(--sans); }
.chart .axis path, .chart .axis line { stroke: var(--rule); }
.chart .bar { shape-rendering: crispEdges; }
.chart .label { fill: var(--ink-2); font-size: 11.5px; font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); margin: 6px 0 10px; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.12); }
table.data .sw { width: 11px; height: 11px; margin-right: 2px; }
.map { width: 100%; }
.map svg { display: block; width: 100%; height: auto; }
.map path { stroke: #fff; stroke-width: 0.8; cursor: default; }
.map path.rated { stroke: #333; stroke-width: 0.9; }
.map path:hover { opacity: .78; }
.map text.state-label { font-size: 9px; fill: var(--ink); pointer-events: none; font-weight: 600; font-family: var(--sans); }
.mode-row { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); margin: 8px 0; flex-wrap: wrap; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 8px 8px 8px 0; border-top: 1px solid var(--rule-soft); vertical-align: top; white-space: nowrap; }
table.data th { font-size: 12.5px; color: var(--ink-2); font-weight: 500; border-top: 0; border-bottom: 1px solid var(--rule); padding-top: 0; }
table.data th .sub { display: block; color: var(--ink-3); font-weight: 400; }
table.data td.num, table.data th.num { text-align: right; padding-right: 10px; }
table.data td.wrap { white-space: normal; min-width: 150px; }
table.data td.ratings-cell { white-space: normal; min-width: 72px; max-width: 80px; line-height: 1.3; }
.pill { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 12px; font-weight: 600; border: 1px solid rgba(0,0,0,.08); }
.pill.lightink { color: #fff; }
.thin { color: var(--ink-3); font-size: 11.5px; margin-left: 4px; font-weight: 400; }
.muted { color: var(--ink-3); }
button.mode { font: inherit; font-size: 13px; border: 1px solid var(--rule); background: var(--paper); border-radius: 4px; padding: 4px 10px; cursor: pointer; color: var(--ink); }
button.mode.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; margin: 10px 0 6px; }
.race-card { border-top: 1px solid var(--rule-soft); padding: 12px 0; }
.race-card .meta { font-size: 14px; color: var(--ink-2); max-width: none; }
.spark { vertical-align: middle; margin-left: 6px; }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: #fff; padding: 8px 10px; border-radius: 4px; font-size: 12.5px; line-height: 1.35; max-width: 320px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-family: var(--sans); }
.tooltip b { font-weight: 600; }
.tooltip .row { display: flex; justify-content: space-between; gap: 12px; }
.tooltip hr { border: 0; border-top: 1px solid rgba(255,255,255,.2); margin: 5px 0; }
.sources { margin: 0; padding-left: 18px; font-size: 14.5px; color: var(--ink-2); }
.sources li { margin: 2px 0; }
.foot { color: var(--ink-3); font-size: 13px; padding: 14px 20px 36px; border-top: 1px solid var(--rule); margin-top: 48px; }
@media (max-width: 640px) {
  body { font-size: 14px; }
  .board .lead { border-right: 0; border-bottom: 1px solid var(--rule); padding: 14px 0; }
  .board .lead + .lead { padding-left: 0; }
  .figure { border-right: 0; border-bottom: 1px solid var(--rule-soft); padding-left: 0 !important; }
  .figure .k { min-height: 0; }
  .moves-list li { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: no-preference) { .segmented button, button.mode { transition: background-color .15s, color .15s; } }
