:root {
  color-scheme: light;
  --ink: #0f1c1c;
  --muted: #556160;
  --paper: #f7f1e8;
  --sand: #f0dfc4;
  --sky: #d4eef0;
  --teal: #0f5b5f;
  --teal-dark: #0a3f42;
  --saffron: #e08b2c;
  --brick: #b84a35;
  --forest: #1f3d2b;
  --lime: #b9c66f;
  --white: #ffffff;
  --shadow: 0 14px 34px rgba(15, 28, 28, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Libre Franklin", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(circle at 15% 20%, rgba(15, 91, 95, 0.18), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(224, 139, 44, 0.2), transparent 42%),
    linear-gradient(120deg, #f6e9cf 0%, #f7f1e8 35%, #e8f2f2 100%),
    repeating-linear-gradient(45deg, rgba(15, 28, 28, 0.04) 0 1px, transparent 1px 9px);
  min-height: 100vh;
}

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

img {
  max-width: 100%;
  display: block;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 241, 232, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 28, 28, 0.08);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--teal), var(--forest));
  color: var(--white);
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 1px;
}

.brand-title {
  font-family: "Source Serif 4", serif;
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.nav-links {
  display: flex;
  gap: 18px;
  font-weight: 500;
  color: var(--muted);
}

.nav-links a {
  padding: 6px 10px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-links a:hover {
  background: rgba(15, 91, 95, 0.1);
  color: var(--teal-dark);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.live-pill {
  background: rgba(184, 74, 53, 0.12);
  color: var(--brick);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.ticker {
  border-top: 1px solid rgba(15, 28, 28, 0.06);
  border-bottom: 1px solid rgba(15, 28, 28, 0.08);
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.ticker-track {
  display: inline-flex;
  gap: 32px;
  white-space: nowrap;
  padding: 10px 0;
  animation: ticker 40s linear infinite;
}

.ticker-item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.ticker-item strong {
  color: var(--ink);
  font-weight: 600;
}

.ticker-sep {
  color: rgba(15, 28, 28, 0.3);
  padding: 0 12px;
}

@keyframes ticker {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

main {
  display: flex;
  flex-direction: column;
  gap: 80px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  padding: 70px 0 30px;
}

.hero-copy,
.hero-panel {
  animation: rise 0.8s ease both;
}

.hero-panel {
  animation-delay: 0.15s;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
  align-items: center;
}

.hero-copy h1 {
  font-family: "Source Serif 4", serif;
  font-size: clamp(2.6rem, 4vw, 3.8rem);
  line-height: 1.05;
  margin-bottom: 18px;
}

.hero-subtext {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 22px;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--teal-dark);
  margin-bottom: 12px;
  font-weight: 600;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.btn {
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: var(--teal);
  color: var(--white);
  box-shadow: var(--shadow);
}

.btn.ghost {
  background: transparent;
  border-color: rgba(15, 28, 28, 0.2);
  color: var(--teal-dark);
}

.btn:hover {
  transform: translateY(-2px);
}

.hero-highlights {
  display: grid;
  gap: 12px;
}

.highlight-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 18px;
}

.panel-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 28, 28, 0.08);
}

.panel-title {
  font-weight: 600;
  margin-bottom: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.metric {
  padding: 12px;
  border-radius: 16px;
  background: rgba(212, 238, 240, 0.5);
}

.metric-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.coalition {
  display: grid;
  gap: 10px;
}

.coalition-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(240, 223, 196, 0.6);
  font-weight: 600;
}

.section {
  padding: 20px 0;
  animation: rise 0.8s ease both;
}

main > section:nth-of-type(2) {
  animation-delay: 0.1s;
}

main > section:nth-of-type(3) {
  animation-delay: 0.18s;
}

main > section:nth-of-type(4) {
  animation-delay: 0.26s;
}

main > section:nth-of-type(5) {
  animation-delay: 0.34s;
}

main > section:nth-of-type(6) {
  animation-delay: 0.42s;
}

.section-grid {
  display: grid;
  gap: 28px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-head h2 {
  font-family: "Source Serif 4", serif;
  font-size: clamp(1.8rem, 2.6vw, 2.4rem);
}

.legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(15, 28, 28, 0.08);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 22px;
}

.map-spotlight .wrap {
  max-width: 1280px;
}

.map-spotlight .section-head h2 {
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.map-spotlight .map-layout {
  grid-template-columns: minmax(0, 1.8fr) minmax(240px, 0.6fr);
  align-items: stretch;
}

.map-spotlight .map-card {
  min-height: 460px;
}

.map-spotlight .map-canvas {
  height: clamp(360px, 60vh, 560px);
}

.map-card {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 28, 28, 0.08);
  background: rgba(255, 255, 255, 0.9);
}

.map-canvas {
  height: 340px;
  transition: opacity 0.3s ease;
}

#map-canvas .leaflet-tile-pane {
  filter: grayscale(1) contrast(1.05) brightness(1.05);
  -webkit-filter: grayscale(1) contrast(1.05) brightness(1.05);
}

.map-overlay {
  position: absolute;
  left: 18px;
  bottom: 74px;
  background: rgba(255, 255, 255, 0.85);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 28, 28, 0.08);
  font-size: 0.85rem;
  max-width: 220px;
  z-index: 5;
}

.map-note {
  position: absolute;
  left: 18px;
  bottom: 18px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 28, 28, 0.08);
  font-size: 0.75rem;
  line-height: 1.4;
  max-width: 260px;
  color: var(--muted);
  display: block;
  box-shadow: 0 8px 18px rgba(15, 28, 28, 0.12);
  z-index: 6;
}

