/* Simplified access-to applet — mobile-first responsive shell.
   Single column on phones; controls + map stack, info card is a bottom sheet.
   At a wide breakpoint the controls become a left rail and the info card a
   right-side panel. */

:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #e2e2e2;
  --accent: #2b6cb0;
  --sheet-shadow: 0 -2px 16px rgba(0,0,0,0.12);
  --panel-shadow: 0 2px 16px rgba(0,0,0,0.12);
  --pad: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  /* Clip the tap-card's hidden state (translateY/translateX off #app's edge) —
     a transformed descendant otherwise extends the page's scrollable region and
     the "closed" card becomes reachable by scrolling (mobile) or panning right
     (desktop). overflow:clip (not hidden) clips WITHOUT making #app a scroll
     container: `hidden` still permits programmatic scrolling, so Driver.js's
     scrollIntoView during the walkthrough would chase the off-screen card and
     shift the whole layout. `hidden` stays as a fallback for pre-clip browsers.
     The card scrolls internally via its own overflow-y. */
  overflow: hidden;
  overflow: clip;
}
/* <main> is a landmark only — its children must stay direct flex/grid items of #app */
#app > main { display: contents; }

/* ---------- Headline ---------- */
#headline {
  padding: 7px var(--pad) 6px;
  border-bottom: 1px solid var(--line);
}
#headline-main {
  font-size: 1.0rem;   /* it's an <h1> — override the UA heading size/margin */
  font-weight: 650;
  line-height: 1.22;
  margin: 0;
}
#headline-main .num { color: var(--accent); font-weight: 800; }
#headline-main .delta-up { color: #1a7a4c; }
#headline-main .delta-down { color: #b3402a; }
#headline-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
#headline-sub:not(:empty) { margin-top: 3px; }

/* ---------- Controls ---------- */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 7px var(--pad);
  border-bottom: 1px solid var(--line);
}
.ctl { display: flex; flex-direction: column; gap: 2px; flex: 1 1 150px; min-width: 130px; }
.ctl-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
/* Desktop-only static section label for the always-expanded rail sections */
.ctl-head-static { display: none; }
.ctl select {
  font-size: 0.9rem; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); width: 100%;
}
/* Shared label column so every row's label|control break lines up at the same
   x (Taylor 2026-07-10). Fixed first column = the labels; control fills the rest
   and can't overflow the rail (minmax(0,1fr) shrinks). Labels wrap within column. */
#controls { --label-w: 132px; }
.ctl-dest { display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); align-items: center; gap: 8px; flex: 1 1 100%; }

/* Unified control "field" (Taylor 2026-07-13): one visual language for all four
   top-level controls — a bordered box showing the current value with a down-
   chevron. The two single selects render native inside it; the two collapsible
   headers (scenario / profile) reuse the same box and just expand a panel below.
   Previously selects and accordions looked like two different widgets. */
