:root {
  --bg: #f2c49a;
  --bg-soft: rgba(247, 231, 212, 0.9);
  --panel: rgba(252, 244, 234, 0.94);
  --panel-strong: rgba(255, 248, 241, 0.98);
  --line: rgba(116, 92, 61, 0.18);
  --text: #241811;
  --muted: #665244;
  --blue: #53b3ff;
  --amber: #c98642;
  --green: #2f8a67;
  --red: #b24d55;
  --shadow: 0 24px 80px rgba(115, 74, 30, 0.14);
  --radius: 24px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "IBM Plex Sans", "Avenir Next", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(83, 179, 255, 0.1), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(201, 134, 66, 0.18), transparent 26%),
    linear-gradient(180deg, #f3c89f 0%, #efbe92 54%, #e8b283 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 28px;
  background: rgba(249, 239, 228, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-weight: 700;
  color: #fffaf4;
  background: linear-gradient(135deg, var(--blue), #96d5ff);
}

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

.topnav a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.topnav a:hover,
.topnav a.active {
  color: var(--text);
  background: rgba(83, 179, 255, 0.12);
  transform: translateY(-1px);
}

main {
  display: grid;
  gap: 28px;
}

.view {
  display: none;
  gap: 24px;
}

.view.active {
  display: grid;
}

.panel {
  position: relative;
  padding: 24px;
  background: linear-gradient(180deg, rgba(252, 245, 237, 0.96), rgba(246, 234, 221, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 134, 66, 0.3), transparent);
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: #7b5127;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.4rem, 5vw, 4.9rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

h3 {
  margin-bottom: 10px;
  font-size: 1.15rem;
}

.hero-subtitle {
  max-width: 18ch;
  margin-bottom: 12px;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  color: #1b120d;
}

.hero-detail,
.summary-item p,
.explainer-card p,
.prose-panel p,
.proof-meta p,
.status-note {
  color: var(--muted);
  line-height: 1.6;
}

.hero-stats,
.metric-strip,
.grid,
.stack,
.counter-result,
.signal-log {
  display: grid;
  gap: 14px;
}

.source-panel {
  display: grid;
  gap: 14px;
}

.hero-stats {
  align-content: start;
}

.stat-card,
.summary-item,
.district-card,
.signal-card,
.rollup-card,
.candidate-card,
.rule-card {
  padding: 18px;
  border: 1px solid rgba(116, 92, 61, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
}

.stat-card strong,
.summary-item strong,
.district-card strong,
.rollup-card strong,
.candidate-card strong {
  display: block;
  font-size: 1.45rem;
  margin-bottom: 6px;
}

.grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.counter-grid {
  grid-template-columns: 0.9fr 1.1fr;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading.wide,
.section-heading.tight {
  margin-bottom: 0;
}

.panel-link {
  align-self: center;
  color: var(--blue);
}

.verify-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
}

.verify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.button:hover,
.proof-chip:hover,
.drawer-close:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: #fdf8f2;
  background: linear-gradient(135deg, var(--blue), #8bd0ff);
}

.button.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.3);
  border-color: var(--line);
}

.summary-item,
.district-card,
.signal-card,
.rollup-card,
.candidate-card {
  display: grid;
  gap: 8px;
}

.summary-inline,
.district-meta,
.signal-meta,
.result-badges,
.rollup-meta,
.candidate-meta,
.proof-meta,
.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  border: 1px solid rgba(116, 92, 61, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.32);
}

.pill.blue {
  color: #184567;
  border-color: rgba(83, 179, 255, 0.4);
  background: rgba(83, 179, 255, 0.12);
}

.pill.amber {
  color: #70431b;
  border-color: rgba(201, 134, 66, 0.36);
  background: rgba(201, 134, 66, 0.14);
}

.pill.green {
  color: #18533b;
  border-color: rgba(47, 138, 103, 0.32);
  background: rgba(47, 138, 103, 0.12);
}

.pill.red {
  color: #7c2c33;
  border-color: rgba(178, 77, 85, 0.32);
  background: rgba(178, 77, 85, 0.11);
}

.select-wrap,
.counter-form label {
  display: grid;
  gap: 8px;
}

.select-wrap span,
.counter-form span {
  color: var(--muted);
  font-size: 0.92rem;
}

select,
input {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 251, 247, 0.76);
  border: 1px solid rgba(116, 92, 61, 0.2);
  border-radius: 14px;
}

.counter-form {
  display: grid;
  gap: 16px;
}

.status-banner {
  min-height: 52px;
  margin: 18px 0;
}

.status-highlight {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(116, 92, 61, 0.16);
  background: rgba(255, 255, 255, 0.34);
}

.signal-card button,
.district-card button,
.rollup-card button,
.candidate-card button {
  justify-self: start;
}

.proof-chip,
.drawer-close {
  padding: 9px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.proof-drawer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.proof-drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(57, 34, 15, 0.28);
  opacity: 0;
  transition: opacity 180ms ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100%;
  padding: 24px;
  overflow-y: auto;
  background: var(--panel-strong);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 220ms ease;
}

.proof-drawer.open .drawer-backdrop {
  opacity: 1;
}

.proof-drawer.open .drawer-panel {
  transform: translateX(0);
}

.proof-json {
  padding: 16px;
  overflow-x: auto;
  border-radius: 18px;
  background: #201712;
  border: 1px solid rgba(116, 92, 61, 0.18);
}

.proof-json code {
  white-space: pre-wrap;
  color: #f5e7db;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  padding: 24px 6px 0;
  color: var(--muted);
}

.prose-panel {
  max-width: 76ch;
}

.rules-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .hero,
  .grid.two-up,
  .grid.three-up,
  .counter-grid,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    border-radius: 28px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 24px, 1240px);
    padding-top: 12px;
  }

  .topbar {
    position: static;
    padding: 16px;
  }

  .panel,
  .hero {
    padding: 20px;
  }

  h1 {
    font-size: clamp(2.1rem, 12vw, 3.1rem);
  }
}
