/* ==========================================================================
   App — the departure board
   A dark transit display anchored to a dark map. Consumes tokens.css +
   components.css. Class names are the contract with js/app.js; do not rename
   without updating the renderers.

   Reading order mirrors the screen: map, board shell, the nearby list, the
   line detail, the stop popup, the map markers, the map controls, then the
   compact bottom-sheet layout.
   ========================================================================== */

/* --- Map canvas ------------------------------------------------------ */

#map {
  --map-rail-size: 48px;
  --map-rail-width: 50px;
  --map-rail-wide-width: 154px;
  width: 100%;
  height: 100%;
  background: var(--board-sunken);
}

/* --- Skip link ------------------------------------------------------- */

.skip {
  position: absolute;
  z-index: 2000;
  top: 12px;
  left: 12px;
  padding: 8px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  background: var(--board);
  color: var(--ink);
  font: 600 13px/1.2 var(--font-body);
  text-decoration: none;
  box-shadow: var(--shadow-panel);
  transform: translateY(-160%);
}

.skip:focus-visible {
  transform: none;
}

/* --- Board shell ----------------------------------------------------- */

.hud {
  position: absolute;
  z-index: 1000;
  top: 0;
  left: 0;
  right: auto;
  width: clamp(320px, 30vw, var(--hud-width));
  height: 100dvh;
  max-height: none;
  display: flex;
  flex-direction: column;
  background: var(--board);
  border: 0;
  border-right: 1px solid var(--hairline-strong);
  border-radius: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-shadow: 12px 0 36px oklch(0.02 0.02 245 / 0.32);
  overflow: hidden;
  color: var(--ink);
}

.hud-grip {
  display: none;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

/* --- Header: identity, feed state, and the station clock -------------- */

.hud-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--hairline);
}

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

.hud-logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--hairline-strong);
  border-radius: 13px;
  background: var(--board-raised);
  color: var(--ink);
  font: 800 12px/1 var(--font-body);
  letter-spacing: 0.06em;
  box-shadow: inset 0 1px 0 var(--hairline);
  flex-shrink: 0;
}

.hud-brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.hud-brand-name {
  overflow: hidden;
  color: var(--ink);
  font: 700 15px/1 var(--font-body);
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-brand-subtitle {
  color: var(--ink-faint);
  font: 700 9px/1 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud-clock-wrap {
  display: grid;
  justify-items: end;
  gap: 5px;
  min-width: 0;
}

.hud-clock {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.hud-clock-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
}

.hud-feed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--live);
  font: 800 9px/1 var(--font-body);
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.hud-feed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
  flex-shrink: 0;
}

.hud-feed.is-sync {
  color: var(--ink-faint);
}

.hud-feed.is-live {
  color: var(--live);
}

.hud-feed.is-warn {
  color: var(--warn);
}

.hud-feed.is-error {
  color: var(--err);
}

.hud-date {
  color: var(--ink-faint);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-nearby {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.hud-line {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.hud-nearby[hidden],
.hud-line[hidden] {
  display: none !important;
}

.hud.is-line {
  max-height: none;
}

/* --- Search (composes .field) ---------------------------------------- */

.hud-search {
  margin: 14px 18px 0;
  padding-left: 40px;
  padding-right: 42px;
}

.hud-search-icon {
  position: absolute;
  left: 13px;
  font-size: 16px;
  color: var(--ink-faint);
  pointer-events: none;
}

.hud-search input {
  padding: 0;
}

.hud-search-clear {
  position: absolute;
  right: 2px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-faint);
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
}

.hud-search-clear:hover {
  color: var(--ink);
}

/* --- Filter chips ---------------------------------------------------- */

.hud-chips {
  display: flex;
  gap: 6px;
  padding: 14px 18px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hud-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  --chip-color: var(--map-accent);
  flex-shrink: 0;
  padding: 7px 13px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-dim);
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.chip:hover {
  color: var(--ink);
  border-color: var(--chip-color);
}

.chip.on {
  background: color-mix(in srgb, var(--chip-color) 16%, transparent);
  border-color: var(--chip-color);
  color: var(--chip-color);
}

/* --- Board head ------------------------------------------------------ */

.hud-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 18px 6px;
}

.hud h1 {
  font: 700 17px/1.15 var(--font-body);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.hud-count {
  margin: 0;
  color: var(--ink-faint);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hud-count.err {
  color: var(--err);
}

.hud-status {
  margin: 0;
  padding: 0 18px 12px;
  font: 500 11.5px/1.35 var(--font-body);
  color: var(--ink-dim);
}

.hud-status .count {
  color: var(--live);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-status.warn {
  color: var(--warn);
  font-weight: 600;
}

.hud-status.err {
  color: var(--err);
  font-weight: 600;
}

.hud-empty {
  padding: 10px 16px 20px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.5;
}

/* --- Board list ------------------------------------------------------ */

.hud-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-top: 1px solid var(--hairline);
  -webkit-overflow-scrolling: touch;
}

/* --- Departure row: bullet · destination · time --------------------- */
/* The heart of the board. Rows are divided by hairlines, never boxed as
   cards. Live times glow amber; scheduled times sit back in gray. */

.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--hairline);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.line-row.selected {
  background: var(--board-raised);
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
}

.line-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 58px;
  padding: 9px 6px 9px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .line-row:hover {
    background: var(--board-raised);
  }
}

@media (hover: none) {
  .line-main:active {
    background: var(--board-raised);
  }
}

.line-bullet,
.stop-bullet {
  min-width: 2.9em;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  flex-shrink: 0;
}

.line-mid,
.stop-dest {
  min-width: 0;
  display: block;
}

.line-dest,
.stop-dest-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  color: var(--ink);
}

