:root {
  --paper: #f5f3ee;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #55565b;
  --ink-faint: #6b6c71;
  --line: #e1ded6;
  --democrat: #3667b0;
  --democrat-light: #dbe5f4;
  --republican: #c3423a;
  --republican-light: #f6dcd9;
  --independent: #7a5ba6;
  --independent-light: #e8e0f2;
  --vacant: #cfccc4;
  --focus: #e08a1e;
  --radius: 10px;
  --panel-width: 400px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }
a { color: inherit; text-decoration-color: rgba(0, 0, 0, 0.3); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.subtitle { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); max-width: 60ch; }
.controls { display: flex; align-items: center; gap: 12px; }

.segmented { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.segmented.small button { font-size: 12px; padding: 5px 10px; }

.search { position: relative; }
.search input {
  width: 280px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); font: inherit; font-size: 14px;
}
#search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 320px; max-height: 360px; overflow: auto;
  list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); z-index: 30;
}
#search-results li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--paper); outline: 2px solid var(--ink); outline-offset: -2px; }
#search-results .result-seat { color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.map-area { position: relative; flex: 1; min-width: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--ink-soft); }

#map .seat { stroke: #fff; stroke-width: 0.6; vector-effect: non-scaling-stroke; cursor: pointer; transition: opacity 120ms; }
#map .seat:hover { opacity: 0.82; }
#map .state-lines { fill: none; stroke: #fff; stroke-width: 1.8; vector-effect: non-scaling-stroke; pointer-events: none; }
#map .selected-outline { fill: none; stroke: var(--ink); stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
#map.dimmed .seat:not(.match) { opacity: 0.25; }

.map-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.map-tools > * { pointer-events: auto; }
.map-tools .segmented { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
.zoom-buttons { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
.zoom-buttons button { width: 36px; height: 36px; border: 0; background: transparent; font-size: 18px; }
.zoom-buttons button + button { border-top: 1px solid var(--line); }

.legend {
  position: absolute; left: 12px; bottom: 12px; background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; font-size: 12px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: calc(100% - 24px);
}
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45); }

.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 13px; padding: 6px 9px;
  border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); z-index: 20;
}
.tooltip .tooltip-seat { color: #c9c9cf; }

/* Panel */
.panel { width: var(--panel-width); flex-shrink: 0; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); }
.sheet-handle { display: none; }
#panel-content { padding: 20px 20px 40px; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 4px; }
.member-name { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.member-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 14px; color: var(--ink-soft); }
.party-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.party-chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--party-color, var(--vacant)); }

.back-link { border: 0; background: none; padding: 6px 0; min-height: 24px; color: var(--ink-soft); font-size: 13px; margin-bottom: 12px; }
.back-link:hover { color: var(--ink); }

.section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.section h3 { font-size: 16px; margin: 0; }
.section p { font-size: 14px; line-height: 1.5; margin: 0 0 10px; color: var(--ink-soft); }
.source { font-size: 12px; color: var(--ink-faint); margin-top: 10px; line-height: 1.5; }
.source a { color: var(--ink-soft); }

.button-link {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; font-weight: 600; font-size: 14px; background: var(--paper);
}
.button-link:hover { border-color: var(--ink-faint); }
.button-link .arrow { color: var(--ink-faint); }

.donor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.donor-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.donor-name { font-weight: 600; }
.donor-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.donor-kind { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.donor-bar { height: 6px; border-radius: 3px; background: var(--paper); margin-top: 6px; overflow: hidden; }
.donor-bar span { display: block; height: 100%; background: var(--party-color, var(--ink-soft)); border-radius: 3px; }

.filer-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.filer-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 8px 10px; border-radius: 8px; background: var(--paper); }
.filer-list li.same-party { background: #fdf1e0; }
.filer-tag { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.deadline-box { font-size: 14px; padding: 10px 12px; border-radius: 8px; border: 1px dashed var(--line); margin: 10px 0; }
.deadline-box strong { font-variant-numeric: tabular-nums; }

.senator + .senator { margin-top: 34px; padding-top: 24px; border-top: 3px solid var(--paper); }

/* Overview list */
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li button {
  width: 100%; border: 0; background: none; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 9px 8px; border-radius: 8px; font-size: 14px;
}
.member-list li button:hover { background: var(--paper); }
.member-list .list-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.member-list .list-name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--party-color); flex-shrink: 0; }
.member-list .list-detail { grid-column: 1; font-size: 12px; color: var(--ink-faint); }
.member-list .list-years { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); }
.flag { color: #8a5208; font-weight: 600; }

/* Phone and narrow tablet */
@media (max-width: 760px) {
  .top-bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 12px; }
  h1 { font-size: 18px; }
  .subtitle { display: none; }
  .controls { justify-content: space-between; }
  .search { flex: 1; }
  .search input { width: 100%; }
  #search-results { width: 100%; left: 0; }
  .layout { flex-direction: column; }
  .map-area { flex: 1; }
  .map-tools { top: 8px; left: 8px; right: 8px; }
  .legend { bottom: auto; top: 54px; left: 8px; font-size: 11px; padding: 6px 8px; max-width: calc(100% - 64px); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 38vh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12); transition: height 200ms ease; z-index: 25;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.expanded { height: 82vh; }
  .sheet-handle { display: block; position: sticky; top: 0; width: 100%; height: 28px; border: 0; background: var(--surface); z-index: 2; }
  .sheet-handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
  #panel-content { padding: 4px 16px 32px; }
  .map-area { padding-bottom: 38vh; }
}

