/* Public live map (live.html), design A "มรกตราตรี": the map fills the screen and glass panels float over it.
   Loaded after css/legacy.css, so these unlayered rules beat the legacy layer whatever its specificity. The one legacy
   !important rule that reaches this page (the inset header) is answered in @layer console-fix, declared first in legacy.css.
   Sizes are in rem: TV mode enlarges everything by raising the root font size. */

:root:has(.live-page) {
  --l-ink: #06150F;
  /* See-through panels: a light green tint over the map, which is blurred and dimmed behind the panel so light text
     stays readable on Longdo's pale tiles (worst case ≈ 4.6:1 for the small gold and blue text) */
  --l-glass: rgba(7, 26, 19, .45);
  --l-glass-strong: rgba(6, 21, 15, .6);
  --l-backdrop: blur(14px) saturate(1.4) brightness(.55);
  --l-line: rgba(227, 196, 119, .3);
  --l-text: #EAF4EF;
  --l-dim: #BCD2C7;
  --l-faint: #B4CABF;
  --l-gold: #E3C477;
  --l-ivory: #F3EBD3;
  --l-mission: #FF9A92;
  --l-ready: #A9CBFF;
  --l-online: #6EE7B7;
  --l-alert: #FF6B6B;
  --l-font: 'Kanit', system-ui, sans-serif;
  --l-display: 'Kanit', sans-serif;
  --l-mono: 'IBM Plex Mono', 'Kanit', ui-monospace, monospace;
  /* Panel geometry; the map controls and the "fit the whole area" padding are placed around these */
  --l-gap: 1.5rem;
  --l-top-h: 6.75rem;
  --l-rail-w: 26rem;
  --l-tools-h: 10.5rem;
  --l-today-h: 4.25rem;
  --l-inset-w: 22rem;
  --l-inset-h: 14rem;
  --l-under-top: calc(var(--l-gap) + var(--l-top-h) + 1rem);
  --l-beside-rail: calc(var(--l-gap) + var(--l-rail-w) + 1rem);
  font-size: 16px;
  color-scheme: dark;
}
/* Browsers without backdrop-filter cannot dim the map behind a panel: keep the panels nearly solid there */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root:has(.live-page) { --l-glass: rgba(7, 26, 19, .86); --l-glass-strong: rgba(6, 21, 15, .93); }
}
/* Drawing without a graphics card (live-map.js sets data-no-gpu, e.g. Chrome with graphics acceleration off): blurring the
   map behind every panel on each frame of a followed vehicle drops it to ~18 fps, so the panels go nearly solid instead */
:root[data-no-gpu]:has(.live-page) { --l-glass: rgba(7, 26, 19, .86); --l-glass-strong: rgba(6, 21, 15, .93); --l-backdrop: none; }
/* About 20px on a 1920 px wall screen, never smaller than the normal page */
:root:has(.live-page.tv-mode) { font-size: clamp(16px, 1.04vw, 26px); }

body.live-page {
  display: block; margin: 0; padding: 0; min-height: 100vh; overflow: hidden;
  background: var(--l-ink); background-image: none; color: var(--l-text);
  font-family: var(--l-font); line-height: 1.5;
}
.live-page :is(h1, h2, h3, p, dl, dd) { margin: 0; }
.live-page :is(h1, h2, h3) { background: none; -webkit-text-fill-color: currentColor; text-shadow: none; letter-spacing: 0; }
.live-page button { font-family: inherit; }
.live-page [hidden] { display: none !important; }
.live-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.live-short { display: none; }

