:root {
  --bg: #111318;
  --surface: #171A22;
  --surface-2: #1E222D;
  --border: #262B36;
  --border-strong: #353C4B;
  --text: #F4F6F9;
  --muted: #8E97A8;
  --teal: #4EA8A2;
  --teal-soft: rgba(78, 168, 162, 0.14);
  --coral: #E06D53;
  --coral-soft: rgba(224, 109, 83, 0.15);
  --amber: #E5B567;
  --radius: 10px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="paper"] {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #EFECE5;
  --border: #DDD8CE;
  --border-strong: #C5BEB0;
  --text: #14171F;
  --muted: #5A6270;
  --teal: #2C7A75;
  --teal-soft: rgba(44, 122, 117, 0.12);
  --coral: #C44E36;
  --coral-soft: rgba(196, 78, 54, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(1240px, 100% - 32px);
  margin: 0 auto;
}

.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

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

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 600;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.masthead-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.live-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.btn:hover { border-color: var(--teal); }
.btn:active { transform: translateY(1px); }

.btn-teal {
  background: var(--teal);
  border-color: var(--teal);
  color: #0D1114;
}
.btn-teal:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-val.teal { color: var(--teal); }
.kpi-val.coral { color: var(--coral); }

.kpi-sub {
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Controls */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active {
  color: var(--text);
  background: var(--teal-soft);
  border-color: var(--teal);
}

.search-wrap {
  flex: 1 1 260px;
  max-width: 380px;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  outline: none;
}

.search-wrap input:focus { border-color: var(--teal); }

.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0 8px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}

.results-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.legend {
  display: inline-flex;
  gap: 14px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}
.swatch.teal { background: var(--teal); }
.swatch.coral { background: var(--coral); }

/* Cards */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 42px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s ease;
}

.card:hover { border-color: var(--border-strong); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
}

.badge.teal { color: var(--teal); border-color: var(--teal); background: var(--teal-soft); }
.badge.coral { color: var(--coral); border-color: var(--coral); background: var(--coral-soft); }

.score-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.card h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
  font-weight: 650;
}

.card h3 a {
  color: inherit;
  text-decoration: none;
}
.card h3 a:hover { color: var(--teal); }

.card-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Split Bar (Divisions) */
.split-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.split-numbers {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.split-numbers .aye { color: var(--teal); font-weight: 600; }
.split-numbers .no { color: var(--coral); font-weight: 600; }

.split-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
}

.split-bar .aye-seg { background: var(--teal); height: 100%; }
.split-bar .no-seg { background: var(--coral); height: 100%; }

.tellers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.party-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

/* Bill Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.step {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
}

.step.done .step-bar { background: var(--teal); opacity: 0.55; }
.step.current .step-bar { background: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }

.step-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.step.current .step-lbl { color: var(--text); font-weight: 600; }

/* Petition meter */
.meter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
}

.sig-count {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #6AD0C9);
  border-radius: 999px;
}

.card-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

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

.alert-banner {
  background: var(--coral-soft);
  border: 1px solid var(--coral);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}

.hidden { display: none !important; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 36px;
  color: var(--muted);
  font-size: 12.5px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.site-footer a { color: var(--teal); }
.mono { font-family: var(--font-mono); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 40;
}

.modal {
  width: min(640px, 100%);
  max-height: 82vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 4px 0 0; font-size: 1.15rem; }

.pub-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pub-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  color: var(--teal);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.about-body {
  padding-top: 12px;
  font-size: 13.5px;
  color: var(--muted);
}

.about-body p { margin: 0 0 12px; }
.about-body strong { color: var(--text); }
.about-body h4 {
  margin: 16px 0 8px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
}
.about-body ul {
  margin: 0 0 12px;
  padding-left: 18px;
}
.about-body li { margin-bottom: 6px; }
.about-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}
.about-body a:not(.btn) { color: var(--teal); }
.about-body a.btn { text-decoration: none; }
.about-body a.btn-teal { color: #0D1114; font-weight: 700; }
.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--teal);
  color: #0D1114;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
