:root {
  --bg: #0b0e13;
  --bg-2: #11151d;
  --panel: #0e1219;
  --sea: #0b0e13;
  --line: #1d2733;
  --line-2: #2a3645;
  --ink: #e7edf4;
  --ink-dim: #93a1b3;
  --ink-faint: #5d6b7d;
  --accent: #4dd6c1;
  --accent-2: #ffd166;
  --land: #1b2530;
  --land-hi: #2b3a49;
  --stroke: #05070c;   /* near-black seat borders — high contrast against the coloured seats */
  --select: #ffd166;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- keyboard focus ring (visible only for keyboard users) ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* .seg clips overflow, so inset the ring on its buttons to keep it visible */
.seg button:focus-visible { outline-offset: -2px; }
/* the search input zeroes its outline by default — re-assert it on keyboard focus */
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

#app {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "stage panel";
  height: 100vh;
  height: 100dvh;
}

/* ---- top bar ---- */
#topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand .mark { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.brand .brand-symbol { font-family: var(--sans); }
.brand .brand-word { font-family: var(--font-display); }
.brand .mark b { color: var(--accent); font-weight: 700; }
.brand .tag { font-size: 11px; color: var(--ink-faint); letter-spacing: .02em; margin-top: 2px; }

.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  font-family: var(--mono); font-size: 12px; letter-spacing: .03em;
  color: var(--ink-dim); background: transparent; border: 0; padding: 7px 13px;
  cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover:not(:disabled) { color: var(--ink); background: var(--bg-2); }
.seg button.on { color: var(--bg); background: var(--accent); font-weight: 600; }
.seg button:disabled { color: var(--ink-faint); cursor: not-allowed; opacity: .55; }
/* "Soon/Segera" badge on the gated Skor tab — communicates "coming" instead of a dead button.
   Rendered as a ::after pill from data-after (set by applyStatic); guarded on [data-after]
   so an unset attribute never paints an empty dot. The tab stays disabled — gating is unchanged. */
.seg button[data-after]::after {
  content: attr(data-after);
  margin-left: 6px; vertical-align: middle;
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 999px;
  background: var(--accent-2); color: var(--bg);
}

.search { position: relative; }
.search input {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; width: 190px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 260px; z-index: 30;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,.5);
}
.results button {
  display: flex; justify-content: space-between; gap: 10px; width: 100%;
  text-align: left; background: transparent; border: 0; color: var(--ink);
  padding: 9px 12px; cursor: pointer; font-family: var(--sans); font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.results button:last-child { border-bottom: 0; }
.results button:hover,
.results button.active { background: var(--bg-2); }
.results button.active { box-shadow: inset 2px 0 0 var(--accent); }
.results .code { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }

/* ---- stage / map ---- */
#stage { grid-area: stage; position: relative; background:
  radial-gradient(120% 90% at 50% 0%, #0d141d 0%, var(--sea) 70%); overflow: hidden; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }

.seat {
  fill: var(--land);
  stroke: var(--stroke);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;   /* borders stay a constant ~1px wide at EVERY zoom */
  stroke-linejoin: round;
  transition: fill .12s ease;
  cursor: pointer;
}
.seat:hover { filter: brightness(1.3) saturate(1.1); stroke: var(--accent); stroke-width: 1.8; }
.seat.dim { opacity: .28; }
.seat.match { stroke: var(--accent); stroke-width: 1.8; }
.seat.sel {
  stroke: var(--select);
  stroke-width: 2.4;
  paint-order: stroke;
}
#seats.has-data .seat { stroke-width: 1; }
/* federal territories (KL/Putrajaya/Labuan) have no state assembly → shown as a muted,
   inert underlay in DUN mode so they read as "no DUN here", not as missing black holes. */
.seat.no-dun { fill: #31353e; stroke: none; pointer-events: none; }

#tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  background: rgba(8,11,16,.94); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 6px 10px; font-size: 12px; color: var(--ink);
  transform: translate(-50%, -130%); white-space: nowrap;
  box-shadow: 0 6px 22px rgba(0,0,0,.5);
}
#tooltip .t-statename { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 1px; }
#tooltip .t-code { font-family: var(--mono); color: var(--accent); font-size: 10px; }
#tooltip .t-state { color: var(--ink-faint); font-size: 11px; }
#tooltip .t-win { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
#tooltip .pill { font-size: 10px; padding: 1px 6px; }

/* big state name centred at the TOP of the map, shown on hover (desktop). Fades + lifts in. */
#state-label {
  position: absolute; top: clamp(36px, 6.5vh, 88px); left: 50%;
  transform: translateX(-50%) translateY(7px);
  z-index: 16; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; line-height: 1;
  font-size: clamp(28px, 4vw, 60px); letter-spacing: .01em;
  color: var(--ink); text-align: center; white-space: nowrap;
  text-shadow: 0 2px 30px rgba(0,0,0,.72), 0 1px 3px rgba(0,0,0,.55);
  opacity: 0; transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
#state-label.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) {
  #state-label { transition: opacity 120ms linear; transform: translateX(-50%); }
}

/* coalition seat-share bar (overview) */
.sharebar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; margin: 16px 0 8px; }
.sharebar span { display: block; height: 100%; }
.sharebar-key { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--ink-dim); }
.sharebar-key b { color: var(--ink); font-family: var(--mono); font-weight: 500; }