.line-dest {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stop-dest-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.line-kind {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font: 500 10px/1.2 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.line-eta,
.stop-eta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  text-align: right;
  white-space: nowrap;
}

.eta-val {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--live);
}

.eta-val.is-sked {
  color: var(--ink-dim);
}

.eta-val.is-now {
  font-size: 20px;
  letter-spacing: 0.04em;
}

.eta-num {
  font-variant-numeric: tabular-nums;
}

.eta-unit {
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.eta-dash {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-faint);
}

.eta-flag {
  font: 700 9px/1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stop-eta-more {
  font: 500 12px/1 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: no-preference) {
  /* Only a tracked vehicle pulses; a schedule-derived "now" stays still. */
  .eta-val.is-now:not(.is-sked) {
    animation: now-pulse 1.6s var(--ease-out) infinite;
  }
}

@keyframes now-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.line-fav {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 16px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}

.line-fav.on {
  color: var(--live);
}

.line-fav:hover {
  color: var(--ink);
}

.line-fav.on:hover {
  color: var(--live);
}

/* --- Search result rows ---------------------------------------------- */

.place-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  flex-shrink: 0;
  gap: 13px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.place-row:hover {
  background: var(--board-raised);
}

.place-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--board-raised);
  color: var(--ink-dim);
  font: 700 13px/1 var(--font-body);
  flex-shrink: 0;
}

.place-mid {
  min-width: 0;
  display: block;
}

.place-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-desc {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Line detail: header bar ----------------------------------------- */

.line-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 10px 6px 4px;
  border-bottom: 1px solid var(--hairline);
  background: var(--board-raised);
  flex-shrink: 0;
}

.line-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 600 15px/1 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.line-back:hover {
  background: var(--board-sunken);
}

.line-back-chevron {
  font-size: 18px;
  line-height: 1;
  color: var(--ink-dim);
}

.line-bar-route {
  min-width: 2.9em;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font: 700 13px/1.1 var(--font-body);
  letter-spacing: -0.01em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.line-page {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

/* Section labels across the detail read as small board captions. */
.line-page h2,
.line-dirs-label {
  margin: 0;
  color: var(--ink-faint);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.line-dirs-label {
  margin-bottom: 8px;
}

.line-dirs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.line-dirs.is-one {
  grid-template-columns: 1fr;
}

.line-dir {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--board-raised);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.line-dir:hover {
  border-color: var(--ink-faint);
}

.line-dir-kicker {
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.line-dir-name {
  font: 600 13.5px/1.25 var(--font-body);
}

.line-dir-count {
  font: 500 11.5px/1.25 var(--font-body);
  color: var(--ink-dim);
}

/* Active direction fills with the line's own color (data-driven). */
.line-dir.on {
  border-color: transparent;
  background: var(--line, var(--live));
  color: var(--line-ink, var(--live-ink));
}

.line-dir.on .line-dir-kicker {
  color: inherit;
  opacity: 0.75;
}

.line-dir.on .line-dir-count {
  color: inherit;
  opacity: 0.85;
}

.line-next {
  margin-top: 20px;
}

.line-next-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 18px;
  margin-top: 8px;
}

.line-from,
.line-tt-empty,
.line-info p {
  margin-top: 5px;
  color: var(--ink-dim);
  font-size: 12.5px;
  line-height: 1.4;
}

/* --- Line detail: timetable board ------------------------------------ */

.line-tt {
  margin-top: 22px;
}

.line-tt-board {
  margin-top: 10px;
}

.line-tt-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.line-tt-time {
  font: 500 15px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

/* The next departure reads as the one to catch. */
.line-tt-time.is-next {
  font-weight: 700;
  color: var(--ink);
}

.organization-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--ink-dim);
  font-size: 12px;
  line-height: 1.25;
}

.organization-logo {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--board-sunken);
  object-fit: contain;
  padding: 2px;
}

.organization-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-identity {
  margin-top: 10px;
}

.line-organization {
  margin: 2px 0 5px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--hairline);
}

.timetable-details {
  margin-top: 10px;
  border-top: 1px solid var(--hairline);
}

.timetable-details summary {
  padding: 9px 0 2px;
  color: var(--ink-dim);
  font: 600 11.5px/1.3 var(--font-body);
  cursor: pointer;
}

.timetable-details summary:hover {
  color: var(--ink);
}

.timetable-full {
  display: grid;
  gap: 5px;
  padding: 7px 0 2px;
}