.ctl-field {
  position: relative; display: block; min-width: 0;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.ctl-field:hover { border-color: #b9b9b9; }
.ctl-field::after {                       /* ▾ — one chevron style for all four */
  content: '\25BE'; position: absolute; right: 9px; top: 50%;
  transform: translateY(-50%); color: var(--muted); font-size: 0.72rem;
  pointer-events: none; transition: transform 0.15s;
}
.ctl-collapsible.open .ctl-field::after { transform: translateY(-50%) rotate(180deg); }
.ctl-field select {
  appearance: none; -webkit-appearance: none; border: none; background: transparent;
  width: 100%; padding: 5px 26px 5px 8px; font-size: 0.9rem; color: var(--ink);
}
.ctl-field .ctl-summary {
  display: block; padding: 5px 26px 5px 8px; font-size: 0.9rem; color: var(--ink);
  line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Collapsible scenario / profile sections (accordion) — same label column + field */
.ctl-collapsible { flex: 1 1 100%; gap: 0; }
.ctl-head {
  display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); align-items: center; gap: 8px; width: 100%;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left; color: inherit;
}
.ctl-body { display: none; margin-top: 6px; }
.ctl-collapsible.open .ctl-body { display: block; }

.ctl-profile { flex: 1 1 100%; }
#profile-axes { display: flex; flex-wrap: wrap; gap: 8px; }
#profile-axes select { flex: 1 1 40%; min-width: 110px; font-size: 0.88rem; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; }


/* ---------- Map ---------- */
#map-wrap { position: relative; flex: 1 1 auto; min-height: 280px; }
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* "About" pill — full methodology page, top-right of the map just below the
   MapLibre zoom buttons (the "?" tour button above it retired with tour.js). */
#about-link {
  position: absolute; top: 78px; right: 10px; z-index: 6;
  display: flex; align-items: center; height: 24px; padding: 0 9px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.95); box-shadow: var(--panel-shadow);
  color: var(--accent); font-size: 0.7rem; font-weight: 700; text-decoration: none;
  letter-spacing: 0.02em;
}
#about-link:hover { border-color: var(--accent); }

/* Full-width bottom legend bar on mobile (Taylor 2026-07-13): spans the screen,
   the two colour sections sit side by side, the no-data note wraps below. Narrows
   back to a compact bottom-left box at the wide breakpoint (media query below). */
#legend {
  position: absolute; left: 8px; right: 8px; bottom: 24px; z-index: 5;
  background: rgba(255,255,255,0.95); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 11px; box-shadow: var(--panel-shadow);
  font-size: 0.7rem;
  display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 24px; row-gap: 4px;
}
.lg-sec { margin: 0; }
.lg-title { font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.lg-sub { color: var(--muted); font-weight: 400; }   /* inline demographic phrase in the title */
.lg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; margin: 0; }
.lg-modes { gap: 4px 8px; }
.lg-chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.lg-chip i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lg-ramp { display: inline-flex; border-radius: 2px; overflow: hidden; }
.lg-ramp i { width: 18px; height: 11px; display: inline-block; }
.lg-end { color: var(--muted); }