/* ---------- Shell: the map underneath, panels on top ---------- */
.live-page #view-map.live-shell {
  position: fixed; inset: 0; z-index: 0; display: block; width: auto; max-width: none; margin: 0; padding: 0;
  align-self: stretch; justify-self: stretch;  /* legacy centres #view-map, which would shrink a fixed box to nothing */
  background: var(--l-ink); animation: none;
}
.live-stage { position: absolute; inset: 0; }
.live-page .live-stage #gps-map {
  position: absolute; inset: 0; z-index: 0; height: auto; min-height: 0; border-radius: 0; background: #0A1D16;
  font-family: var(--l-font);
}
/* Road maps in Longdo's / OSM's own colours: the internal map's darker, more saturated tiles (legacy) are not used here */
.live-page:is(.basemap-longdo, .basemap-osm) :is(#gps-map, #gps-inset-map) .leaflet-tile-pane { filter: none; }

.live-glass {
  background: var(--l-glass); border: 1px solid var(--l-line); border-radius: 1rem; color: var(--l-text);
  -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
}
.live-top, .live-rail, .live-tools, .live-today, .live-page .live-stage .gps-inset, .live-disabled { position: absolute; z-index: 2; }
.live-top { z-index: 3; }

/* ---------- Header: brand, summary figures, clock ---------- */
.live-top {
  top: var(--l-gap); left: var(--l-gap); right: var(--l-gap); height: var(--l-top-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem;
}
.live-brand { display: flex; align-items: center; gap: 1rem; padding: .625rem 1.5rem .625rem .75rem; border-radius: 1.125rem; min-width: 0; }
.live-logo { flex: none; width: 4.6rem; height: 4.6rem; border-radius: 50%; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .55)); }
.live-eyebrow { color: var(--l-gold); font-size: .82rem; font-weight: 500; letter-spacing: .04em; white-space: nowrap; }
.live-brand h1 { margin-top: .1rem; font: 600 1.85rem/1.25 var(--l-display); color: var(--l-ivory); white-space: nowrap; }

.live-kpis { display: flex; justify-content: center; gap: .75rem; min-width: 0; }
.live-kpi {
  flex: 1 1 0; min-width: 0; max-width: 12rem; display: flex; flex-direction: column-reverse; justify-content: center; gap: .3rem;
  padding: .75rem 1.15rem;
}
.live-kpi dd { font: 600 2.9rem/1 var(--l-display); font-variant-numeric: tabular-nums; color: var(--l-text); }
.live-kpi dt { font-size: .85rem; line-height: 1.3; color: var(--l-dim); }
.live-kpi.is-mission dd { color: var(--l-mission); }
.live-kpi.is-ready dd { color: var(--l-ready); }
.live-kpi.is-online dd { color: var(--l-online); }
.live-kpi.is-speed.is-alert { border-color: rgba(255, 107, 107, .75); box-shadow: 0 0 0 1px rgba(255, 107, 107, .35), 0 0 28px -6px rgba(255, 107, 107, .65); }
.live-kpi.is-speed.is-alert dd { color: var(--l-alert); }
.live-off .live-kpis { visibility: hidden; }

.live-clock {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: .15rem;
  min-width: 15rem; padding: .75rem 1.375rem; border-radius: 1.125rem; margin: 0; line-height: 1.3;
}
.live-clock strong { font: 600 2.45rem/1 var(--l-mono); font-variant-numeric: tabular-nums; color: var(--l-gold); }
.live-clock small { font-size: .85rem; color: var(--l-dim); }
.live-status { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--l-dim); }
.live-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--l-online); box-shadow: 0 0 0 3px rgba(110, 231, 183, .25); animation: live-blink 1.6s ease-in-out infinite; }
.live-tag { font: 600 .72rem var(--l-mono); letter-spacing: .08em; color: var(--l-online); }