.map-note.leaflet-control {
  position: relative;
  left: auto;
  bottom: auto;
  margin: 0 0 12px 12px;
  z-index: 500;
}

.side-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 28, 28, 0.08);
}

.side-panel h3 {
  font-family: "Source Serif 4", serif;
  font-size: 1.4rem;
}

.side-metric {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 28, 28, 0.08);
}

.side-metric:last-child {
  border-bottom: none;
}

.view-toggle,
.filter-toggle,
.year-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 28, 28, 0.2);
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.toggle.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.swing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.swing-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.swing-province-grid {
  display: grid;
  gap: 12px;
}

.province-swing-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.province-name {
  font-weight: 700;
}

.swing-row {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
}

.swing-row span:last-child {
  color: var(--teal-dark);
}

.swing-row.loss span:last-child {
  color: var(--brick);
}

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

.table-title {
  font-weight: 700;
}

.table-note {
  font-size: 0.85rem;
  color: var(--muted);
}

.table-footer {
  display: flex;
  justify-content: center;
  padding: 16px;
}

.load-more {
  font-size: 0.95rem;
}

.is-hidden {
  display: none;
}


.swing-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.swing-table th,
.swing-table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.95rem;
}

.swing-table thead {
  background: rgba(212, 238, 240, 0.5);
}

.swing-table tbody tr {
  border-top: 1px solid rgba(15, 28, 28, 0.08);
}

.chart-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 28, 28, 0.08);
}

.chart-title {
  font-weight: 600;
  margin-bottom: 14px;
}

.party-list {
  display: grid;
  gap: 12px;
}

.party-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(212, 238, 240, 0.35);
}

.party-name {
  font-weight: 600;
}

.party-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.party-pill {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--white);
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
}

.table-card {
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
}

.district-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.district-table th,
.district-table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.95rem;
}

.district-table thead {
  background: rgba(212, 238, 240, 0.5);
}

.district-table tbody tr {
  border-top: 1px solid rgba(15, 28, 28, 0.08);
}

.counted-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 28, 28, 0.1);
  overflow: hidden;
}

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

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box input {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 28, 28, 0.2);
  font-size: 0.95rem;
  min-width: 200px;
}

.search-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.news-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 28, 28, 0.08);
  display: grid;
  gap: 12px;
}

.news-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--teal-dark);
}

.news-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.news-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.social-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.social-feed {
  display: grid;
  gap: 14px;
}

.social-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
}

.social-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.social-body {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.social-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
}

.fact-card {
  padding: 20px;
  border-radius: 20px;
  background: rgba(240, 223, 196, 0.75);
  border: 1px solid rgba(15, 28, 28, 0.1);
  display: grid;
  gap: 12px;
  align-content: start;
}

.fact-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.pulse-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brick);
  box-shadow: 0 0 10px rgba(184, 74, 53, 0.7);
  animation: pulse 1.6s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.method-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
  line-height: 1.5;
  color: var(--muted);
}

.admin-status {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(15, 28, 28, 0.08);
}

.admin-status[data-tone="ok"] {
  background: rgba(15, 91, 95, 0.12);
  color: var(--teal-dark);
}

.admin-status[data-tone="warn"] {
  background: rgba(224, 139, 44, 0.18);
  color: #9b5b10;
}

.admin-status[data-tone="error"] {
  background: rgba(184, 74, 53, 0.18);
  color: var(--brick);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
}

.admin-card {
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 28, 28, 0.08);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.admin-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.admin-subtext {
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-field input {
  border-radius: 14px;
  border: 1px solid rgba(15, 28, 28, 0.16);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-input {
  display: none;
}

.file-pill {
  cursor: pointer;
}

.admin-textarea {
  width: 100%;
  min-height: 260px;
  border-radius: 16px;
  border: 1px solid rgba(15, 28, 28, 0.14);
  padding: 12px;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-message,
.admin-meta {
  min-height: 18px;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-message[data-tone="ok"] {
  color: var(--teal-dark);
}

.admin-message[data-tone="error"] {
  color: var(--brick);
}

.admin-meta[data-tone="ok"] {
  color: var(--teal-dark);
}

.admin-meta[data-tone="error"] {
  color: var(--brick);
}

.site-footer {
  margin-top: 60px;
  padding: 40px 0 60px;
  border-top: 1px solid rgba(15, 28, 28, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  color: var(--muted);
}

.footer-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

@media (max-width: 960px) {
  .nav-links {
    display: none;
  }

  .map-layout,
  .social-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .map-spotlight .map-canvas {
    height: clamp(320px, 55vh, 480px);
  }
}

@media (max-width: 640px) {
  .nav-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-head {
    align-items: flex-start;
  }

  .map-canvas {
    height: 260px;
  }

  .map-spotlight .map-canvas {
    height: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
