/* Layout: Karte füllt den ganzen Bildschirm, alle Infos in einem Bottom-Sheet
   (ab 900 px Breite als schwebendes Panel links). Akzent = Blinker-Gelb. */
:root {
  --bg: #e9ecf0;
  --sheet: #ffffff;
  --ink: #14171c;
  --muted: #5f6874;
  --line: #e2e5ea;
  --soft: #f2f4f7;
  --accent: #f2a20c;
  --accent-ink: #1d1400;
  --accent-soft: #fff3d6;
  --route: #1b2232;
  --casing: #ffffff;
  --you: #2f6fed;
  --ok: #18864b;
  --ok-soft: #e3f5ea;
  --warn: #c2410c;
  --warn-soft: #fdeadd;
  --plate-band: #0b3a9e;
  --plate-bg: #fbfbf7;
  --plate-ink: #111111;
  --shadow: 0 -10px 34px rgba(16, 22, 34, .14);
  --float-shadow: 0 4px 18px rgba(16, 22, 34, .2);
  --f-ui: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-num: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --sheet: #171a20; --ink: #eef1f5; --muted: #9aa3af; --line: #2a2f38; --soft: #1f232a;
    --accent: #f5b02e; --accent-ink: #1d1400; --accent-soft: #3a2c0e;
    --route: #e6ecf7; --casing: #0e1014; --you: #5b8dff;
    --ok: #3ccf7e; --ok-soft: #14301f; --warn: #ff8a4c; --warn-soft: #3a1d10;
    --shadow: 0 -10px 34px rgba(0, 0, 0, .5); --float-shadow: 0 4px 18px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --sheet: #171a20; --ink: #eef1f5; --muted: #9aa3af; --line: #2a2f38; --soft: #1f232a;
  --accent: #f5b02e; --accent-ink: #1d1400; --accent-soft: #3a2c0e;
  --route: #e6ecf7; --casing: #0e1014; --you: #5b8dff;
  --ok: #3ccf7e; --ok-soft: #14301f; --warn: #ff8a4c; --warn-soft: #3a1d10;
  --shadow: 0 -10px 34px rgba(0, 0, 0, .5); --float-shadow: 0 4px 18px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.4 var(--f-ui);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; background: var(--bg); z-index: 0; }

/* ---------- Bottom-Sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 500;
  background: var(--sheet); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  max-height: 64%; overflow-y: auto; overscroll-behavior: contain;
  padding-top: 8px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; flex: none; }
@media (min-width: 900px) {
  .sheet {
    left: 20px; right: auto; bottom: 20px; width: 400px;
    max-height: calc(100% - 40px); border-radius: 22px; box-shadow: var(--float-shadow);
    padding-top: 18px; padding-bottom: 18px;
  }
  .grab { display: none; }
}

/* ---------- Status / Ankunft ---------- */
.status { display: flex; flex-direction: column; gap: 2px; }
.eta-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.eta { font: 600 46px/1 var(--f-num); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.eta small { font-size: 22px; font-weight: 600; letter-spacing: 0; margin-left: 4px; }
.eta-meta { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.headline { margin: 6px 0 0; font-size: 18px; font-weight: 600; text-wrap: balance; }
.progress { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .8s ease; }
.progress.blink span { animation: hazard 1.1s steps(2, jump-none) infinite; }
@keyframes hazard { 0% { opacity: 1; } 100% { opacity: .25; } }

/* ---------- Fahrer-Karte ---------- */
.driver-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--ink); font: 600 22px var(--f-num);
}
.who { min-width: 0; display: flex; flex-direction: column; }
.who strong { font-size: 17px; }
.who span { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Deutsches Kennzeichen: blaues EU-Feld links, schwarzer Rand */
.plate {
  display: inline-flex; align-items: stretch; height: 32px;
  border: 2px solid var(--plate-ink); border-radius: 5px; overflow: hidden;
  background: var(--plate-bg); color: var(--plate-ink);
}
.plate i {
  font-style: normal; width: 17px; background: var(--plate-band); color: #ffffff;
  font: 600 11px/1 var(--f-ui); display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; padding-bottom: 4px; gap: 3px;
}
.plate i::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px dotted #ffd200; }
.plate b { font: 600 20px/28px var(--f-num); letter-spacing: 1.5px; padding: 0 8px; white-space: nowrap; }

/* ---------- Live-Tacho ---------- */
.live {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--soft); border-radius: var(--r); padding: 12px 14px;
}
.speedo { display: flex; align-items: baseline; gap: 6px; }
.speedo .num { font: 600 36px/1 var(--f-num); font-variant-numeric: tabular-nums; min-width: 2ch; }
.speedo .unit { color: var(--muted); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; }
.signal { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ok); text-align: right; }
.signal .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; animation: pulse 1.6s ease-in-out infinite; }
.signal.stale { color: var(--muted); }
.signal.stale .dot { animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- Stopps ---------- */
.stops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; position: relative; }
.stops::before { content: ""; position: absolute; left: 10px; top: 26px; bottom: 26px; width: 2px; background: var(--line); }
.stops.single::before { display: none; }
.stop { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 0; position: relative; }
.stop small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stop .label { display: block; font-weight: 500; overflow-wrap: anywhere; }
.stop .sub { display: block; color: var(--muted); font-size: 13px; }
.pin { width: 12px; height: 12px; justify-self: center; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--ink); }
.stop.dest .pin { background: var(--accent); box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--accent); }
.stop.done .pin { opacity: .35; }

