:root {
  --bg: #0c141b;
  --fg: #f5f7f9;
  --card: #101d26;
  --primary: #ffbf00;
  --primary-fg: #101820;
  --secondary: #202d37;
  --muted: #a3afb9;
  --border: #30404b;
  --call: #008b43;
  --marker: #16a05e;
  --warn-bg: #302b15;
  --danger: #e5484d;
  --shadow: 0 6px 20px #00000040;
}
svg { width: 20px; height: 20px; flex-shrink: 0; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Manrope", ui-sans-serif, system-ui, sans-serif;
  background: var(--bg); color: var(--fg);
  overscroll-behavior: none;
}
#app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font-family: inherit; font-size: 16px; color: var(--fg);
  background: var(--secondary); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--primary); }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 14px 16px 90px; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 6px; flex-shrink: 0; }
.topbar h1 { font-size: 20px; font-weight: 800; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--border); color: var(--fg); flex-shrink: 0;
}
.iconbtn svg { width: 20px; height: 20px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--primary); color: var(--primary-fg);
  font-size: 17px; font-weight: 800; border-radius: 14px; padding: 16px;
  width: 100%; text-align: center;
}
.btn svg { width: 22px; height: 22px; }
.btn.secondary { background: var(--secondary); color: var(--fg); border: 1px solid var(--border); font-weight: 700; }
.btn.danger { background: var(--secondary); color: var(--danger); border: 1px solid var(--border); }
.btn.small { padding: 10px 12px; font-size: 14px; border-radius: 10px; width: auto; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  text-align: left; min-height: 84px;
}
.tile svg { width: 22px; height: 22px; color: var(--primary); }
.tile b { font-size: 14px; font-weight: 800; }
.tile span { font-size: 11px; color: var(--muted); font-weight: 600; }

.bottomnav {
  flex-shrink: 0; display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px; font-size: 11px; font-weight: 700; color: var(--muted);
}
.bottomnav button.active { color: var(--primary); }
.bottomnav svg { width: 22px; height: 22px; }