.timetable-content.is-loading,
.timetable-content.is-empty,
.timetable-content.is-error {
  padding: 8px 0 3px;
  color: var(--ink-faint);
  font: 500 11px/1.35 var(--font-mono);
}

.timetable-content.is-error {
  color: var(--warn);
}

.timetable-hour {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.35;
}

.timetable-hour-label {
  color: var(--ink);
  font: 600 12px/1.35 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.timetable-hour-minutes {
  color: var(--ink-dim);
  font: 500 12px/1.35 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.stop-organization {
  margin-top: 8px;
}

.stop-line-organization {
  max-width: 125px;
  margin-left: 2px;
  font-size: 10.5px;
}

.stop-line-organization .organization-logo {
  width: 17px;
  height: 17px;
  border-radius: 5px;
}

.stop-line-organization .organization-name {
  max-width: 92px;
}

.stop-timetables {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--hairline);
}

.stop-timetables-title {
  color: var(--ink-faint);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stop-timetable {
  margin-top: 8px;
}

.stop-timetable .timetable-details {
  margin-top: 0;
}

.stop-timetable .timetable-details summary {
  padding-top: 0;
}

.line-info {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* --- Line detail: stop sequence -------------------------------------- */

.line-stops {
  margin-top: 22px;
}

.line-stop-list {
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.line-stop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.line-stop:last-child {
  border-bottom: 0;
}

.line-stop:hover:not(:disabled) {
  color: var(--live);
}

.line-stop:disabled {
  cursor: default;
}

.line-stop-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

.line-stop.is-near .line-stop-name {
  color: var(--live);
}

.line-stop-near {
  flex-shrink: 0;
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--live);
}

/* --- Line detail: footer status -------------------------------------- */

.line-foot {
  flex-shrink: 0;
  margin-top: auto;
  padding: 11px 16px 12px;
  border-top: 1px solid var(--hairline);
  background: var(--board-sunken);
  color: var(--ink-dim);
  font: 500 12.5px/1.35 var(--font-body);
}

.line-foot:empty {
  display: none;
}

.line-foot.ok {
  color: var(--ink);
}

.line-foot.warn {
  color: var(--warn);
}

.line-foot.err {
  color: var(--err);
}

/* --- Skeletons (loading, not spinners) ------------------------------- */

.stop-skel {
  height: 46px;
  margin: 0 16px 8px;
  border-radius: var(--radius);
  background: var(--board-raised);
}

.line-skel {
  height: 44px;
  margin-top: 8px;
  border-radius: var(--radius);
  background: var(--board-raised);
}

@media (prefers-reduced-motion: no-preference) {
  .stop-skel,
  .line-skel {
    animation: skel-pulse 1.2s var(--ease-out) infinite;
  }
}

@keyframes skel-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* --- Stop popup: a mini board over the map --------------------------- */
/* Not a Leaflet balloon. Same dark board, same departure rows. */

.maplibregl-popup-content {
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--board);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  font-family: var(--font-body);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: var(--board);
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: var(--board);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--board);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--board);
}

.vehicle-popup-wrap .maplibregl-popup-content {
  width: 352px;
  max-width: min(352px, calc(100vw - 16px));
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: var(--board-raised);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.vehicle-popup-wrap .maplibregl-popup-close-button {
  top: 8px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-faint);
  font: 400 20px/1 var(--font-body);
}

.vehicle-popup-wrap .maplibregl-popup-close-button:hover,
.vehicle-popup-wrap .maplibregl-popup-close-button:focus-visible {
  background: var(--board);
  color: var(--ink);
}

.vehicle-popup-wrap.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--board-raised);
}

.vehicle-popup-wrap.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--board-raised);
}

.vehicle-popup-wrap.maplibregl-popup-anchor-left .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-left-top .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-left-bottom .maplibregl-popup-tip {
  border-right-color: var(--board-raised);
}

.vehicle-popup-wrap.maplibregl-popup-anchor-right .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-right-top .maplibregl-popup-tip,
.vehicle-popup-wrap.maplibregl-popup-anchor-right-bottom .maplibregl-popup-tip {
  border-left-color: var(--board-raised);
}

.vehicle-popup {
  max-height: min(70dvh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
}

.vehicle-popup-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 14px 42px 13px 14px;
  border-bottom: 1px solid var(--hairline);
}

.vehicle-popup-route {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 30px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: var(--popup-route, var(--map-accent));
  color: var(--popup-route-ink, var(--on-map));
  font: 800 15px/1 var(--font-body);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-marker);
}

.vehicle-popup-heading {
  min-width: 0;
}

