:root {
  --bg: #f4f5f7; --surface: #ffffff; --text: #14161a; --muted: #565c66;
  --accent: #0a6cdc; --accent-fg: #ffffff; --border: #d9dce1; --warn: #8a4b00; --warn-bg: #fff1d6; --ok: #11663a; --ok-bg: #e3f6ea; --ok-border: #8fd3a8;
  --shadow: 0 4px 24px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --surface: #1c1f26; --text: #f2f4f7; --muted: #aab0bb;
    --accent: #4da3ff; --accent-fg: #06121f; --border: #343944; --warn: #ffd28a; --warn-bg: #3a2c10; --ok: #8be0ad; --ok-bg: #12301f; --ok-border: #2f6b48;
    --shadow: 0 4px 24px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; }
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  margin: 0 auto; max-width: 560px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
}
@media (min-width: 600px) { .panel { bottom: 16px; border-radius: 18px; padding-bottom: 16px; } }
.panel h1 { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: .95rem; min-height: 1.3em; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 12px 0 0; }
.stats > div { min-width: 0; }
.stats dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stats dd { margin: 0; font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.sub.warn { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.panel.arrived { background: var(--ok-bg); box-shadow: var(--shadow), inset 0 3px 0 var(--ok-border); }
.panel.arrived h1 { color: var(--ok); }
.panel.arrived h1::before { content: "\2713\00a0"; }
.panel.arrived #dest { color: var(--ok); }
.directions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--accent);
  font-weight: 600; font-size: .95rem; text-decoration: none; }
.panel.arrived .btn { border-color: var(--ok-border); background: transparent; color: var(--ok); }
.btn:active { opacity: .7; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.approx { margin: 10px 0 0; color: var(--muted); font-size: .8rem; }
.fab {
  position: fixed; z-index: 6; right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--panel-h, 150px) + 16px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 22px; background: var(--accent); color: var(--accent-fg);
  font: 600 .95rem inherit; font-family: inherit; box-shadow: var(--shadow); cursor: pointer;
}
.fab[hidden] { display: none; }
.fab:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.banner {
  position: fixed; z-index: 7; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 16px; font-size: .9rem; font-weight: 600;
  background: var(--warn-bg); color: var(--warn); box-shadow: var(--shadow);
}
.banner[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0,0,0,.35);
}
.overlay[hidden] { display: none; }
.overlay.passive { position: fixed; inset: auto; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 8px); background: none; pointer-events: none; }
.card { background: var(--surface); border-radius: 18px; padding: 24px; max-width: 360px; text-align: center; box-shadow: var(--shadow); }
.card .icon { font-size: 2.2rem; }
.card h2 { margin: 8px 0 6px; font-size: 1.25rem; }
.card p { margin: 0; color: var(--muted); }
/* when the card is shown over a map with a last-known spot, move it up so the spot stays visible */
.overlay.ended { align-items: flex-start; background: none; pointer-events: none; padding-top: calc(48px + env(safe-area-inset-top)); }

.marker { width: 44px; height: 44px; position: relative; }
.marker .dot { position: absolute; left: 14px; top: 14px; width: 16px; height: 16px; border-radius: 50%;
  background: #0a84ff; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.marker .arrow { position: absolute; inset: 0; transition: transform .6s linear; display: none; }
.marker.has-hdg .arrow { display: block; }
.marker .arrow::before { content: ""; position: absolute; left: 14px; top: -2px; width: 0; height: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 16px solid #0a84ff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.marker.stale .dot { background: #8e8e93; } .marker.stale .arrow::before { border-bottom-color: #8e8e93; }
.dest-pin { font-size: 28px; line-height: 1; transform: translateY(-12px); filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { margin-bottom: var(--panel-h, 150px); }
@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group { background: var(--surface); }
  .maplibregl-ctrl-group button + button { border-top-color: var(--border); }
  .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1); }
  .maplibregl-ctrl-attrib { background: rgba(28,31,38,.8) !important; color: var(--muted) !important; }
  .maplibregl-ctrl-attrib a { color: var(--muted) !important; }
  .maplibregl-ctrl-attrib-button { filter: invert(1); }
}