#reset {
  position: absolute; left: 16px; bottom: 16px; z-index: 15;
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: rgba(14,18,25,.9); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 12px; cursor: pointer; backdrop-filter: blur(6px);
}
#reset:hover { border-color: var(--accent); }
/* draw the eye when "Show all" first appears, so the way back is discoverable */
#reset:not([hidden]) { animation: reset-in .4s ease both; }
@keyframes reset-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { #reset:not([hidden]) { animation: none; } }

/* ---- first-load tap hint ---- */
.tap-hint {
  position: absolute; z-index: 16; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: min(90%, 380px);
  font-size: 12.5px; line-height: 1.4; color: var(--ink);
  background: rgba(14,18,25,.92); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 8px 8px 8px 15px; backdrop-filter: blur(6px);
  box-shadow: 0 6px 22px rgba(0,0,0,.45);
  animation: hint-in .45s ease both;
}
.tap-hint[hidden] { display: none; }
.tap-hint-x {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center; cursor: pointer; font-size: 11px; line-height: 1;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-dim);
}
.tap-hint-x:hover { color: var(--ink); border-color: var(--accent); }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .tap-hint { animation: none; } }

#loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px; color: var(--ink-faint);
  pointer-events: none;
}
#loading[hidden] { display: none; }
/* subtle "still working" affordance while boundaries load; no layout impact */
#loading:not(.error) { animation: loading-pulse 1.5s ease-in-out infinite; }
@keyframes loading-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
/* friendly, non-alarming message when a data layer can't be fetched */
#loading.error span {
  display: block; max-width: 260px; text-align: center; line-height: 1.5;
  color: var(--ink-dim); padding: 0 24px;
}
@media (prefers-reduced-motion: reduce) { #loading { animation: none; } }

/* ---- panel ---- */
#panel {
  grid-area: panel; background: var(--panel); border-left: 1px solid var(--line);
  padding: 20px 18px; overflow-y: auto;
}
/* the bottom-sheet grab-handle only exists on mobile (see the ≤820px block) */
.sheet-handle { display: none; }
#panel h2 { font-size: 16px; margin: 0 0 6px; letter-spacing: .01em; }
.muted { color: var(--ink-dim); }
.src { font-size: 11px; margin-top: 22px; }

/* ---- "Find your YB" front door (empty panel hero) ---- */
.find { padding: 4px 0 2px; }
.find-kicker { font-family: var(--mono); font-size: 11px; color: var(--accent);
  letter-spacing: .12em; margin: 0 0 6px; }
.find h2 { font-size: 22px; line-height: 1.2; margin: 0 0 8px; }
.find-sub { font-size: 13px; line-height: 1.5; margin: 0 0 16px; }
.find-loc {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 12px 16px; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: var(--bg); background: var(--accent); border: 0; border-radius: var(--radius);
}
.find-loc:hover { filter: brightness(1.06); }
.find-loc:disabled { cursor: progress; opacity: .7; }
.find-or { font-size: 12px; text-align: center; margin: 12px 0 2px; }
.find-eg { font-size: 12px; line-height: 1.5; margin: 0; color: var(--ink-faint); }
.find-status { font-size: 12px; line-height: 1.5; margin: 10px 0 0; padding: 8px 10px;
  border-radius: var(--radius); background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink); }

/* legend + summary demoted into a collapsible "explore" disclosure */
.empty-more { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.empty-more > summary {
  cursor: pointer; font-size: 12px; color: var(--ink-dim);
  list-style: none; user-select: none; padding: 2px 0;
}
.empty-more > summary::-webkit-details-marker { display: none; }
.empty-more > summary::before { content: "▸ "; color: var(--ink-faint); }
.empty-more[open] > summary::before { content: "▾ "; }
.empty-more > summary:hover { color: var(--ink); }

.legend { margin: 20px 0 10px; display: flex; flex-direction: column; gap: 5px; }
.legend .row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); }
/* 1px ring keeps low-contrast swatches distinguishable from the panel and each
   other — colour is never the only cue (every row is paired with a text label). */
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(231,237,244,.22); }
.sharebar-key .sw { border: 1px solid rgba(231,237,244,.22); }