.vehicle-popup-title {
  overflow: hidden;
  color: var(--ink);
  font: 700 14px/1.2 var(--font-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-popup-subtitle {
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink-dim);
  font: 500 11px/1.2 var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-popup-context {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--hairline);
}

.vehicle-popup-context > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.vehicle-popup-context span {
  color: var(--ink-faint);
  font: 700 8px/1 var(--font-mono);
  letter-spacing: 0.12em;
}

.vehicle-popup-context strong {
  overflow: hidden;
  color: var(--ink);
  font: 700 12px/1.2 var(--font-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-popup-status {
  align-self: start;
  margin-top: 1px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  font: 700 9px/1 var(--font-mono);
  letter-spacing: 0.08em;
}

.vehicle-popup-status.is-live {
  background: var(--live-soft);
  color: var(--live);
}

.vehicle-popup-status.is-stale {
  background: var(--board-sunken);
  color: var(--warn);
}

.vehicle-popup-status.is-unknown {
  background: var(--board-sunken);
  color: var(--ink-faint);
}

.vehicle-enrichment {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 0;
}

.vehicle-enrichment-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
  color: var(--ink-faint);
  font: 700 9px/1.2 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.vehicle-enrichment-heading span:last-child {
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  text-transform: none;
}

.vehicle-enrichment .vehicle-api-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  font-size: 12px;
  line-height: 1.3;
}

.vehicle-enrichment .vehicle-api-row > span {
  color: var(--ink-faint);
}

.vehicle-enrichment .vehicle-api-row > strong {
  color: var(--ink);
  font: 700 12px/1.3 var(--font-body);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vehicle-enrichment .vehicle-api-row > strong.is-stale {
  color: var(--warn);
}

.vehicle-enrichment .vehicle-api-row.vehicle-enrichment-access > strong {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ok);
}

.vehicle-enrichment .vehicle-api-row.vehicle-enrichment-access > strong .access-icon {
  color: var(--ok);
}

.vehicle-data-empty {
  padding: 7px 0 4px;
  color: var(--ink-faint);
  font: 500 11px/1.35 var(--font-body);
}

.vehicle-enrichment-source {
  margin-top: 3px;
  color: var(--ink-faint);
  font: 500 9px/1.2 var(--font-mono);
  letter-spacing: 0.04em;
}

.vehicle-api-details {
  border-top: 1px solid var(--hairline);
}

.vehicle-api-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: var(--ink-dim);
  font: 700 10px/1.2 var(--font-mono);
  letter-spacing: 0.06em;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.vehicle-api-details summary::-webkit-details-marker {
  display: none;
}

.vehicle-api-details summary::after {
  content: "+";
  color: var(--ink-faint);
  font: 400 18px/0.8 var(--font-body);
}

.vehicle-api-details[open] summary::after {
  content: "−";
}

.vehicle-api-details summary:hover,
.vehicle-api-details summary:focus-visible {
  color: var(--ink);
}

.vehicle-api-count {
  margin-left: auto;
  color: var(--ink-faint);
  font: 500 9px/1 var(--font-mono);
  letter-spacing: 0;
}

.vehicle-api-groups {
  display: grid;
  gap: 14px;
  padding: 2px 14px 14px;
}

.vehicle-api-group {
  display: grid;
  gap: 5px;
}

.vehicle-api-group h3 {
  margin: 0 0 2px;
  color: var(--ink-faint);
  font: 700 9px/1.2 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.vehicle-api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
  min-height: 17px;
  font-size: 10px;
  line-height: 1.3;
}

.vehicle-api-row > span {
  color: var(--ink-faint);
}

.vehicle-api-row > strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font: 500 10px/1.3 var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vehicle-api-row > strong.is-stale {
  color: var(--warn);
}

.stop-popup-wrap .maplibregl-popup-content {
  width: 318px;
  min-width: 286px;
  margin: 0;
  padding: 0;
  border-radius: 16px;
  background: var(--board-raised);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.stop-popup-wrap .maplibregl-popup-close-button {
  top: 8px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-faint);
  font: 400 20px/1 var(--font-body);
}

.stop-popup-wrap .maplibregl-popup-close-button:hover,
.stop-popup-wrap .maplibregl-popup-close-button:focus-visible {
  background: var(--board);
  color: var(--ink);
}

.stop-popup-wrap.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--board-raised);
}

.stop-popup-wrap.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--board-raised);
}

.stop-popup-wrap.maplibregl-popup-anchor-left .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-left-top .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-left-bottom .maplibregl-popup-tip {
  border-right-color: var(--board-raised);
}

.stop-popup-wrap.maplibregl-popup-anchor-right .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-right-top .maplibregl-popup-tip,
.stop-popup-wrap.maplibregl-popup-anchor-right-bottom .maplibregl-popup-tip {
  border-left-color: var(--board-raised);
}

.stop-popup {
  max-height: min(56vh, 380px);
  overflow-y: auto;
}

.stop-head {
  position: relative;
  padding: 16px 46px 13px 16px;
}

.stop-head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  margin-top: 8px;
}

.stop-feed-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 4px 7px;
  border-radius: var(--radius-xs);
  font: 700 9px/1 var(--font-mono);
  letter-spacing: 0.1em;
}

.stop-feed-status.is-live {
  background: var(--live-soft);
  color: var(--live);
}

.stop-feed-status.is-schedule,
.stop-feed-status.is-empty {
  background: var(--board-sunken);
  color: var(--ink-dim);
}

