/* fusion.place/live (Vercel Geist) dark canvas + Fluorescent Neon accents + Mobile & TV adaptive */
:root {
  color-scheme: dark;
  --bg: #0A0A0A;
  --card: #111111;
  --card2: #1A1A1A;
  --tile: #171717;
  --tile-hi: #202020;
  --rule: #242424;
  --dash: #383838;
  --track: #1F1F1F;

  --ink: #EDEDED;
  --soft: #A1A1A1;
  --muted: #6E6E6E;

  /* Fluorescent Neon semantic palette */
  --kmt: #2B6EF2;
  --dpp: #00F59B;
  --tpp: #00F0FF;
  --ind: #94A3B8;
  --other: #D580FF;
  --ok: #00F59B;
  --warn: #FFD60A;
  --err: #FF3B6B;
  --cyan: #00F0FF;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

html, body {
  min-height: 100%;
  background:
    radial-gradient(1000px 460px at 8% -12%, rgba(0, 240, 255, 0.085), transparent 60%),
    radial-gradient(900px 420px at 94% -8%, rgba(0, 245, 155, 0.065), transparent 58%),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }

/* ==================== SHELL ==================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  padding-bottom: 0;
}

@media (min-width: 1120px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100vh; padding-bottom: 0; overflow: hidden; }
}

/* ==================== HEADER (Clean Single-Row Minimalist) ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 10px 20px;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid #1E1E22;
}
.top-bar-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.beat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(0, 245, 155, 0.65);
  animation: beat 2s ease-out infinite;
  flex: none;
}
.beat-dot.off { background: var(--err); box-shadow: 0 0 8px var(--err); animation: none; }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(0, 245, 155, 0.5), 0 0 8px rgba(0, 245, 155, 0.65); }
  100% { box-shadow: 0 0 0 8px rgba(0, 245, 155, 0), 0 0 8px rgba(0, 245, 155, 0.65); }
}

.brand-title {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #FAFAFA;
  white-space: nowrap;
}

.seat-strip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-left: 10px;
  border-left: 1px solid #26262A;
  font-size: 12px;
  color: var(--soft);
}
.seat { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; white-space: nowrap; }
.seat i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.seat b {
  font-family: "JetBrains Mono", monospace;
  font-size: 13.5px;
  font-weight: 800;
  margin-left: 1px;
}
.s-kmt i { background: var(--kmt); }
.s-kmt b { color: var(--kmt); }
.s-dpp i { background: var(--dpp); }
.s-dpp b { color: var(--dpp); }
.s-tpp i { background: var(--tpp); }
.s-tpp b { color: var(--tpp); }
.s-ind i { background: var(--ind); }
.s-ind b { color: var(--ind); }
.s-none { border-left: 1px solid var(--rule); padding-left: 8px; }
.s-none b { color: var(--muted); }

/* Primary 5-Tab Bar */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.view-tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #9A9AA2;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tab:hover { color: #FFF; background: rgba(255, 255, 255, 0.05); }
.tab.active {
  background: #1C1C20;
  border-color: #323238;
  color: #FFF;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chip-clock {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--soft);
  padding: 3px 6px;
}

/* More / Tools Popover */
.more-wrap { position: relative; }
.more-btn {
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid #2A2A2F;
  background: #151518;
  color: var(--soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.more-btn:hover { border-color: #44444C; color: #FFF; }
.more-btn.active { border-color: var(--cyan); color: var(--cyan); background: rgba(0, 240, 255, 0.08); }

.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 12px;
  background: rgba(18, 18, 22, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid #2D2D34;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.72);
  display: flex;
  flex-direction: column;
  gap: 11px;
  z-index: 80;
}
.mm-sec { display: flex; flex-direction: column; gap: 6px; }
.mm-sec + .mm-sec { border-top: 1px solid #24242A; padding-top: 9px; }
.mm-lbl { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.mm-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.mm-tab { justify-content: center; padding: 6px 8px; font-size: 12.5px; background: #141418; border: 1px solid #26262C; }
.mm-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.mm-health .source-health { display: flex; flex-wrap: wrap; gap: 5px; }

.chip-countdown { font-size: 11px; font-weight: 700; color: var(--soft); }
.source-health { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sh-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--soft);
  background: #141418;
  border: 1px solid #24242A;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.sh-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.sh-pill.ok i { background: var(--ok); }
.sh-pill.warn i { background: var(--warn); }
.sh-pill.err i { background: var(--err); }
.sh-pill b { color: var(--ink); font-weight: 700; }
.sh-rec b { color: var(--cyan); }

/* Keep summary & full-map pages spacious without a scrolling bottom ticker */
body.on-summary .ticker-bar, body.on-map .ticker-bar { display: none; }
body.on-summary .app-shell, body.on-map .app-shell { padding-bottom: 0; }

.seg-control {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 2px;
}
.seg {
  padding: 3px 9px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.seg.active {
  background: var(--card2);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.35);
}

.tool-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--soft);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--dash); color: var(--ink); }
.tool-btn.on {
  border-color: rgba(0, 245, 155, 0.65);
  color: var(--ok);
  background: rgba(0, 245, 155, 0.08);
  box-shadow: 0 0 10px rgba(0, 245, 155, 0.18);
}
.tool-tg {
  text-decoration: none;
  border-color: rgba(43, 110, 242, 0.55);
  color: var(--kmt);
  background: rgba(43, 110, 242, 0.09);
}
.tool-tg:hover {
  border-color: var(--kmt);
  color: #fff;
  box-shadow: 0 0 10px rgba(43, 110, 242, 0.35);
}

/* ==================== BREAKING TOAST ==================== */
.breaking-toast {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(20, 10, 16, 0.96);
  border: 1.5px solid var(--err);
  box-shadow: 0 0 28px rgba(255, 59, 107, 0.45), 0 12px 32px rgba(0, 0, 0, 0.8);
  font-size: clamp(14px, 1.2vw, 19px);
  font-weight: 800;
  color: #fff;
  max-width: 92vw;
}
.breaking-tag {
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--err);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  flex: none;
}

/* ==================== MAIN STAGE & CARDS ==================== */
.main-stage {
  flex: 1;
  min-height: 0;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}
.view-panel.active { display: flex; }

.card {
  background: linear-gradient(180deg, #161616, var(--card) 160px);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}

.sec-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  flex: none;
}

/* ==================== REFERENDUM BAR ==================== */
.ref-card {
  background: linear-gradient(180deg, #161616, var(--card) 120px);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  flex: none;
}
.ref-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ref-tag {
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 214, 10, 0.65);
  color: var(--warn);
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(255, 214, 10, 0.35);
}
.ref-name { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.ref-src { font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.ref-meta { font-size: 11px; color: var(--soft); }

.ref-body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: min(100%, 470px);
}
.ref-side { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.ref-lbl { font-size: 12px; font-weight: 700; }
.ref-side strong { font-size: clamp(16px, 1.25vw, 22px); font-weight: 800; }
.ref-pct { font-size: 12px; color: var(--soft); }
.ref-agree .ref-lbl, .ref-agree strong { color: var(--ok); text-shadow: 0 0 10px rgba(0, 245, 155, 0.35); }
.ref-disagree .ref-lbl, .ref-disagree strong { color: var(--err); text-shadow: 0 0 10px rgba(255, 59, 107, 0.35); }

.ref-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--track);
}
.ref-fill-agree { background: var(--ok); box-shadow: 0 0 10px var(--ok); transition: width 0.5s ease; }
.ref-fill-disagree { background: var(--err); box-shadow: 0 0 10px var(--err); transition: width 0.5s ease; }
.ref-midline { position: absolute; left: 50%; top: 0; bottom: 0; width: 1.5px; background: rgba(255, 255, 255, 0.75); }

/* ==================== VIEW 0: CLEAN EDITORIAL ELECTION SUMMARY ==================== */
#view-summary {
  overflow-y: auto;
  padding: 4px 2px 24px;
}
.sum-wrap {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sum-top-row {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(340px, 1.15fr);
  gap: 16px;
  align-items: center;
}
.sum-title-blk { display: flex; flex-direction: column; gap: 7px; }
.sum-title-blk h2 {
  font-size: clamp(22px, 1.9vw, 28px);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #FFF;
  margin: 0;
}
.sum-prog-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--soft);
}
.sum-prog-line .is-done { color: var(--ok); font-weight: 800; }
.sum-dot { color: #3A3A40; }
.sum-prog-track { height: 4px; border-radius: 999px; background: #1E1E22; overflow: hidden; max-width: 380px; margin-top: 2px; }
.sum-prog-track i { display: block; height: 100%; background: linear-gradient(90deg, #2B6EF2, #00F59B); border-radius: 999px; transition: width 0.5s ease; }

/* Compact Referendum Card with Stamped 通過 Seal */
.sum-ref-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  background: #121215;
  border: 1px solid #222227;
}
.sref-main { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.sref-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: #FFF; }
.sref-tag {
  font-size: 11px;
  font-weight: 800;
  color: #D4D4D8;
  background: #202026;
  padding: 2px 7px;
  border-radius: 5px;
}
.sref-nums { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.sref-nums .ag { color: var(--ok); }
.sref-nums .dis { color: #A1A1AA; }
.sref-nums b { font-size: 15px; font-weight: 800; }
.sref-main .ref-track { flex: none; width: 100%; height: 7px; }
.sref-sub { font-size: 11px; color: var(--muted); }
.sref-stamp { flex: none; display: flex; align-items: center; justify-content: center; }
.sref-pend { font-size: 11.5px; font-weight: 700; color: var(--soft); padding: 3px 8px; border-radius: 6px; background: #1C1C20; }

/* 5 Clean Flat Tier Strips (縣市長 / 議員 / 鄉鎮長 / 代表 / 村里長) */
.sum-tier-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 11px;
}
.sum-tier-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 15px;
  border-radius: 11px;
  background: #121215;
  border: 1px solid #222227;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.sum-tier-card:hover { border-color: #383842; background: #16161A; }
.stc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.stc-title { font-size: 13.5px; font-weight: 800; color: #F4F4F5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stc-total { font-size: 12.5px; color: var(--soft); font-weight: 700; white-space: nowrap; flex: none; }
.sum-sbar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: #1E1E22; }
.sum-sbar i { display: block; height: 100%; }
.sum-sbar i + i { border-left: 1px solid #121215; }
.stc-legend { display: flex; flex-wrap: wrap; gap: 4px 11px; font-size: 12px; color: #A1A1AA; }
.stc-p { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.stc-p i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.stc-p b { color: #F4F4F5; font-weight: 700; }
.stc-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.stc-arr { color: var(--soft); transition: transform 0.15s; }
.sum-tier-card:hover .stc-arr { transform: translateX(2px); color: #FFF; }

/* Ultra-slim Live Unfinished Strip */
.sum-spotlight {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.28);
}
.spot-tag {
  font-size: 11px;
  font-weight: 800;
  color: #FBBF24;
  background: rgba(245, 158, 11, 0.16);
  padding: 2px 8px;
  border-radius: 999px;
  flex: none;
}
.spot-list { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.spot-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: #F4F4F5;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.spot-item:hover { border-color: rgba(245, 158, 11, 0.45); background: rgba(255, 255, 255, 0.07); }
.si-c { display: inline-flex; align-items: center; gap: 4px; }
.si-c i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.si-vs { color: var(--muted); font-size: 11px; }
.si-diff { color: #FBBF24; font-weight: 800; font-size: 12px; }
.si-prog { color: var(--muted); font-size: 11px; }

/* 22-County Main Split: Large Prominent Map + Clean Stamped Cards */
.sum-mayor-split {
  display: grid;
  grid-template-columns: minmax(380px, 490px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.sum-map-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #101013;
  border: 1px solid #202026;
}
.sum-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sum-sec-head h3 { font-size: 14px; font-weight: 800; margin: 0; color: #E4E4E7; letter-spacing: 0.01em; }
.sum-link-btn {
  border: none;
  background: transparent;
  color: #8A8A94;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}
.sum-link-btn:hover { color: #FFF; }
.sum-mini-map-wrap { position: relative; width: 100%; height: 610px; display: flex; align-items: center; justify-content: center; }
.sum-map-leg {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding-top: 10px;
  border-top: 1px solid #1E1E24;
  font-size: 11.5px;
  color: var(--soft);
}
.sum-map-leg span { display: inline-flex; align-items: center; gap: 5px; }
.sum-map-leg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sum-map-leg i.leg-stamp {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.4px solid #F43F5E;
  color: #FF4D6A;
  font-style: normal;
  font-family: "Noto Serif TC", serif;
  font-size: 9px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-10deg);
}

.sum-mayors-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sum-six-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.sm-six-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px 14px;
  border-radius: 11px;
  background: #121215;
  border: 1px solid #222227;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.sm-six-card:hover { border-color: #383842; background: #16161A; }
.sm-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 15px; color: #FFF; min-height: 28px; }
.sm-six-card.is-stamped .sm-head { padding-right: 42px; margin-bottom: 4px; }
.sm-six-card .win-stamp.sz-md { width: 38px; height: 38px; }
.sm-six-card .card-corner-stamp { top: 6px; right: 10px; }
.sm-prog { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.sm-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; position: relative; z-index: 1; }
.sm-row.win b { font-size: 16px; color: #FFF; }
.sm-row.lose { opacity: 0.56; }
.sm-who { display: inline-flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; }
.sm-who i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.sm-who small { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.sm-num { display: inline-flex; align-items: baseline; gap: 5px; flex: none; font-size: 12px; color: var(--soft); }
.sm-num strong { font-size: 15px; color: #FFF; }
.sm-split-bar { display: flex; height: 4px; border-radius: 999px; overflow: hidden; background: #1E1E22; margin-top: 2px; }
.sm-split-bar i { display: block; height: 100%; }
.sm-split-bar i + i { border-left: 1.5px solid #121215; }

.sum-16-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.sm-mini-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #121215;
  border: 1px solid #202026;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.sm-mini-card.is-hot { border-color: rgba(245, 158, 11, 0.45); }
.sm-mini-card:hover { border-color: #383842; background: #16161A; }
.sm-mini-card .sm-head { font-size: 13.5px; }
.sm-mini-card.is-stamped .sm-head { padding-right: 34px; }
.sm-mini-win { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-size: 13px; position: relative; z-index: 1; }
.sm-mini-win b { color: #FFF; font-size: 14px; }
.sm-mini-sub { display: flex; justify-content: space-between; gap: 4px; font-size: 11px; color: var(--muted); position: relative; z-index: 1; }
.close-tag {
  font-size: 10px;
  font-weight: 800;
  color: #FBBF24;
  background: rgba(245, 158, 11, 0.15);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Party Change & 2026 vs 2022 Delta Scorecard (3x2 clean editorial grid) */
.sum-party-sec { display: flex; flex-direction: column; gap: 10px; }
.sum-vs-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #26262E;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.sum-party-tools { display: inline-flex; align-items: center; gap: 10px; }
.sm-head-l { display: inline-flex; align-items: center; gap: 5px; }
.sm-flip-tag {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #71717A;
  line-height: 1.25;
}
.sm-flip-tag b { font-weight: 900; }

.sum-flips-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 13px;
  border-radius: 9px;
  background: #121216;
  border: 1px solid #22222A;
  font-size: 12px;
}
.sfs-lbl { color: #D4D4D8; font-weight: 800; white-space: nowrap; }
.sfs-lbl b { color: var(--cyan); }
.sfs-groups { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.sfs-grp { display: inline-flex; align-items: center; gap: 6px; }
.sfs-cities { color: #9CA3AF; font-size: 12px; }
.sfs-city {
  border: none;
  background: transparent;
  padding: 0;
  color: #E4E4E7;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sfs-city:hover { color: var(--cyan); text-decoration: underline; }

.sum-party-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.sp-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 15px;
  border-radius: 11px;
  background: #121215;
  border: 1px solid #222229;
  border-top: 2px solid var(--pc, #383842);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.sp-card:hover { border-color: var(--pc, #444); background: #16161B; }
.sp-card.sp-coalition {
  border-top: 2px solid transparent;
  background:
    linear-gradient(#121215, #121215) padding-box,
    linear-gradient(90deg, #4ADE80 0%, #FB7185 33%, #F472B6 66%, #FACC15 100%) border-box;
  border-top-width: 2.5px;
}
.sp-card.sp-coalition:hover {
  background:
    linear-gradient(#16161B, #16161B) padding-box,
    linear-gradient(90deg, #4ADE80 0%, #FB7185 33%, #F472B6 66%, #FACC15 100%) border-box;
}
.sp-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp-name { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; color: #F4F4F5; }
.sp-name > i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sp-coal-dots { display: inline-flex; align-items: center; gap: 2px; }
.sp-coal-dots i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.sp-gbp {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.03em;
}
.sp-head-num { display: inline-flex; align-items: baseline; gap: 6px; }
.sp-big-inline { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.sp-big-inline b { font-size: 20px; font-weight: 800; color: var(--pc, #FFF); margin-right: 1px; }
.sp-delta {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.sp-delta.is-up { color: #34D399; background: rgba(52, 211, 153, 0.12); }
.sp-delta.is-down { color: #FB7185; background: rgba(251, 113, 133, 0.12); }
.sp-delta.is-flat { color: #71717A; background: rgba(255, 255, 255, 0.04); }
.stc-p .sp-delta { font-size: 10px; padding: 0 3px; margin-left: 2px; }
.sp-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  font-size: 11.5px;
  color: #9A9AA6;
  border-top: 1px solid #1E1E24;
  padding-top: 8px;
}
.sp-rows > span { display: flex; align-items: center; gap: 5px; }
.sp-rows b { color: #F4F4F5; font-weight: 800; }
.sp-rows .sp-delta { font-size: 10.5px; padding: 0 4px; margin-left: auto; }
.sp-foot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed #22222A;
  font-size: 11px;
  color: #8A8A96;
}
.sp-foot-row b { color: #E4E4E7; }
.sp-prev { color: #6B6B76; }
.sp-members {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 6px;
  border-top: 1px dashed #22222A;
}
.sp-mem-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid #262630;
  color: #D4D4D8;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.sp-mem-chip:hover { border-color: #4B5563; background: rgba(255, 255, 255, 0.07); }
.sp-mem-chip i { width: 6px; height: 6px; border-radius: 50%; }
.sp-mem-chip .sp-delta { font-size: 10px; padding: 0 3px; }

@media (max-width: 1360px) {
  .sum-tier-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .party-kpi-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1279px) {
  .sum-party-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-16-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1119px) {
  #view-summary { overflow: visible; }
  .sum-top-row { grid-template-columns: 1fr; }
  .sum-tier-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-mayor-split { grid-template-columns: 1fr; }
  .sum-mini-map-wrap { height: 500px; }
  .sum-six-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-16-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-party-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .sum-six-grid { grid-template-columns: 1fr; }
  .sum-party-grid { grid-template-columns: 1fr; gap: 9px; }
  .sum-ref-card { padding: 11px 12px; gap: 10px; }
}

/* ==================== VIEW 1: SIX METROS (v6: no stacked left glow bars) ==================== */
.six-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
}

/* Leader is shown by a soft tinted top glow + coloured margin text, not by a left bar */
.metro-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #161616, var(--card) 170px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--leader-color, #383838) 9%, #141414), var(--card) 150px);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 13px 16px 11px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.metro-card:hover { border-color: var(--dash); }
.metro-card.flash-card { animation: cardFlash 1.1s ease; }
@keyframes cardFlash {
  0% { border-color: var(--cyan); box-shadow: 0 0 22px rgba(0, 240, 255, 0.28); }
  100% { border-color: var(--rule); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
}

.mc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mc-title-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mc-city {
  font-size: clamp(20px, 1.65vw, 30px);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
}
.mc-badge-close {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 59, 107, 0.12);
  color: var(--err);
  font-size: 11px;
  font-weight: 800;
}

.mc-src-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.mc-src-pill.src-cec { color: var(--ok); }
.mc-src-pill.src-votes_tw { color: var(--cyan); }
.mc-src-pill.src-youtube { color: #FF7A99; }

/* Head-to-head share bar: one bar for the whole race instead of one glowing bar per row */
.race-bar {
  position: relative;
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
  flex: none;
}
.race-seg {
  height: 100%;
  background: var(--pcolor);
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.race-seg + .race-seg { border-left: 2px solid var(--card); }
.race-seg.lead { box-shadow: 0 0 12px var(--pcolor); }
.race-seg.rest { background: #3A3A3A; }
.race-mid {
  position: absolute;
  left: 50%;
  top: -1px;
  bottom: -1px;
  width: 1.5px;
  background: rgba(255, 255, 255, 0.55);
}

.mc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 0;
}
.mc-cands {
  display: flex;
  flex-direction: column;
}

/* Flat candidate rows separated by hairlines; colour lives in the number badge + party label */
.cand-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  padding: 7px 2px;
  border-radius: 6px;
  transition: background 0.25s;
}
.cand-row + .cand-row { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.cand-row.flash-row { animation: rowFlash 1.1s ease; }
@keyframes rowFlash {
  0% { background: rgba(0, 240, 255, 0.16); }
  100% { background: transparent; }
}

.cand-left, .cand-id { display: flex; align-items: center; gap: 7px; min-width: 0; }
/* Name gets its own line; party label sits underneath so the name is never squeezed into "蔣…" */
.cand-id { flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; }
.cand-nm-line { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.cand-row.is-zero .cand-id { flex-direction: row; align-items: center; justify-content: flex-start; gap: 7px; }
.cand-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--pcolor);
  color: var(--pcolor);
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  font-size: 12px;
  flex: none;
}
.cand-row.is-leader .cand-num {
  background: var(--pcolor);
  color: #0A0A0A;
  box-shadow: 0 0 10px color-mix(in srgb, var(--pcolor) 60%, transparent);
}
.cand-name {
  font-size: clamp(16px, 1.25vw, 23px);
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cand-row:not(.is-leader) .cand-name { color: #CFCFCF; font-weight: 700; }
.cand-party {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--pcolor);
  opacity: 0.9;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Traditional Taiwanese Cinnabar-Red Ink Stamp (朱紅印章) for 當選 / 通過 */
.stamp-txt {
  font-family: "Noto Serif TC", "DFKai-SB", "BiauKai", "Songti TC", Georgia, serif;
}
.win-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #F43F5E;
  transform: rotate(-12deg);
  filter: drop-shadow(0 0 8px rgba(244, 63, 94, 0.24));
  user-select: none;
  pointer-events: none;
  flex: none;
  opacity: 0.93;
}
.win-stamp svg { width: 100%; height: 100%; display: block; }
.win-stamp.sz-sm { width: 35px; height: 35px; }
.win-stamp.sz-md { width: 48px; height: 48px; }
.win-stamp.sz-lg { width: 56px; height: 56px; }

.card-corner-stamp {
  position: absolute;
  top: 6px;
  right: 9px;
  z-index: 2;
  pointer-events: none;
}
.card-corner-stamp.sm {
  top: 5px;
  right: 7px;
}

/* Inline Mini Rectangular Red Ink Stamp (候選人列表「當選」方章) */
.stamp-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1.5px solid #F43F5E;
  box-shadow: inset 0 0 0 1px rgba(10, 10, 12, 0.85), inset 0 0 0 2px rgba(244, 63, 94, 0.42);
  background: rgba(244, 63, 94, 0.09);
  color: #FF526D;
  font-family: "Noto Serif TC", "DFKai-SB", "BiauKai", Georgia, serif;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  white-space: nowrap;
  flex: none;
  transform: rotate(-6deg);
}
.cd-row .stamp-mini { font-size: 10px; padding: 0 5px; }

/* Compact Circular Red Ink Seal Icon (16px) */
.win-ic {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  min-width: 15px;
  min-height: 15px;
  color: #FF4D6A;
  vertical-align: -0.2em;
  flex: none;
  transform: rotate(-10deg);
}
.lose-ic {
  display: inline-block;
  width: 1em;
  height: 1em;
  min-width: 13px;
  min-height: 13px;
  color: #71717A;
  vertical-align: -0.15em;
  flex: none;
  opacity: 0.8;
}
.res-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  flex: none;
}
.res-badge.is-lose {
  background: rgba(255, 255, 255, 0.035);
  color: #787882;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.cand-row.is-not-elected, .tw-cand.is-not-elected { opacity: 0.56; }
.cd-row.not-el { opacity: 0.56; }
.cd-row .res-badge { padding: 0 5px; font-size: 9.5px; }
.cand-name + .win-ic, .pc-name + .win-ic, .cd-name + .win-ic { margin-left: 3px; }
.pc-status .win-ic, .pc-status .lose-ic, .cd-chip .win-ic { width: 13px; height: 13px; min-width: 13px; min-height: 13px; margin-right: 3px; vertical-align: -2px; }

.cand-right { display: flex; align-items: baseline; gap: 6px; flex: none; }
.cand-delta {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ok);
  text-shadow: 0 0 8px rgba(0, 245, 155, 0.5);
}
.cand-votes {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(20px, 1.75vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}
.cand-votes .approx { font-family: inherit; font-size: 0.5em; color: var(--muted); margin-right: 2px; letter-spacing: 0; }
.cand-row:not(.is-leader) .cand-votes {
  font-size: clamp(17px, 1.4vw, 26px);
  color: #C8C8C8;
}
.cand-pct {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 800;
  color: var(--pcolor);
  min-width: 48px;
  text-align: right;
}
.cand-row:not(.is-leader) .cand-pct { color: var(--soft); font-weight: 700; }

/* Legacy per-row bar (still used by compare header) */
.bar-track {
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--pcolor);
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
}
.mc-margin { display: inline-flex; align-items: baseline; gap: 5px; font-weight: 700; color: var(--soft); white-space: nowrap; }
.mc-margin b {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 800;
  color: var(--leader-color, var(--warn));
}
.mc-margin em { font-style: normal; font-family: "JetBrains Mono", monospace; color: var(--muted); }
.mc-subsources {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-subsources b { color: var(--soft); font-family: "JetBrains Mono", monospace; font-weight: 700; }

.mc-head-right { display: flex; align-items: center; gap: 6px; }
.mc-spark { width: 58px; height: 22px; flex: none; opacity: 0.92; }
.pin-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
  transition: color 0.15s, transform 0.15s;
}
.pin-btn:hover { color: var(--warn); transform: scale(1.15); }
.pin-btn.pinned { color: var(--warn); text-shadow: 0 0 8px rgba(255, 214, 10, 0.6); }

/* Desktop: use the empty vertical space for bigger, calmer numbers */
@media (min-width: 1120px) {
  .cand-row { padding: 9px 2px; }
  .cand-votes { font-size: clamp(22px, 2.2vw, 42px); }
  .cand-row:not(.is-leader) .cand-votes { font-size: clamp(18px, 1.75vw, 33px); }
  .cand-name { font-size: clamp(17px, 1.4vw, 26px); }
  .mc-body { gap: 14px; }
  .race-bar { height: 14px; }
}
/* Candidates with zero votes collapse into a quiet line */
.cand-row.is-zero { padding-top: 5px; padding-bottom: 5px; opacity: 0.5; }
.cand-row.is-zero .cand-name { font-size: 14px !important; }
.cand-row.is-zero .cand-votes { font-size: 14px !important; color: var(--muted) !important; }
.cand-row.is-zero .cand-num { width: 20px; height: 20px; font-size: 11px; }

/* Live Delta Pulse Strip (View 1 bottom) */
.pulse-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--rule);
  min-height: 34px;
  overflow: hidden;
  flex: none;
}
.pulse-badge {
  flex: none;
  font-size: 11px;
  font-weight: 800;
  color: var(--ok);
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 245, 155, 0.1);
  border: 1px solid rgba(0, 245, 155, 0.4);
  white-space: nowrap;
}
.pulse-items {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  font-size: 12px;
}
.pulse-items::-webkit-scrollbar { display: none; }
.pulse-empty { color: var(--muted); }
.pulse-entry { display: inline-flex; align-items: center; gap: 5px; color: var(--soft); }
.pulse-entry time { color: var(--muted); font-family: "JetBrains Mono", monospace; font-size: 11px; }
.pulse-entry .p-src { color: var(--cyan); font-weight: 700; }
.pulse-entry .p-delta { color: var(--ok); font-family: "JetBrains Mono", monospace; font-weight: 800; }

/* ==================== VIEW 2: TAIWAN MAP + ALL 22 COUNTIES ==================== */
.all-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex: none;
}
.filter-pills, .sort-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ctrl-hint { font-size: 11px; color: var(--muted); font-weight: 700; margin-right: 2px; }
.fpill, .spill {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.fpill.active, .spill.active {
  background: var(--card2);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.all-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 12px;
}

.map-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px;
}
.tw-hex-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin: auto 0;
}
.map-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px 3px;
  border-radius: 6px;
  background: var(--tile);
  border: 1px solid var(--rule);
  border-top: 2.5px solid var(--tcolor, var(--dash));
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  min-height: 46px;
}
.map-tile:hover { transform: translateY(-1px); border-color: var(--tcolor, var(--cyan)); box-shadow: 0 0 12px rgba(0, 240, 255, 0.2); }
.map-tile.has-lead {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), var(--tile));
  box-shadow: inset 0 0 16px -10px var(--tcolor);
}
.map-tile.is-close { border-color: var(--err); box-shadow: 0 0 10px rgba(255, 59, 107, 0.35); }
.map-tile-name { font-size: 12px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.map-tile-lead { font-size: 9.5px; color: var(--tcolor, var(--muted)); font-weight: 700; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-spacer { visibility: hidden; pointer-events: none; }
.map-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.map-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.all-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 8px;
  overflow-y: auto;
  align-content: start;
}

/* ==================== REAL GEOGRAPHIC TAIWAN MAP (vote.harlos.tw inspired) ==================== */
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex: none;
}
.map-mode-wrap { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.map-ctl-grp { display: inline-flex; align-items: center; gap: 6px; }
.map-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-search-wrap { position: relative; }
.map-search-input { width: 175px; padding: 4px 10px; font-size: 12.5px; }
.map-search-results {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  width: 240px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 60;
  background: rgba(14, 16, 22, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid var(--dash);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.msr-item:hover { background: rgba(0, 240, 255, 0.1); color: #fff; }
.msr-tag { font-size: 10px; color: var(--muted); font-weight: 700; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); }
.msr-empty { padding: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.seg.is-disabled { opacity: 0.36; }

.geo-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(350px, 430px);
  gap: 12px;
}

.geo-map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 6px;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(22, 30, 42, 0.55) 0%, rgba(11, 13, 18, 0.96) 72%, #090A0D 100%);
}
.map-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
  flex: none;
}
.crumb-title { font-size: 15px; font-weight: 800; color: var(--ink); }
.crumb-sel {
  font-size: 12px;
  font-weight: 800;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.35);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.crumb-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.btn-sm { padding: 3px 9px; font-size: 12px; }

.geo-map-svg-wrap {
  flex: 1;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: none;
}
.geo-map-svg-wrap.is-zoomed { cursor: grab; }
.geo-map-svg-wrap.is-panning { cursor: grabbing; }
.geo-canvas {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  touch-action: none;
}
.geo-svg {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
  overflow: hidden;
  user-select: none;
  --z-inv: 1;
}
.geo-svg[data-lod="county"] { filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55)); }
.geo-poly {
  vector-effect: non-scaling-stroke;
  stroke: #0A0C10;
  stroke-width: 1.05;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 0.25s ease, opacity 0.22s ease, filter 0.15s ease;
}
.geo-poly:hover { filter: brightness(1.22); }
.geo-poly.selected {
  stroke: #FFFFFF;
  stroke-width: 1.8;
  filter: brightness(1.12);
  paint-order: stroke;
}
.geo-poly.dimmed { opacity: 0.14; }
.geo-poly.dimmed:hover { opacity: 0.45; }

/* Continuous 3-tier LOD cross-fade inside ONE unified SVG */
.geo-layer-towns,
.geo-county-borders,
.geo-layer-villages,
.geo-labels-counties,
.geo-labels-towns,
.geo-labels-villages,
.geo-callouts {
  transition: opacity 0.22s ease;
}
.geo-county-border {
  fill: none;
  stroke: rgba(255, 255, 255, 0.34);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
.geo-poly.town-poly { stroke: rgba(10, 12, 16, 0.65); stroke-width: 0.75; }
.geo-poly.town-poly.no-race { stroke: rgba(255, 255, 255, 0.05); }
.geo-poly.vill-poly { stroke: rgba(10, 12, 16, 0.75); stroke-width: 0.75; }
.vill-town-grp { opacity: 0; transition: opacity 0.24s ease; }
.vill-town-grp.is-ready { opacity: 1; }

/* LOD = county (1.0x - 1.75x): crisp 22 counties */
.geo-svg[data-lod="county"] .geo-layer-towns { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="county"] .geo-county-borders { opacity: 0; }
.geo-svg[data-lod="county"] .geo-layer-villages { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="county"] .geo-labels-towns { opacity: 0; }
.geo-svg[data-lod="county"] .geo-labels-villages { opacity: 0; }
/* Township/Rep race mode always shows towns even at 1x */
.geo-svg[data-race="township"] .geo-layer-towns,
.geo-svg[data-race="rep"] .geo-layer-towns { opacity: 1; pointer-events: auto; }
.geo-svg[data-race="township"] .geo-county-borders,
.geo-svg[data-race="rep"] .geo-county-borders { opacity: 0.9; }

/* LOD = town (1.75x+): ALL 368 townships visible across county borders! */
.geo-svg[data-lod="town"] .geo-layer-towns { opacity: 1; pointer-events: auto; }
.geo-svg[data-lod="town"] .geo-county-borders { opacity: 1; }
.geo-svg[data-lod="town"] .geo-layer-villages { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="town"] .geo-labels-counties { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="town"] .geo-callouts { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="town"] .geo-labels-towns { opacity: 1; }
.geo-svg[data-lod="town"] .geo-labels-villages { opacity: 0; }

/* LOD = village (zoomed tight): villages overlay smoothly ON TOP of surrounding townships! */
.geo-svg[data-lod="village"] .geo-layer-towns { opacity: 1; pointer-events: auto; }
.geo-svg[data-lod="village"] .geo-county-borders { opacity: 0.85; }
.geo-svg[data-lod="village"] .geo-layer-villages { opacity: 1; pointer-events: auto; }
.geo-svg[data-lod="village"] .geo-labels-counties { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="village"] .geo-callouts { opacity: 0; pointer-events: none; }
.geo-svg[data-lod="village"] .geo-labels-towns { opacity: 0.72; }
.geo-svg[data-lod="village"] .geo-labels-villages { opacity: 1; }

.map-mini-busy {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 18;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(14, 16, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.map-loading { color: var(--muted); font-size: 13px; }

.map-inset-box {
  fill: rgba(255, 255, 255, 0.02);
  stroke: rgba(255, 255, 255, 0.09);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: stroke 0.15s, fill 0.15s;
}
.map-inset-grp:hover .map-inset-box { stroke: rgba(255, 255, 255, 0.28); fill: rgba(255, 255, 255, 0.035); }
.map-inset-box.selected { stroke: rgba(255, 255, 255, 0.62); fill: rgba(255, 255, 255, 0.04); }
.map-inset-tag { display: none; }
.map-inset-lbl { display: none; }

.geo-markers { pointer-events: none; }
.geo-win .geo-win-bg { fill: #0F1014; }
.geo-win .geo-win-ring { fill: none; stroke: #F43F5E; stroke-width: 2; stroke-dasharray: 20 1 25 1 18 1; }
.geo-win .geo-win-in { fill: none; stroke: #F43F5E; stroke-width: 0.7; opacity: 0.72; }
.geo-win .geo-win-txt {
  fill: #FF5570;
  font-family: "Noto Serif TC", "DFKai-SB", "BiauKai", Georgia, serif;
  font-size: 11.5px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
}
.geo-win { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.75)); }
.geo-hot { fill: #F59E0B; }
.geo-hot-ring {
  fill: none;
  stroke: #F59E0B;
  stroke-width: 1.4;
  transform-box: fill-box;
  transform-origin: center;
  animation: geoHotPulse 1.8s ease-out infinite;
}
@keyframes geoHotPulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(3.2); opacity: 0; }
}

.geo-lbl {
  fill: rgba(255, 255, 255, 0.96);
  font-size: 16.5px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.88);
  stroke-width: 4px;
  stroke-linejoin: round;
  transition: opacity 0.2s ease;
}
.geo-svg .lbl-anchor > .geo-lbl {
  transform: scale(var(--z-inv, 1));
}
.geo-lbl.inset-t { font-size: 15px; }
.geo-lbl.town-lbl {
  font-size: 12.5px;
  stroke-width: 3.2px;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.geo-lbl.town-lbl.is-vis { opacity: 0.95; }
.geo-lbl.town-lbl.dimmed { opacity: 0.16 !important; }
.geo-lbl.vill-lbl {
  font-size: 11.5px;
  stroke-width: 2.8px;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.geo-lbl.vill-lbl.is-vis { opacity: 0.96; }
.geo-lbl.vill-lbl.dimmed { opacity: 0.16 !important; }
.geo-lbl.dimmed { opacity: 0.22; }
.sum-mini-map-wrap .geo-lbl { font-size: 14.5px; stroke-width: 4px; }
.sum-mini-map-wrap .geo-lbl.inset-t { font-size: 13.5px; }
.sum-mini-map-wrap .gc-txt { font-size: 13.5px; }

/* Clickable enclave callout badges (基隆 / 竹市 / 嘉市) */
.geo-callout { cursor: pointer; transition: opacity 0.22s ease; }
.geo-callout.dimmed { opacity: 0.2; }
.gc-line { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.gc-anchor { fill: rgba(255, 255, 255, 0.78); }
.gc-pill { fill: rgba(14, 17, 24, 0.92); stroke: rgba(255, 255, 255, 0.18); stroke-width: 1.1; transition: stroke 0.15s, fill 0.15s; }
.geo-callout:hover .gc-pill { stroke: rgba(255, 255, 255, 0.6); fill: rgba(22, 26, 36, 0.96); }
.geo-callout.selected .gc-pill { stroke: #FFFFFF; stroke-width: 1.6; }
.gc-txt { fill: #F4F4F5; font-size: 14.5px; font-weight: 800; dominant-baseline: central; pointer-events: none; }

/* Floating zoom controls */
.map-zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 84px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: rgba(12, 14, 20, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.mz-level { font-size: 10px; color: var(--cyan); font-weight: 800; padding: 1px 2px; }
.mz-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.mz-btn:hover { background: rgba(0, 240, 255, 0.14); border-color: rgba(0, 240, 255, 0.4); color: #fff; }
.mz-btn.is-dim { opacity: 0.35; }

/* Map Spotlight Filter Bar */
.map-spotlight-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 3px;
  flex: none;
}
.msp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.03);
  color: var(--soft);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.msp-pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.msp-pill b { font-size: 11px; color: var(--muted); }
.msp-pill:hover { border-color: var(--dash); color: #fff; }
.msp-pill.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--sc, var(--cyan));
  color: #fff;
}
.msp-pill.active b { color: var(--sc, var(--cyan)); }

/* Compact Ref Mini Bar & Township Inspector Subfilter */
.insp-ref-mini {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--tile);
  font-size: 11.5px;
  color: var(--soft);
}
.insp-ref-bar { display: flex; height: 5px; border-radius: 999px; overflow: hidden; background: var(--track); }
.insp-ref-bar i { display: block; height: 100%; }
.tw-subfilter { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; flex: none; }
.tw-subfilter .fpill { padding: 3px 8px; font-size: 11.5px; }

.tw-base-poly { fill: #12151C; stroke: none; pointer-events: none; }
.tw-poly {
  vector-effect: non-scaling-stroke;
  stroke: rgba(10, 12, 16, 0.72);
  stroke-width: 0.65;
}
.tw-poly.drill { stroke-width: 1.05; }
.tw-poly.no-race { stroke: rgba(255, 255, 255, 0.04); cursor: default; }
.tw-poly.no-race:hover { filter: none; }
.tw-poly.selected { stroke: #FFFFFF; stroke-width: 1.8; }
.tw-borders path { fill: none; stroke: #0A0C10; stroke-width: 1.3; stroke-linejoin: round; pointer-events: none; }

.tw-tally-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--soft);
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--tile);
  flex: none;
}
.tw-tally-row.tw-nat { background: transparent; padding: 2px 2px; font-size: 11.5px; }
.tw-tally { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tw-tally i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.tw-tally b { color: #fff; }
.tw-cand { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: baseline; font-size: 13px; padding: 2px 0; }
.tw-cn { font-weight: 700; color: #fff; }
.tw-cn small { color: var(--pcolor); font-size: 11px; font-weight: 700; margin-left: 3px; }
.tw-cand b em { color: var(--soft); font-style: normal; font-size: 11px; margin-left: 4px; font-weight: 600; }
.tw-bar { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; }
.tw-bar i { display: block; height: 100%; background: var(--pcolor); border-radius: 999px; }
.tw-tag { font-size: 10px; padding: 0 4px; border-radius: 3px; background: rgba(0, 240, 255, 0.12); color: var(--cyan); font-weight: 700; }
.tw-hot { font-size: 10px; padding: 0 4px; border-radius: 3px; background: rgba(255, 59, 107, 0.16); color: var(--err); font-weight: 800; }
.tw-lead { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

.cm-seat-bar {
  position: relative;
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
  flex: none;
}
.cm-seat-bar i { display: block; height: 100%; }
.cm-seat-bar i + i { border-left: 1px solid var(--bg); }
.cm-half { position: absolute; left: 50%; top: 0; bottom: 0; width: 1.5px; background: rgba(255, 255, 255, 0.75); }
.cm-wchip { font-size: 11.5px; font-weight: 800; padding: 0 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); }

.map-legend-bar {
  padding-top: 5px;
  margin-top: 4px;
  border-top: 1px solid var(--rule);
  flex: none;
}
.mleg-swatches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--soft);
}
.mleg-swatches span { display: inline-flex; align-items: center; gap: 5px; }
.mleg-swatches i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mleg-note { color: var(--muted); font-size: 11px; }
.mleg-grad-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11.5px;
}
.mleg-grad { width: min(260px, 55%); height: 8px; border-radius: 999px; border: 1px solid var(--rule); }

.map-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  will-change: transform;
  min-width: 195px;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(10, 12, 18, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--cyan);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.78), 0 0 14px rgba(0, 240, 255, 0.2);
  font-size: 12px;
}
.tt-title { font-weight: 800; font-size: 13.5px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tt-src { font-size: 10px; color: var(--cyan); font-family: "JetBrains Mono", monospace; }
.tt-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.tt-sub { color: var(--muted); font-size: 11.5px; }
.tt-foot { margin-top: 5px; padding-top: 4px; border-top: 1px solid var(--rule); font-size: 10.5px; color: var(--soft); }

.geo-side-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 13px 15px;
  overflow: hidden;
}
.map-detail-pane, .map-list-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}
.insp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.insp-city { font-size: 22px; font-weight: 900; line-height: 1.1; }
.insp-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.insp-cands { display: flex; flex-direction: column; gap: 6px; }
.insp-diff-box {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--tile);
  font-size: 12px;
  color: var(--soft);
}
.insp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.insp-focus {
  padding: 9px 11px;
  border-radius: 7px;
  background: var(--tile-hi);
  border-left: 3px solid var(--cyan);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.insp-subhead { font-weight: 800; font-size: 13.5px; margin-bottom: 2px; color: var(--cyan); }
.insp-bar-row { display: flex; justify-content: space-between; font-size: 13px; }

.dist-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--tile);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
}
.dist-row:hover { border-color: var(--dash); background: var(--tile-hi); }
.dist-row.active { border-color: var(--cyan); background: rgba(0, 240, 255, 0.08); }
.dist-r-grp { display: inline-flex; align-items: center; gap: 7px; flex: none; }
.dist-vill-btn {
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid #2F2F38;
  background: #17171C;
  color: #B4B4BE;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.dist-vill-btn:hover { border-color: var(--cyan); color: var(--cyan); background: rgba(0, 240, 255, 0.08); }

/* Level 3 & 4 Integrated Area Hub Panel (村里 + 投票所 + 全選舉整合) */
.ah-station-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #141418;
  border: 1px solid #24242C;
  font-size: 12px;
}
.ah-station-bar label { font-weight: 800; color: var(--soft); white-space: nowrap; }
.ah-st-sel { flex: 1; min-width: 0; font-size: 12px; padding: 4px 8px; }
.ah-st-note { font-size: 11.5px; color: var(--muted); }
.ah-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.ah-body { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 0; padding-right: 2px; }
.ah-sec {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 11px;
  border-radius: 9px;
  background: #131317;
  border: 1px solid #222229;
}
.ah-sec-hi { border-color: rgba(244, 63, 94, 0.32); background: rgba(244, 63, 94, 0.03); }
.ah-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ah-sec-head h4 { margin: 0; font-size: 13.5px; font-weight: 800; color: #FFF; display: inline-flex; align-items: center; gap: 6px; }
.ah-scope { font-size: 10.5px; font-weight: 700; color: #9A9AA6; background: #1E1E24; padding: 1px 6px; border-radius: 4px; }
.ah-meta { font-size: 11px; color: var(--muted); }
.ah-num { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; background: rgba(255,255,255,0.06); color: var(--soft); font-size: 10px; margin-right: 4px; flex: none; }
.ah-vsearch { width: 130px; padding: 3px 7px; font-size: 11.5px; }
.ah-vill-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.ah-ref-nums { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.ah-ref-nums b { font-size: 14px; }
.vill-layer-switch { margin-left: auto; }
.map-zoom-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(14, 16, 22, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #E4E4E7;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}
.vill-layer-notice {
  position: absolute;
  left: 14px;
  right: 60px;
  bottom: 12px;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(16, 17, 22, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #E4E4E7;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.list-subbar { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* ==================== VIEW: PARTY CANDIDATE TRACKER ==================== */
.party-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}
.party-selector-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  padding-bottom: 6px;
}
.party-pill { flex: none; }

/* Horizontal scrollers: thin visible neon scrollbar so overflowing pills are always reachable */
.party-selector-pills, .county-pills, .view-tabs {
  scrollbar-width: thin;
  scrollbar-color: #3A3A3A transparent;
}
.party-selector-pills::-webkit-scrollbar, .county-pills::-webkit-scrollbar, .view-tabs::-webkit-scrollbar { display: block; height: 4px; }
.party-selector-pills::-webkit-scrollbar-track, .county-pills::-webkit-scrollbar-track, .view-tabs::-webkit-scrollbar-track { background: transparent; }
.party-selector-pills::-webkit-scrollbar-thumb, .county-pills::-webkit-scrollbar-thumb, .view-tabs::-webkit-scrollbar-thumb { background: #3A3A3A; border-radius: 4px; }
.party-selector-pills:hover::-webkit-scrollbar-thumb, .county-pills:hover::-webkit-scrollbar-thumb, .view-tabs:hover::-webkit-scrollbar-thumb { background: var(--cyan); }
.hs-drag { cursor: grabbing; user-select: none; }
.party-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.party-pill i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.party-pill:hover { border-color: var(--dash); color: var(--ink); }
.party-pill.active {
  background: var(--card2);
  border-color: var(--pc, var(--cyan));
  color: #fff;
  box-shadow: 0 0 12px -2px var(--pc, var(--cyan));
}
.pp-win, .pp-cnt {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
}
.party-pill.active .pp-win { color: var(--pc, var(--cyan)); }

.party-kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 9px;
  flex: none;
}
.pkpi {
  position: relative;
  padding: 10px 14px;
  border-radius: 9px;
  background: linear-gradient(180deg, #161616, var(--card));
  background: linear-gradient(180deg, color-mix(in srgb, var(--pkc, #383838) 8%, #141414), var(--card) 90px);
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.pkpi-lbl { font-size: 11px; font-weight: 700; color: var(--muted); }
.pkpi-val { font-size: 24px; font-weight: 800; color: #fff; line-height: 1.15; margin: 3px 0; }
.pkpi-val b { color: var(--pkc, #fff); }
.pkpi-val span { font-size: 14px; color: var(--muted); font-weight: 600; }
.pkpi-sub { font-size: 11px; color: var(--soft); }

.party-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex: none;
}
.party-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.party-search { width: 140px; min-width: 110px; }
.party-res-cnt { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.party-cand-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 10px;
  overflow-y: auto;
  align-content: start;
  padding-right: 2px;
  padding-bottom: 12px;
}
.party-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: 13px;
}

.pcand-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 7px;
  min-height: 96px;
  padding: 10px 13px 9px;
  border-radius: 9px;
  background: linear-gradient(180deg, #161616, var(--card));
  border: 1px solid var(--rule);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.pcand-card.st-elected {
  background: linear-gradient(180deg, color-mix(in srgb, var(--warn) 10%, #141414), var(--card) 96px);
  border-color: rgba(255, 214, 10, 0.32);
}
.pcand-card.st-in {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 7%, #141414), var(--card) 96px);
  border-color: rgba(0, 245, 155, 0.2);
}
.pcand-card.st-close {
  background: linear-gradient(180deg, color-mix(in srgb, var(--err) 9%, #141414), var(--card) 96px);
  border-color: rgba(255, 59, 107, 0.35);
}
.pcand-card:hover { border-color: var(--dash); }

.pc-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.pc-meta-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pc-tier {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  flex: none;
}
.pc-tier.t-mayor { background: rgba(255, 214, 10, 0.14); color: var(--warn); border: 1px solid rgba(255, 214, 10, 0.4); }
.pc-tier.t-council { background: rgba(0, 240, 255, 0.12); color: var(--cyan); border: 1px solid rgba(0, 240, 255, 0.35); }
.pc-tier.t-township { background: rgba(213, 128, 255, 0.12); color: var(--other); border: 1px solid rgba(213, 128, 255, 0.35); }
.pc-tier.t-rep { background: rgba(0, 245, 155, 0.11); color: var(--ok); border: 1px solid rgba(0, 245, 155, 0.35); }
.pc-area { font-size: 12px; color: var(--soft); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pc-status {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex: none;
}
.pc-status.st-elected { background: rgba(255, 214, 10, 0.16); color: var(--warn); border: 1px solid rgba(255, 214, 10, 0.45); display: inline-flex; align-items: center; }
.pc-status.st-lose { background: rgba(248, 113, 113, 0.1); color: #F87171; border: 1px solid rgba(248, 113, 113, 0.3); display: inline-flex; align-items: center; }
.pcand-card.st-lose { opacity: 0.72; }
.pcand-card.st-lose:hover { opacity: 1; }
.pc-status.st-in { background: rgba(0, 245, 155, 0.14); color: var(--ok); border: 1px solid rgba(0, 245, 155, 0.45); }
.pc-status.st-close { background: rgba(255, 59, 107, 0.16); color: var(--err); border: 1px solid rgba(255, 59, 107, 0.55); }
.pc-status.st-out { background: var(--card2); color: var(--muted); }
.pc-status.st-pend { background: var(--card2); color: var(--muted); }

.pc-mid { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pc-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--pc, var(--cyan));
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  flex: none;
}
.pc-name { font-size: 18px; font-weight: 900; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-close-tag { font-size: 10px; font-weight: 800; color: var(--err); border: 1px solid var(--err); border-radius: 4px; padding: 0 4px; }
.pc-nums { display: flex; align-items: baseline; gap: 6px; flex: none; }
.pc-votes { font-size: 20px; font-weight: 800; color: #fff; }
.pc-pct { font-size: 11.5px; color: var(--soft); }

.pc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
}
.pc-margin { font-family: "JetBrains Mono", monospace; font-weight: 700; }
.pc-margin.m-pos { color: var(--ok); }
.pc-margin.m-neg { color: var(--err); }
.pc-margin-muted { color: var(--muted); }
.pc-src { color: var(--muted); white-space: nowrap; }

@media (max-width: 1119px) {
  .party-kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .party-cand-grid { grid-template-columns: repeat(2, 1fr); overflow: visible; }
}
@media (max-width: 640px) {
  .party-kpi-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pkpi { padding: 8px 10px 8px 12px; }
  .pkpi-val { font-size: 20px; }
  .party-cand-grid { grid-template-columns: 1fr; }
  .party-search { flex: 1; min-width: 120px; }
}

.chart-head-row, .matrix-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  margin-bottom: 4px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.divergence-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  padding: 2px 9px;
  border-radius: 5px;
}
.divergence-pill:empty { display: none; }

.modal-dialog.wide-modal { width: min(1040px, 95vw); }
.lightbox-img { width: 100%; border-radius: 8px; border: 1px solid var(--rule); display: block; background: #000; }
.yt-thumb-wrap { cursor: zoom-in; }

.mini-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px 9px;
  border-radius: 9px;
  background: linear-gradient(180deg, #161616, var(--card));
  border: 1px solid var(--rule);
  cursor: pointer;
  overflow: hidden;
}
.mini-race { display: flex; height: 4px; border-radius: 999px; overflow: hidden; background: var(--track); margin-top: 6px; }
.mini-race i { display: block; height: 100%; background: var(--pcolor); }
.mini-race i + i { border-left: 1.5px solid var(--card); }
.mini-race i.rest { background: #3A3A3A; }
.mini-card:hover { border-color: var(--dash); background: #161616; }
.mini-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mini-city { font-size: 16px; font-weight: 800; }
.mini-src { font-size: 10px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.mini-cand { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0; font-size: 13.5px; }
.mini-cname { display: flex; align-items: center; gap: 6px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.mini-votes { font-family: "JetBrains Mono", monospace; font-weight: 800; font-size: 15px; color: var(--ink); }
.mini-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding-top: 5px;
  margin-top: 5px;
}
.mini-margin { color: var(--warn); font-family: "JetBrains Mono", monospace; font-weight: 700; }

/* ==================== VIEW: COUNCILORS ==================== */
.council-summary {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 12px;
  flex: none;
}
.cs-block {
  background: linear-gradient(180deg, #161616, var(--card) 120px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.cs-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cs-title { font-size: 16px; font-weight: 900; }
.cs-sub { font-size: 12px; color: var(--soft); }
.cs-note { font-size: 11px; color: var(--muted); margin-left: auto; }
.cs-muted { color: var(--muted); font-size: 11px; }
.seat-bar {
  position: relative;
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
}
.sb-seg { height: 100%; background: var(--pcolor); transition: width 0.6s ease; }
.sb-seg + .sb-seg { border-left: 2px solid var(--card); }
.sb-mid { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1.5px; background: rgba(255, 255, 255, 0.6); }
.seat-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--soft); }
.sl-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.sl-item i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sl-item b { font-family: "JetBrains Mono", monospace; color: var(--ink); font-size: 13.5px; }

.council-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; flex-wrap: wrap; min-width: 0; }
.county-pills.council-pills { flex: 1 1 100%; min-width: 0; max-width: 100%; order: 2; }
.county-pills.rep-town-pills {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  order: 3;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--rule);
}
.county-pills.rep-town-pills .cpill { padding: 3px 8px; font-size: 12px; }
.council-toolbar > .filter-pills { order: 1; }
.race-switch { flex: none; }
.cd-title[data-focus] { cursor: pointer; }
.cd-title[data-focus]:hover h3 { color: var(--cyan); }
.cd-head-r { display: flex; align-items: center; gap: 6px; flex: none; }
.cd-share {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--soft);
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
  padding: 3px 5px;
  cursor: pointer;
}
.cd-share:hover { border-color: var(--cyan); color: #fff; }
.focus-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.07);
  border: 1px solid rgba(0, 240, 255, 0.3);
  font-size: 13px;
  color: var(--soft);
}
.focus-bar b { color: #fff; }
.focus-wrap { grid-column: 1 / -1; max-width: 560px; width: 100%; margin: 0 auto; }
.focus-wrap .cd-card { padding: 14px 16px 12px; }
.focus-wrap .cd-title h3 { font-size: 22px; }
.focus-wrap .cd-row { font-size: 15px; padding: 5px 8px; }
.focus-wrap .cd-votes { font-size: 16px; }
.mini-toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 300;
  max-width: 92vw;
  padding: 9px 16px;
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.96);
  border: 1px solid rgba(0, 240, 255, 0.5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  word-break: break-all;
  transition: opacity 0.2s, transform 0.2s;
}
.mini-toast.show { opacity: 1; transform: translate(-50%, 0); }
.race-switch .seg { font-size: 13px; padding: 5px 12px; }
.council-grid.township { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.council-grid.township .cd-row { font-size: 14px; padding: 5px 6px; }
.council-grid.township .cd-votes { font-size: 15px; }
.cp-sub { margin-left: 5px; font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--muted); }
.cpill.active .cp-sub { color: var(--cyan); opacity: 0.8; }
.cp-hot { margin-left: 3px; font-size: 10px; }

.council-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  align-content: start;
  align-items: start;
}
.council-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; }

.cd-card {
  background: linear-gradient(180deg, #161616, var(--card) 120px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.cd-card.hot { border-color: rgba(255, 59, 107, 0.45); }
.cd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cd-title { display: flex; align-items: baseline; gap: 7px; min-width: 0; flex-wrap: wrap; }
.cd-title h3 { font-size: 17px; font-weight: 900; }
.cd-seats { font-size: 11.5px; color: var(--soft); white-space: nowrap; }
.cd-seats b { color: var(--ink); font-family: "JetBrains Mono", monospace; }
.cd-chip { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); color: var(--soft); }
.cd-chip.hot { background: rgba(245, 158, 11, 0.14); color: #FBBF24; }
.cd-chip.tie { background: rgba(168, 85, 247, 0.15); color: #C084FC; border: 1px solid rgba(168, 85, 247, 0.35); }
.cd-chip.final { background: rgba(244, 63, 94, 0.1); color: #FF5570; border: 1px solid rgba(244, 63, 94, 0.42); display: inline-flex; align-items: center; }
.cd-chip.final .win-ic { color: #FF5570; }
.cd-src { font-family: "JetBrains Mono", monospace; font-size: 10.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.cd-src.src-cec { color: var(--ok); }
.cd-src.src-votes_tw { color: var(--cyan); }
.cd-scope {
  font-size: 12px;
  font-weight: 600;
  color: #93C5FD;
  margin-top: -2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.council-search { width: 175px; padding: 4px 9px; font-size: 12px; margin-left: 4px; }
.cm-dist-left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cm-dist-scope { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.cd-progress { height: 3px; border-radius: 999px; background: var(--track); overflow: hidden; }
.cd-progress span { display: block; height: 100%; background: var(--soft); transition: width 0.6s ease; }
.cd-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--soft); }
.cd-wbar { display: flex; height: 16px; border-radius: 5px; overflow: hidden; gap: 2px; }
.cd-wbar span {
  background: color-mix(in srgb, var(--pcolor) 70%, #000);
  color: #0A0A0A;
  font-size: 10.5px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  min-width: 14px;
}
.cd-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.cd-row {
  display: grid;
  grid-template-columns: 22px minmax(0, auto) auto auto 1fr auto;
  align-items: center;
  column-gap: 6px;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 13px;
  color: #9A9A9A;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pcolor) 9%, transparent) var(--w), transparent var(--w));
}
.cd-row.in {
  color: var(--ink);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pcolor) 22%, transparent) var(--w), rgba(255, 255, 255, 0.025) var(--w));
}
.cd-row.zero { opacity: 0.45; }
.cd-row.bump { animation: rowFlash 1.2s ease; }
.cd-rank { font-size: 11px; color: var(--muted); text-align: right; }
.cd-row.in .cd-rank { color: var(--pcolor); font-weight: 800; }
.cd-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-party { font-size: 10.5px; font-weight: 700; color: var(--pcolor); white-space: nowrap; }
.cd-tag { font-size: 9.5px; font-weight: 900; padding: 0 4px; border-radius: 3px; white-space: nowrap; }
.cd-tags { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; min-width: 0; }
.cd-tag.el { background: var(--warn); color: #0A0A0A; }
.cd-tag.q { background: rgba(255, 122, 153, 0.18); color: #FF7A99; }
.re-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex: none;
}
.re-badge .re-pct {
  font-style: normal;
  font-size: 0.92em;
  opacity: 0.85;
}
.re-badge.is-up { background: rgba(0, 245, 155, 0.12); color: #34D399; border: 1px solid rgba(0, 245, 155, 0.24); }
.re-badge.is-down { background: rgba(255, 59, 107, 0.12); color: #FB7185; border: 1px solid rgba(255, 59, 107, 0.24); }
.re-badge.is-flat { background: rgba(255, 255, 255, 0.06); color: #A1A1AA; border: 1px solid rgba(255, 255, 255, 0.12); }
.cd-row { column-gap: 4px; }
.cd-row .re-badge { font-size: 9px; padding: 0 3px; gap: 2px; }
.sm-mini-card .re-badge { font-size: 9px; padding: 0 3.5px; margin-left: 3px; gap: 2px; }
.sm-six-card .re-badge { font-size: 10px; padding: 0 5px; margin-left: 4px; }
.sm-lose-re { margin: -2px 0 2px 13px; display: flex; align-items: center; }
.sm-lose-re .re-badge { margin-left: 0; font-size: 9.5px; padding: 0 4px; }
.cd-votes { grid-column: 5; text-align: right; font-weight: 800; font-size: 13.5px; }
.cd-row.in .cd-votes { color: #fff; }
.cd-pct { font-size: 11px; color: var(--muted); min-width: 40px; text-align: right; }
.cd-cut {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
  padding-top: 3px;
  border-top: 1px dashed rgba(255, 214, 10, 0.55);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--warn);
}
.cd-cut b { margin-left: auto; font-size: 11.5px; }
.cd-cut em { font-style: normal; color: var(--muted); font-weight: 700; }

/* ==================== VIEW 3: COMPARE ==================== */
.compare-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}
.county-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: none;
}
.cpill {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.cpill.six { border-color: rgba(43, 110, 242, 0.35); }
.cpill.active {
  background: var(--card2);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

.compare-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.compare-top { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; min-height: 210px; }
.compare-header-card, .chart-card, .matrix-card { display: flex; flex-direction: column; min-height: 0; }
.matrix-card { flex: 1; }
.svg-chart-wrap { flex: 1; min-height: 150px; width: 100%; }
.matrix-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }

.matrix-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.matrix-table th, .matrix-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  white-space: nowrap;
}
.matrix-table th:first-child, .matrix-table td:first-child { text-align: left; }
.matrix-table th { color: var(--muted); font-weight: 700; background: var(--card); position: sticky; top: 0; }
.matrix-table td.mono-cell { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 15px; }
.matrix-table td.best-cell { color: var(--cyan); text-shadow: 0 0 8px rgba(0, 240, 255, 0.35); }

/* ==================== VIEW 4: YOUTUBE WALL ==================== */
.yt-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; flex: none; }
.yt-stats-line { font-size: 12.5px; color: var(--soft); font-family: "JetBrains Mono", monospace; }
.yt-toolbar-actions { display: flex; gap: 8px; }

.btn-neon, .btn-primary, .btn-ghost, .btn-secondary {
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-neon, .btn-primary {
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid var(--cyan);
  color: var(--cyan);
}
.btn-ghost, .btn-secondary {
  background: var(--card2);
  border: 1px solid var(--rule);
  color: var(--ink);
}
.btn-ghost:hover, .btn-secondary:hover { border-color: var(--dash); }

.yt-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 10px;
  overflow-y: auto;
  align-content: start;
}

.yt-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 9px;
  overflow: hidden;
}
.yt-thumb-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.yt-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.yt-overlay-top { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; justify-content: space-between; gap: 6px; }
.yt-chan-badge { padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 800; color: #fff; background: rgba(0,0,0,0.78); border-left: 3px solid currentColor; }
.yt-status-badge {
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.78);
  color: var(--soft);
  font-family: "JetBrains Mono", monospace;
}
.yt-status-badge.live { color: var(--ok); }
.yt-status-badge.analyzing { color: var(--warn); }
.yt-status-badge.error, .yt-status-badge.offline { color: var(--err); }

.yt-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.yt-headline { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt-extracted-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }
.yt-chip {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--card2);
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
}
.yt-card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); }
.yt-mini-btns { display: flex; gap: 4px; }
.yt-mini-btn { padding: 2px 6px; border-radius: 4px; border: 1px solid var(--rule); background: var(--card2); color: var(--soft); font-size: 11px; cursor: pointer; }

/* ==================== VIEW 5: CHANGES AUDIT ==================== */
.changes-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; flex: none; }
.changes-filters, .changes-exports { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sel-input {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--card2);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
}
.changes-count-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--card2);
  border: 1px solid var(--rule);
}

.changes-split { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 320px; gap: 12px; }
.changes-table-wrap { padding: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.events-sidebar { display: flex; flex-direction: column; min-height: 0; }
.changes-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.changes-table th, .changes-table td { padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.changes-table th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 700; text-align: left; }
.changes-table th.num, .changes-table td.num { text-align: right; font-family: "JetBrains Mono", monospace; }
.delta-pos { color: var(--ok); font-weight: 800; }
.delta-neg { color: var(--err); font-weight: 800; }

.events-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }
.ev-item { padding: 7px 10px; border-radius: 6px; background: var(--tile); border-left: 3px solid var(--muted); font-size: 12px; line-height: 1.4; }
.ev-item.flip { border-left-color: var(--err); }
.ev-item.elected { border-left-color: var(--warn); }
.ev-item.source { border-left-color: var(--ok); }
.ev-time { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); margin-right: 6px; }

/* ==================== BOTTOM TICKER ==================== */
.ticker-bar {
  display: flex;
  align-items: center;
  height: 36px;
  background: #0D0D0D;
  border-top: 1px solid var(--rule);
  overflow: hidden;
  flex: none;
}
.ticker-label {
  flex: none;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 13px;
  background: rgba(0, 240, 255, 0.12);
  border-right: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--cyan);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
}
.ticker-viewport { flex: 1; overflow: hidden; white-space: nowrap; }
.ticker-track { display: inline-flex; align-items: center; gap: 24px; padding-left: 20px; animation: tickerScroll 65s linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
@keyframes tickerScroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.tick-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.tick-city { color: var(--ink); font-weight: 800; }
.tick-votes { font-family: "JetBrains Mono", monospace; color: #fff; }
.tick-sep { color: var(--muted); }

/* ==================== MODAL ==================== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(4px); }
.modal-dialog {
  position: relative;
  width: min(680px, 94vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: #111111;
  border: 1px solid var(--dash);
  border-radius: 10px;
  overflow: hidden;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.modal-header h2 { font-size: 16px; }
.modal-close { border: none; background: transparent; color: var(--soft); font-size: 18px; cursor: pointer; }
.modal-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.disc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 7px; background: var(--tile); }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 12.5px; color: var(--soft); font-weight: 700; }
.form-input { padding: 9px 11px; border-radius: 6px; border: 1px solid var(--dash); background: #0A0A0A; color: #fff; font-size: 14px; }

/* ==================== TABLET & MOBILE RESPONSIVE ==================== */
@media (max-width: 1119px) {
  .six-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: auto; }
  .geo-split { grid-template-columns: 1fr; }
  .geo-map-svg-wrap { min-height: 480px; height: 68vh; max-height: 75vh; }
  .geo-side-card { min-height: 360px; }
  .map-toolbar-right { width: 100%; justify-content: space-between; }
  .map-search-wrap { flex: 1; min-width: 140px; }
  .map-search-input { width: 100%; }
  .map-search-results { left: 0; right: auto; width: 100%; }
  .map-zoom-controls { right: 10px; bottom: 96px; }
  .all-grid { grid-template-columns: repeat(2, 1fr); }
  .yt-grid { grid-template-columns: repeat(2, 1fr); }
  .compare-top { grid-template-columns: 1fr; }
  .changes-split { grid-template-columns: 1fr; }
  .council-summary { grid-template-columns: 1fr; }
  .council-grid { overflow: visible; }
  .ticker-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; }
}

@media (max-width: 880px) {
  .topbar { padding: 8px 12px; }
  .top-bar-inner { flex-wrap: wrap; gap: 8px; }
  .brand { flex: 1; }
  .view-tabs { order: 3; width: 100%; border-top: 1px solid #1E1E22; padding-top: 7px; gap: 4px; }
  .tab { padding: 5px 11px; font-size: 13px; }
  .chip-clock { display: none; }
}

@media (max-width: 640px) {
  .brand { gap: 7px; }
  .brand-title { font-size: 14.5px; }
  .seat-strip { padding-left: 7px; gap: 5px; font-size: 11px; }
  .seat b { font-size: 12px; }
  .s-tpp { display: none; }
  .more-btn { padding: 4px 8px; font-size: 12px; }
  .stc-title { font-size: 12.5px; }
  .stc-total { font-size: 11.5px; }
  #btn-tv, #btn-fullscreen { display: none; }

  .main-stage { padding: 10px 10px 16px; }
  .ref-card { padding: 10px 12px; gap: 8px; }
  .ref-name { font-size: 12.5px; }
  .ref-meta { display: none; }
  .ref-body { min-width: 100%; gap: 6px 8px; flex-wrap: wrap; justify-content: space-between; }
  .ref-track { order: 3; flex: 1 1 100%; }
  .ref-side strong { font-size: 16px; }

  .six-grid { grid-template-columns: 1fr; gap: 10px; }
  .metro-card { padding: 12px 12px 10px 14px; }
  .mc-city { font-size: 21px; }
  .cand-name { font-size: 16px; }
  .cand-votes { font-size: 21px; }
  .cand-row:not(.is-leader) .cand-votes { font-size: 18px; }
  .mc-foot { flex-direction: column; align-items: flex-start; gap: 4px; }

  .all-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .mini-city { font-size: 15px; }
  .mini-cand { font-size: 12.5px; }
  .mini-votes { font-size: 13.5px; }

  .council-grid { grid-template-columns: 1fr; }
  .cs-note { margin-left: 0; flex-basis: 100%; }
  .council-toolbar { flex-direction: column; align-items: stretch; }
  .council-toolbar > .race-switch { align-self: flex-start; }
  .county-pills.council-pills { flex: none; }
  .county-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; max-width: 100%; }
  .county-pills .cpill { scroll-snap-align: start; flex: none; }
  .yt-grid { grid-template-columns: 1fr; gap: 10px; }
  .changes-table-wrap { max-height: 55vh; }
  .ticker-bar { height: 32px; }
  .ticker-label { padding: 0 10px; font-size: 11px; }
}

/* ==================== TV / BIG-SCREEN 1920x1080 SCALED CANVAS (fusion.place/live ?tv mode) ==================== */
html.tv { overflow: hidden; background: var(--bg); height: 100%; }
html.tv body {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
  min-height: 0;
}
html.tv .app-shell { height: 1080px; padding-bottom: 0; overflow: hidden; }
html.tv.idle, html.tv.idle * { cursor: none !important; }
html.tv .brand-title { font-size: 26px; }
html.tv .chip-clock { font-size: 20px; }
html.tv .mc-city { font-size: 32px; }
html.tv .cand-name { font-size: 24px; }
html.tv .cand-votes { font-size: 40px; }
html.tv .cand-row:not(.is-leader) .cand-votes { font-size: 31px; }
html.tv .six-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
html.tv .geo-split { grid-template-columns: minmax(0, 1.45fr) minmax(440px, 0.95fr); }
html.tv .all-grid { grid-template-columns: repeat(2, 1fr); }
html.tv .yt-grid { grid-template-columns: repeat(5, 1fr); }
html.tv .council-grid { grid-template-columns: repeat(5, 1fr); }

@media (prefers-reduced-motion: reduce) {
  .beat-dot, .ticker-track { animation: none; }
}

/* Polling station pins toggle, tooltip & Area Hub station address bar */
.map-pin-toggle {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.map-pin-toggle:hover { color: #fff; border-color: rgba(255, 255, 255, 0.22); }
.map-pin-toggle.active {
  background: rgba(0, 240, 255, 0.13);
  border-color: rgba(0, 240, 255, 0.45);
  color: var(--cyan);
}
.ah-st-info {
  margin: -2px 0 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.18);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ah-st-info-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ah-st-venue { font-weight: 800; color: #F4F4F5; }
.ah-st-addr { color: var(--soft); font-size: 11.5px; line-height: 1.35; }
.ah-st-siblings { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ah-st-sib {
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.ah-st-sib.active {
  background: rgba(0, 240, 255, 0.18);
  border-color: rgba(0, 240, 255, 0.55);
  color: #fff;
}
.tt-st-addr { font-size: 11px; color: #A1A1AA; margin: -2px 0 6px; line-height: 1.35; }
.tt-st-more { font-size: 10.5px; color: #94A3B8; margin-top: 3px; }

/* Lightweight HMR status indicator & silent CSS hot-swap pill */
.beat-dot.hmr-on {
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.25), 0 0 10px rgba(0, 245, 155, 0.65);
}
.hmr-pill {
  position: fixed;
  right: 16px;
  bottom: 48px;
  z-index: 300;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(14, 18, 24, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #67E8F9;
  font-family: "JetBrains Mono", "Noto Sans TC", monospace;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.hmr-pill.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== 2026 EDITORIAL ATLAS REDESIGN & CANDIDATE PROFILES ==================== */
.brand { text-decoration: none; color: inherit; cursor: pointer; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(0, 245, 155, 0.22));
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #67E8F9;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.04em;
  flex: none;
}
.beat-dot.dev-only { display: none; }
.beat-dot.dev-only.hmr-on { display: inline-block; width: 6px; height: 6px; animation: none; }

/* Topbar Global Instant Omni-Search */
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.global-search-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}
.gs-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
  line-height: 1;
}
.gs-input {
  width: 100%;
  height: 34px;
  padding: 0 32px 0 30px;
  border-radius: 8px;
  border: 1px solid #2A2A30;
  background: rgba(255, 255, 255, 0.04);
  color: #F4F4F5;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.gs-input::placeholder { color: #71717A; }
.gs-input:focus {
  border-color: rgba(0, 240, 255, 0.55);
  background: rgba(18, 22, 28, 0.96);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.12);
}
.gs-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #303038;
  background: #17171B;
  color: #71717A;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  pointer-events: none;
}
.gs-input:focus + .gs-kbd { opacity: 0; }

.gs-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 390px;
  max-width: min(94vw, 420px);
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid #2C2D36;
  background: rgba(14, 15, 19, 0.98);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
  z-index: 120;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gs-sec-lbl {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #71717A;
  padding: 6px 8px 3px;
}
.gs-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--soft);
  font-size: 13px;
}
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease;
}
.gs-item:hover, .gs-item.is-hi { background: rgba(0, 240, 255, 0.1); }
.gs-ava {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pc, #94A3B8) 22%, #18181B);
  border: 1.5px solid color-mix(in srgb, var(--pc, #94A3B8) 65%, transparent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  overflow: hidden;
  flex: none;
}
.gs-ava img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.gs-area-ic {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: none;
}
.gs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gs-nm { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.gs-nm b { font-weight: 800; color: #FAFAFA; }
.gs-nm em { font-style: normal; font-size: 11px; font-weight: 700; }
.gs-sub { font-size: 11.5px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-num { font-size: 12.5px; font-weight: 800; color: #E4E4E7; flex: none; }
.gs-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  flex: none;
}
.gs-more {
  justify-content: center;
  margin-top: 4px;
  border-top: 1px solid #22232A;
  border-radius: 0 0 8px 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cyan);
}

/* Universal Clickable Candidate Link */
a.cand-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.12s ease;
}
a.cand-link:hover {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgba(0, 240, 255, 0.55);
  text-underline-offset: 3px;
}
.pc-area-btn {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.pc-area-btn:hover { color: var(--cyan); text-decoration: underline; }

/* Archival Site Footer */
.site-footer {
  flex: none;
  border-top: 1px solid #1C1D22;
  background: #0B0B0D;
  padding: 10px 20px;
  font-size: 11.5px;
  color: var(--muted);
}
body.on-map .site-footer { display: none; }
.sf-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  flex-wrap: wrap;
}
.sf-copy { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sf-copy strong { color: var(--soft); font-weight: 800; }
.sf-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sf-links a {
  color: var(--soft);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.14s ease;
}
.sf-links a:hover { color: var(--cyan); }

/* Homepage Atlas KPI Chips & Highlights Storyboard */
.sum-atlas-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.sac-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid #24262E;
  background: rgba(255, 255, 255, 0.03);
  color: var(--soft);
  font-size: 11.5px;
}
.sac-chip b { color: #F4F4F5; font-weight: 800; }
button.sac-chip {
  cursor: pointer;
  border-color: rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.08);
  color: #BAE6FD;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
button.sac-chip:hover { border-color: rgba(0, 240, 255, 0.7); background: rgba(0, 240, 255, 0.15); }

.sum-highlights { display: flex; flex-direction: column; gap: 10px; }
.hl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.hl-card {
  background: linear-gradient(180deg, #15161B, #101114 140px);
  border: 1px solid #23252C;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.hl-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.hl-title {
  font-size: 14px;
  font-weight: 900;
  color: #FAFAFA;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hl-cnt {
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
}
.hl-sub { font-size: 11px; color: var(--muted); }
.hl-more-link {
  border: none;
  background: transparent;
  color: var(--cyan);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
}
.hl-more-link:hover { text-decoration: underline; }
.hl-mini-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: #1A1B21;
  border: 1px solid #272830;
}
.hmt {
  border: none;
  background: transparent;
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
}
.hmt.active { background: rgba(0, 240, 255, 0.16); color: #fff; }
.hl-list { display: flex; flex-direction: column; gap: 4px; }
.hl-list.is-flips-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
@media (max-width: 640px) {
  .hl-list.is-flips-2col { grid-template-columns: 1fr; }
}
.hl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.hl-row:hover {
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.25);
  text-decoration: none !important;
}
.hl-ava {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pc, #94A3B8) 22%, #18181B);
  border: 1.5px solid color-mix(in srgb, var(--pc, #94A3B8) 65%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  overflow: hidden;
  flex: none;
}
.hl-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.hl-ava.has-img .ava-fb { opacity: 0; }
.hl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hl-nm { display: flex; align-items: center; gap: 6px; font-size: 13.5px; flex-wrap: wrap; }
.hl-nm strong { color: #FAFAFA; font-weight: 800; }
.hl-nm em { font-style: normal; font-size: 11px; font-weight: 700; }
.hl-tier {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  font-weight: 700;
}
.hl-desc { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-stat { display: flex; flex-direction: column; align-items: flex-end; flex: none; font-size: 12.5px; }
.hl-stat b { font-weight: 800; color: #F4F4F5; }
.hl-stat b.is-hot { color: #FB923C; }
.hl-stat b.is-up { color: var(--ok); }
.hl-stat span { font-size: 11px; color: var(--soft); }
.hl-stat span.is-down { color: #FB7185; font-weight: 700; }
.hl-empty { padding: 14px 8px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ==================== VIEW: CANDIDATE DIRECTORY (/candidates) ==================== */
#view-candidates, #view-candidate {
  overflow-y: auto;
  padding: 6px 2px 34px;
}
.cdir-wrap, .cand-profile-wrap {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cdir-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.cdir-hero-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cdir-hero h2 { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; color: #FAFAFA; }
.cdir-sub { font-size: 13px; color: var(--soft); margin-top: 3px; }
.cdir-meta {
  font-size: 12.5px;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.22);
  padding: 4px 10px;
  border-radius: 7px;
  font-weight: 700;
}
.cdir-toolbar {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #16171C, #111216);
  border: 1px solid #24252D;
}
.cdir-selects {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cdir-search { flex: 1; min-width: 210px; }
.cdir-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}
.cdir-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 46px 16px;
  color: var(--soft);
  font-size: 14px;
}
.cdir-more-wrap { display: flex; justify-content: center; padding: 8px 0 18px; }

.cand-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 11px;
  background: linear-gradient(180deg, #16171B, #101114 140px);
  border: 1px solid #24252C;
  border-left: 3px solid var(--pc, #94A3B8);
  text-decoration: none;
  color: inherit;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.cand-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--pc, #00F0FF) 65%, #333);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
}
.cc-top { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cc-ava {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--pc, #94A3B8) 20%, #191A20);
  border: 1.5px solid color-mix(in srgb, var(--pc, #94A3B8) 55%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  overflow: hidden;
  flex: none;
}
.cc-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.cc-ava.has-img .ava-fb { opacity: 0; }
.cc-head { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cc-no {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--pc, var(--cyan));
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.cc-name { font-size: 16.5px; font-weight: 900; color: #FAFAFA; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-party-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.cc-party { font-weight: 800; }
.cc-tier {
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  font-weight: 700;
}
.cc-race { font-size: 12px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #202127;
}
.cc-votes-box { display: flex; align-items: baseline; gap: 6px; }
.cc-votes-box b { font-size: 18px; font-weight: 900; color: #fff; }
.cc-votes-box span { font-size: 12px; color: var(--soft); }
.cc-rank { font-size: 11px; color: var(--muted); }
.cc-foot { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==================== VIEW: DEDICATED CANDIDATE PROFILE (/c/{cid}) ==================== */
.cand-profile-wrap { max-width: 1180px; }
.cp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cp-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.cp-crumb-txt { font-size: 13px; color: var(--soft); font-weight: 600; }
.cp-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.cp-hero {
  border-left: 4px solid var(--pc, var(--cyan));
  background:
    radial-gradient(480px 180px at 0% 0%, color-mix(in srgb, var(--pc, #00F0FF) 12%, transparent), transparent 72%),
    linear-gradient(180deg, #17181E, #111216);
  padding: 20px 22px;
}
.cp-hero-main { display: flex; align-items: flex-start; gap: 20px; }
.cp-ava {
  position: relative;
  width: 104px;
  height: 122px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--pc, #94A3B8) 18%, #1A1B22);
  border: 2px solid color-mix(in srgb, var(--pc, #94A3B8) 60%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  overflow: hidden;
  flex: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.cp-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.cp-ava.has-img .ava-fb { opacity: 0; }
.cp-hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cp-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cp-no {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pc, #00F0FF) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc, #00F0FF) 45%, transparent);
  color: #FAFAFA;
  font-size: 13px;
  font-weight: 800;
}
.cp-name { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; color: #FFFFFF; line-height: 1.1; }
.cp-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}
.cp-pill.is-inc { background: rgba(0, 245, 155, 0.14); color: #34D399; border: 1px solid rgba(0, 245, 155, 0.35); }
.cp-pill.is-upset { background: rgba(251, 113, 133, 0.14); color: #FB7185; border: 1px solid rgba(251, 113, 133, 0.4); }
.cp-pill.is-new { background: rgba(0, 240, 255, 0.12); color: #67E8F9; border: 1px solid rgba(0, 240, 255, 0.32); }
.cp-pill.is-al { background: rgba(168, 85, 247, 0.15); color: #D8B4FE; border: 1px solid rgba(168, 85, 247, 0.38); }
.cp-pill.is-rcl { background: rgba(251, 146, 60, 0.14); color: #FDBA74; border: 1px solid rgba(251, 146, 60, 0.42); }
.cp-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
}
.cp-tag.is-new { background: rgba(0, 240, 255, 0.12); color: #67E8F9; }
.cp-tag.is-prev { background: rgba(255, 255, 255, 0.06); color: var(--soft); }
.cp-tag.is-shift { background: rgba(251, 191, 36, 0.15); color: #FBBF24; border: 1px solid rgba(251, 191, 36, 0.35); margin-left: 4px; }
.cp-tag.is-al-tag { background: rgba(168, 85, 247, 0.16); color: #D8B4FE; border: 1px solid rgba(168, 85, 247, 0.35); margin-right: 4px; }
.cp-tag.is-rcl-tag { background: rgba(251, 146, 60, 0.16); color: #FDBA74; border: 1px solid rgba(251, 146, 60, 0.4); margin-right: 4px; }
.cp-chart-note { font-size: 11px; color: var(--muted); text-align: right; padding: 4px 6px 2px; }
.cp-hist-table tr.is-recall { background: rgba(251, 146, 60, 0.06); }
.cp-hist-table tr.is-atlarge { background: rgba(168, 85, 247, 0.045); }
.cht-note { font-size: 10.5px; color: var(--muted); font-weight: 600; margin-top: 1px; }
.cht-rcl-v { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 12px; line-height: 1.3; }
.rcl-dis { color: #34D399; }
.rcl-ag { color: #FB7185; }
.rcl-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.rcl-badge.is-fail { background: rgba(0, 245, 155, 0.12); color: #34D399; border: 1px solid rgba(0, 245, 155, 0.35); }
.rcl-badge.is-pass { background: rgba(251, 113, 133, 0.15); color: #FB7185; border: 1px solid rgba(251, 113, 133, 0.45); }

.cp-sub-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.cp-party-chip {
  padding: 2px 10px;
  border-radius: 6px;
  font-weight: 800;
  background: color-mix(in srgb, var(--pc, #94A3B8) 20%, transparent);
  color: color-mix(in srgb, var(--pc, #94A3B8) 75%, #fff);
  border: 1px solid color-mix(in srgb, var(--pc, #94A3B8) 45%, transparent);
}
.cp-race-chip { font-weight: 700; color: #E4E4E7; }
.cp-scope-txt { font-size: 12px; color: var(--muted); }

.cp-hero-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.cp-kpi {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #252730;
}
.cp-kpi-lbl { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.cp-kpi-val { font-size: 16.5px; font-weight: 900; color: #FAFAFA; display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.cp-kpi-val small { font-size: 12px; font-weight: 700; color: var(--soft); }
.cp-kpi-val.is-pos { color: var(--ok); font-size: 13.5px; }
.cp-kpi-val.is-neg { color: #FB7185; font-size: 13.5px; }

.cp-two-col {
  display: grid;
  grid-template-columns: minmax(290px, 0.85fr) minmax(360px, 1.15fr);
  gap: 14px;
  align-items: start;
}
.cp-sec { display: flex; flex-direction: column; gap: 12px; }
.cp-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cp-sec-head h3 { font-size: 15.5px; font-weight: 900; color: #FAFAFA; }
.cp-sec-sub { font-size: 11.5px; color: var(--muted); }

.cp-facts {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px 12px;
  font-size: 13.5px;
}
.cp-facts dt { color: var(--muted); font-weight: 700; }
.cp-facts dd { color: #E4E4E7; font-weight: 600; }

.cp-opp-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.cp-opp-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto auto 54px;
  align-items: center;
  column-gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  text-decoration: none;
  color: #A1A1AA;
  font-size: 13px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #94A3B8) 12%, transparent) var(--w), rgba(255, 255, 255, 0.02) var(--w));
  border: 1px solid transparent;
  transition: border-color 0.12s ease;
}
.cp-opp-row.is-in {
  color: #F4F4F5;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #94A3B8) 22%, transparent) var(--w), rgba(255, 255, 255, 0.03) var(--w));
}
.cp-opp-row.is-me { border-color: rgba(0, 240, 255, 0.55); box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.2); }
.cp-opp-row:hover { border-color: rgba(255, 255, 255, 0.35); }
.cor-rk { font-size: 11.5px; color: var(--muted); text-align: right; }
.cor-nm { font-weight: 800; color: inherit; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cor-me { font-style: normal; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; background: rgba(0, 240, 255, 0.18); color: var(--cyan); }
.cor-pt { font-size: 11px; font-weight: 700; white-space: nowrap; }
.cor-v { font-weight: 800; text-align: right; }
.cor-p { font-size: 12px; color: var(--soft); text-align: right; }

.cp-chart-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #22242C;
  border-radius: 10px;
  padding: 10px 12px 6px;
}
.cp-hist-wrap { overflow-x: auto; }
.cp-hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cp-hist-table th {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #262832;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
.cp-hist-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #1C1E26;
  vertical-align: middle;
}
.cp-hist-table tr.is-cur { background: rgba(0, 240, 255, 0.05); }
.cp-hist-table th.num, .cp-hist-table td.num { text-align: right; }
.cht-title { font-weight: 800; color: #F4F4F5; }
.cht-area { font-size: 11.5px; color: var(--soft); margin-top: 1px; }
.cht-party { font-weight: 800; }

/* Candidate Geographic Stronghold Grid */
.cp-geo-grid, .cp-geo-bars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.cp-geo-grid.is-st { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cp-geo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 52px;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid #23252D;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #00F0FF) 20%, transparent) var(--w), rgba(255, 255, 255, 0.02) var(--w));
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease;
}
.cp-geo-row:hover { border-color: rgba(0, 240, 255, 0.5); }
.cp-geo-row.is-won { border-color: color-mix(in srgb, var(--pc, #00F59B) 40%, #262830); }
.cgr-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cgr-crown { font-style: normal; color: #FACC15; margin-right: 4px; font-size: 11px; }
.cgr-votes { font-size: 12px; color: var(--soft); }
.cgr-pct { font-size: 12.5px; font-weight: 800; color: #FAFAFA; text-align: right; }

.cp-sub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.cp-mini-lbl { font-size: 12px; font-weight: 800; color: var(--soft); margin-bottom: 6px; }
.cp-vill-list { display: flex; flex-direction: column; gap: 4px; }
.cp-vill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  border: 1px solid #22242C;
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}
.cp-vill-row:hover { border-color: rgba(0, 240, 255, 0.45); background: rgba(0, 240, 255, 0.06); }
.cvr-rk { width: 18px; font-size: 11px; color: var(--muted); }
.cvr-nm { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cvr-v { font-size: 12px; color: var(--soft); }
.cvr-p { font-weight: 800; min-width: 46px; text-align: right; }

/* Candidate Per-Village / Per-Station Interactive Vote Share Choropleth Map */
.cp-geo-sec { gap: 12px; }
.cm-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.cm-kpi {
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid #232630;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
  min-width: 0;
}
.cm-kpi.is-btn {
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.12s ease;
}
.cm-kpi.is-btn:hover {
  border-color: rgba(0, 240, 255, 0.55);
  background: rgba(0, 240, 255, 0.06);
  transform: translateY(-1px);
}
.cm-kpi.is-hi { border-left: 3px solid #34D399; }
.cm-kpi.is-lo { border-left: 3px solid #FB7185; }
.cm-kpi-lbl { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.cm-kpi-val {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.cm-kpi-val b { font-size: 16px; font-weight: 900; color: #FAFAFA; }
.cm-kpi-val small {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cm-tb-left, .cm-tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cm-ctl-grp { display: flex; align-items: center; gap: 6px; }
.cm-ctl-lbl { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.cm-town-sel { padding: 4px 9px; font-size: 12px; max-width: 210px; }

.cm-exp-wrap { position: relative; display: inline-flex; }
.cm-exp-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 212px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(12, 16, 25, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.62);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cm-exp-head {
  padding: 5px 9px 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 2px;
}
.cm-exp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #F4F4F5;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.cm-exp-item:hover {
  background: rgba(0, 240, 255, 0.14);
  color: #FFFFFF;
}
.cm-exp-ratio {
  font-size: 11px;
  font-weight: 600;
  color: #94A3B8;
}
.cm-exp-item:hover .cm-exp-ratio { color: #67E8F9; }

.cm-split {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(300px, 0.92fr);
  gap: 12px;
  align-items: stretch;
}
.cm-split.is-expanded {
  grid-template-columns: 1fr;
}

.cm-stage {
  position: relative;
  height: 520px;
  border-radius: 11px;
  overflow: hidden;
  background: #0B0D12;
  border: 1px solid #242731;
  user-select: none;
  touch-action: none;
}
.cm-split.is-expanded .cm-stage { height: 700px; }
.cm-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.cm-canvas.is-drag { cursor: grabbing; }
.cm-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
  background: rgba(11, 13, 18, 0.72);
  pointer-events: none;
}

.cm-scope-chip {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(11, 14, 21, 0.86);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  color: #E4E4E7;
  font-size: 11.5px;
  font-weight: 600;
}
.cm-scope-chip b { color: #FFFFFF; }
.cm-chip-sep { color: rgba(255, 255, 255, 0.22); }
.cm-chip-x {
  background: rgba(0, 240, 255, 0.14);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--cyan);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.cm-chip-x:hover { background: rgba(0, 240, 255, 0.24); }

.cm-zoom-ctl {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(11, 14, 21, 0.84);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cm-zval {
  font-size: 11px;
  font-weight: 700;
  color: var(--soft);
  padding: 0 6px;
}
.cm-zbtn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #F4F4F5;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cm-zbtn:hover { background: rgba(0, 240, 255, 0.16); border-color: rgba(0, 240, 255, 0.5); color: #FFFFFF; }

.cm-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  min-width: 196px;
  max-width: 245px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(11, 14, 21, 0.86);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.cm-legend.is-tl { left: 10px; top: 10px; right: auto; bottom: auto; }
.cm-legend.is-tr { right: 10px; top: 10px; left: auto; bottom: auto; }
.cm-legend.is-bl { left: 10px; bottom: 10px; right: auto; top: auto; }
.cm-legend.is-br { right: 10px; bottom: 10px; left: auto; top: auto; }
.cml-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #E4E4E7;
  margin-bottom: 6px;
}
.cml-note {
  font-style: normal;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.16);
  color: #FCD34D;
}
.cml-bar-wrap { position: relative; height: 9px; margin-bottom: 5px; }
.cml-bar {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.cml-avg-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #FFFFFF;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  transform: translateX(-1px);
}
.cml-avg-mark.is-delta {
  top: -3px;
  bottom: -3px;
  width: 2.5px;
  background: #090E1A;
  box-shadow: 0 0 0 1.2px rgba(255, 255, 255, 0.92), 0 0 6px rgba(0, 0, 0, 0.65);
  transform: translateX(-1.25px);
}
.cml-ticks {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--soft);
}
.cml-mid { color: #FAFAFA; font-weight: 700; }
.cml-extra {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  color: var(--soft);
}
.cml-sym {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cml-st-dot {
  display: inline-block;
  width: 9.5px;
  height: 9.5px;
  border-radius: 50%;
  background: var(--st-col, #00F0FF);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(4, 7, 14, 0.88);
  flex: none;
}
.cml-zero-sw {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2.5px;
  background: #141720;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: none;
}

.cm-sel-card {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  width: 240px;
  max-width: calc(100% - 20px);
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(12, 15, 23, 0.93);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.42);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cms-top { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.cms-title { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 12.5px; color: #FFFFFF; }
.cms-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cms-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; border: 1px solid rgba(255, 255, 255, 0.5); }
.cms-crown { font-size: 10px; font-weight: 800; color: #FACC15; white-space: nowrap; }
.cms-rk { font-size: 10px; color: var(--soft); white-space: nowrap; }
.cms-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 1px 4px;
  line-height: 1;
}
.cms-close:hover { color: #FFFFFF; }
.cms-addr { font-size: 10.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cms-nums { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.cms-pct { font-size: 17px; font-weight: 900; color: #FFFFFF; }
.cms-v { font-size: 11px; color: var(--soft); }
.cms-diff { font-size: 11px; font-weight: 800; color: var(--soft); }
.cms-diff.is-pos { color: #34D399; }
.cms-diff.is-neg { color: #FB7185; }
.cms-empty { font-size: 11.5px; color: var(--muted); }
.cms-st-head { font-size: 10px; font-weight: 800; color: var(--soft); margin-top: 1px; }
.cms-st-list { display: flex; flex-direction: column; gap: 2px; max-height: 84px; overflow-y: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 4px; }
.cms-st-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--soft); }
.cms-st-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cms-st-row b { color: #F4F4F5; white-space: nowrap; flex: none; }
.cms-st-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--soft);
  font-size: 10.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cms-st-btn:hover { border-color: rgba(0, 240, 255, 0.5); background: rgba(0, 240, 255, 0.08); color: #FFFFFF; }
.cms-st-btn b { color: #FAFAFA; flex: none; }
.cms-st-nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#cm-side-tabs .seg { padding: 3px 7px; font-size: 11px; }
.cms-jump {
  width: 100%;
  justify-content: center;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.cm-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  pointer-events: none;
  min-width: 195px;
  max-width: 270px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(10, 13, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  color: #F4F4F5;
  font-size: 12px;
  will-change: transform;
}
.cmt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cmt-head strong { font-size: 13px; font-weight: 800; color: #FFFFFF; }
.cmt-crown { font-size: 10.5px; font-weight: 800; color: #FACC15; white-space: nowrap; }
.cmt-badge { font-size: 10.5px; color: var(--soft); background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.cmt-addr { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.cmt-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cmt-pct { font-size: 18px; font-weight: 900; color: #FFFFFF; }
.cmt-votes { font-size: 12px; color: #D4D4D8; font-weight: 700; }
.cmt-diff { font-size: 11px; font-weight: 800; color: var(--soft); }
.cmt-diff.is-pos, .cmt-diff-line.is-pos { color: #34D399; }
.cmt-diff.is-neg, .cmt-diff-line.is-neg { color: #FB7185; }
.cmt-diff-line { font-size: 11.5px; font-weight: 700; margin-top: 2px; color: var(--soft); }
.cmt-foot { font-size: 10.5px; color: var(--muted); margin-top: 5px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.cmt-empty { font-size: 11.5px; color: var(--muted); }
.cmt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--soft); margin-top: 3px; }
.cmt-row b { color: #F4F4F5; }
.cmt-more { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

/* Synchronized Side Explorer Panel */
.cm-side {
  display: flex;
  flex-direction: column;
  height: 520px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #232630;
  overflow: hidden;
}
.cm-split.is-expanded .cm-side { height: 340px; }
.cm-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px 6px;
  border-bottom: 1px solid #1E2029;
  flex-wrap: wrap;
}
.cm-side-title { font-size: 12.5px; font-weight: 800; color: #E4E4E7; }
.cm-sort-pills { display: inline-flex; gap: 3px; }
.cm-sp {
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid #272A35;
  background: transparent;
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.cm-sp:hover { border-color: rgba(255, 255, 255, 0.25); color: #FAFAFA; }
.cm-sp.active { background: rgba(0, 240, 255, 0.14); border-color: rgba(0, 240, 255, 0.45); color: var(--cyan); }

.cm-side-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid #1E2029;
}
.cm-search-input { flex: 1; min-width: 0; padding: 5px 9px; font-size: 12px; }
.cm-list-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }

.cm-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cm-empty { padding: 24px 12px; text-align: center; font-size: 12.5px; color: var(--muted); }
.cm-row {
  display: grid;
  grid-template-columns: auto 20px minmax(0, 1fr) auto 54px;
  align-items: center;
  column-gap: 6px;
  padding: 4.5px 7px;
  border-radius: 6px;
  border: 1px solid #20232C;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #00F0FF) 14%, transparent) var(--w), rgba(255, 255, 255, 0.015) var(--w));
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cm-row[data-kind="town"] { grid-template-columns: 22px minmax(0, 1fr) auto 58px; }
.cm-row:hover, .cm-row.is-hov {
  border-color: rgba(255, 255, 255, 0.36);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #00F0FF) 24%, transparent) var(--w), rgba(255, 255, 255, 0.04) var(--w));
}
.cm-row.is-sel {
  border-color: rgba(0, 240, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.28);
}
.cm-row.is-zero { opacity: 0.55; }
.cmr-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: none;
}
.cmr-rk { font-size: 10.5px; color: var(--muted); text-align: right; }
.cmr-main { display: flex; flex-direction: column; min-width: 0; }
.cmr-nm {
  font-weight: 700;
  color: #F4F4F5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmr-tn {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}
.cmr-sub {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmr-v { font-size: 11.5px; color: var(--soft); text-align: right; }
.cmr-p-wrap { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.cmr-p { font-size: 12.5px; font-weight: 800; color: #FAFAFA; }
.cmr-d { font-style: normal; font-size: 10px; font-weight: 700; color: var(--muted); }
.cmr-d.is-pos { color: #34D399; }
.cmr-d.is-neg { color: #FB7185; }
.cm-more-btn {
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px dashed #2E3240;
  background: rgba(255, 255, 255, 0.02);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.cm-more-btn:hover { background: rgba(0, 240, 255, 0.08); border-color: rgba(0, 240, 255, 0.45); }

@media (max-width: 1119px) {
  #view-candidates, #view-candidate { overflow: visible; }
  .hl-grid { grid-template-columns: 1fr; }
  .cdir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-hero-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-two-col { grid-template-columns: 1fr; }
  .cp-geo-grid, .cp-geo-bars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-sub-grid { grid-template-columns: 1fr; }
  .cm-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm-split { grid-template-columns: 1fr; }
  .cm-stage { height: 420px; }
  .cm-side { height: 360px; }
}
@media (max-width: 880px) {
  .global-search-wrap { width: 210px; }
  .gs-kbd { display: none; }
}
@media (max-width: 640px) {
  .global-search-wrap { width: 165px; }
  .cdir-grid { grid-template-columns: 1fr; }
  .cp-hero { padding: 14px 14px; }
  .cp-hero-main { flex-direction: column; gap: 12px; }
  .cp-ava { width: 78px; height: 92px; font-size: 30px; }
  .cp-name { font-size: 24px; }
  .cp-geo-grid, .cp-geo-bars, .cp-geo-grid.is-st { grid-template-columns: 1fr; }
  .cp-opp-row { grid-template-columns: 20px minmax(0, 1fr) auto auto 46px; }
  .cor-st { display: none; }
  .cm-stage { height: 350px; }
  .cm-legend { min-width: 165px; padding: 6px 8px; }
  .cm-sel-card { width: calc(100% - 20px); left: 10px; right: 10px; }
}

/* ==================== PARLIAMENT HEMICYCLE SEATING CHART & 22-COUNTY SEAT MATRIX ==================== */
.hemi-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  user-select: none;
}
.hemi-maj-line {
  stroke: rgba(255, 255, 255, 0.34);
  stroke-width: 1.25;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.hemi-dot {
  transition: opacity 0.14s ease, filter 0.14s ease;
}
.hemi-dot.is-int {
  cursor: pointer;
}
.hemi-dot.is-pend {
  fill: rgba(255, 255, 255, 0.14);
}
.hemi-svg.is-filtering .hemi-dot {
  opacity: 0.16;
}
.hemi-svg.is-filtering .hemi-dot.is-hi {
  opacity: 1;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.35));
}
.hemi-dot.is-hover {
  opacity: 1 !important;
  stroke: #FFFFFF;
  stroke-width: 1.8;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
}
.hemi-total {
  fill: #FAFAFA;
  font-weight: 900;
  letter-spacing: -0.03em;
  pointer-events: none;
}
.hemi-sub-txt {
  fill: #8E94A0;
  font-size: 11.5px;
  font-weight: 700;
  font-family: "Noto Sans TC", sans-serif;
  pointer-events: none;
}

.hemi-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  align-content: flex-start;
}
.hl-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
  color: var(--soft);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.12s ease;
}
.hl-pill.is-int {
  cursor: pointer;
}
.hl-pill.is-int:hover,
.hl-pill.is-active {
  border-color: var(--pc, var(--cyan));
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}
.hl-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.hl-pill b {
  color: #FAFAFA;
  font-size: 12.5px;
}
.hl-nums {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}
.hl-pct {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}
.cs-hemi-side .hemi-legend,
.shn-side .hemi-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 7px;
}
.cs-hemi-side .hl-pill,
.shn-side .hl-pill {
  width: 100%;
  padding: 4px 8px;
  justify-content: flex-start;
  min-width: 0;
}
.cs-hemi-side .hl-nm,
.shn-side .hl-nm {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-hemi-side .hl-nums,
.shn-side .hl-nums {
  margin-left: auto;
  flex: none;
}
.cs-hemi-side .hl-pct,
.shn-side .hl-pct {
  min-width: 34px;
  text-align: right;
}

/* Council view dual hemicycle cards */
.council-summary {
  grid-template-columns: 1fr 1fr;
}
.cs-hemi-body {
  display: grid;
  grid-template-columns: minmax(200px, 275px) minmax(0, 1fr);
  gap: 12px 14px;
  align-items: center;
}
.cs-hemi-chart {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.cs-hemi-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.cs-hemi-tip {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.cs-maj-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: var(--pc, #FAFAFA);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cs-maj-pill.is-maj {
  border-color: var(--pc, var(--cyan));
  background: rgba(255, 255, 255, 0.08);
}
.cs-mat-btn {
  margin-left: auto;
  font-size: 11.5px;
  padding: 3px 9px;
}
.cs-mat-btn.is-open {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
}

/* 22-County Wikipedia-style Party Seat Matrix Table */
.council-matrix-wrap {
  flex: none;
}
.council-matrix-wrap.hidden {
  display: none;
}
.cmat-card {
  background: linear-gradient(180deg, #161618, var(--card) 140px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cmat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.cmat-head h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  color: #FAFAFA;
}
.cmat-sub {
  font-size: 11.5px;
  color: var(--muted);
}
.cmat-scroll {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.cmat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 660px;
}
.cmat-table th {
  padding: 8px 8px;
  text-align: center;
  font-weight: 800;
  font-size: 11.5px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.cmat-table th.cmat-city-th,
.cmat-table th.cmat-bar-th {
  text-align: left;
}
.cmat-table th.cmat-pcol {
  border-bottom: 3px solid var(--pc, var(--rule));
  min-width: 52px;
}
.cmat-row {
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s ease;
}
.cmat-row:hover {
  background: rgba(255, 255, 255, 0.045);
}
.cmat-row.is-active {
  background: rgba(0, 240, 255, 0.08);
}
.cmat-city {
  padding: 6px 10px;
  border-left: 4px solid var(--lead, transparent);
  white-space: nowrap;
  font-weight: 800;
  color: #F4F4F5;
}
.cmat-six {
  display: inline-block;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.1);
}
.cmat-tot {
  padding: 6px 8px;
  text-align: center;
  font-weight: 700;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.015);
}
.cmat-bar-cell {
  padding: 6px 10px;
  min-width: 170px;
}
.cmat-bar {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
  margin-bottom: 3px;
}
.cmat-bar i {
  display: block;
  height: 100%;
}
.cmat-mid {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: rgba(255, 255, 255, 0.65);
}
.cmat-maj {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
}
.cmat-maj.is-maj {
  color: var(--pc, #FAFAFA);
}
.cmat-num {
  padding: 6px 8px;
  text-align: center;
  color: var(--soft);
  font-size: 12.5px;
}
.cmat-num.is-zero {
  color: rgba(255, 255, 255, 0.16);
}
.cmat-num.is-lead {
  font-weight: 900;
  color: var(--pc, #FFFFFF);
  background: rgba(255, 255, 255, 0.04);
}
.cmat-foot-row td {
  padding: 8px 8px;
  border-top: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 900;
}

/* Homepage Summary Parliament Hemicycle Section */
.sum-council-hemi {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sum-hemi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr);
  gap: 12px;
  align-items: stretch;
}
.sum-hemi-nat {
  background: linear-gradient(180deg, #15171D, var(--card) 160px);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.shn-chart {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.shn-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.shn-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.shn-title-row strong {
  font-size: 16px;
  font-weight: 900;
  color: #FAFAFA;
}
.shn-title-row span {
  font-size: 12px;
  color: var(--soft);
}
.sum-hemi-six {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.sum-hemi-mini {
  background: linear-gradient(180deg, #16171B, var(--card) 100px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 9px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.14s ease, background 0.15s ease;
}
.sum-hemi-mini:hover {
  border-color: rgba(0, 240, 255, 0.45);
  background: linear-gradient(180deg, #1A1D26, #14161D);
  transform: translateY(-1px);
}
.shm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.shm-head strong {
  font-size: 13px;
  font-weight: 800;
  color: #FAFAFA;
}
.shm-maj {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.shm-maj.is-maj {
  color: var(--pc, #FAFAFA);
}
.shm-svg-wrap {
  width: 100%;
  max-width: 150px;
  margin: 2px auto 0;
}
.shm-tallies {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  font-size: 10.5px;
  color: var(--soft);
}
.shm-p {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
}
.shm-p i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.shm-p b {
  color: #FAFAFA;
  font-size: 11px;
}

/* Map Council Right Inspector Hemicycle */
.map-hemi-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 10px 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mhb-chart {
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
}
.map-hemi-box .hemi-legend {
  justify-content: center;
  gap: 4px 5px;
}
.map-hemi-box .hl-pill {
  padding: 2px 6px;
  font-size: 11px;
}

/* Floating Hemicycle Seat Tooltip */
.hemi-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  min-width: 165px;
  max-width: 260px;
  padding: 8px 11px;
  border-radius: 9px;
  background: rgba(12, 14, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  color: #F4F4F5;
  font-size: 12px;
  line-height: 1.4;
  will-change: transform;
}
.hemi-tooltip.hidden {
  display: none;
}
.ht-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ht-head i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.ht-head strong {
  font-size: 13.5px;
  font-weight: 900;
  color: #FFFFFF;
}
.ht-party {
  font-size: 11.5px;
  font-weight: 800;
}
.ht-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 3px;
}
.ht-tag.is-re {
  background: rgba(0, 240, 255, 0.14);
  color: var(--cyan);
}
.ht-tag.is-q {
  background: rgba(244, 114, 182, 0.16);
  color: #F472B6;
}
.ht-dist {
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 700;
  color: #D4D4D8;
}
.ht-scope {
  font-size: 10.5px;
  color: var(--muted);
}
.ht-nums {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--soft);
}
.ht-nums b {
  font-size: 13.5px;
  color: #FFFFFF;
}
.ht-nums em {
  font-style: normal;
  color: var(--cyan);
  font-weight: 800;
}
.ht-foot {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .council-summary { grid-template-columns: 1fr; }
  .sum-hemi-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .cs-hemi-body,
  .sum-hemi-nat {
    grid-template-columns: 1fr;
  }
  .cs-hemi-chart,
  .shn-chart {
    max-width: 240px;
  }
  .sum-hemi-six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