.summary { margin: 6px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.summary dt { color: var(--ink-faint); font-size: 12px; }
.summary dd { margin: 0; font-family: var(--mono); font-size: 13px; text-align: right; }

/* seat panel */
.seat-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.seat-head .kicker { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .08em; }
.seat-head h2 { font-size: 22px; margin: 4px 0 2px; }
.seat-head .where { font-size: 13px; color: var(--ink-dim); }
.seat-head .where b { color: var(--ink); font-weight: 500; }

/* detail as a CLOSED bordered table: an outer box with row + column hairlines, so every
   metric is a boxed cell — easy to scan on mobile. min-width:0 lets the value cell shrink
   and WRAP rather than overflow; overflow-wrap breaks even an unbroken long string. */
.rows {
  display: grid; grid-template-columns: auto 1fr;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.rows dt, .rows dd { padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.rows dt { color: var(--ink-dim); font-size: 12.5px; white-space: nowrap; border-right: 1px solid var(--line); }
.rows dd { margin: 0; text-align: right; font-size: 14px; overflow-wrap: anywhere; }
.rows dd.mono { font-family: var(--mono); }
.rows .bloc-unit { white-space: nowrap; }   /* "· <pill>" stays as one unit when the party name wraps */
.rows dt:last-of-type, .rows dd:last-of-type { border-bottom: 0; }   /* last row closed by the outer border */

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  font-family: var(--mono); color: #0b0e13; }
.placeholder { color: var(--ink-faint); font-style: italic; font-size: 13px; }

.note { margin-top: 18px; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; color: var(--ink-dim); line-height: 1.5; }
.note b { color: var(--ink); }

/* per-card data provenance (transparency: every number shows its source) */
.src-line { margin-top: 12px; font-size: 11px; line-height: 1.4; }

/* share / copy-link */
.seat-actions { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn { flex: 1 1 140px; width: 100%; min-height: 44px; padding: 11px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); transition: border-color .15s, color .15s; }
.share-btn:hover { border-color: var(--accent); color: var(--accent); }

/* transient confirmation toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  max-width: min(92vw, 420px); padding: 11px 16px; font-size: 13px; text-align: center;
  color: var(--bg); background: var(--accent); border-radius: 999px; z-index: 50;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s; } }

/* ============================================================
   KD Labs font pairing — Space Grotesk (body) + Redaction (serif display)
   self-hosted woff2 (same files as kd-labs), zero external requests
   ============================================================ */
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/space-grotesk-latin.woff2) format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/space-grotesk-latinext.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Redaction 20"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/redaction-20-latin.woff2) format("woff2"); }
@font-face { font-family: "Redaction 20"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/fonts/redaction-20-bold-latin.woff2) format("woff2"); }
@font-face { font-family: "Redaction"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/redaction-latin.woff2) format("woff2"); }

:root {
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "Redaction 20", Georgia, "Times New Roman", serif;
  --font-display-fine: "Redaction", Georgia, "Times New Roman", serif;
}

/* the pairing move: headlines in the Redaction serif, body stays Space Grotesk */
h1, h2, .seat-head h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0; }

/* =================================================================
   XIO-STYLE DARK FLOATING LAYOUT  (consolidated — replaces all prior
   light/mono/mobile-vN overrides). Full-bleed map; logo + icons float
   top; a bordered (no-shadow) card floats bottom and expands into the
   seat detail. Body font Space Grotesk, headlines Redaction.
   ================================================================= */

/* ---- near-black palette (XIO) + light monochrome chrome ---- */
:root {
  --bg: #0e0f12; --bg-2: #181a1f; --panel: #16181c; --sea: #0e0f12;
  --line: #2a2d33; --line-2: #383c45;
  --ink: #e9eaed; --ink-dim: #9a9da4; --ink-faint: #6b6f77;
  --accent: #eceef1; --accent-2: #eceef1;
  --land: #1c2026; --land-hi: #2a2f37; --stroke: #3a3f48; --select: #ffffff;
  --control-radius: 12px;
  /* ---- motion vocabulary (one source of truth; compositor-only props only) ---- */
  --dur-1: 150ms; --dur-2: 200ms; --dur-3: 300ms; --dur-4: 400ms;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);      /* entrances / user-triggered */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); /* reflow */
}

body { font-family: var(--sans); }
#app { display: block; position: relative; height: 100vh; height: 100dvh; }