.stop-line-count {
  color: var(--ink-faint);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.04em;
}

.stop-title {
  font: 700 16px/1.2 var(--font-body);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.stop-street {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ink-dim);
}

.stop-line-schedule {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-faint);
  font: 500 10px/1.35 var(--font-mono);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.stop-board {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline);
}

.stop-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.stop-line:last-child {
  border-bottom: 0;
}

@media (hover: hover) {
  .stop-line:hover {
    background: var(--board);
  }
}

.stop-line:focus-visible {
  position: relative;
  z-index: 1;
  background: var(--board);
  outline: 2px solid var(--ring);
  outline-offset: -2px;
}

.stop-line:active {
  background: var(--board-sunken);
}

.stop-note {
  padding: 14px 16px 18px;
  font-size: 13px;
  color: var(--ink-dim);
}

.stop-note.is-err {
  color: var(--err);
}

/* --- Vehicle markers (on the dark map) -------------------------------- */
/* These live in the MAP world: bright casings for contrast on dark tiles,
   the line's own color as the fill. */

.vehicle-no {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  cursor: pointer;
  overflow: visible;
  will-change: transform;
  --veh: var(--map-ink);
  --veh-ink: var(--on-map);
  --veh-delay: 0s;
}

.vehicle-no:focus-visible {
  outline-offset: 3px;
}

.vehicle-mark {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  overflow: visible;
}

.vehicle-beacon {
  position: relative;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  overflow: visible;
}

.vehicle-beacon::before,
.vehicle-beacon::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--veh);
  border-radius: 50%;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}

.vehicle-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.vehicle-icon.has-heading {
  transform: rotate(var(--veh-brg, 0deg));
}

.vehicle-arrow {
  display: none;
  position: absolute;
  top: -13px;
  left: 50%;
  width: 12px;
  height: 14px;
  margin-left: -6px;
  color: var(--veh);
  filter: drop-shadow(0 0 1px oklch(1 0 0 / 0.7));
  z-index: 2;
}

.vehicle-icon.has-heading .vehicle-arrow {
  display: block;
}

.vehicle-icon-svg {
  display: block;
  width: 26px;
  height: 26px;
  color: var(--veh);
  filter: drop-shadow(0 1px 2px oklch(0 0 0 / 0.3));
}

@media (prefers-reduced-motion: no-preference) {
  .vehicle-beacon::before,
  .vehicle-beacon::after {
    animation: vehicle-ping 2.2s var(--ease-out) infinite;
    animation-delay: var(--veh-delay);
  }
  .vehicle-beacon::after {
    animation-delay: calc(var(--veh-delay) + 1.1s);
  }
}