/* ---------- Mission rail (a bottom sheet on phones) ---------- */
.live-rail {
  left: var(--l-gap); top: var(--l-under-top); bottom: var(--l-gap); width: var(--l-rail-w);
  display: flex; flex-direction: column; gap: .625rem; min-height: 0;
}
.live-sheet-handle, .live-sheet-today, .live-sheet-toggle, .live-peek { display: none; }
.live-rail-head { display: grid; gap: .3rem; padding: .55rem .9rem; border: 1px solid var(--l-line); border-radius: .875rem; background: var(--l-glass); -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop); }
.live-rail-head h2 { display: flex; align-items: center; gap: .5rem; font: 600 .95rem var(--l-font); color: var(--l-gold); letter-spacing: .03em; }
#gps-crew-summary { min-width: 1.6rem; padding: 0 .45rem; border-radius: 999px; background: rgba(255, 154, 146, .18); color: var(--l-mission); font: 600 .8rem/1.5 var(--l-mono); text-align: center; }
#gps-crew-summary:empty { display: none; }
.live-switch { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--l-dim); cursor: pointer; }
.live-switch input { accent-color: var(--l-gold); width: .95rem; height: .95rem; margin: 0; }
.live-missions {
  flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0 .25rem 0 0;
  display: flex; flex-direction: column; gap: .625rem;
  scrollbar-width: thin; scrollbar-color: rgba(227, 196, 119, .35) transparent;
}
.live-credit {
  align-self: flex-start; padding: .3rem .7rem; border: 1px solid var(--l-line); border-radius: .5rem; background: var(--l-glass-strong);
  -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop);
  font-size: .72rem; line-height: 1.5; color: var(--l-ivory); white-space: nowrap;  /* one line: live-map.js fitCredit shrinks it to fit */
}
.live-credit strong { font-weight: 600; color: var(--l-gold); }
.live-viewers { color: var(--l-online); }
.live-viewers b { font: 600 1.05em var(--l-mono); font-variant-numeric: tabular-nums; }
.live-viewers-dot { display: inline-block; width: .45rem; height: .45rem; margin-right: .3rem; border-radius: 50%; vertical-align: .05em;
  background: var(--l-online); box-shadow: 0 0 0 2px rgba(110, 231, 183, .25); animation: live-blink 1.6s ease-in-out infinite; }