/* ---- full-bleed map canvas ---- */
#stage {
  position: fixed; inset: 0; z-index: 1; border: 0;
  /* the grid is part of the stage BACKGROUND, so it's always behind the map;
     smaller cells (24px) with a fainter 96px major line for a chart feel */
  background:
    linear-gradient(to right,  rgba(255,255,255,.045) 1px, transparent 1px) 0 0 / 96px 96px,
    linear-gradient(to bottom, rgba(255,255,255,.045) 1px, transparent 1px) 0 0 / 96px 96px,
    linear-gradient(to right,  rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(to bottom, rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(120% 90% at 50% 0%, #15171c 0%, var(--sea) 72%);
}
#loading, #tooltip, #tap-hint, #seats { position: relative; z-index: 2; }
/* The map owns the visible band between the floating top chrome and the bottom card.
   JS keeps --map-top/--map-h in sync with the real chrome/card heights on resize. */
#map {
  margin-top: var(--map-top, 70px);
  height: var(--map-h, calc(100% - var(--map-top, 70px) - 200px));
}

/* ---- floating top bar: logo left, icon cluster right ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;   /* stays above the lifted map when a state is open */
  background: none; border: 0; flex-wrap: nowrap;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { flex-direction: row; align-items: center; }
.brand .mark { font-size: 18px; }
.brand .tag { display: none; }
.brand-home {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font: inherit;
  line-height: 1.05;
  background: rgba(20,22,26,.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.brand-home:hover { border-color: var(--line-2); }
.topicons { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.iconbtn {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  background: rgba(20,22,26,.72); border: 1px solid var(--line); border-radius: var(--control-radius);
  color: var(--ink-dim); cursor: pointer; backdrop-filter: blur(8px);
  transition: color .15s, border-color .15s;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { color: var(--ink); border-color: var(--line-2); }
.iconbtn:active { transform: scale(.92); }
.top-controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: auto;
}
.top-controls .seg.chip {
  background: rgba(20,22,26,.72);
  border-color: var(--line);
  backdrop-filter: blur(8px);
}
.top-controls .seg.chip button {
  min-height: 44px;
  padding: 8px 14px;
}
.lang-seg {
  background: rgba(20,22,26,.72); border: 1px solid var(--line); border-radius: var(--control-radius);
  backdrop-filter: blur(8px); overflow: hidden;
}
.lang-seg button { min-width: 44px; min-height: 44px; padding: 9px 9px; font-size: 11px; }

@media (max-width: 860px) {
  .top-controls {
    top: calc(max(12px, env(safe-area-inset-top)) + 54px);
  }
}

@media (max-width: 430px) {
  #topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .brand-home { padding-inline: 10px; }
  #topbar .brand .mark { font-size: 16px; }
  .topicons { gap: 6px; }
  .top-map-btn { display: none; }
  .top-controls {
    width: calc(100vw - 20px);
    gap: 6px;
  }
  .top-controls .seg.chip button {
    padding: 8px 10px;
    font-size: 11px;
  }
}

/* ---- info card: pops up under the top nav, same card style ---- */
#info-card {
  position: fixed; top: 62px; right: 14px; z-index: 55;
  width: min(360px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: none; padding: 16px;
}
#info-card[hidden] { display: none; }
.info-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.info-head h2 { font-size: 17px; margin: 0; }
.info-head .card-back { width: 32px; height: 32px; font-size: 14px; }
#info-card p { font-size: 13px; line-height: 1.55; margin: 10px 0 0; }
#info-card .src { margin-top: 12px; }

/* ---- floating bottom card (search/controls ⇄ seat detail) ---- */
#panel {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30;
  display: flex; justify-content: center; align-items: flex-end;
  background: none; border: 0; overflow: visible;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  transition: padding 280ms cubic-bezier(0.4, 0, 0.2, 1);   /* ease the lift when crossing the breakpoint */
}
#panel-empty {
  transform-origin: bottom center;   /* the minimize collapse grows/shrinks from the bottom */
  max-height: var(--panel-card-max-h, none);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#panel-empty, #panel-seat, #panel-state {
  width: 100%; max-width: 560px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: none; padding: 12px;
  /* mobile↔desktop is a media-query flip; transition the size props so the card MORPHS
     between the two sizes instead of snapping (also a smooth follow on window drag). */
  transition: width 280ms cubic-bezier(0.4, 0, 0.2, 1), max-width 280ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  #panel, #panel-empty, #panel-seat, #panel-state { transition: none; }
}
#panel-seat, #panel-state {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#panel-state {
  display: flex;
  flex-direction: column;
}
#panel.state-summary #panel-state {
  height: auto;
  max-height: var(--panel-card-max-h, calc(100dvh - 86px));
}
#panel.seat-detail #panel-state {
  height: auto;
  max-height: var(--panel-card-max-h, calc(100dvh - 70px));
}
/* the card shows exactly one view at a time (toggled by the [hidden] attrs in JS) */
#panel.empty #panel-seat, #panel.empty #panel-state { display: none; }
#panel:not(.empty) #panel-empty { display: none; }
#panel-empty[hidden], #panel-seat[hidden], #panel-state[hidden] { display: none; }