/* Transit-route overlay key — short line swatches matching the map layers. */
.lg-transit { gap: 4px 10px; }
.lg-line { width: 16px; height: 0; display: inline-block; border-radius: 2px; }
.lg-line-existing { border-top: 2px solid #9aa3b2; }
.lg-line-new { border-top: 3px solid #37527a; }

/* ---------- Info / tap card ---------- */
#info-card {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: var(--sheet-shadow);
  max-height: 60%; overflow-y: auto;
  padding: 14px var(--pad) 18px;
  transform: translateY(0); transition: transform 0.18s ease;
}
#info-card.hidden { transform: translateY(110%); pointer-events: none; }
#info-card:focus { outline: none; }   /* programmatic dialog focus — no ring on the container */
/* Padding (not size) grows the touch target to ~44px while the × glyph stays put */
#info-close {
  position: absolute; top: 0; right: 0; border: none; background: none; padding: 10px 12px;
  font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.info-zone-title { font-size: 0.95rem; font-weight: 650; margin-bottom: 2px; }
.info-zone-sub { font-size: 0.78rem; color: var(--muted); margin-bottom: 3px; }
.info-zone-headline { font-size: 0.9rem; font-weight: 600; line-height: 1.25; margin-bottom: 3px; }
.info-zone-headline strong { color: var(--accent); }
.info-zone-group { font-size: 0.78rem; color: var(--muted); margin: 0 0 10px; }
.mode-row {
  display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; gap: 4px 8px;
  align-items: baseline; padding: 5px 0; border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.mode-row.head { color: var(--muted); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.03em; border-top: none; }
.mode-row.convenient { font-weight: 700; }   /* most convenient (lowest-impedance) mode */
.mode-name { display: flex; align-items: center; gap: 6px; }
.mode-swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.mode-row .was { display: block; color: var(--muted); font-size: 0.72rem; line-height: 1.1; margin-top: 1px; }

/* ---------- Wide breakpoint: rail + side panel ---------- */
@media (min-width: 760px) {
  #app {
    display: grid;
    grid-template-columns: 344px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "head head"
      "ctl  map";
    height: 100%;
  }
  /* Polished title bar — plenty of room on desktop, so give the headline larger
     type, generous padding, a constrained measure, and a faint tinted band. */
  #headline {
    grid-area: head; padding: 15px 24px;
    background: linear-gradient(180deg, #f7f9fc 0%, #ffffff 100%);
  }
  #headline-main { font-size: 1.3rem; line-height: 1.32; }
  #controls {
    grid-area: ctl; flex-direction: column; flex-wrap: nowrap;
    border-right: 1px solid var(--line); border-bottom: none; align-content: start;
    gap: 14px 10px;
  }
  .ctl, .ctl-profile { flex: 0 0 auto; }
  /* Desktop rail = stacked sections: each of the four controls is a prominent
     header label above its control(s), clearly distinct from the smaller muted
     sub-axis labels beneath it (Arlington bus / Regional rail / …). */
  .ctl-dest { grid-template-columns: 1fr; gap: 4px; }
  .ctl-dest > .ctl-label,
  .ctl-head-static {
    font-size: 0.75rem; font-weight: 700; color: var(--ink); letter-spacing: 0.02em;
  }
  /* Plenty of vertical room in the rail → keep the scenario + profile sections
     always expanded (no accordion). The disclosure button leaves the page
     entirely (a focusable aria-expanded button over an always-open section is
     wrong semantics) and the static section label shows in its place. */
  .ctl-collapsible .ctl-head { display: none; }
  .ctl-head-static { display: block; }
  .ctl-collapsible .ctl-body { display: block; margin-top: 6px; }
  #map-wrap { grid-area: map; }
  #info-card {
    left: auto; right: 16px; bottom: 16px; top: auto; width: 340px;
    max-height: calc(100% - 32px); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--panel-shadow);
  }
  #info-card.hidden { transform: translateX(120%); }
  /* Legend reverts to a compact stacked box bottom-left on desktop (full-width
     only makes sense on the narrow phone layout). */
  #legend { right: auto; max-width: 310px; display: block; bottom: 22px; padding: 9px 12px; }
  .lg-sec { margin-bottom: 5px; }
  .lg-sec:last-child { margin-bottom: 0; }
}

.hidden-soft { display: none; }

/* Phone-width only: selects at ≥16px so iOS Safari doesn't auto-zoom the viewport
   on focus (pinch-zoom is enabled again for WCAG 1.4.4, which re-arms that
   behavior). Desktop keeps the compact 0.9rem type. The collapsed accordion
   summaries (.ctl-summary) are <span>s, not selects, so they don't get the bump
   automatically — match them to 16px too, otherwise "Show access for" and
   the old "Transit scenario" read a hair smaller than the native Destination / growth
   selects beside them. */
@media (max-width: 759.98px) {
  #controls select,
  #controls .ctl-summary { font-size: 16px; }
}

/* =====================================================================
   v2 scenario flow (flow.js) — intro card, choice screens, map screens,
   results box. Ported from the 2026-10-01 layout sketches (Round 3).
   ===================================================================== */
:root { --hypo: #b7791f; --hypo-bg: #fdf6e7; --hypo-stripe: #f8ebcc; --hypo-line: #d9c49a; }

/* ---------- stages ---------- */
/* Intro + flow: the map fills #app; the results chrome is out of the way. */
body:not(.stage-results) #headline,
body:not(.stage-results) #controls,
body:not(.stage-results) #legend,
body:not(.stage-results) #about-link,
body:not(.stage-results) #plan-box,
body:not(.stage-results) #info-card { display: none; }
body.stage-results #flow { display: none; }
@media (min-width: 760px) {
  body:not(.stage-results) #app {
    grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "map";
  }
}

