:root {
  --bg: #0b1220;
  --bg-2: #151d2e;
  --fg: #f4f1ea;
  --muted: #b7c0d0;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #f4c15d;
  --accent-ink: #1a1408;
  --origin: #3dd68c;
  --dest: #ef6b6b;
  --danger: #ff8a8a;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b1220; color: var(--fg);
  font-family: "Noto Sans", "Segoe UI", "Helvetica Neue", sans-serif; }
#app, #map { position: fixed; inset: 0; }
#map { z-index: 0; }

.maplibregl-ctrl-bottom-left { margin-bottom: 12px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.top {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 3;
  max-width: 520px;
  margin: 0 auto;
}
body.navigating .top { display: none; }

.search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#search {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  padding: 14px 16px;
  min-width: 0;
}
#search::placeholder { color: var(--muted); }
#searchClear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  width: 44px;
  height: 44px;
}

.results {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 45vh;
  overflow: auto;
}
.results li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
}
.results li button:hover,
.results li button:focus { background: var(--bg-2); }
.results .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.results .empty, .results .warn {
  color: var(--muted);
  padding: 12px;
  font-size: 14px;
}

.fab-col {
  position: fixed;
  right: calc(12px + var(--safe-right));
  bottom: calc(210px + var(--safe-bottom));
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.navigating .fab-col { bottom: calc(110px + var(--safe-bottom)); }
.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.fab.active { color: var(--accent); }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 8px 16px calc(16px + var(--safe-bottom));
  max-height: 48vh;
  overflow: auto;
  max-width: 640px;
  margin: 0 auto;
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 4px;
  background: var(--line); margin: 4px auto 10px;
}
.points { display: flex; flex-direction: column; gap: 10px; }
.point { display: flex; gap: 10px; align-items: flex-start; }
.point .k { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.point strong { font-weight: 600; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 8px; flex: none; }
.dot.origin { background: var(--origin); }
.dot.dest { background: var(--dest); }

.eta-row {
  display: flex;
  gap: 16px;
  align-items: baseline;
  margin: 14px 0 10px;
  font-variant-numeric: tabular-nums;
}
#eta, #navEta { font-size: 28px; font-weight: 700; }
#dist, #navRemain { color: var(--muted); font-size: 16px; }

.actions { display: flex; gap: 8px; }
button {
  font: inherit;
  cursor: pointer;
}
.actions button, .pick-menu button, .nav-hud #btnStop, .actions + * {
  border-radius: 12px;
}
#btnStart, #setOrigin, #setDest {
  flex: 1;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 12px 14px;
  font-weight: 700;
}
.ghost, #btnClear, #pickCancel, #btnStop {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 12px 14px;
}
.error { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.maneuvers {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.maneuvers li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.maneuvers .ico {
  width: 28px; flex: none; color: var(--accent); font-size: 18px; text-align: center;
}
.maneuvers .len { color: var(--muted); font-size: 12px; margin-top: 2px; }

.pick-menu {
  position: fixed;
  z-index: 5;
  left: 12px;
  right: 12px;
  bottom: calc(24px + var(--safe-bottom));
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}
.pick-label { margin: 0 0 4px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom));
  z-index: 6;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: min(92vw, 420px);
}

.nav-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: calc(10px + var(--safe-top)) 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}
.maneuver-card, .nav-eta {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.maneuver-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}
.nav-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 700;
}
.maneuver-text p { margin: 0; }
#navDist { font-size: 20px; font-weight: 700; }
#navNext { color: var(--muted); font-size: 15px; margin-top: 2px; }
.nav-eta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 16px;
}

.marker-pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.marker-pin.origin { background: var(--origin); }
.marker-pin.dest { background: var(--dest); }
.puck {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25);
}

[hidden] { display: none !important; }