/* ---- state card: header + a mini-map of that state's districts ---- */
.state-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.state-h { min-width: 0; }
.state-h h2 { font-size: 18px; margin: 0; line-height: 1.1; }
.state-h .muted { font-size: 12px; }
.state-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.state-actions[hidden] { display: none; }
.share-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 0;
}
.share-icon svg { width: 20px; height: 20px; }
.share-icon:hover { border-color: var(--line-2); background: #20242b; }
.share-icon:disabled,
.share-icon[aria-busy="true"] {
  opacity: .62;
  cursor: progress;
}
.card-back {
  flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--ink-dim); cursor: pointer; font-size: 17px; line-height: 1; padding: 0;
}
.card-back:hover { color: var(--ink); border-color: var(--line-2); }
#panel-seat .card-back { width: auto; min-width: 44px; height: 44px; padding: 0 12px; gap: 6px; font-size: 13px; margin-bottom: 12px; }
.state-map-wrap { width: 100%; height: 300px; }
#state-map { width: 100%; height: 100%; display: block; }
.mini-seat { stroke: var(--line-2); stroke-width: .25; cursor: pointer; transition: filter .12s; }
.mini-seat:hover { filter: brightness(1.3) saturate(1.1); stroke: var(--accent); stroke-width: .5; }
.mini-seat.sel { stroke: var(--select); stroke-width: .8; paint-order: stroke; }

