/* Plain CSS, served by Propshaft. Every file in this folder is linked by stylesheet_link_tag :app. */

:root {
  --color-bg: #111418;
  --color-surface: #1b2027;
  --color-border: #2c333d;
  --color-text: #e8eaed;
  --color-muted: #9aa3ad;
  --color-accent: #4285f4;
  --color-danger: #e5484d;
  --color-success: #3dd68c;
  --color-selected: #f5a524;
  /* Panels over the map: the tab bar's frosted glass, a shade darker so their text reads on light tiles.
     Secondary text is translucent white rather than --color-muted, which is too dark for the glass. */
  --color-hud: rgb(20 20 20 / 78%);
  --color-hud-muted: rgb(255 255 255 / 72%);

  --radius: 6px;
  --space: 1rem;

  /* The phone tab bar: a pill inset from the viewport edges and floating above the bottom. It only has
     to clear the home indicator, which sits well inside the safe area, so the lift doesn't stack on the
     full inset. --tab-bar-space is everything it covers, which content keeps clear of. */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --tab-bar-inset: 20px;
  --tab-bar-height: 60px;
  --tab-bar-bottom: max(12px, calc(var(--safe-bottom) - 16px));
  --tab-bar-space: calc(var(--tab-bar-height) + var(--tab-bar-bottom));
  --nav-pill-height: 48px;

  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--color-accent);
}

h1, h2 {
  line-height: 1.2;
}

code {
  font-size: 0.9em;
}

/* Admin's header is still text; everywhere else the logo is the Segras lockup as an image,
   from the brand repo's dist/segras/logo. */