.chip { min-height: 32px; }
.button-link .new-tab, .new-tab { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.search input::placeholder { color: #6b6c71; opacity: 1; }

/* Section headings carry their source on the right, so the body stays clean. */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.source-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 0; text-align: right; }
.source-tag { font-size: 12px; color: var(--ink-faint); white-space: nowrap; display: inline-block; min-height: 24px; line-height: 24px; }
.source-tag:hover { color: var(--ink); }
.note { font-size: 12px !important; color: var(--ink-faint) !important; line-height: 1.5; margin: 10px 0 0 !important; }
.list-label { font-size: 13px !important; font-weight: 600; color: var(--ink) !important; margin: 14px 0 6px !important; }
.deadline { color: var(--ink) !important; }

.member-line { margin: 6px 0 0; font-size: 15px; color: var(--ink-soft); }
.member-line strong { color: var(--ink); }
.member-line .party-chip { font-weight: 600; }
.member-links a { display: inline-block; min-height: 24px; line-height: 24px; }
.member-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin: 12px 0 0; font-size: 13px; }

/* Senate: one senator at a time, with both names up top. */
.senator-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin: 4px 0 18px; }
.senator-tabs button {
  border: 0; background: none; text-align: left; padding: 8px 4px 10px; border-bottom: 3px solid transparent; margin-bottom: -1px;
  display: flex; flex-direction: column; gap: 2px; min-height: 44px;
}
.senator-tabs button[aria-selected="true"] { border-bottom-color: var(--party-color); }
.senator-tabs .tab-name { font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.senator-tabs button[aria-selected="true"] .tab-name { color: var(--ink); }
.senator-tabs .tab-detail { font-size: 12px; color: var(--ink-faint); }

/* What you can do */
.action-section h3 { font-size: 18px; margin: 0 0 14px; }
.action-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 22px; }
.action-steps > li { counter-increment: step; position: relative; padding-left: 40px; }
.action-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
.action-steps h4 { font-size: 15px; margin: 0 0 4px; }
.action-steps p { margin: 0 0 8px; }
.action-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; font-weight: 600; }
.action-links a { display: inline-block; min-height: 24px; line-height: 24px; color: var(--ink); }
.organization-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.organization-list li { font-size: 14px; display: grid; gap: 1px; }
.organization-list a { font-weight: 600; display: inline-block; min-height: 24px; line-height: 24px; }
.organization-list span { font-size: 13px; color: var(--ink-soft); }

/* Section tabs */
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  text-decoration: none; font-size: 14px; font-weight: 600; color: var(--ink-soft); padding: 8px 10px;
  border-bottom: 3px solid transparent; min-height: 24px;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.top-bar { flex-wrap: wrap; }
.site-name { margin: 0; font-size: 20px; font-weight: 700; }
.site-name a { text-decoration: none; }

/* Article pages */
body.page { display: block; overflow: auto; height: auto; }
.article { max-width: 680px; margin: 0 auto; padding: 40px 20px 80px; }
.article h1 { font-size: 34px; letter-spacing: -0.02em; margin: 0 0 12px; }
.article .lede { font-size: 18px; line-height: 1.55; color: var(--ink-soft); margin: 0 0 36px; }
.article p { font-size: 16px; line-height: 1.65; margin: 0 0 12px; }
.article .source { font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 3px solid var(--line); }
.timeline > li { position: relative; padding: 0 0 36px 28px; }
.timeline > li::before { content: ""; position: absolute; left: -12px; top: 4px; width: 15px; height: 15px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); }
.timeline .year { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-faint); margin: 0 0 2px; }
.timeline h2 { font-size: 22px; margin: 0 0 8px; }
.so-what { border-left: 3px solid #e3913a; padding-left: 12px; color: var(--ink); font-weight: 500; }
.glossary { margin: 0; }
.glossary dt { font-size: 20px; font-weight: 700; margin: 32px 0 6px; scroll-margin-top: 20px; }
.glossary dd { margin: 0; }
.next-step { margin-top: 48px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.next-step h2 { font-size: 20px; margin: 0 0 8px; }
.next-step .button-link { margin-top: 12px; }

@media (max-width: 760px) {
  .site-nav { order: 3; width: 100%; overflow-x: auto; }
  .site-nav a { white-space: nowrap; padding: 6px 8px; }
  .article { padding-top: 24px; }
  .article h1 { font-size: 28px; }
}
.organization-list .listed-by { font-size: 12px; color: var(--ink-faint); font-weight: 400; display: inline; min-height: 0; line-height: inherit; white-space: nowrap; }
.action-steps .list-label:first-of-type { margin-top: 4px !important; }