.routecard { display: flex; align-items: center; gap: 12px; }
.routecard .bus { width: 44px; height: 44px; border-radius: 12px; background: var(--secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.routecard .bus svg { width: 24px; height: 24px; color: var(--primary); }
.routecard .info { flex: 1; min-width: 0; }
.routecard .info b { font-size: 16px; display: block; }
.routecard .info span { font-size: 12px; color: var(--muted); font-weight: 600; }
.chip { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 20px; background: var(--secondary); color: var(--muted); border: 1px solid var(--border); }
.chip.ok { color: var(--marker); border-color: var(--marker); }
.chip.warn { color: var(--primary); border-color: var(--primary); }

.stoprow { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.stopnum { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--marker); display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; font-size: 14px; }
.stoprow .info { flex: 1; min-width: 0; }
.stoprow .info b { display: block; font-size: 15px; }
.stoprow .info span { font-size: 12px; color: var(--muted); display: block; word-break: break-word; }
.stoprow .acts { display: flex; flex-direction: column; gap: 4px; }
.stoprow .acts button { width: 34px; height: 34px; border-radius: 9px; background: var(--secondary); display: flex; align-items: center; justify-content: center; }
.stoprow .acts svg { width: 16px; height: 16px; }

/* ---------- driving mode ---------- */
.drive { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.drive-head { height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-size: 14px; font-weight: 700; }
.drive-head .left { display: flex; align-items: center; gap: 8px; }
.drive-head svg { width: 20px; height: 20px; color: var(--primary); }
.simchip { font-size: 10px; font-weight: 800; background: var(--warn-bg); color: var(--primary); border: 1px solid var(--primary); border-radius: 6px; padding: 2px 6px; }
.mapwrap { position: relative; flex: 1; min-height: 160px; overflow: hidden; }
.mapwrap .map { position: absolute; inset: 0; }
.banner {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 12px; align-items: center;
  background: rgba(16,29,38,.95); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.banner svg { width: 40px; height: 40px; color: var(--primary); flex-shrink: 0; }
.banner .dist { font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1.15; }
.banner .instr { font-size: 15px; font-weight: 700; line-height: 1.25; }
.recenter {
  position: absolute; right: 12px; top: 116px; z-index: 5;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.recenter svg { width: 22px; height: 22px; }
.mapstatus {
  position: absolute; left: 12px; bottom: 10px; z-index: 5; max-width: 75%;
  background: rgba(16,29,38,.95); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.stopcard { margin: 0 12px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); flex-shrink: 0; }
.stopcard .head { background: var(--primary); color: var(--primary-fg); display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-weight: 800; font-size: 14px; }
.stopcard .head svg { width: 18px; height: 18px; }
.stopcard .body { padding: 12px 14px; }
.stopcard .row { display: flex; align-items: center; gap: 12px; }
.stopcard .avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--secondary); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stopcard .avatar svg { width: 26px; height: 26px; color: var(--muted); }
.stopcard .who { flex: 1; min-width: 0; }
.stopcard .who b { font-size: 17px; display: block; word-break: break-word; }
.stopcard .who span { font-size: 13px; display: block; word-break: break-word; }
.stopcard .who .addr { color: var(--muted); font-size: 12px; margin-top: 2px; }
.callbtn { background: var(--call); color: #fff; border-radius: 12px; height: 46px; padding: 0 14px; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; flex-shrink: 0; text-decoration: none; }
.callbtn:hover { filter: brightness(1.12); }
.callbtn svg { width: 18px; height: 18px; }
.corner { margin-top: 10px; background: var(--warn-bg); color: var(--primary); border: 1px solid var(--primary); border-radius: 10px; padding: 9px 10px; font-size: 13px; font-weight: 800; display: flex; gap: 8px; align-items: flex-start; }
.corner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.upnext { flex-shrink: 0; padding: 10px 12px 0; }
.upnext h3 { font-size: 11px; font-weight: 700; color: var(--muted); margin: 0 4px 6px; }
.upnext ol { list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.upnext li button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.upnext li:last-child button { border-bottom: none; }
.upnext .n { width: 28px; height: 28px; border: 2px solid var(--marker); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.upnext .t { flex: 1; min-width: 0; }
.upnext .t b { font-size: 14px; display: block; }
.upnext .t span { font-size: 11px; color: var(--muted); display: block; }
.drive-foot { flex-shrink: 0; display: flex; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.drive-foot .btn { padding: 13px; font-size: 15px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 78dvh;
  background: var(--card); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.drawer .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto; flex-shrink: 0; }
.drawer .dhead { display: flex; align-items: center; gap: 10px; padding: 4px 16px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer .dhead b { flex: 1; font-size: 16px; }
.drawer .dhead span { font-size: 12px; color: var(--muted); }
.drawer .list { overflow-y: auto; padding: 10px 12px; min-height: 0; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 90px; z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 700;
}
.toast button { background: var(--primary); color: var(--primary-fg); border-radius: 8px; padding: 8px 14px; font-weight: 800; font-size: 13px; flex-shrink: 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; font-weight: 600; }
.empty svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: .5; }
.note { font-size: 12px; color: var(--muted); font-weight: 600; line-height: 1.5; }
.hr { height: 1px; background: var(--border); margin: 16px 0; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 700; }
.kv span { color: var(--muted); font-size: 12px; font-weight: 600; }

.stopmarker {
  width: 30px; height: 30px; border-radius: 50%; background: var(--card);
  border: 2px solid var(--marker); color: var(--fg); font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.stopmarker.current { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.stopmarker.done { opacity: .35; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: #4da3ff; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(77,163,255,.35); }
.pinmark { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #0006; display: flex; align-items: center; justify-content: center; }
.pinmark svg { width: 14px; height: 14px; transform: rotate(45deg); color: #fff; }

@media (max-height: 700px) {
  .upnext { display: none; }
  .mapwrap { min-height: 120px; }
  .stopcard .body { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