.brand {
  color: var(--color-text);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand img {
  display: block;
}

.button,
input[type="submit"],
button {
  background: var(--color-accent);
  border: 0;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  padding: 0.45rem 0.9rem;
  text-decoration: none;
}

.button-danger {
  background: var(--color-danger);
}

/* A screen's actions are buttons, never bare links. A wide button is a full-width row in one of three
   shapes: an icon and a line, an icon and two lines (.btn-text around a line and a <small>), or a short
   centered line. .action fills that line for save and confirm; .cancel is its muted, unfilled way out. */
.btn {
  align-items: center;
  background: var(--color-surface);
  border-radius: 12px;
  color: var(--color-text);
  display: inline-flex;
  font-weight: 500;
  gap: 12px;
  justify-content: center;
  min-height: 48px;
  padding: 12px 14px;
  text-decoration: none;
}

.btn.wide {
  display: flex;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.btn:active {
  transform: scale(0.99);
}

.btn:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

/* A wide button whose icon and line sit in the middle, like a link out of the app. */
.btn.wide.center {
  justify-content: center;
}

.btn.action,
.btn.cancel,
.btn.danger {
  justify-content: center;
  text-align: center;
}

.btn.action {
  background: var(--color-accent);
  color: white;
  font-weight: 600;
}

.btn.cancel {
  background: none;
  color: var(--color-muted);
}

.btn.danger {
  color: var(--color-danger);
}

.btn.alarm {
  background: var(--color-danger);
  color: white;
  font-weight: 600;
  justify-content: center;
}

.btn.alert-option {
  color: var(--color-danger);
}

.hud .btn.alarm {
  margin-top: 0.5rem;
  min-height: 40px;
  padding: 8px 12px;
}

.btn svg {
  fill: none;
  flex-shrink: 0;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

.btn-text {
  display: grid;
}

.btn-text small {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

/* Wide buttons in a column, and the column's room above whatever comes before it. */
.btn-stack {
  display: grid;
  gap: 0.6rem;
  margin-top: var(--space);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font: inherit;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.flash {
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

.flash-notice {
  background: color-mix(in srgb, var(--color-success) 20%, transparent);
}

.flash-alert,
.form-errors {
  background: color-mix(in srgb, var(--color-danger) 20%, transparent);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

/* Sign in */

.sign-in {
  margin: 15vh auto 0;
  max-width: 22rem;
  padding: var(--space);
}

.sign-in .brand img {
  margin: 0 auto;
  width: 9rem;
}

.sign-in-form,
.admin-form,
.settings-form {
  display: grid;
  gap: 0.4rem;
}

.admin-form input[type="submit"] {
  justify-self: start;
  margin-top: 0.8rem;
}

/* Dashboard: a full-screen map with translucent panels over it */

.dashboard {
  height: 100%;
  position: relative;
}

.map,
.map-canvas {
  height: 100%;
  width: 100%;
}

/* The map sits under the HUD panels. */
.map-canvas {
  z-index: 0;
}

/* Leaflet's divIcon wrapper; .car-marker draws the marker. */
.leaflet-div-icon.marker {
  background: none;
  border: 0;
}

/* What tapping the car opens: its name over a stack of links to its pages, on the same dark glass as the
   HUD panels. Leaflet's popup gets the "car-popup-frame" class (see the map controller). */
.car-popup-frame .leaflet-popup-content-wrapper,
.car-popup-frame .leaflet-popup-tip {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 35%);
  color: white;
}

.car-popup-frame .leaflet-popup-content-wrapper {
  border-radius: 20px;
}

.car-popup-frame .leaflet-popup-content {
  font: inherit;
  margin: 0.8rem 0.9rem;
}

.leaflet-container .car-popup-frame a.leaflet-popup-close-button {
  color: var(--color-hud-muted);
  right: 6px;
  top: 6px;
}

.car-popup {
  display: grid;
  gap: 0.6rem;
  min-width: 200px;
}

.car-popup-name {
  font-size: 1.05rem;
  padding-right: 1.2rem;
}

.car-popup-links {
  display: grid;
  gap: 0.4rem;
}

.leaflet-container .car-popup-links .btn {
  background: rgb(255 255 255 / 12%);
  color: white;
  justify-content: flex-start;
  min-height: 40px;
  padding: 8px 12px;
}

.car-popup-links .btn svg {
  height: 18px;
  width: 18px;
}

.hud {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  border-radius: 20px;
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 35%);
  color: white;
  padding: 0.6rem 0.9rem;
  position: absolute;
  z-index: 1;
}

/* The wordmark and the vehicle switcher, each floating on its own over the map. With the desktop
   navigation on the page, its pill carries the wordmark and the switcher sits under it. */
.hud-top {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  align-items: center;
  background: none;
  box-shadow: none;
  display: flex;
  gap: var(--space);
  left: var(--space);
  padding: 0;
  top: var(--space);
}

body:has(.top-nav) .hud-top {
  top: calc(var(--space) + var(--nav-pill-height) + 0.6rem);
}

body:has(.top-nav) .hud-top .brand {
  display: none;
}

/* Over the map: the lockup with the word in ink, lifted off busy tiles by a white glow. */
.hud-top .brand img {
  filter: drop-shadow(0 0 3px rgb(255 255 255 / 80%));
  height: 1.75rem;
}

.hud-top .vehicle-switcher {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}

/* Shown by the push controller once it knows this browser supports Web Push. */
.push-toggle[hidden] {
  display: none;
}

.vehicle-switcher {
  display: flex;
  gap: 0.6rem;
}

.vehicle-link {
  color: var(--color-muted);
  text-decoration: none;
}

.vehicle-link.current {
  color: white;
  font-weight: 600;
}

.hud-side {
  max-width: 340px;
  right: var(--space);
  top: 5rem;
}

.vehicle-summary {
  font-size: 1.4rem;
  margin: 0 0 0.3rem;
}

.vehicle-last-report {
  color: var(--color-hud-muted);
  margin: 0 0 0.6rem;
}

.vehicle-coordinates {
  color: var(--color-hud-muted);
  font-variant-numeric: tabular-nums;
  margin: 0;
}

/* The tracker is checking in: a quick pulse while the car is driven, a slow one with zzz while it's parked.
   It sits in the panel's top right corner, with the summary kept clear of it. */
.vehicle-summary:has(.tracker-pulse) {
  padding-right: 1.4rem;
}

.hud-side:has(.tracker-pulse) {
  anchor-name: --tracker-pulse;
}

.tracker-pulse {
  animation: tracker-pulse 1.2s ease-out infinite;
  background: var(--color-success);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  height: 0.6rem;
  padding: 0;
  position: absolute;
  right: 1.1rem;
  top: 1rem;
  width: 0.6rem;
}

/* A finger-sized target around the dot. */
.tracker-pulse::before {
  content: "";
  inset: -0.7rem;
  position: absolute;
}

.tracker-pulse.asleep {
  animation-duration: 4s;
}

.tracker-pulse.asleep::after {
  color: var(--color-hud-muted);
  content: "zzz";
  font-size: 0.55rem;
  font-weight: 600;
  left: 75%;
  line-height: 1;
  position: absolute;
  top: 70%;
}

@keyframes tracker-pulse {
  from { box-shadow: 0 0 0 0 rgb(61 214 140 / 60%); }
  to { box-shadow: 0 0 0 0.5rem rgb(61 214 140 / 0%); }
}

@media (prefers-reduced-motion: reduce) {
  .tracker-pulse {
    animation: none;
    box-shadow: 0 0 6px var(--color-success);
  }
}

.tracker-pulse-details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.85rem;
  max-width: calc(100vw - 2rem);
  overflow-x: auto;
  padding: 0.9rem 1.1rem;
  width: max-content;
}

/* Beside the panel where anchoring is supported, toward the map on its left, or on its right when there's no
   room; centered on the screen elsewhere. */
@supports (anchor-name: --tracker-pulse) {
  .tracker-pulse-details {
    inset: auto;
    margin: 0 0.75rem;
    position-anchor: --tracker-pulse;
    position-try-fallbacks: flip-inline;
    right: anchor(left);
    top: anchor(top);
  }
}

.tracker-pulse-details p {
  margin: 0 0 0.6rem;
  max-width: 32rem;
}

/* The dot again, leading the sentence, centered on it with the same room on either side. */
.tracker-pulse-note {
  align-items: center;
  display: flex;
  gap: 14px;
  padding-left: 14px;
}

.tracker-pulse-note .tracker-pulse {
  cursor: default;
  flex: none;
  position: relative;
  right: auto;
  top: auto;
}

/* Clears the zzz, so the gap starts after it. */
.tracker-pulse-note .tracker-pulse.asleep {
  margin-right: 0.8rem;
}

.tracker-pulse-details table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tracker-pulse-details th,
.tracker-pulse-details td {
  padding: 0.3rem 1.2rem 0.3rem 0;
  text-align: left;
}

.tracker-pulse-details :is(th, td):last-child {
  padding-right: 0;
}

.tracker-pulse-details th {
  color: var(--color-muted);
  font-weight: 500;
}

.tracker-pulse-close {
  display: none;
}

/* A page of its own on phones, over the whole screen. */
@media (max-width: 640px) {
  .tracker-pulse-details {
    border: 0;
    border-radius: 0;
    height: 100%;
    inset: 0;
    margin: 0;
    max-height: none;
    max-width: none;
    padding: calc(var(--safe-top) + 1rem) var(--space) calc(var(--safe-bottom) + 1rem);
    position-try-fallbacks: none;
    width: 100%;
  }

  /* Its cells wrap to two lines rather than scroll sideways. */
  .tracker-pulse-details table {
    font-size: 0.75rem;
    white-space: normal;
    width: 100%;
  }

  .tracker-pulse-details th,
  .tracker-pulse-details td {
    padding-right: 0.6rem;
    vertical-align: top;
  }

  .tracker-pulse-close {
    background: none;
    border: 0;
    color: var(--color-accent);
    display: block;
    font: inherit;
    margin: 0 0 1rem auto;
    padding: 0.4rem 0;
  }
}

.hud-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

/* button_to wraps its button in a form, which shouldn't take part in the row. */
.hud-actions form {
  display: contents;
}

.hud-actions .btn {
  background: rgb(255 255 255 / 12%);
  color: white;
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
}

/* The car on the map: a puck of the HUD panels' dark glass with the car glyph, rimmed and haloed in the
   accent color so it reads as live and stands out on the light tiles. */
.car-marker {
  display: grid;
  height: 100%;
  place-items: center;
  width: 100%;
}

.car-marker > * {
  grid-area: 1 / 1;
}

.car-marker-halo {
  animation: car-marker-halo 2.4s ease-out infinite;
  background: var(--color-accent);
  border-radius: 50%;
  height: 40px;
  width: 40px;
}

.car-marker-puck {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 35%);
  display: grid;
  height: 40px;
  place-items: center;
  width: 40px;
}

.car-marker-puck svg {
  fill: none;
  height: 20px;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 20px;
}

/* In a risky place, the car glows in the place's level color (see ZoneVisit). */
.in-zone .car-marker-halo {
  background: var(--level-color);
}

.in-zone .car-marker-puck {
  border-color: var(--level-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--level-color) 40%, transparent), 0 0 22px 8px var(--level-color);
}

/* Greyed and still: the car was here when its tracker went quiet, it isn't known to be here now. */
.signal-lost .car-marker-halo {
  display: none;
}

.signal-lost .car-marker-puck {
  border-color: var(--color-muted);
}

.signal-lost .car-marker-puck svg {
  stroke: var(--color-muted);
}

@keyframes car-marker-halo {
  from { opacity: 0.45; transform: scale(1); }
  to { opacity: 0; transform: scale(2.2); }
}

@media (prefers-reduced-motion: reduce) {
  .car-marker-halo {
    animation: none;
    opacity: 0.2;
    transform: scale(1.5);
  }
}

@media (max-width: 640px) {
  /* Just the wordmark floats over the map. */
  .hud-top,
  body:has(.top-nav) .hud-top {
    top: max(var(--space), var(--safe-top));
  }

  .hud-top .brand,
  body:has(.top-nav) .hud-top .brand {
    display: block;
  }

  .hud-side {
    bottom: calc(var(--tab-bar-space) + 1.75rem);
    left: var(--space);
    max-width: none;
    top: auto;
  }

  /* Pinch zooms on a phone; the attribution sits just above the tab bar, under the vehicle panel. */
  .map .leaflet-control-zoom {
    display: none;
  }

  .map .leaflet-bottom {
    bottom: calc(var(--tab-bar-space) + 4px);
  }
}

/* Car presence setup: instructions for the iOS Shortcuts automations */

.setup {
  margin: 0 auto;
  max-width: 40rem;
  padding: var(--space);
}

.setup li {
  margin-bottom: 0.4rem;
}

.setup-status,
.setup-hint {
  color: var(--color-muted);
}

.settings-label {
  margin-top: 0.8rem;
}

/* Under "When a car starts moving", which it applies to. */
.settings-interval {
  align-items: center;
  color: var(--color-muted);
  display: flex;
  gap: 0.5rem;
}

.settings-interval input {
  width: 4.5rem;
}

/* History: a vehicle's events, by day */

.history-header {
  align-items: center;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
}

.icon-link {
  color: var(--color-muted);
  display: flex;
  padding: 0.4rem;
}

.icon-link svg {
  fill: none;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

.history .vehicle-switcher {
  margin-bottom: var(--space);
}

.history-day h2 {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 1.4rem 0 0.4rem;
  text-transform: uppercase;
}

.history-events {
  background: var(--color-surface);
  border-radius: var(--radius);
  list-style: none;
  margin: 0;
  padding: 0 0.9rem;
}

.history-event {
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 0.9rem;
  padding: 0.65rem 0;
}

.history-event:last-child {
  border-bottom: 0;
}

.history-event time {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.history-event-alarm span {
  color: var(--color-danger);
}

/* Advanced mode: every report and event, with what the tracker sent */

.history-mode {
  background: var(--color-surface);
  border-radius: 999px;
  color: var(--color-text);
  font-size: 0.9rem;
  margin-left: auto;
  padding: 0.3rem 0.9rem;
  text-decoration: none;
}

.history-entry {
  font-size: 0.9rem;
}

.history-entry > div {
  min-width: 0;
}

.history-detail {
  color: var(--color-muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.history-report span {
  color: var(--color-muted);
}

/* Tracker: how a vehicle's tracker is doing, now and over a window */

.health-windows {
  display: flex;
  font-variant-numeric: tabular-nums;
  gap: 0.8rem;
  margin-left: auto;
}

.tracker-health .vehicle-switcher {
  margin-bottom: var(--space);
}

.health-now {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  margin: 0;
}

.health-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}

.health-tile-warning {
  border-color: var(--color-selected);
}

.health-tile dt {
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.health-tile dd {
  margin: 0.2rem 0 0;
}

.health-tile .health-detail {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.health-bars {
  align-items: end;
  display: inline-flex;
  gap: 2px;
  height: 0.9em;
  margin-left: 0.3rem;
}

.health-bars i {
  background: var(--color-border);
  border-radius: 1px;
  width: 4px;
}

.health-bars i:nth-child(1) { height: 25%; }
.health-bars i:nth-child(2) { height: 50%; }
.health-bars i:nth-child(3) { height: 75%; }
.health-bars i:nth-child(4) { height: 100%; }

.health-bars[data-level="1"] i:nth-child(-n+1),
.health-bars[data-level="2"] i:nth-child(-n+2),
.health-bars[data-level="3"] i:nth-child(-n+3),
.health-bars[data-level="4"] i {
  background: var(--color-text);
}

.health-section h2 {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 1.6rem 0 0.5rem;
  text-transform: uppercase;
}

.health-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
}

.health-chart {
  display: grid;
  font-size: 0.75rem;
  gap: 0.2rem 0.5rem;
  grid-template-columns: 2.2rem 1fr;
}

.health-chart-scale {
  color: var(--color-muted);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
}

.health-chart-plot {
  background: var(--color-surface);
  border-radius: var(--radius);
  height: 110px;
  position: relative;
  touch-action: pan-y;
}

.health-chart-plot svg {
  display: block;
  height: 100%;
  width: 100%;
}

.health-chart-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-linejoin: round;
  stroke-width: 2;
}

.health-chart-span {
  fill: var(--color-selected);
  opacity: 0.18;
}

.health-chart-cursor {
  border-left: 1px solid var(--color-muted);
  bottom: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
}

.health-chart-tip {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  pointer-events: none;
  position: absolute;
  top: 0.3rem;
  transform: translateX(-50%);
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}

.health-chart-cursor[hidden],
.health-chart-tip[hidden] {
  display: none;
}

.health-chart-time {
  color: var(--color-muted);
  display: flex;
  font-variant-numeric: tabular-nums;
  grid-column: 2;
  justify-content: space-between;
}

.health-summary {
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.85rem;
  gap: 0.3rem 1rem;
  margin: 0.3rem 0 0;
}

.health-legend {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
}

.health-legend-span {
  background: var(--color-selected);
  border-radius: 2px;
  height: 0.7rem;
  opacity: 0.5;
  width: 0.7rem;
}

.health-raw {
  color: var(--color-muted);
  margin-left: 0.3rem;
}

.health-byte code {
  font-size: 1.05rem;
  margin-right: 0.6rem;
}

.health-bits {
  border-collapse: collapse;
  font-size: 0.9rem;
  width: 100%;
}

.health-bits td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.4rem 0.5rem 0.4rem 0;
}

.health-bits td:first-child {
  color: var(--color-muted);
  width: 3rem;
}

.copy-field {
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: grid;
  gap: 0.2rem 0.6rem;
  grid-template-columns: 1fr auto;
  padding: 0.5rem 0.7rem;
}

.copy-field-label {
  color: var(--color-muted);
  font-size: 0.85em;
  grid-column: 1 / -1;
}

.copy-field code {
  overflow-wrap: anywhere;
}

/* The install guide (app_installs/show): an iPhone/Android switch, then the steps for the chosen
   phone. The app-install controller swaps the panel shown. */

.app-install-switch {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  display: flex;
  margin: var(--space) 0;
  padding: 4px;
}

.app-install-switch-option {
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--color-muted);
  flex: 1;
  font: inherit;
  font-weight: 600;
  min-height: 48px;
}

.app-install-switch-option[aria-pressed="true"] {
  background: var(--color-border);
  color: var(--color-text);
}

.app-install-steps {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  line-height: 1.5;
  padding-left: 1.4rem;
}

.app-install-label {
  color: var(--color-accent);
  font-weight: 600;
}

.app-install-glyph {
  color: var(--color-accent);
  fill: none;
  height: 1.2em;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vertical-align: -0.25em;
  width: 1.2em;
}

.app-install-done {
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
  border-radius: var(--radius);
  padding: 0.8rem var(--space);
}

.app-install-done strong {
  color: var(--color-success);
}

/* The menu's install link, for when the app runs installed but its session wasn't opened from the
   home screen icon (an app installed before the start_url said so). */
@media (display-mode: standalone) {
  .menu-item-install {
    display: none;
  }
}

/* Navigation (shared/_navigation): the desktop pills at the top, the phone tab bar at the bottom,
   the menu, and the desktop modal pages open in. */

.top-nav {
  display: flex;
  justify-content: space-between;
  left: var(--space);
  pointer-events: none;
  position: fixed;
  right: var(--space);
  top: var(--space);
  z-index: 1100; /* over Leaflet's controls (1000) */
}

.nav-pill {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  align-items: center;
  background: var(--color-hud);
  border-radius: 999px;
  box-shadow: 0 10px 32px rgb(0 0 0 / 45%), 0 2px 8px rgb(0 0 0 / 30%);
  display: flex;
  gap: 2px;
  height: var(--nav-pill-height);
  padding: 6px;
  pointer-events: auto;
}

.nav-brand {
  padding: 0 1.1rem;
}

.nav-brand img {
  height: 1.5rem;
}

.nav-item {
  align-items: center;
  background: none;
  border-radius: 999px;
  color: var(--color-hud-muted);
  display: flex;
  font-size: 0.9rem;
  font-weight: 500;
  gap: 7px;
  height: 100%;
  padding: 0 14px;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgb(255 255 255 / 8%);
  color: white;
}

.nav-item.active {
  background: color-mix(in srgb, var(--color-accent) 28%, transparent);
  color: white;
}

.nav-item svg,
.tab-bar-item svg {
  fill: none;
  flex-shrink: 0;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 20px;
}

.nav-item.active svg,
.tab-bar-item.active svg {
  color: color-mix(in srgb, var(--color-accent) 55%, white);
}

/* Pages clear the pills. */
body:has(.top-nav) .setup {
  padding-top: calc(var(--space) + var(--nav-pill-height) + var(--space));
}

.modal {
  background: var(--color-bg);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgb(0 0 0 / 60%);
  color: var(--color-text);
  max-height: calc(100vh - 2 * (var(--nav-pill-height) + var(--space)));
  padding: 0;
  width: min(40rem, calc(100vw - 2 * var(--space)));
}

.modal[open] {
  animation: modal-in 0.18s ease-out;
}

.modal::backdrop {
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  background: rgb(0 0 0 / 45%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* Inside the modal, the pills are behind the backdrop and closing it is the way back to the map. */
body:has(.top-nav) .modal .setup {
  padding-top: var(--space);
}

.modal .back-link[href="/"],
.modal .back-link[href^="/?"] {
  display: none;
}

.modal-close {
  background: var(--color-surface);
  border-radius: 50%;
  color: var(--color-muted);
  display: grid;
  float: right;
  height: 36px;
  margin: 12px 12px 0 0;
  padding: 0;
  place-items: center;
  position: sticky;
  top: 12px;
  width: 36px;
  z-index: 1;
}

.modal-close svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
  width: 18px;
}

@media (max-width: 640px) {
  .top-nav {
    display: none;
  }

  body:has(.top-nav) .setup {
    padding-top: max(var(--space), var(--safe-top));
  }
}

/* Phone tab bar and the menu sheet */

.tab-bar {
  display: none;
}

@media (max-width: 640px) {
  .tab-bar {
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    background: rgb(28 28 28 / 68%);
    border-radius: 999px;
    bottom: var(--tab-bar-bottom);
    box-shadow: 0 10px 32px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 35%);
    display: flex;
    height: var(--tab-bar-height);
    left: var(--tab-bar-inset);
    padding: 6px 8px;
    position: fixed;
    right: var(--tab-bar-inset);
    z-index: 1100; /* over Leaflet's controls (1000) */
  }

  /* Pages scroll clear of the pill, and it replaces their way back to the map. */
  .setup {
    padding-bottom: calc(var(--tab-bar-space) + var(--space));
    padding-top: max(var(--space), var(--safe-top));
  }

  .back-link {
    display: none;
  }
}

/* Each item is a capsule, so the active fill wraps both icon and label. */
.tab-bar-item {
  align-items: center;
  background: transparent;
  border-radius: 18px;
  color: var(--color-hud-muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  transition: background-color 0.15s;
}

.tab-bar-item:active {
  transform: scale(0.95);
}

.tab-bar-item.active {
  background: color-mix(in srgb, var(--color-accent) 24%, transparent);
  color: white;
}

.tab-bar-item svg {
  height: 23px;
  width: 23px;
}

.tab-bar-label {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.menu-sheet {
  background: var(--color-surface);
  border: 0;
  border-radius: 20px 20px 0 0;
  color: var(--color-text);
  margin: auto 0 0;
  max-width: none;
  padding: 0;
  width: 100%;
}

.menu-sheet[open] {
  animation: menu-sheet-up 0.2s ease-out;
}

.menu-sheet::backdrop {
  background: rgb(0 0 0 / 50%);
}

@media (min-width: 641px) {
  .menu-sheet {
    border-radius: 16px;
    box-shadow: 0 24px 64px rgb(0 0 0 / 60%);
    margin: calc(var(--space) + var(--nav-pill-height) + 0.5rem) var(--space) auto auto;
    width: 18rem;
  }

  .menu-sheet[open] {
    animation: modal-in 0.15s ease-out;
  }

  .menu-sheet::backdrop {
    background: rgb(0 0 0 / 25%);
  }
}

@keyframes menu-sheet-up {
  from { transform: translateY(100%); }
}

.menu-sheet-panel {
  padding: 0.5rem var(--space) calc(var(--space) + var(--safe-bottom));
}

.menu-sheet-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.menu-sheet-header h2 {
  font-size: 1.1rem;
  margin: 0.5rem 0;
}

.menu-sheet-items {
  display: grid;
}

.menu-item-form {
  display: contents;
}

.menu-item {
  background: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  color: var(--color-text);
  padding: 0.9rem 0;
  text-align: left;
  text-decoration: none;
}

.menu-item:last-child,
.menu-item-form:last-child .menu-item {
  border-bottom: 0;
}

.menu-item-danger {
  color: var(--color-danger);
}

/* Admin */

.admin-header {
  align-items: center;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  padding: 0.8rem var(--space);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
}

.admin-exit {
  margin-left: auto;
}

.admin-main {
  margin: 0 auto;
  max-width: 72rem;
  padding: var(--space);
}

.admin-heading {
  align-items: center;
  display: flex;
  gap: var(--space);
  justify-content: space-between;
}

.admin-inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.admin-inline-form input[type="text"] {
  flex: 1;
  font-family: ui-monospace, monospace;
  max-width: 24rem;
}

.admin-table {
  border-collapse: collapse;
  margin-bottom: 2rem;
  width: 100%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.admin-table th {
  color: var(--color-muted);
  font-weight: 500;
}

.admin-details {
  display: grid;
  gap: 0.3rem var(--space);
  grid-template-columns: max-content 1fr;
}

.admin-details dt {
  color: var(--color-muted);
}

.admin-details dd {
  margin: 0;
}

.admin-form {
  max-width: 28rem;
}

.checkbox {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.button-danger {
  margin-top: 2rem;
}

/* Ask: questions as wide buttons, and a row to ask about a day */

.question-form {
  align-items: center;
  background: var(--color-surface);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
}

/* People: safety contacts */

.contacts {
  display: grid;
  gap: 0.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.contact {
  background: var(--color-surface);
  border-radius: 12px;
  color: var(--color-text);
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
}

.contact span {
  color: var(--color-muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* A safety contact on a share's page, with buttons to send them the link. */
.contact-send-buttons {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr;
  margin-top: 0.5rem;
}

.contact-send-buttons form,
.contact-send-buttons .btn {
  width: 100%;
}

.contact-send-buttons .btn {
  min-height: 40px;
  padding: 8px 12px;
}

.contact-send-buttons .btn:not(.action) {
  background: var(--color-bg);
}

/* A safety contact: their name after a person icon. */
.contact.person {
  align-items: center;
  display: flex;
  gap: 0.8rem;
}

.contact.person svg {
  color: var(--color-muted);
  fill: none;
  flex-shrink: 0;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

/* A safety contact's email and phone, partly hidden, on their page. */
.contact-details {
  display: grid;
  gap: 0.2rem 1rem;
  grid-template-columns: auto 1fr;
  margin: 0;
}

.contact-details dt {
  color: var(--color-muted);
}

.contact-details dd {
  font-variant-numeric: tabular-nums;
  margin: 0;
  overflow-wrap: anywhere;
}

/* People: location shares */

.share-link {
  align-items: center;
  background: var(--color-surface);
  border-radius: 12px;
  display: flex;
  gap: 0.6rem;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
}

.share-link code {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* What anyone with a share link sees: the dashboard's map and car panel, with no tab bar under them. */

.live-share-risk {
  border-radius: var(--radius);
  font-weight: 600;
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
}

.live-share-risk.concern {
  background: color-mix(in srgb, #f5a524 45%, transparent);
}

.live-share-risk.emergency {
  background: var(--color-danger);
}

.live-share-note {
  border-left: 3px solid var(--color-hud-muted);
  margin: 0.6rem 0 0;
  padding-left: 0.7rem;
}

@media (max-width: 640px) {
  .live-share {
    bottom: max(var(--space), var(--safe-bottom));
  }

  .dashboard:has(.live-share) .map .leaflet-bottom {
    bottom: 0;
  }
}

/* A safety contact's page: cards of rows that each switch something for the contact, like an alert or a car's
   location. The whole row is the switch; an alert's name and its "?" sit before it. */
.toggle-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  list-style: none;
  margin: 0 0 1rem;
  overflow: hidden;
  padding: 0;
}

.toggle-card li {
  align-items: center;
  display: flex;
}

.toggle-card li + li {
  border-top: 1px solid var(--color-border);
}

.toggle-card form {
  flex: 1;
}

.toggle-card li > .toggle-row-name {
  flex: none;
  padding-left: 1rem;
}

.toggle-card li > [data-controller="dialog"] {
  margin-left: 0.5rem;
}

.toggle-row {
  align-items: center;
  background: none;
  border: 0;
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 0.75rem;
  justify-content: flex-end;
  min-height: 3.2rem;
  padding: 0.75rem 1rem;
  text-align: left;
  width: 100%;
}

.toggle-row-name {
  flex: 1;
  font-weight: 600;
}

.toggle-row-state {
  color: var(--color-success);
  font-size: 0.9rem;
}

.switch {
  background: var(--color-border);
  border-radius: 999px;
  flex: none;
  height: 26px;
  position: relative;
  transition: background 0.15s;
  width: 44px;
}

.switch::after {
  background: white;
  border-radius: 50%;
  content: "";
  height: 20px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 0.15s;
  width: 20px;
}

[aria-checked="true"] > .switch {
  background: var(--color-success);
}

[aria-checked="true"] > .switch::after {
  transform: translateX(18px);
}

.contact-pick {
  align-items: center;
  display: flex;
  gap: 0.6rem;
}

.contact-pick span {
  color: var(--color-muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.live-share-stops {
  display: grid;
  font-size: 0.9rem;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  max-height: 30vh;
  overflow-y: auto;
  padding: 0;
}

.live-share-stops li {
  display: grid;
}

.live-share-privacy {
  color: var(--color-hud-muted);
  font-size: 0.8rem;
  margin: 0.6rem 0 0;
}

/* Day map: the day's stops and drives on a map that stays on top while their list scrolls under it */

.day-map-canvas {
  height: 42vh;
  position: sticky;
  top: 0;
  /* Above the list: the selected badge's transform would otherwise paint it over the map. */
  z-index: 1;
}

.day-map-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.day-map-header h1 {
  margin: 0;
}

.day-map-header .icon-link {
  font-size: 1.8rem;
  min-width: 2rem;
  text-align: center;
  text-decoration: none;
}

.day-segments {
  list-style: none;
  margin: var(--space) 0 0;
  padding: 0;
}

.day-segment {
  align-items: center;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 28px 1fr auto;
  padding: 0.5rem 0.6rem;
}

.day-segment-place-link {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.day-segment > div {
  display: grid;
  gap: 0.15rem;
}

.day-segment time {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.day-segment-drive span {
  color: var(--color-muted);
}

.day-segment.selected {
  background: var(--color-surface);
}

/* A stop's number, the same on the map and in the list; a drive's line between them. The selected one is
   orange in both. */
.leaflet-marker-icon.day-stop-icon {
  background: none;
  border: 0;
}

.day-stop-marker,
.day-segment-stop .day-segment-marker {
  align-items: center;
  background: white;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgb(0 0 0 / 35%);
  color: #1a5fd0;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  transition: transform 0.15s;
  width: 28px;
}

.day-segment-drive .day-segment-marker {
  align-self: stretch;
  background: var(--color-accent);
  border-radius: 2px;
  justify-self: center;
  margin: -0.5rem 0;
  width: 4px;
}

.day-stop-icon.selected .day-stop-marker,
.day-segment-stop.selected .day-segment-marker {
  background: var(--color-selected);
  border-color: white;
  color: #111;
  transform: scale(1.2);
}

.day-segment-drive.selected .day-segment-marker {
  background: var(--color-selected);
}

/* Room to scroll the last segments up under the map. */
.day-map-list {
  padding-bottom: 50vh;
}

/* What's new: a popup with what changed since the user last looked */

.whats-new {
  background: var(--color-surface);
  border: 0;
  border-radius: 20px;
  color: var(--color-text);
  max-height: 80vh;
  max-width: min(28rem, calc(100vw - 2 * var(--space)));
  padding: var(--space);
}

.whats-new::backdrop {
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  background: rgb(0 0 0 / 50%);
}

.whats-new h2 {
  margin: 0 0 0.6rem;
}

.whats-new-entries {
  margin-bottom: var(--space);
  max-height: 55vh;
  overflow-y: auto;
}

.whats-new-entry h3 {
  font-size: 1rem;
  margin: 0.8rem 0 0.2rem;
}

.whats-new-entry p {
  color: var(--color-muted);
  margin: 0;
}

/* Now: a live share someone who trusts the user pushed to them, above the car. */
.contact-alert {
  background: color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-radius: 12px;
  color: white;
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
}

.contact-alert.emergency {
  background: var(--color-danger);
}

.contact-alert span {
  font-size: 0.9rem;
  opacity: 0.9;
}

.live-share-steps-title {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}

.live-share-steps {
  margin: 0;
  padding-left: 1.2rem;
}

/* Places: the map on the name form, with a pin to drag where the place is. */
.place-pin-canvas {
  border-radius: 12px;
  height: 220px;
  margin-top: 0.4rem;
}

.leaflet-marker-icon.place-pin-icon {
  background: none;
  border: 0;
}

.place-pin-marker {
  background: var(--color-selected);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 6px rgb(0 0 0 / 40%);
  display: block;
  height: 100%;
  width: 100%;
}

/* Ask: a spot the car keeps stopping at, to name. */
.place-suggestion {
  background: var(--color-surface);
  border-radius: 12px;
  margin-bottom: var(--space);
  padding: 0.9rem 1rem;
}

.place-suggestion p {
  margin: 0 0 0.7rem;
}

/* Now: the one card asking for something, at the top of the car panel. */
.now-card {
  border-bottom: 1px solid rgb(255 255 255 / 15%);
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
}

.now-card p {
  font-weight: 400;
  margin: 0 0 0.6rem;
}

.now-card-buttons {
  display: flex;
  gap: 0.5rem;
}

.now-card-buttons form {
  display: contents;
}

.now-card-buttons .btn {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
}

.now-card-buttons .btn:not(.action) {
  background: rgb(255 255 255 / 12%);
  color: white;
}

.pin-map-fields {
  display: contents;
}

/* Zonas de risco: levels in their colors, faint when they're a default rather than the account's choice. */
.level {
  --level-color: var(--color-success);
  border: 1px solid var(--level-color);
  border-radius: 999px;
  color: var(--level-color);
  font-size: 0.85rem;
  padding: 0.05rem 0.55rem;
  white-space: nowrap;
}

.level-risk { --level-color: #f5d90a; }
.level-high-risk { --level-color: #f5a524; }
.level-extreme-risk { --level-color: var(--color-danger); }

.level-default {
  border-style: dashed;
  opacity: 0.7;
}

.checkbox small {
  color: var(--color-muted);
  display: block;
  font-size: 0.85rem;
}

.risk-section {
  margin-top: 2rem;
}

.section-header {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}

.level-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.level-buttons form {
  display: contents;
}

.level-buttons .btn {
  border: 1px solid var(--level-color);
  color: var(--level-color);
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

.level-buttons .level-normal { --level-color: var(--color-success); }

.level-fields {
  border: 0;
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
}

.help-button {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  cursor: pointer;
  font-weight: 600;
  height: 1.8rem;
  line-height: 1;
  padding: 0;
  width: 1.8rem;
}

.levels-help {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  max-width: min(28rem, calc(100vw - 32px));
  padding: 1.2rem;
}

.levels-help::backdrop {
  background: rgb(0 0 0 / 60%);
}

.levels-help dd {
  margin: 0.3rem 0 0.9rem;
}

.neighborhood-levels {
  list-style: none;
  margin: 0 0 var(--space);
  padding: 0;
}

.neighborhood-levels a {
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.6rem 0;
  text-decoration: none;
}

.link-button {
  background: none;
  border: 0;
  color: var(--color-accent);
  cursor: pointer;
  font: inherit;
  margin-top: var(--space);
  padding: 0;
  text-decoration: underline;
}

/* Now: the user's live links for the car, and why each one exists. */
.live-link {
  background: color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-radius: 12px;
  color: white;
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
}

/* Now: the risky place the car is in, edged in its level's color, and what happens next there. */
.zone-status {
  border: 1px solid var(--level-color);
  border-radius: 12px;
  color: white;
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
}

.zone-status .level {
  margin-left: 0.3rem;
}

.zone-status > span {
  font-size: 0.9rem;
  opacity: 0.9;
}

.live-link.concern { background: color-mix(in srgb, var(--color-selected) 45%, transparent); }
.live-link.emergency { background: var(--color-danger); }

.live-link span {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Now: zone mode's toggle under the vehicle switcher, its overlay's markers and tooltip, and the button that
   leaves it, floating over the car panel. */
.hud-top:has(.zone-toggle) {
  align-items: start;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
}

.zone-toggle {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  align-items: center;
  background: var(--color-hud);
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-weight: 600;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
}

.zone-toggle svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.zone-toggle.on {
  background: var(--color-accent);
}

.zone-toggle.pending:not(.on) {
  animation: zone-toggle-shine 2.4s ease-in-out infinite;
}

.zone-toggle .badge {
  background: var(--color-selected);
  border-radius: 999px;
  color: black;
  font-size: 0.8rem;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  text-align: center;
}

.zone-toggle .badge[hidden] {
  display: none;
}

@keyframes zone-toggle-shine {
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-selected) 45%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .zone-toggle.pending:not(.on) {
    animation: none;
  }
}

.leaflet-div-icon.zone-pending {
  background: var(--color-accent);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgb(0 0 0 / 40%);
  color: white;
  display: grid;
  font-weight: 700;
  place-items: center;
}

.zone-tooltip {
  display: grid;
  gap: 0.3rem;
  min-width: 220px;
}

.zone-tooltip > strong {
  font-size: 1.05rem;
  padding-right: 1.2rem;
}

.zone-tooltip > span {
  color: var(--color-hud-muted);
}

.zone-tooltip .btn[aria-pressed="true"] {
  background: var(--level-color);
  color: black;
}

/* The car panel, with zone mode's exit button above it. */
.hud-side-stack {
  display: grid;
  gap: 0.6rem;
  max-width: 340px;
  position: absolute;
  right: var(--space);
  top: 5rem;
  z-index: 1;
}

.hud-side-stack .hud-side {
  max-width: none;
  position: relative;
  top: auto;
  right: auto;
}

/* Brings the map back to the car: under the panel here, above it on a phone (like map apps). */
.recenter {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 35%);
  color: white;
  cursor: pointer;
  display: grid;
  height: 48px;
  justify-self: end;
  order: 1;
  padding: 0;
  place-items: center;
  width: 48px;
}

.recenter svg {
  fill: none;
  height: 24px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
  width: 24px;
}

.recenter:active {
  transform: scale(0.95);
}

.zone-exit {
  align-items: center;
  display: flex;
  gap: 0.6rem;
}

.zone-exit .btn {
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%);
}

.zone-exit .help-button {
  flex: none;
  height: 2.6rem;
  width: 2.6rem;
}

@media (max-width: 640px) {
  .hud-side-stack {
    bottom: calc(var(--tab-bar-space) + 1.75rem);
    left: var(--space);
    max-width: none;
    top: auto;
  }

  .hud-side-stack .hud-side {
    bottom: auto;
    left: auto;
  }

  .recenter {
    order: -1;
  }

  /* The map needs the room more than the car's buttons do, except the red alert. */
  .zone-mode .hud-actions,
  .zone-mode .vehicle-coordinates {
    display: none;
  }
}

/* Zone mode's paint tool: its button by the toggle, and the levels to paint with under them. */
.zone-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  grid-column: 1 / -1;
}

button.zone-toggle {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.paint-panel {
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  background: var(--color-hud);
  border-radius: 16px;
  color: white;
  display: grid;
  gap: 0.5rem;
  grid-column: 1 / -1;
  max-width: 340px;
  padding: 0.8rem 0.9rem;
}

.paint-panel[hidden] {
  display: none;
}

.paint-panel p {
  color: var(--color-hud-muted);
  font-size: 0.9rem;
  font-weight: 400;
  margin: 0;
}

.paint-panel .btn[aria-pressed="true"] {
  background: var(--level-color);
  color: black;
}

.paint-actions {
  display: flex;
  gap: 0.5rem;
}

.paint-actions .btn {
  flex: 1;
}

.leaflet-container.painting,
.leaflet-container.painting .leaflet-interactive {
  cursor: crosshair;
}

.admin-pager {
  align-items: center;
  display: flex;
  gap: var(--space);
  justify-content: center;
  margin-block: 0.6rem 1.2rem;
}