/* info under the state map: coalition make-up by default, the tapped district's detail when chosen */
#state-info { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.state-info-h { font-size: 12px; margin: 0 0 8px; }
.state-tap-hint { font-size: 12px; margin: 12px 0 0; text-align: center; }
.state-turnout { font-size: 12px; margin-top: 8px; }
.state-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.state-stat {
  min-width: 0;
  min-height: 72px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.state-stat-label {
  color: var(--ink-dim);
  font-size: 11px;
  line-height: 1.2;
}
.state-stat-value {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.state-stat-note {
  min-width: 0;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.state-bloc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.state-bloc .sw {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  border: 1px solid rgba(231,237,244,.22);
  flex: 0 0 auto;
}
#state-info .seat-head { border-bottom: 0; padding-bottom: 0; margin-bottom: 12px; }
#state-info .seat-actions { margin-top: 14px; }
.seat-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seat-tabs::-webkit-scrollbar { display: none; }
.seat-tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.seat-tab:hover { color: var(--ink); border-color: var(--line-2); background: #20242b; }
.seat-tab.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.seat-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.seat-tabpanel { min-width: 0; }
.seat-overview {
  display: grid;
  gap: 10px;
}
.seat-yb-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.seat-yb-card span,
.seat-metric span,
.module-empty-kicker,
.module-empty-needed span {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.seat-yb-card strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
}
.seat-yb-card p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.4;
}
.seat-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.seat-metric {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.seat-metric b {
  min-width: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.seat-metric small {
  color: var(--ink-faint);
  font-size: 11px;
}
.rows.seat-score-row { margin-top: 10px; }
.module-empty {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.module-empty h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.25;
}
.module-empty p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.45;
}
.module-empty-needed {
  display: grid;
  gap: 5px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.candidate-module,
.voting-guide {
  display: grid;
  gap: 10px;
}
.module-source {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.module-source span {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.module-source p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 12px;
  line-height: 1.4;
}
.candidate-vote-share {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.018)),
    rgba(255,255,255,.018);
}
.candidate-vote-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.candidate-vote-head h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.candidate-vote-head span {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.candidate-vote-sides {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
}
.candidate-vote-sides.single {
  grid-template-columns: minmax(0, 1fr);
}
.candidate-vote-side {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.candidate-vote-side.right {
  justify-items: end;
  text-align: right;
}
.candidate-vote-side-name {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}
.candidate-vote-side-name .candidate-vote-dot {
  flex: 0 0 auto;
}
.candidate-vote-side.right .candidate-vote-side-name {
  flex-direction: row-reverse;
}
.candidate-vote-side-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.candidate-vote-side-meta {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}
.candidate-vote-bar {
  display: flex;
  width: 100%;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.candidate-vote-seg {
  flex-basis: 0;
  flex-shrink: 1;
  min-width: 3px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 8px;
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  box-shadow: inset -1px 0 rgba(9,13,18,.7);
}
.candidate-vote-seg:last-child {
  box-shadow: none;
}
.candidate-vote-seg span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.candidate-vote-seg.middle {
  justify-content: center;
}
.candidate-vote-seg.right-edge {
  justify-content: flex-end;
}
.candidate-vote-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 10px;
}
.candidate-vote-key-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--ink-dim);
  font-size: 11px;
  line-height: 1.3;
}
.candidate-vote-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.18);
}
.candidate-vote-key-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.candidate-vote-key-item b {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}
.candidate-list {
  display: grid;
  gap: 8px;
}
.candidate-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.candidate-card.won {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: rgba(255,255,255,.045);
}
.candidate-main {
  min-width: 0;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.candidate-rank {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.candidate-card h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.25;
}
.candidate-card p {
  margin: 3px 0 0;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.candidate-side {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}
.candidate-status {
  color: var(--ink-dim);
  font-size: 12px;
  white-space: nowrap;
}
.candidate-meta {
  grid-column: 1 / -1;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
}
@media (max-width: 430px) {
  .candidate-vote-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
  .candidate-vote-bar {
    height: 32px;
  }
  .candidate-vote-seg {
    padding: 0 5px;
    font-size: 10px;
  }
  .candidate-vote-sides {
    gap: 10px;
  }
  .candidate-vote-side-name {
    font-size: 12px;
  }
  .candidate-vote-key {
    grid-template-columns: 1fr;
  }
}
.voting-privacy {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-dim);
  background: rgba(255,255,255,.025);
  font-size: 13px;
  line-height: 1.45;
}
.voting-actions {
  display: grid;
  gap: 8px;
}
.voting-action {
  min-height: 44px;
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  color: var(--ink);
  text-decoration: none;
}
.voting-action:hover {
  border-color: var(--line-2);
  background: #20242b;
  text-decoration: none;
}
.voting-action strong {
  font-size: 14px;
  line-height: 1.25;
}
.voting-action span {
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.4;
}
.voting-action em {
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

/* idle card: search and locate share one control row */
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.search { flex: 1 1 auto; min-width: 0; position: relative; }
.search input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 14px; font-family: var(--sans); color: var(--ink);
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus { border-color: var(--line-2); outline: none; }
.results { top: auto; bottom: calc(100% + 8px); left: 0; right: 0; width: auto;
  background: var(--panel); border-color: var(--line-2); box-shadow: 0 -16px 40px rgba(0,0,0,.5); }

/* ---- national at-a-glance: the Dewan Rakyat (GE15) makeup, idle card header ---- */
.nat-glance { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.nat-glance[hidden] { display: none; }
.nat-glance-h { font-size: 11px; color: var(--ink-faint); letter-spacing: .02em; }
.nat-glance .sharebar { margin: 9px 0 7px; }
.nat-glance .sharebar-key { gap: 5px 13px; }
.nat-glance .sharebar-key .sk { display: inline-flex; align-items: center; gap: 5px; }  /* keep each PH·82 together on wrap */
.nat-glance-maj { font-size: 11px; color: var(--ink-faint); margin-top: 7px; }

@media (min-aspect-ratio: 1/1) {
  .nat-glance-h {
    font-size: 13px;
    line-height: 1.3;
  }
  .nat-glance .sharebar {
    height: 14px;
    margin: 10px 0 8px;
  }
  .nat-glance .sharebar-key {
    gap: 6px 16px;
    font-size: 13px;
    line-height: 1.35;
  }
  .nat-glance-maj {
    font-size: 12.5px;
    line-height: 1.35;
  }
}

.card-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.find-actions { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; }
.seg.chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--control-radius); }
.seg.chip button { min-height: 44px; padding: 8px 13px; font-size: 12px; }
.seg.chip button.on { background: var(--accent); color: var(--bg); font-weight: 600; }
.seg.chip button:hover:not(:disabled):not(.on) { background: #20242b; color: var(--ink); }

/* circular locate button — the XIO "send" position */
.loc-fab {
  flex: 0 0 auto; width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--accent); color: var(--bg); border: 0; cursor: pointer;
  transition: filter .15s;
}
.loc-fab svg { width: 22px; height: 22px; }
.loc-fab:hover { filter: brightness(.9); }
.find-status { margin: 10px 2px 0; }

/* ---- things we no longer show in the card ---- */
#reset { display: none !important; }
.empty-more[hidden] { display: none; }
.sheet-handle { display: none !important; }

/* ---- seat detail card (reuses .seat-head/.rows/.seat-actions, dark) ---- */
.seat-actions { margin-top: 16px; }
.share-btn { background: var(--bg-2); }

/* ---- share-card preview dialog ---- */
.card-preview {
  width: min(420px, calc(100vw - 28px));
  max-height: min(92dvh, 760px);
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.62);
  overflow: hidden;
}
.card-preview::backdrop { background: rgba(0,0,0,.62); }
.card-preview-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(92dvh, 760px);
}
.card-preview-head,
.card-preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.card-preview-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.card-preview-head h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
}
.card-preview-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-dim);
  cursor: pointer;
}
.card-preview-close svg { width: 18px; height: 18px; }
.card-preview-close:hover { color: var(--ink); border-color: var(--line-2); }
.card-preview-frame {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 14px;
  background: #101217;
}
.card-preview-frame img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(62dvh, 560px);
  height: auto;
  border-radius: 0;
  border: 0;
  background: #0f141b;
}
.card-preview-actions {
  border-top: 1px solid var(--line);
}
.preview-download {
  min-height: 44px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.preview-download svg { width: 18px; height: 18px; }
.preview-download:hover { filter: brightness(.92); }
.preview-download:disabled { opacity: .6; cursor: progress; }

/* ---- boot coachmark → light bubble on the dark canvas ---- */
.coach { background: #f3f4f6; color: #121316; box-shadow: 0 10px 30px rgba(0,0,0,.5); border: 0; }
.coach-arrow { background: #f3f4f6; }

/* ---- state-first overview: hide internal seat borders so states read as blobs ---- */
#seats.overview .seat { stroke: var(--stroke); stroke-width: 1; }
#seats.overview .seat:hover { stroke: var(--stroke); filter: brightness(1.12); }
/* hover (mouse only): light up every seat of the state under the cursor, uniformly */
#seats .seat.state-hover, #seats.overview .seat.state-hover:hover { filter: brightness(1.32); }

/* ---- spotlight: with a state card open, the open state stays lit, the rest dim back ---- */
#seats .seat { transition: opacity .18s ease; }
#seats.overview .seat.outstate { opacity: .24; }
#seats.overview .seat.instate { opacity: 1; }

/* ---- isolate & zoom: tap a state → the others fade out, its districts get borders,
   and the map zooms in (the big map becomes the district map; card rises behind) ---- */
#seats.isolated .seat.outstate { opacity: 0; pointer-events: none; }
#seats.isolated .seat.instate { opacity: 1; stroke: var(--stroke); stroke-width: 1; paint-order: stroke; }
#seats.isolated .seat.instate:hover { stroke: var(--accent); stroke-width: 1.8; filter: brightness(1.12); }
#seats.isolated .seat.sel { stroke: var(--select); stroke-width: 2.4; paint-order: stroke; }
.state-map-wrap { display: none; }   /* the isolated state IS the map now — drop the card mini-map */

/* ---- state open: keep the same bottom card, expanding it upward by view state. ---- */
body.state-open #stage { z-index: 1; pointer-events: auto; }
body.state-open #seats .seat.instate { pointer-events: auto; }   /* districts stay tappable */
body.state-open #tap-hint { display: none; }                     /* overview coachmark off while drilled in */
body.state-open #panel-state {
  max-width: 620px;
  justify-content: flex-start;
  transform-origin: bottom center;
}

/* ---- wider than a phone (landscape / desktop): the bottom sheet becomes a FLOATING card
   over a full-bleed map. An open state zooms into the map full-bleed with its detail in the
   floating card — NOT the tall mobile backdrop (which left a lot of empty space here). ---- */
@media (min-aspect-ratio: 1/1) {
  #panel { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  /* cap the map width on wide screens and CENTRE it (grid stays full-bleed behind). The map
     is aspect-locked, so a width cap also bounds its height. */
  #map {
    max-width: 1280px; margin-left: auto; margin-right: auto;
    height: var(--map-h, calc(100% - var(--map-top, 70px) - 200px));
    transition: height 320ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* the card widens with the viewport on wider screens (not a lost 560px under a huge map),
     capped so the content stays readable */
  #panel-empty, #panel-seat, #panel-state {
    max-width: clamp(560px, 62vw, 820px);
    box-shadow: 0 22px 60px rgba(0,0,0,.55);
  }
  body.state-open #stage { z-index: 1; pointer-events: auto; }
  body.state-open #map { height: var(--map-h, calc(100% - var(--map-top, 70px) - 200px)); }
  body.state-open #panel { top: auto; bottom: 0; align-items: flex-end; padding-top: 0; }
  body.state-open #panel-state {
    max-width: clamp(560px, 62vw, 820px);
    justify-content: flex-start;
    transform-origin: bottom center;
  }
  #panel.state-summary #panel-state { height: auto; }
  #panel.seat-detail #panel-state { height: auto; max-height: var(--panel-card-max-h, calc(100dvh - 70px)); }
}