/* ---------- Bedienelemente ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 14px 16px;
  font: 600 16px var(--f-ui); background: var(--soft); color: var(--ink);
  cursor: pointer; width: 100%; text-align: center; text-decoration: none; display: block;
}
.btn.primary { background: var(--ink); color: var(--sheet); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger.armed { background: var(--warn); color: var(--sheet); box-shadow: none; }
.btn.small { padding: 10px 12px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.live-on { background: var(--ok-soft); color: var(--ok); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

h2 { font: 600 26px/1.1 var(--f-num); margin: 0; letter-spacing: .2px; text-wrap: balance; }
.lbl { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 7px; }
input[type="text"], input[type="search"], input[type="password"] {
  width: 100%; min-width: 0; border: 1.5px solid var(--line); background: var(--soft); color: var(--ink);
  border-radius: 12px; padding: 12px; font: 500 16px var(--f-ui);
}
input::placeholder { color: var(--muted); }
.search { display: flex; gap: 8px; }
.search input { flex: 1; }
.search .btn { width: auto; flex: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px;
  padding: 7px 12px; font: 600 13px var(--f-ui); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .sw { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line); }
.results { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 10px 12px; cursor: pointer; }
.results button:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.results strong { display: block; font-weight: 600; }
.results small, .results .empty { color: var(--muted); font-size: 13px; display: block; overflow-wrap: anywhere; }
.results .empty { padding: 10px 12px; }
.chosen { display: flex; align-items: center; gap: 10px; background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.chosen .label { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.chosen .btn { width: auto; flex: none; }
.notice { border-radius: 12px; padding: 11px 12px; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.muted { background: var(--soft); color: var(--muted); }
.linkbox { display: flex; flex-direction: column; gap: 8px; border: 1.5px dashed var(--line); border-radius: 14px; padding: 12px; }
.linkbox input { font-size: 14px; }
details { border-top: 1px solid var(--line); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; color: var(--muted); }
details[open] summary { margin-bottom: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Karte: Marker ---------- */
.bgd-icon { background: none; border: 0; }
.car { position: relative; width: 64px; height: 64px; }
.car .rot { position: absolute; left: 50%; top: 50%; width: 28px; height: 50px; margin: -25px 0 0 -14px; will-change: transform; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35)); }
.car .rot svg { width: 100%; height: 100%; display: block; }
.car .chip-speed {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, -4px);
  background: var(--ink); color: var(--sheet); font: 600 13px/1 var(--f-num);
  padding: 4px 8px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums;
  letter-spacing: .02em; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.pinmark { width: 24px; height: 24px; border-radius: 7px; background: var(--ink); display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); border: 2px solid var(--sheet); }
.pinmark::after { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--sheet); }
.pinmark.dest { background: var(--accent); }
.pinmark.dest::after { background: var(--accent-ink); }
.pinmark.draft { opacity: .75; }
.you { width: 20px; height: 20px; border-radius: 50%; background: var(--you); border: 3px solid #ffffff; box-shadow: 0 0 0 6px rgba(47, 111, 237, .22), 0 2px 6px rgba(0, 0, 0, .3); }
.leaflet-tooltip.tag {
  background: var(--sheet); color: var(--ink); border: 0; border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2); font: 600 12px var(--f-ui); padding: 4px 8px;
}
.leaflet-tooltip.tag::before { border-top-color: var(--sheet); }
.leaflet-container { font-family: var(--f-ui); background: var(--bg); }
.leaflet-control-attribution {
  background: var(--sheet) !important; color: var(--muted) !important; opacity: .85;
  border-radius: 0 0 8px 0; font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-top.leaflet-left { top: env(safe-area-inset-top, 0px); }

/* ---------- Schwebende Knöpfe / Toast ---------- */
.fab {
  position: fixed; z-index: 600;
  right: max(16px, env(safe-area-inset-right, 0px)); top: calc(16px + env(safe-area-inset-top, 0px));
  background: var(--sheet); color: var(--ink); border: 0; border-radius: 999px;
  padding: 10px 16px; font: 600 14px var(--f-ui); box-shadow: var(--float-shadow); cursor: pointer;
}
.toast {
  position: fixed; z-index: 700; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--sheet); padding: 11px 16px; border-radius: 12px;
  font-weight: 600; box-shadow: var(--float-shadow); text-align: center;
}
.gone { padding: 18px 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