.live-mission {
  appearance: none; margin: 0; width: 100%; display: grid; gap: .35rem; padding: .8rem 1rem;
  font: inherit; text-align: left; color: var(--l-text); cursor: pointer; transition: border-color .2s;
}
.live-mission:hover { border-color: rgba(227, 196, 119, .6); }
:is(.live-mission, .live-standby-row, .live-tool, .live-sheet-handle):focus-visible { outline: 2px solid var(--l-gold); outline-offset: 2px; }
.live-mission-head { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.live-swatch { flex: none; width: .75rem; height: .75rem; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px var(--l-ink), 0 0 0 3.5px var(--swatch); }
.live-code { font-size: 1.15rem; font-weight: 700; color: var(--l-text); }
.live-type {
  display: inline-flex; align-items: center; gap: .35rem; padding: .05rem .6rem; border-radius: 999px; border: 1px solid var(--l-line);
  background: rgba(255, 255, 255, .06); font-size: .76rem; font-weight: 600; color: var(--l-ivory); white-space: nowrap;
}
/* The mission type's dot, the same colours as the app (console.css --type-*); the name beside it carries the meaning */
.live-type::before { content: ''; flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: #8FA39A; }
.live-type.is-refer::before { background: #2a78d6; }
.live-type.is-ems::before { background: #eb6834; }
.live-type.is-mobile_unit::before { background: #1baf7a; }
.live-type.is-staff_transport::before { background: #eda100; }
.live-type.is-lab_transport::before { background: #e87ba4; }
/* Case colour after Refer / EMS (the triage level picked at dispatch): a dot in the colour and its name */
.live-triage { flex: none; display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .55rem .05rem .4rem; border: 1px solid; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.live-triage::before { content: ""; flex: none; width: .55rem; height: .55rem; border-radius: 50%; background: var(--dot); }
.live-triage.is-red { --dot: #FF5A5A; color: #FFC4C4; border-color: rgba(255, 90, 90, .65); background: rgba(255, 90, 90, .16); }
.live-triage.is-pink { --dot: #F472B6; color: #FBD0E8; border-color: rgba(244, 114, 182, .65); background: rgba(244, 114, 182, .16); }
.live-triage.is-yellow { --dot: #FACC15; color: #FEF08A; border-color: rgba(250, 204, 21, .6); background: rgba(250, 204, 21, .13); }
.live-triage.is-green { --dot: #34D399; color: #B5F5DC; border-color: rgba(52, 211, 153, .6); background: rgba(52, 211, 153, .13); }
/* Nurse on board, after the crew's names (em-sized like the shift pill); no nurse is an amber warning */
.live-nurse { display: inline-block; padding: 0 .5em; border: 1px solid; border-radius: 999px; font-size: .78em; font-weight: 600; line-height: 1.45; white-space: nowrap; vertical-align: .08em; }
.live-nurse::before { content: "✓ " / ""; }
.live-nurse.is-yes { color: #BFE6FF; border-color: rgba(125, 200, 255, .55); background: rgba(125, 200, 255, .12); }
.live-nurse.is-no { color: #FFD3A8; border-color: rgba(251, 146, 60, .65); background: rgba(251, 146, 60, .16); }
.live-nurse.is-no::before { content: "! " / ""; }
.live-elapsed { margin-left: auto; font: 600 .85rem var(--l-mono); color: var(--l-gold); white-space: nowrap; }
.live-driver { font-size: .95rem; overflow-wrap: anywhere; }
/* The driver's shift after the name ("เวร บ3"); em-sized so it follows the line it sits in */
.live-shift { display: inline-block; padding: 0 .45em; border: 1px solid rgba(227, 196, 119, .5); border-radius: 999px; font-size: .78em; font-weight: 600; line-height: 1.45; color: var(--l-gold); white-space: nowrap; vertical-align: .08em; }
.live-dest { font-size: .84rem; color: var(--l-dim); overflow-wrap: anywhere; }
.live-dest b { font-weight: 600; color: var(--l-ivory); }
.live-legs, .live-leg-labels { display: grid; grid-template-columns: 1fr .55fr 1fr; gap: .25rem; }
.live-legs { margin-top: .2rem; }
.live-leg { position: relative; height: .45rem; overflow: hidden; border-radius: .25rem; background: rgba(255, 255, 255, .12); }
.live-leg i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, #B8954A, var(--l-gold)); }
.live-leg.is-now i { box-shadow: 0 0 10px rgba(227, 196, 119, .65); }
.live-leg.is-now.is-done i { animation: live-breathe 2s ease-in-out infinite; }  /* handing over at the destination */
.live-leg.is-unknown {
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .08) 0 .35rem, rgba(227, 196, 119, .32) .35rem .7rem);
  background-size: 200% 100%; animation: live-stripes 3s linear infinite;
}
.live-leg-labels { font-size: .7rem; color: var(--l-faint); }
.live-leg-labels .is-now { font-weight: 600; color: var(--l-ivory); }
.live-mission-foot { display: flex; justify-content: space-between; gap: .75rem; font-size: .78rem; color: var(--l-dim); }
.live-mission-foot > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.live-mission-foot > span + span { flex: none; white-space: nowrap; }
.live-mission-foot .is-moving { font-weight: 600; color: var(--l-online); }
.live-mission-foot .is-overspeed { font-weight: 700; color: var(--l-alert); }

.live-standby { display: grid; gap: .1rem; padding: .6rem 1rem; }
.live-standby h3 { margin-bottom: .2rem; font: 600 .78rem var(--l-font); letter-spacing: .03em; color: var(--l-ready); }
.live-standby-row {
  appearance: none; display: flex; align-items: baseline; gap: .65rem; width: 100%; margin: 0; padding: .2rem 0;
  border: 0; background: none; font: inherit; font-size: .85rem; text-align: left; color: var(--l-text); cursor: pointer;
}
.live-standby-row b { flex: none; min-width: 4.2rem; font-weight: 600; color: var(--l-ready); }
.live-standby-row span { min-width: 0; overflow-wrap: anywhere; color: var(--l-dim); }
.live-empty { padding: 1rem; text-align: center; color: var(--l-dim); }

/* ---------- Tool buttons ---------- */
.live-tools { right: var(--l-gap); top: var(--l-under-top); display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; transition: opacity .3s; }
.live-tool {
  appearance: none; margin: 0; display: inline-flex; align-items: center; gap: .5rem; height: 2.25rem; padding: 0 .95rem;
  border-radius: 999px; font-size: .85rem; font-weight: 500; color: var(--l-ivory); cursor: pointer; white-space: nowrap;
}
.live-tool svg { flex: none; width: 1.15rem; height: 1.15rem; fill: none; stroke: var(--l-gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.live-tool[aria-pressed="true"] { background: rgba(227, 196, 119, .22); border-color: var(--l-gold); }
#live-voice-btn .live-i-on, #live-voice-btn[aria-pressed="true"] .live-i-off { display: none; }
#live-voice-btn[aria-pressed="true"] .live-i-on { display: block; }

/* ---------- Today strip ---------- */
.live-today {
  left: var(--l-beside-rail); right: calc(var(--l-gap) + var(--l-inset-w) + 1rem); bottom: var(--l-gap); min-height: var(--l-today-h);
  display: flex; align-items: center; gap: 1rem; padding: .5rem 1.25rem;
}
.live-today-title { flex: none; font: 600 1.15rem var(--l-display); color: var(--l-gold); }
.live-stat { flex: none; display: grid; line-height: 1.2; padding-left: 1rem; border-left: 1px solid var(--l-line); }
.live-stat b { font: 600 1.55rem var(--l-display); font-variant-numeric: tabular-nums; color: var(--l-ivory); }
.live-stat span { font-size: .72rem; color: var(--l-dim); }
.live-today-types { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem .4rem; }
.live-today-types .live-type { font-size: .72rem; }

/* ---------- Street inset (GpsMap) ---------- */
.live-page .live-stage .gps-inset {
  right: var(--l-gap); bottom: calc(var(--l-gap) + 1.4rem); width: var(--l-inset-w); overflow: hidden;
  border: 1px solid rgba(227, 196, 119, .5); border-radius: 1rem; background: var(--l-ink); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .8);
}
.live-page .gps-inset-head { padding: .4rem .75rem; border-bottom: 1px solid var(--l-line); font-size: .8rem; color: var(--l-ivory); }
.live-page .gps-inset-head button { border-color: var(--l-line); color: var(--l-ivory); }
.live-page #gps-inset-map { height: var(--l-inset-h); }
@layer console-fix {
  @media screen {
    html[data-theme] .live-page .gps-inset-head { background: var(--l-glass-strong) !important; }
  }
}

/* ---------- Map controls, markers and messages ---------- */
.live-page .live-stage .leaflet-top.leaflet-left { top: calc(var(--l-under-top) - 10px); left: calc(var(--l-beside-rail) - 10px); }
.live-page .live-stage .leaflet-top.leaflet-right { top: calc(var(--l-under-top) + var(--l-tools-h) + .75rem - 10px); right: calc(var(--l-gap) - 10px); }
.live-page .live-stage .leaflet-bottom.leaflet-right { right: var(--l-gap); bottom: calc(var(--l-gap) - 2px); }
.live-page .leaflet-control-container { transition: opacity .3s; }
.live-page #gps-map .leaflet-bar { overflow: hidden; border: 1px solid var(--l-line); border-radius: .75rem; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .8); }
.live-page #gps-map .leaflet-bar { -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop); }
.live-page #gps-map .leaflet-bar a { background: var(--l-glass-strong); color: var(--l-ivory); border-color: var(--l-line); }
/* The layer box and the group labels on the map are one set (L37): see-through glass that blurs and dims the map behind it,
   a faint gold edge, a light shadow, so they cover as little of the map as possible. The dimmed backdrop keeps the light
   text readable even on a white tile (L35); without backdrop-filter --l-glass-strong turns nearly solid (above) */
.live-page :is(#gps-map .leaflet-control-layers, #gps-map .gps-group) {
  background: var(--l-glass-strong); color: var(--l-text); border: 1px solid var(--l-line);
  -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop); box-shadow: 0 6px 16px -10px rgba(0, 0, 0, .7);
}
.live-page #gps-map .leaflet-control-layers { border-radius: .75rem; }
.live-page #gps-map .leaflet-control-layers-separator { border-top-color: var(--l-line); }
/* Leaflet's layers.png is not shipped with the vendored copy: draw the stack icon here */
.live-page #gps-map .leaflet-control-layers-toggle {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E3C477' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M12 3 2.5 8 12 13l9.5-5z'/%3E%3Cpath d='m2.5 12.5 9.5 5 9.5-5M2.5 16.5l9.5 5 9.5-5'/%3E%3C/svg%3E") center / 1.4rem no-repeat;
}
.live-page #gps-map .leaflet-control-layers-selector { accent-color: var(--l-gold); }
.live-page .leaflet-control-attribution { background: rgba(6, 21, 15, .8); color: var(--l-dim); border-radius: .4rem; }
.live-page .leaflet-control-attribution a { color: var(--l-gold); }
/* Vehicle labels larger than the internal map's, readable on a wall screen (vehicle sizes: css/gps-vehicles.css) */
.live-page .gps-marker-wrap .gps-marker { font-size: .47rem; padding: .037rem .3rem; border-radius: 6px; opacity: .9; }  /* .62rem → .5 → .25 → .3 → .39 → .47rem, the user's steps on 2026-10-29 */
.live-page .gps-marker.gps-moving { background: #15803d; }  /* legacy #16a34a gives white text only 3.3:1 */
.live-page .gps-map-empty { z-index: 2; -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop); background: var(--l-glass-strong); border: 1px solid var(--l-line); color: var(--l-ivory); font-size: .9rem; }

.live-disabled { z-index: 3; margin: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(34rem, calc(100% - 2rem)); padding: 2rem; text-align: center; }
.live-disabled h2 { margin-bottom: .5rem; font: 600 1.5rem var(--l-display); color: var(--l-gold); }
.live-disabled p { color: var(--l-dim); }

/* ---------- TV mode: buttons and map controls fade out after a few still seconds (live-map.js) ---------- */
.live-page.tv-mode.is-idle { cursor: none; }
.live-page.tv-mode.is-idle :is(.live-tools, .leaflet-control-container) { opacity: 0; pointer-events: none; }

/* Every crew on the wall screen at once (a TV remote scrolls badly). live-map.js adds these steps to the rail one by one
   until the list fits; past the last step it turns pages and shows "หน้า 1/2" in the heading. */
.live-rail-page { margin-left: auto; padding: 0 .55rem; border: 1px solid var(--l-line); border-radius: 999px; font: 600 .78rem/1.5 var(--l-mono); color: var(--l-ivory); }
/* Step 1: no leg names under the bar (the stage is named on the line above), less padding */
.live-rail.is-compact .live-missions { gap: .45rem; }
.live-rail.is-compact .live-mission { gap: .2rem; padding: .55rem .9rem; }
.live-rail.is-compact .live-leg-labels { display: none; }
.live-rail.is-compact .live-standby { padding: .45rem .9rem; }
.live-rail.is-compact .live-standby-row { padding: .1rem 0; }
/* Step 2: three lines (vehicle; driver and the vehicle's state; stage and destination beside the bar).
   The arrival estimate gives way. */
.live-rail.is-dense .live-mission {
  grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head head" "driver state" "dest legs";
  column-gap: .75rem; row-gap: .1rem; padding: .45rem .85rem;
}
.live-rail.is-dense .live-mission-head { grid-area: head; }
.live-rail.is-dense .live-driver { grid-area: driver; }
.live-rail.is-dense .live-dest { grid-area: dest; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.live-rail.is-dense .live-legs { grid-area: legs; align-self: center; width: 7rem; margin: 0; }
.live-rail.is-dense .live-mission-foot { display: contents; }
.live-rail.is-dense .live-mission-foot > span:first-child { display: none; }
.live-rail.is-dense .live-mission-foot > span + span { grid-area: state; align-self: center; }
/* Step 3: the same three lines set closer together; names stay whole */
.live-rail.is-tight .live-missions { gap: .35rem; }
.live-rail.is-tight :is(.live-mission, .live-standby) { line-height: 1.35; padding: .3rem .85rem; }
.live-rail.is-tight .live-code { font-size: 1.05rem; }
.live-rail.is-tight .live-standby-row { padding: 0; }
/* With reduced motion, legacy ios.css gives every element a .01ms transition (!important). A step must resize the cards
   at once, or live-map.js measures the old sizes and breaks the pages in the wrong places. */
@layer console-fix {
  @media (prefers-reduced-motion: reduce) {
    .live-page :is(.live-missions, .live-missions *) { transition: none !important; }
  }
}

/* ---------- Short desktop screens ---------- */
@media (min-width: 901px) and (max-width: 1500px) {
  :root:has(.live-page) { --l-inset-w: 19rem; --l-rail-w: 24rem; }
  /* Room for the figure labels on one line at laptop widths */
  .live-brand { gap: .8rem; padding-right: 1.2rem; }
  .live-brand h1 { font-size: 1.5rem; }
  .live-kpi { padding: .75rem .9rem; }
  .live-kpi dt { font-size: .78rem; }
  .live-clock { min-width: 0; padding: .75rem 1.1rem; }
  .live-clock strong { font-size: 2rem; }
}
@media (min-width: 901px) and (max-height: 760px) {
  :root:has(.live-page) { --l-inset-h: 10rem; }
}

/* ---------- Phones and narrow tablets: map full screen, compact header, missions in a bottom sheet ---------- */
@media (max-width: 900px) {
  /* Folded: the head, today and the first mission, so the map keeps about three quarters of the screen */
  :root:has(.live-page) { --l-sheet: calc(8rem + env(safe-area-inset-bottom, 0px)); --l-sheet-open: 64vh; }
  @supports (height: 1dvh) { :root:has(.live-page) { --l-sheet-open: 64dvh; } }

  .live-top {
    top: calc(env(safe-area-inset-top, 0px) + .625rem); left: max(.625rem, env(safe-area-inset-left, 0px)); right: max(.625rem, env(safe-area-inset-right, 0px));
    height: auto; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand clock" "kpis kpis"; gap: .5rem .75rem;
    padding: .625rem .75rem; border: 1px solid var(--l-line); border-radius: 1.125rem; background: var(--l-glass);
    -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop);
  }
  .live-top > .live-glass { background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 0; border-radius: 0; }
  .live-brand { grid-area: brand; gap: .6rem; }
  .live-logo { width: 2.25rem; height: 2.25rem; }
  .live-eyebrow { font-size: .68rem; }
  .live-eyebrow span { display: none; }
  .live-brand h1 { margin: 0; font-size: 1.05rem; }
  .live-clock { grid-area: clock; min-width: 0; max-width: 7.4rem; gap: 0; }
  .live-clock strong { font-size: 1.05rem; }
  .live-clock small { display: none; }
  /* "LIVE" and the update time stack under the clock, leaving the title its room beside the logo */
  .live-status { flex-wrap: wrap; justify-content: flex-end; column-gap: .3rem; row-gap: 0; font-size: .66rem; line-height: 1.35; }
  .live-tag { font-size: .62rem; }
  .live-kpis { grid-area: kpis; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .375rem; }
  .live-kpis:has(#live-kpi-speed-box[hidden]) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* The figures as one row of chips: label, then the number */
  .live-top .live-kpi { max-width: none; flex-direction: row; align-items: baseline; justify-content: center; gap: .3rem; height: 2rem; box-sizing: border-box; padding: 0 .45rem; border: 1px solid var(--l-line); border-radius: 1rem; background: rgba(255, 255, 255, .05); }
  .live-kpi dd { order: 2; font-size: 1rem; line-height: 2rem; }
  .live-kpi dt { order: 1; font-size: .7rem; line-height: 2rem; white-space: nowrap; }
  .live-long { display: none; }
  .live-short { display: inline; }

  .live-rail {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; height: var(--l-sheet); gap: .5rem;
    padding: 0 max(.75rem, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + .5rem) max(.75rem, env(safe-area-inset-left, 0px));
    border: 1px solid var(--l-line); border-bottom: 0; border-radius: 1.5rem 1.5rem 0 0; background: var(--l-glass-strong);
    -webkit-backdrop-filter: var(--l-backdrop); backdrop-filter: var(--l-backdrop); box-shadow: 0 -16px 40px -20px rgba(0, 0, 0, .8);
    transition: height .3s ease;
  }
  .live-rail.is-open { height: var(--l-sheet-open); }
  .live-sheet-handle {
    display: flex; justify-content: center; align-items: center; flex: none; width: 100%; min-height: 1.9rem; margin: 0; padding: .4rem 0 0;
    border: 0; background: none; cursor: pointer; touch-action: none;
  }
  .live-grip { width: 2.75rem; height: .3rem; border-radius: .2rem; background: rgba(255, 255, 255, .35); }
  .live-rail-head { padding: 0; border: 0; border-radius: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .live-rail-head h2 { color: var(--l-ivory); font-size: 1rem; }
  .live-sheet-today { display: block; font-size: .78rem; color: var(--l-dim); }
  .live-rail-head { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .5rem; }
  .live-rail-head > :not(h2, .live-sheet-toggle) { grid-column: 1 / -1; }
  .live-sheet-toggle {
    display: inline-flex; align-items: center; justify-content: center; min-width: 5rem; min-height: 2.75rem; padding: 0 .75rem;
    border: 1px solid var(--l-line); border-radius: 1.375rem; background: rgba(255, 255, 255, .05); color: var(--l-gold);
    font: 600 .82rem var(--l-font); cursor: pointer;
  }
  .live-sheet-toggle:focus-visible { outline: 2px solid var(--l-gold); outline-offset: 2px; }
  .live-peek {
    display: flex; align-items: center; gap: .5rem; min-width: 0; padding-top: .35rem; border-top: 1px solid var(--l-line);
    font-size: .82rem; color: var(--l-dim); white-space: nowrap; overflow: hidden;
  }
  .live-peek .live-code { font-size: .95rem; color: var(--l-text); }
  .live-peek .live-elapsed { margin-left: auto; }
  .live-rail.is-open .live-peek { display: none; }
  /* Tight rows so the folded 8rem holds the handle, the head, today and the first mission */
  .live-rail { gap: .3rem; }
  .live-sheet-handle { min-height: 1.1rem; padding-top: .3rem; }
  .live-rail-head { row-gap: .15rem; }
  .live-sheet-today { font-size: .74rem; line-height: 1.3; }
  .live-peek { padding-top: .2rem; line-height: 1.4; }
  .live-rail:not(.is-open) .live-switch { visibility: hidden; }
  .live-missions { padding: 0; }
  .live-rail :is(.live-mission, .live-standby, .live-empty) { background: rgba(255, 255, 255, .045); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .live-mission { padding: .7rem .85rem; }
  .live-code { font-size: 1.05rem; }
  .live-credit { background: none; border: 0; padding: 0; }

  .live-tools { top: auto; right: max(.75rem, env(safe-area-inset-right, 0px)); bottom: calc(var(--l-sheet) + .75rem); }
  .live-stage:has(.live-rail.is-open) .live-tools { opacity: 0; pointer-events: none; }
  .live-tool { width: 2.75rem; height: 2.75rem; padding: 0; justify-content: center; border-radius: 50%; }
  .live-tool svg { width: 1.3rem; height: 1.3rem; }
  .live-tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #live-tv-btn, #gps-fullscreen-btn { display: none; }

  .live-page .live-today, .live-page .live-stage .gps-inset { display: none !important; }
  .live-page .leaflet-control-zoom { display: none; }
  .live-page .live-stage .leaflet-top.leaflet-right { top: calc(env(safe-area-inset-top, 0px) + 9.2rem); right: 0; }
  .live-page .live-stage .leaflet-bottom.leaflet-right { right: auto; left: 0; bottom: var(--l-sheet); }
}

/* Group labels on the wall screen (material shared with the layer box, above); state dots in colours that read on it */
.live-page .gps-group { padding: .18rem .5rem; font-family: var(--l-font); font-size: .72rem; }
.live-page .gps-group .gps-group-pill { gap: .35rem; }
.live-page .gps-group-dots .gps-state-dot { width: .45rem; height: .45rem; }
.live-page .gps-group:focus-visible { outline: 2px solid var(--l-gold); outline-offset: 2px; }
.live-page :is(.gps-group-head small, .gps-group-more) { color: var(--l-gold); }
.live-page .gps-group-row span { color: var(--l-dim); }
.live-page .gps-state-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #8FA39A; }
.live-page .gps-state-dot.is-moving { background: #6EE7B7; }
.live-page .gps-state-dot.is-overspeed { background: #FF6B6B; }
.live-page .gps-state-dot.is-stopped { background: #A9CBFF; }
.live-page .gps-state-dot.is-parked { background: #BCD2C7; }

@keyframes live-blink { 50% { opacity: .3; } }
@keyframes live-stripes { to { background-position: -100% 0; } }
@keyframes live-breathe { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .live-dot, .live-viewers-dot, .live-leg, .live-leg i { animation: none; }
  .live-rail, .live-tools, .live-page .leaflet-control-container { transition: none; }
}
