/* ==================== MULTI-YEAR ELECTION SWITCHER & HISTORY VIEWS (1994–2026) ==================== */

.cycle-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 4px;
}

.cycle-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #F4F7FA;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.cycle-trigger:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.28);
}
body.is-history-year .cycle-trigger {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.45);
  color: #7DF9FF;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}
.cycle-trigger .ct-yr {
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
}
.cycle-trigger .ct-caret {
  font-size: 10px;
  opacity: 0.7;
}

.cycle-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 348px;
  max-height: 76vh;
  overflow-y: auto;
  background: #11141B;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.72);
  padding: 8px;
  z-index: 2600;
}
.cycle-dropdown.hidden { display: none; }

.cd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}
.cd-head-title {
  font-size: 12px;
  font-weight: 700;
  color: #CBD5E1;
}
.cd-head-sub {
  font-size: 11px;
  color: #64748B;
  font-family: "JetBrains Mono", monospace;
}

.cd-filter-row {
  display: flex;
  gap: 4px;
  padding: 2px 4px 8px;
  flex-wrap: wrap;
}
.cd-fbtn {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #94A3B8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.cd-fbtn.active {
  background: rgba(255, 255, 255, 0.14);
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.28);
}

.cd-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: #E2E8F0;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cd-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.cd-item.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.35);
}
.cd-item-l {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cd-yr {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 800;
  color: #FFF;
  width: 42px;
  flex-shrink: 0;
}
.cd-lbl-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cd-lbl {
  font-size: 12.5px;
  font-weight: 700;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cd-meta {
  font-size: 11px;
  color: #94A3B8;
}
.cd-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}
.cd-badge.t-national { background: rgba(59, 130, 246, 0.2); color: #93C5FD; }
.cd-badge.t-local { background: rgba(0, 245, 155, 0.16); color: #6EE7B7; }
.cd-badge.t-mixed { background: rgba(168, 85, 247, 0.2); color: #D8B4FE; }
.cd-badge.t-special { background: rgba(245, 158, 11, 0.2); color: #FCD34D; }

/* Hide 2026 live panels when viewing a historical year, showing #hist-stage instead */
body.is-history-year .view-panel { display: none !important; }
#hist-stage {
  display: none;
  max-width: 1380px;
  margin: 0 auto;
  padding: 18px 20px 64px;
}
body.is-history-year #hist-stage { display: block; }

.hist-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.08), rgba(43, 110, 242, 0.08));
  border: 1px solid rgba(0, 240, 255, 0.22);
}
.hist-banner-l {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hist-pill-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.16);
  color: #67E8F9;
  border: 1px solid rgba(0, 240, 255, 0.3);
}
.hist-banner-title {
  font-size: 16px;
  font-weight: 900;
  color: #F8FAFC;
}
.hist-banner-meta {
  font-size: 12px;
  color: #94A3B8;
  font-family: "JetBrains Mono", monospace;
}
.hist-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hist-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #E2E8F0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.hist-btn:hover { background: rgba(255, 255, 255, 0.12); color: #FFF; }
.hist-btn.primary {
  background: rgba(0, 245, 155, 0.14);
  border-color: rgba(0, 245, 155, 0.35);
  color: #6EE7B7;
}