/* ---------- shared ---------- */
.fl-btn {
  display: block; width: 100%; border: none; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-size: 1.05rem;
  font-weight: 700; padding: 14px 16px; text-align: center;
}
.fl-btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.fl-link {
  display: block; width: 100%; border: none; background: none; cursor: pointer;
  text-align: center; color: var(--accent); font: inherit; font-size: 0.9rem;
  margin-top: 8px; padding: 6px; text-decoration: underline;
}
.fl-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); }
#flow h1:focus, #flow h2:focus { outline: none; }   /* programmatic focus targets */

/* ---------- intro: card over the dimmed map ---------- */
.fl-dim { position: absolute; inset: 0; background: rgba(20,24,32,0.45); z-index: 30; }
.fl-introcard {
  position: absolute; left: 12px; right: 12px; bottom: 16px; z-index: 31;
  max-height: calc(100% - 32px); overflow-y: auto;
  background: #fff; border-radius: 14px; padding: 20px 18px 12px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.25);
}
/* Linked eyeblack × Ives Street logos in place of a text kicker. */
.fl-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.fl-brand a { display: block; line-height: 0; border-radius: 4px; }
.fl-brand img { height: 36px; width: auto; display: block; }
.fl-brand span { color: var(--muted); font-size: 1.1rem; }
.fl-introcard h1 { font-size: 1.45rem; line-height: 1.2; margin: 6px 0 10px; }
.fl-introcard p { font-size: 0.98rem; line-height: 1.45; margin: 0 0 16px; color: #333; }

/* ---------- choice screen ---------- */
.fl-page { position: absolute; inset: 0; z-index: 30; background: #fff; overflow-y: auto; }
.fl-page-inner { min-height: 100%; display: flex; flex-direction: column; padding: 16px 22px 20px; }
/* Step bar = step navigation: a segment + its name per step, whole column tappable. */
.fl-progress { margin-bottom: 8px; }
.fl-progress ol { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.fl-progress li { flex: 1; min-width: 0; }
.fl-progress button {
  display: block; width: 100%; min-height: 44px; border: none; background: none; cursor: pointer;
  padding: 6px 0 4px; font: inherit; color: var(--muted); text-align: center; border-radius: 6px;
}
.fl-progress button:hover .fl-bar { filter: brightness(0.9); }
.fl-progress button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fl-bar { display: block; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 6px; }
.fl-progress button.on .fl-bar { background: var(--accent); }
.fl-stepname { font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.fl-progress button[aria-current="step"] { color: var(--ink); }
.fl-progress button[aria-current="step"] .fl-stepname { font-weight: 800; }
.fl-changed { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--hypo); margin-left: 4px; vertical-align: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.fl-q { font-size: 1.5rem; line-height: 1.15; margin: 4px 0 8px; font-weight: 750; }
.fl-qsub { font-size: 0.95rem; line-height: 1.45; color: #444; margin: 0 0 16px; }
.fl-tiles { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.fl-tile {
  display: flex; gap: 12px; align-items: center; border: 2px solid var(--line);
  border-radius: 12px; padding: 14px; background: #fff; cursor: pointer;
  font: inherit; color: inherit; text-align: left; width: 100%;
}
.fl-tile .em { font-size: 1.7rem; }
.fl-tile b { display: block; font-size: 1.02rem; }
.fl-tile span span { font-size: 0.85rem; color: var(--muted); }
.fl-tile.sel { border-color: var(--accent); background: #f2f7fc; }
.fl-upgrade {
  margin: 0 0 0 30px; display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  border-left: 3px solid var(--accent); padding: 8px 0 8px 12px;
}
.fl-upgrade input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.fl-upgrade b { display: block; font-size: 0.98rem; }
.fl-upgrade span span { display: block; font-size: 0.84rem; color: var(--muted); }
.fl-nav { display: flex; gap: 10px; margin-top: auto; }
.fl-btn.alt { background: #fff; color: var(--accent); border: 2px solid var(--accent);
  padding: 12px 16px; margin: auto 0 10px; }   /* sits on the nav row, pinned to the bottom */
.fl-btn.alt + .fl-nav { margin-top: 0; }
.fl-nav .fl-btn.ghost { flex: 0 0 104px; white-space: nowrap; }
/* "Your plan so far" stack above the question */
.fl-sofar { background: #f5f7fa; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px 4px; margin-bottom: 14px; }
.fl-sofar-row { display: flex; justify-content: space-between; align-items: center;
  font-size: 0.95rem; font-weight: 600; padding: 5px 0; border-top: 1px solid var(--line); }
.fl-sofar-row:first-of-type { border-top: none; }
.fl-change { border: none; background: none; cursor: pointer; font: inherit; padding: 4px 0 4px 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--accent); text-decoration: underline; }

/* ---------- map screen ---------- */
.fl-mapcard { position: absolute; left: 10px; right: 10px; bottom: 14px; z-index: 30; background: #fff;
  border-radius: 14px; padding: 14px 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.22); }
.fl-mapcard-t { font-size: 1.25rem; font-weight: 750; margin: 2px 0 4px; }
.fl-mapcard-b { font-size: 0.92rem; line-height: 1.4; color: #444; margin-bottom: 12px; }
.fl-ln { display: inline-block; width: 20px; border-top: 4px solid #37527a; vertical-align: middle; margin-right: 8px; }
.fl-ln-light { border-top: 2px solid #5b7bb0; opacity: 0.7; }
.fl-area { display: inline-block; width: 16px; height: 12px; background: rgba(214,158,46,0.45);
  border: 1.5px solid var(--hypo); border-radius: 3px; vertical-align: middle; margin-right: 8px; }

/* ---------- results box (floating, top-left of the map) ---------- */
#plan-box {
  position: absolute; top: 10px; left: 10px; right: 56px; z-index: 7; max-width: 380px;
  background: rgba(255,255,255,0.97); border: 2px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: var(--panel-shadow); display: flex; flex-direction: column; gap: 6px;
}
/* The plan is hypothetical: amber dashed border + hatching only when it's shown. */
#plan-box.hypo { border: 2px dashed var(--hypo);
  background: repeating-linear-gradient(135deg, var(--hypo-bg) 0 8px, var(--hypo-stripe) 8px 16px); }
.pb-top { display: flex; gap: 4px; align-items: center; }
.pb-top .pb-seg { flex: 1; }
.pb-more { display: none; border: 1px solid var(--hypo-line); background: #fff; border-radius: 7px;
  width: 34px; height: 34px; font-size: 1rem; color: var(--hypo); font-weight: 800; cursor: pointer; flex: none; }
#plan-box.collapsed { right: auto; }
#plan-box.collapsed .pb-row { display: none; }
#plan-box.collapsed .pb-more { display: block; }
#plan-box.collapsed .pb-seg button { white-space: nowrap; padding: 7px 10px; }
.pb-seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.pb-seg button { flex: 1; border: none; background: none; font: inherit; font-size: 0.86rem; cursor: pointer;
  font-weight: 650; color: var(--muted); padding: 7px 6px; }
.pb-seg button + button { border-left: 1px solid var(--line); }
.pb-seg button.on { background: var(--ink); color: #fff; }
.pb-seg-xs { flex: 1; }
.pb-seg-xs button { font-size: 0.76rem; padding: 5px 4px; }
.pb-seg-xs button.on { background: var(--accent); }
.pb-row { display: flex; align-items: center; gap: 8px; padding: 0 4px 2px; }
.pb-row[hidden] { display: none; }
.pb-txt { flex: 1; font-size: 0.8rem; line-height: 1.3; }
.pb-k { font-weight: 800; color: var(--hypo); font-size: 0.66rem; letter-spacing: 0.07em;
  text-transform: uppercase; margin-right: 2px; }
.pb-k-muted { color: var(--muted); }
.pb-edit { border: 1px solid var(--hypo-line); background: #fff; color: var(--ink); border-radius: 8px;
  font: inherit; font-size: 0.85rem; font-weight: 700; padding: 7px 10px; white-space: nowrap; cursor: pointer; }

/* ---------- desktop: flow screens as panels over the map ---------- */
@media (min-width: 760px) {
  .fl-introcard { left: 50%; right: auto; width: 480px; transform: translateX(-50%); bottom: 32px; }
  .fl-page { inset: 24px auto 24px 50%; width: 520px; transform: translateX(-50%);
    border-radius: 14px; box-shadow: 0 6px 30px rgba(0,0,0,0.25); }
  .fl-mapcard { left: 16px; right: auto; bottom: 16px; width: 420px; }
}

/* ---------- phone: controls folded into the headline; one-row legend ----------
   (Taylor 2026-10-05, map space.) The destination and the group are underlined
   words in the headline sentence; the labelled rows leave the page. Each word
   opens its panel (#controls, above the map) — label on top, controls, Done at
   the end of the last row — and the two behave identically (Taylor 2026-10-05).
   The legend shows one colour row + "Key ▾"; the full key opens on tap. */
.hl-pick { white-space: normal; }
.lg-strip, .ctl-body-label, .ctl-done { display: none; }
@media (max-width: 759.98px) {
  .hl-pick {
    cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent);
    text-decoration-thickness: 2px; text-underline-offset: 3px; border-radius: 3px;
  }
  .hl-pick::after { content: '\00a0\25BE'; color: var(--accent); font-size: 0.8em; }
  .hl-dest { white-space: nowrap; }
  .hl-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* #controls only appears while a panel is open; the accordion head never
     shows on a phone. */
  #controls { display: none; }
  body.stage-results #controls:has(.open) { display: flex; }
  .ctl-dest, .ctl-profile > .ctl-head { display: none; }
  .ctl-done {
    display: block; flex: none; border: 1px solid var(--line); background: #fff;
    border-radius: 8px; font: inherit; font-size: 0.9rem; font-weight: 700;
    padding: 7px 16px; cursor: pointer; color: var(--ink);
  }
  /* Destination panel: label row, then select | Done. */
  .ctl-dest.open { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; }
  .ctl-dest.open > .ctl-label { grid-column: 1 / -1; }
  /* Profile panel: one wrapping row — label, the three selects, then Done on
     the car select's row (#profile-axes dissolves into the flex row). */
  .ctl-profile.open .ctl-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 0; }
  .ctl-profile .ctl-body-label { display: block; flex: 1 1 100%; margin-bottom: -2px; }
  .ctl-profile #profile-axes { display: contents; }

  /* bottom: clear the MapLibre attribution — 40px is the one-line case; app.js
     tracks the real height (it wraps on narrow phones, shrinks after a pan). */
  #legend { display: block; padding: 5px 8px 5px 11px; bottom: 40px; }
  .lg-strip { display: flex; align-items: center; gap: 8px; }
  .lg-strip > .lg-row { flex: 1; min-width: 0; }
  .lg-more {
    flex: none; margin-left: auto; border: 1px solid var(--line); background: #fff;
    border-radius: 6px; font: inherit; font-size: 0.72rem; font-weight: 700;
    color: var(--accent); padding: 4px 8px; cursor: pointer;
  }
  .lg-full { display: none; }
  #legend.open .lg-full { display: flex; flex-wrap: wrap; column-gap: 24px; row-gap: 4px; margin-top: 4px; }
  /* Open: the strip's row gives way to the full key; the toggle stays top-right. */
  #legend.open .lg-strip > .lg-row { display: none; }
  #legend.open .lg-more { position: absolute; top: 5px; right: 8px; }
  #legend.open .lg-full > .lg-sec:first-child { margin-right: 64px; }
}