@keyframes vehicle-ping {
  0% {
    transform: scale(1);
    opacity: 0.38;
  }
  75%,
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.vehicle-code {
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background: var(--veh);
  color: var(--veh-ink);
  font: 700 11px/1.2 var(--font-body);
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: var(--shadow-marker);
}

.vehicle-no.selected .vehicle-icon-svg,
.vehicle-no.selected .vehicle-code {
  outline: 2px solid var(--map-accent);
  outline-offset: 1px;
}

/* --- Map controls ---------------------------------------------------- */
.map-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: var(--map-rail-width);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.map-rail button {
  display: grid;
  place-items: center;
  width: var(--map-rail-size);
  height: var(--map-rail-size);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--map-label);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.map-rail > button.map-locate {
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: var(--map-accent);
  color: var(--map-accent-ink);
  box-shadow: 0 8px 22px oklch(0.02 0.02 245 / 0.42), 0 1px 3px oklch(0.02 0.02 245 / 0.32);
}

.map-rail-zoom {
  display: grid;
  grid-template-rows: repeat(2, var(--map-rail-size));
  width: var(--map-rail-width);
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: var(--map-control);
  box-shadow: 0 8px 22px oklch(0.02 0.02 245 / 0.4), 0 1px 3px oklch(0.02 0.02 245 / 0.3);
}

.map-rail-zoom button + button {
  border-top: 1px solid var(--hairline);
}

.map-rail button:not(:disabled):not([aria-disabled="true"]):active {
  transform: scale(0.96);
}

.map-rail button:disabled,
.map-rail button[aria-disabled="true"] {
  cursor: default;
  opacity: 0.32;
}

.map-rail > button.map-locate:disabled,
.map-rail > button.map-locate[aria-disabled="true"] {
  cursor: wait;
  opacity: 1;
}

.map-rail button:focus-visible {
  position: relative;
  z-index: 2;
  outline: 2px solid var(--map-accent);
  outline-offset: 2px;
}

.map-rail-zoom button:focus-visible {
  outline-offset: -3px;
}

.map-rail-icon {
  display: block;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.map-zoom-in .map-rail-icon {
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6z'/%3E%3C/svg%3E");
}

.map-zoom-out .map-rail-icon {
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 11h14v2H5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 11h14v2H5z'/%3E%3C/svg%3E");
}

.map-locate .map-rail-icon {
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.25 7 13 7 13s7-7.75 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.25 7 13 7 13s7-7.75 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E");
}

.map-rail > button.map-locate[aria-busy="true"] {
  box-shadow: inset 0 0 0 3px color-mix(in oklch, var(--map-accent-ink) 28%, transparent), 0 8px 22px oklch(0.02 0.02 245 / 0.42), 0 1px 3px oklch(0.02 0.02 245 / 0.32);
}

.map-locate[aria-busy="true"] .map-rail-icon {
  animation: map-locate-pulse 900ms var(--ease-out) infinite;
}

@keyframes map-locate-pulse {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(0.94);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (hover: hover) {
  .map-rail-zoom button:not(:disabled):not([aria-disabled="true"]):hover {
    background: var(--map-control-raised);
  }

  .map-rail > button.map-locate:not(:disabled):not([aria-disabled="true"]):hover {
    background: color-mix(in oklch, var(--map-accent) 88%, var(--ink));
  }

  .map-style-control > button.map-style-button:not(:disabled):hover {
    background: var(--map-control-raised);
  }
}

.map-rail.map-style-control {
  flex-direction: column;
  align-items: stretch;
  width: var(--map-rail-width);
  position: relative;
}

.map-style-control > button.map-style-button {
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: var(--map-control);
  box-shadow: 0 8px 22px oklch(0.02 0.02 245 / 0.4), 0 1px 3px oklch(0.02 0.02 245 / 0.3);
}

.map-style-control > button.map-style-button[aria-pressed="true"] {
  color: var(--map-accent);
}

.map-style-control > button.map-style-button[aria-busy="true"] {
  cursor: wait;
}

.map-style-button .map-rail-icon {
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 3 9 5-9 5-9-5 9-5Zm0 8.4L20.4 7 22 8l-10 5.5L2 8l1.6-1 8.4 4.4ZM4 12.9l1.6-1 6.4 3.4 6.4-3.4 1.6 1L12 17.5 4 12.9Zm0 4 1.6-1 6.4 3.4 6.4-3.4 1.6 1L12 21.5 4 16.9Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 3 9 5-9 5-9-5 9-5Zm0 8.4L20.4 7 22 8l-10 5.5L2 8l1.6-1 8.4 4.4ZM4 12.9l1.6-1 6.4 3.4 6.4-3.4 1.6 1L12 17.5 4 12.9Zm0 4 1.6-1 6.4 3.4 6.4-3.4 1.6 1L12 21.5 4 16.9Z'/%3E%3C/svg%3E");
}

.map-style-status,
.map-rail-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib {
  position: relative;
  min-height: 48px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--map-control);
  color: var(--ink-faint);
  box-shadow: 0 8px 24px oklch(0.02 0.02 245 / 0.36);
  font: 500 10.5px/1.4 var(--font-body);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button {
  border: 0;
  border-radius: 10px;
  background-color: transparent;
  background-image: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not([open]) .maplibregl-ctrl-attrib-button {
  position: static;
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: 48px;
  padding: 0 12px;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not([open]) .maplibregl-ctrl-attrib-button::before {
  content: "HARTĂ";
  font: 700 10px/1 var(--font-mono);
  letter-spacing: 0.1em;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m3 5 6-2 6 2 6-2v16l-6 2-6-2-6 2V5Zm6-1.3v14.6l6 2V5.7l-6-2Zm6 2v14.6l6-2V5.7l-6-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m3 5 6-2 6 2 6-2v16l-6 2-6-2-6 2V5Zm6-1.3v14.6l6 2V5.7l-6-2Zm6 2v14.6l6-2V5.7l-6-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib[open] {
  padding: 11px 58px 11px 12px;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib[open] .maplibregl-ctrl-attrib-button {
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib[open] .maplibregl-ctrl-attrib-button::after {
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.7 5.3 5.3 5.3 5.3-5.3 1.4 1.4-5.3 5.3 5.3 5.3-1.4 1.4-5.3-5.3-5.3 5.3-1.4-1.4 5.3-5.3-5.3-5.3 1.4-1.4Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.7 5.3 5.3 5.3 5.3-5.3 1.4 1.4-5.3 5.3 5.3 5.3-1.4 1.4-5.3-5.3-5.3 5.3-1.4-1.4 5.3-5.3-5.3-5.3 1.4-1.4Z'/%3E%3C/svg%3E");
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not([open]) .maplibregl-ctrl-attrib-inner {
  display: none !important;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib[open] .maplibregl-ctrl-attrib-inner {
  display: block !important;
}

.maplibregl-ctrl-attrib-inner {
  width: max-content;
  max-width: min(280px, calc(100vw - 84px));
  color: var(--ink-faint);
}

.maplibregl-ctrl-attrib a {
  color: var(--ink-dim);
  font-weight: 600;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 2px;
}

.maplibregl-ctrl-attrib a:hover {
  color: var(--ink);
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button:active {
  background-color: var(--map-control-raised);
  color: var(--ink);
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--ring);
  color: var(--ink);
}

@media (hover: hover) {
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button:hover {
    background-color: var(--map-control-raised);
    color: var(--ink);
  }
}

@media (forced-colors: active) {
  .map-rail button,
  .map-rail-zoom {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }

  .map-rail > button.map-locate {
    color: Highlight;
  }

  .map-rail-icon {
    background-color: CanvasText;
  }

  .map-locate .map-rail-icon,
  .map-style-button[aria-pressed="true"] .map-rail-icon {
    background-color: Highlight;
  }

  .map-rail button:focus-visible {
    outline-color: Highlight;
  }

  .map-rail > button.map-locate[aria-busy="true"] {
    outline: 3px solid Highlight;
    outline-offset: -5px;
  }

  .map-style-control > button.map-style-button {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }

  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }

  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button {
    color: CanvasText;
  }

  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-button:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: -4px;
    box-shadow: none;
  }
}

/* Corners own their own insets now that both controls live on the right. */
.maplibregl-ctrl-top-right {
  top: max(var(--hud-gap), env(safe-area-inset-top));
  right: max(var(--hud-gap), env(safe-area-inset-right));
}

.maplibregl-ctrl-bottom-right {
  right: max(var(--hud-gap), env(safe-area-inset-right));
  bottom: max(var(--hud-gap), env(safe-area-inset-bottom));
}

.maplibregl-ctrl-top-right > .maplibregl-ctrl,
.maplibregl-ctrl-bottom-right > .maplibregl-ctrl {
  margin: 0;
}

.maplibregl-ctrl-top-right > .maplibregl-ctrl + .maplibregl-ctrl,
.maplibregl-ctrl-bottom-right > .maplibregl-ctrl + .maplibregl-ctrl {
  margin-top: 8px;
}

/* --- Compact layout (bottom sheet) ----------------------------------- */

@media (max-width: 719px), (orientation: landscape) and (max-height: 560px) {
  .hud,
  .hud.is-line {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: min(90dvh, calc(100dvh - max(64px, calc(env(safe-area-inset-top, 0px) + 60px))));
    max-height: min(90dvh, calc(100dvh - max(64px, calc(env(safe-area-inset-top, 0px) + 60px))));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -14px 36px oklch(0.02 0.02 245 / 0.36);
    transform: translateY(var(--sheet-y));
    will-change: transform;
    transition: transform 0.34s var(--ease-out);
  }

  .hud.dragging {
    transition: none;
  }

  .hud-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    cursor: grab;
    flex-shrink: 0;
  }

  .hud-grip:focus-visible {
    outline-offset: -4px;
  }

  .hud.dragging .hud-grip {
    cursor: grabbing;
  }

  .hud-grip span {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--hairline-strong);
  }

  .hud-top {
    padding: 12px 16px 10px;
    touch-action: none;
  }

  .hud-nearby,
  .hud-line {
    flex: 1 1 auto;
    min-height: 0;
  }

  .hud-list,
  .line-page {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  .hud-list {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .line-bar {
    padding-top: 4px;
    touch-action: none;
  }

  .line-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* The rail already sits top-right; the source pill rides just above the sheet
     so it never disappears behind the board. */
  .maplibregl-ctrl-bottom-right {
    top: auto;
    right: max(var(--hud-gap), env(safe-area-inset-right));
    bottom: calc(var(--hud-stack, 42dvh) + var(--hud-gap));
  }

  .maplibregl-popup {
    max-width: calc(100vw - 24px) !important;
  }

  .stop-popup-wrap .maplibregl-popup-content {
    width: min(300px, calc(100vw - 16px));
    min-width: 0;
  }

  .stop-popup-wrap .maplibregl-popup-close-button {
    top: 2px;
    right: 2px;
    width: 44px;
    height: 44px;
  }

  .vehicle-popup-wrap .maplibregl-popup-content {
    width: min(340px, calc(100vw - 16px));
  }

  .vehicle-popup {
    max-height: min(62dvh, calc(100dvh - var(--hud-stack, 42dvh) - 24px));
  }

  .vehicle-popup-wrap .maplibregl-popup-close-button {
    top: 2px;
    right: 2px;
    width: 44px;
    height: 44px;
  }

  .vehicle-popup-header {
    gap: 8px;
    padding: 9px 38px 9px 10px;
  }

  .vehicle-popup-route {
    min-width: 32px;
    height: 27px;
    font-size: 14px;
  }

  .vehicle-popup-title {
    font-size: 13px;
  }

  .vehicle-popup-subtitle {
    margin-top: 2px;
    font-size: 10px;
  }

  .vehicle-popup-status {
    padding: 3px 5px;
    font-size: 8px;
  }

  .vehicle-popup-context {
    gap: 8px;
    padding: 9px 10px 8px;
  }

  .vehicle-popup-context strong {
    font-size: 11px;
  }

  .vehicle-enrichment {
    gap: 4px;
    padding: 8px 10px 9px;
  }

  .vehicle-enrichment .vehicle-api-row {
    min-height: 17px;
    font-size: 11px;
  }

  .vehicle-enrichment .vehicle-api-row > strong {
    font-size: 11px;
  }

  .vehicle-api-details summary {
    padding: 9px 10px;
    font-size: 9px;
  }

  .vehicle-api-groups {
    gap: 10px;
    padding: 2px 10px 10px;
  }

  .vehicle-api-row {
    gap: 7px;
    font-size: 9px;
  }

  .vehicle-api-row > strong {
    font-size: 9px;
  }

  .stop-popup {
    max-height: min(30dvh, calc(100dvh - var(--hud-stack, 42dvh) - 5.5rem));
  }

  .stop-line {
    min-height: 50px;
    padding: 12px 14px;
  }
}

@media (orientation: portrait) and (max-width: 719px) {
  body.has-full-sheet .map-rail-zoom,
  body.has-full-sheet .map-style-control {
    display: none;
  }

  body.has-full-sheet .maplibregl-ctrl-bottom-right:not(.is-attribution-open) {
    top: max(var(--hud-gap), env(safe-area-inset-top));
    right: calc(max(var(--hud-gap), env(safe-area-inset-right)) + var(--map-rail-width) + 8px);
    bottom: auto;
  }

  body.has-full-sheet .maplibregl-ctrl-bottom-right.is-attribution-open {
    z-index: 1001;
    bottom: calc(var(--hud-stack, 42dvh) - 88px);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .maplibregl-ctrl-bottom-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .maplibregl-ctrl-bottom-right > .maplibregl-ctrl + .maplibregl-ctrl {
    margin-top: 0;
  }

  .maplibregl-ctrl-bottom-right.is-attribution-open .map-style-control {
    display: none;
  }

  body.has-full-sheet .maplibregl-ctrl-top-right,
  body.has-full-sheet .map-style-control {
    display: none;
  }

  .hud,
  .hud.is-line {
    height: 96dvh;
    max-height: 96dvh;
  }

  body.has-full-sheet .maplibregl-ctrl-bottom-right {
    z-index: 1001;
    top: max(var(--hud-gap), env(safe-area-inset-top));
    right: calc(max(var(--hud-gap), env(safe-area-inset-right)) + 52px);
    bottom: auto;
  }

  body.has-full-sheet .maplibregl-ctrl-attrib-inner {
    max-width: min(280px, calc(100vw - 144px - env(safe-area-inset-right, 0px)));
  }

  .map-rail {
    flex-direction: row;
    align-items: center;
    width: var(--map-rail-wide-width);
  }

  .map-rail-zoom {
    width: auto;
    height: var(--map-rail-width);
    grid-template-columns: repeat(2, var(--map-rail-size));
    grid-template-rows: var(--map-rail-size);
  }

  .map-rail-zoom button + button {
    border-top: 0;
    border-left: 1px solid var(--hairline);
  }
}

@media (orientation: landscape) and (max-width: 480px) and (max-height: 260px) {
  .maplibregl-ctrl-top-right {
    z-index: 1001;
  }

  .map-style-control {
    display: none;
  }

  body:not(.has-full-sheet) .maplibregl-ctrl-bottom-right {
    z-index: 1001;
    top: max(var(--hud-gap), env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: max(var(--hud-gap), env(safe-area-inset-left));
  }

  body:has(.maplibregl-ctrl-bottom-right.is-attribution-open) .maplibregl-ctrl-top-right {
    display: none;
  }

  body:has(.maplibregl-ctrl-bottom-right.is-attribution-open) .maplibregl-ctrl-bottom-right {
    z-index: 1001;
    top: max(var(--hud-gap), env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: max(var(--hud-gap), env(safe-area-inset-left));
  }
}

/* --- Inline mode + accessibility icons (board, popups, chips, info) --- */
/* These live in the BOARD world: they inherit ink from their context and
   the wheelchair badge borrows the positive/ok green. Amber stays reserved
   for live times. */

.mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.mode-icon .vehicle-icon-svg {
  width: 15px;
  height: 15px;
  color: inherit;
  filter: none;
}

.access-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  color: var(--ok);
  vertical-align: middle;
}

.access-icon-svg {
  display: block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.access-label {
  color: var(--ink-dim);
  font-size: inherit;
}

/* Board row subtitle now carries the mode glyph and the access badge inline. */
.line-kind {
  display: flex;
  align-items: center;
  gap: 5px;
}

.line-kind .mode-icon .vehicle-icon-svg,
.line-kind .access-icon-svg {
  width: 13px;
  height: 13px;
}

/* Stop popup line: mode + kind + access. */
.stop-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--ink-faint);
}

.stop-kind {
  font: 500 10px/1.2 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stop-meta .mode-icon .vehicle-icon-svg,
.stop-meta .access-icon-svg {
  width: 14px;
  height: 14px;
}

/* Stop popup header accessibility badge. */
.stop-access {
  margin-top: 6px;
  font-size: 11.5px;
}

/* Line detail: accessibility line. */
.line-access {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  color: var(--ink-dim);
  font-size: 12.5px;
}

/* Filter chips gain a leading mode glyph. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip .mode-icon .vehicle-icon-svg {
  width: 14px;
  height: 14px;
}