/* Cards & Grids */
.h-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.h-kpi {
  background: #12151C;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
}
.h-kpi-lbl { font-size: 11.5px; color: #94A3B8; margin-bottom: 4px; }
.h-kpi-val {
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  font-weight: 800;
  color: #F8FAFC;
}
.h-kpi-sub { font-size: 11px; color: #64748B; margin-top: 2px; }

.h-sec {
  background: #11141B;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.h-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.h-sec-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #F8FAFC;
}
.h-sec-sub {
  font-size: 12px;
  color: #94A3B8;
}

.h-split-ov {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 960px) {
  .h-split-ov { grid-template-columns: 1fr; }
}

.h-pres-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.h-pres-card {
  background: #161A23;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left: 4px solid var(--pc, #94A3B8);
  border-radius: 12px;
  padding: 14px 16px;
}
.h-pres-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.h-pres-name {
  font-size: 18px;
  font-weight: 900;
  color: #FFF;
}
.h-pres-vice {
  font-size: 12.5px;
  color: #94A3B8;
  font-weight: 600;
  margin-left: 6px;
}
.h-stamp {
  font-size: 11px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1.5px solid #EF4444;
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.12);
}
.h-stamp.pass { border-color: #00F59B; color: #6EE7B7; background: rgba(0, 245, 155, 0.12); }
.h-stamp.fail { border-color: #64748B; color: #94A3B8; background: rgba(100, 116, 139, 0.12); }
.h-pres-votes {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 800;
  color: #F8FAFC;
}
.h-pres-pct {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--pc, #94A3B8);
  margin-left: 8px;
}
.h-bar-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-top: 8px;
}
.h-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--pc, #94A3B8);
}

/* Mayor / District / Candidate grids */
.h-mayor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 10px;
}
.h-mayor-card {
  background: #151922;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--pc, #94A3B8);
  border-radius: 10px;
  padding: 10px 12px;
}
.h-mc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.h-mc-county { font-size: 13px; font-weight: 800; color: #E2E8F0; }
.h-mc-turnout { font-size: 11px; color: #64748B; font-family: "JetBrains Mono", monospace; }
.h-mc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12.5px;
  padding: 2px 0;
}
.h-mc-nm { color: #F1F5F9; font-weight: 700; }
.h-mc-v { font-family: "JetBrains Mono", monospace; font-size: 12px; color: #CBD5E1; }

/* Referendums & Recalls */
.h-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}
.h-ref-card {
  background: #151922;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.h-ref-card:hover { border-color: rgba(0, 240, 255, 0.35); }
.h-ref-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.h-ref-title { font-size: 13px; font-weight: 800; color: #F8FAFC; }
.h-ref-topic { font-size: 11.5px; color: #94A3B8; line-height: 1.45; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.h-ref-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.08); }
.h-ref-ag { background: #00F59B; }
.h-ref-dis { background: #FF3B6B; }
.h-ref-nums { display: flex; justify-content: space-between; font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: #CBD5E1; margin-top: 6px; }

/* Historical Interactive Map View */
.h-map-layout {
  display: grid;
  grid-template-columns: 1fr 370px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 980px) {
  .h-map-layout { grid-template-columns: 1fr; }
}
.h-map-canvas-box {
  position: relative;
  background: #0B0E14;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  overflow: hidden;
  min-height: 620px;
}
.h-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 20, 27, 0.92);
}
.h-map-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.h-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #CBD5E1;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.h-pill.active {
  background: rgba(0, 240, 255, 0.16);
  border-color: rgba(0, 240, 255, 0.45);
  color: #7DF9FF;
}
.h-map-stage {
  position: relative;
  width: 100%;
  height: 580px;
}
.h-map-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.h-map-stage canvas:active { cursor: grabbing; }
.h-map-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  z-index: 5;
}
.h-map-crumb {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(10, 12, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #E2E8F0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.h-map-tip {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  background: rgba(12, 15, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: #F1F5F9;
  min-width: 165px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.h-map-tip.hidden { display: none; }

.h-map-side {
  background: #11141B;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  max-height: 640px;
  overflow-y: auto;
}

/* Candidates & Districts Toolbar */
.h-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.h-select, .h-input {
  background: #151922;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #F1F5F9;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: "Noto Sans TC", sans-serif;
}
.h-input { min-width: 210px; flex: 1; }

.h-cand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}
.h-cand-card {
  display: flex;
  gap: 12px;
  background: #151922;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--pc, #94A3B8);
  border-radius: 11px;
  padding: 11px 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.h-cand-card:hover { transform: translateY(-1px); border-color: rgba(255, 255, 255, 0.22); }
.h-cand-avatar {
  width: 50px;
  height: 62px;
  border-radius: 8px;
  background: #1E2430;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  font-weight: 800;
  font-size: 18px;
}
.h-cand-avatar img { width: 100%; height: 100%; object-fit: cover; }
.h-cand-body { flex: 1; min-width: 0; }
.h-cand-nm-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.h-cand-nm { font-size: 15px; font-weight: 800; color: #FFF; }
.h-cand-yr { font-family: "JetBrains Mono", monospace; font-size: 11px; color: #7DF9FF; background: rgba(0,240,255,0.12); padding: 1px 6px; border-radius: 4px; }
.h-cand-sub { font-size: 11.5px; color: #94A3B8; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-cand-stat { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; font-family: "JetBrains Mono", monospace; }
.h-cand-votes { font-size: 15px; font-weight: 800; color: #F8FAFC; }
.h-cand-pct { font-size: 12px; color: var(--pc, #94A3B8); font-weight: 700; }

/* Trend chart SVG */
.h-trend-svg { width: 100%; height: auto; display: block; }
.h-hemi-wrap {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: center;
}
@media (max-width: 820px) {
  .h-hemi-wrap { grid-template-columns: 1fr; }
}

.h-timeline-row {
  display: grid;
  grid-template-columns: 58px 92px 1fr 110px 72px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
  cursor: pointer;
}
.h-timeline-row:hover { background: rgba(255, 255, 255, 0.04); }
@media (max-width: 640px) {
  .h-timeline-row { grid-template-columns: 52px 1fr 90px; }
  .h-timeline-row .h-tl-hide-sm { display: none; }
}