@media (prefers-reduced-motion: reduce) { #seats .seat { transition: none; } }

/* ---- tactile press feedback: a small compositor-only scale on :active ---- */
.seg button, .lang-seg button, .brand-home, .iconbtn, .share-btn, .share-icon, .card-back, .seat-tab,
.card-preview-close, .preview-download, .find-loc {
  transition-property: background, color, border-color, transform;
  transition-duration: var(--dur-1);
  transition-timing-function: var(--ease-out);
}
.seg button:focus-visible, .lang-seg button:focus-visible, .brand-home:focus-visible, .iconbtn:focus-visible,
.card-back:focus-visible, .share-btn:focus-visible, .share-icon:focus-visible, .seat-tab:focus-visible,
.card-preview-close:focus-visible, .preview-download:focus-visible, .loc-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.seg button:active:not(:disabled), .lang-seg button:active, .brand-home:active, .card-back:active, .seat-tab:active,
.share-icon:active, .card-preview-close:active { transform: scale(.94); }
.iconbtn:active { transform: scale(.9); }
.share-btn:active, .preview-download:active, .find-loc:active:not(:disabled) { transform: scale(.985); }
@media (prefers-reduced-motion: reduce) {
  .seg button:active, .lang-seg button:active, .brand-home:active, .iconbtn:active,
  .share-btn:active, .card-back:active, .share-icon:active, .seat-tab:active,
  .card-preview-close:active, .preview-download:active, .find-loc:active { transform: none; }
}

/* ---- narrow phones: let the controls row breathe ---- */
@media (max-width: 380px) {
  .seg.chip button { padding: 8px 10px; font-size: 11px; }
  .loc-fab { width: 44px; height: 44px; }
}

/* ---- fluid card type + spacing: scales UP with viewport width on wide screens, giving the
   card bigger text and more height/room. Each clamp's MINIMUM is the existing phone size, and
   vw is tiny on phones/tablets, so those are unchanged — it only grows on wide desktops.
   Continuous (no breakpoint jump), so no transition needed. ---- */
#panel-seat, #panel-state { padding: clamp(16px, 1.55vw, 28px); }
#panel .seat-head h2 { font-size: clamp(16px, 1.9vw, 30px); }   /* min 16 = the real phone size (beats `#panel h2`) */
.seat-head .where { font-size: clamp(13px, 1.05vw, 16px); }
.seat-head .kicker { font-size: clamp(11px, 0.82vw, 13px); }
#panel .state-h h2 { font-size: clamp(16px, 1.6vw, 25px); }
.state-h .muted { font-size: clamp(12px, 0.95vw, 15px); }
.rows dt { font-size: clamp(12.5px, 1.02vw, 15.5px); }
.rows dd { font-size: clamp(14px, 1.18vw, 18px); }
.rows dt, .rows dd { padding-block: clamp(10px, 0.95vw, 16px); }
.sharebar { height: clamp(12px, 1.05vw, 18px); }
.sharebar-key { font-size: clamp(11px, 0.92vw, 14px); }
.state-stat-label, .state-stat-note { font-size: clamp(11px, 0.86vw, 13px); }
.state-stat-value { font-size: clamp(15px, 1.12vw, 18px); }

@media (min-width: 720px) {
  .state-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .state-stats { grid-template-columns: 1fr; }
  .seat-metrics { grid-template-columns: 1fr; }
}

@media (min-aspect-ratio: 1/1) and (max-height: 700px) {
  #panel.seat-detail #panel-state {
    max-height: var(--panel-card-max-h, calc(100dvh - 160px));
    padding: 14px 18px;
  }
  #panel.seat-detail #state-info {
    margin-top: 8px;
    padding-top: 8px;
  }
  #panel.seat-detail #state-info .seat-head {
    margin-bottom: 6px;
  }
  #panel.seat-detail #state-info .seat-head h2 {
    margin-block: 2px;
    font-size: 24px;
  }
  #panel.seat-detail .rows dt,
  #panel.seat-detail .rows dd {
    padding-block: 5px;
  }
  #panel.seat-detail .src-line {
    margin-top: 8px;
  }
}

/* ---- animations OFF for now (per request): instant transitions/animations everywhere.
   Remove this block (and flip ANIM_OFF in app.js) to bring motion back. ---- */
*, *::before, *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}
