:root {
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #1b2531;
  --txt: #e8eef5;
  --muted: #8294a8;
  --go: #18a558;
  --stop: #d23c3c;
  --warn: #f5a623;
  --accent: #2d9cdb;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 480px; margin: 0 auto; padding: 14px 16px 28px; }

.bar { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 24px; margin: 6px 0 14px; letter-spacing: .5px; }
h1 span { color: var(--accent); }

.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.badge-idle { background: #2a3340; color: var(--muted); }
.badge-live { background: #103a25; color: #4fd18b; }
.badge-err  { background: #3a1414; color: #ff8b8b; }

/* Destination bar */
.routebar { display: flex; gap: 8px; margin: 4px 0 6px; position: relative; z-index: 1000; }
.ac { position: relative; flex: 1; min-width: 0; }
.routebar input {
  width: 100%; padding: 13px 14px; border-radius: 10px;
  border: 1px solid #2a3340; background: var(--panel-2); color: var(--txt); font-size: 15px;
}
.routebar input::placeholder { color: #5d6b7c; }

/* Autocomplete dropdown */
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  list-style: none; margin: 0; padding: 4px;
  background: var(--panel-2); border: 1px solid #2a3340; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 1500; max-height: 260px; overflow-y: auto;
}
.suggest li {
  padding: 10px 12px; border-radius: 7px; font-size: 14px; cursor: pointer;
  color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest li:hover, .suggest li.active { background: #243140; }
.suggest li small { display: block; color: var(--muted); font-size: 12px; }
.btn-route { flex: 0 0 auto; padding: 13px 16px; background: var(--warn); color: #1a1206; }
.hint { font-size: 12px; color: var(--muted); margin: 0 2px 8px; }
.hint em { color: #aab8c8; font-style: normal; font-weight: 600; }
.dest-div { font-size: 26px; line-height: 32px; text-align: center; }

/* Map */
#map {
  height: 300px; width: 100%; border-radius: 14px; margin: 4px 0 12px;
  background: #0e1620; z-index: 0;
}
.leaflet-container { background: #0e1620; font: inherit; }
.car-arrow {
  font-size: 24px; line-height: 30px; text-align: center; color: #18a558;
  text-shadow: 0 0 4px #000, 0 0 8px #000; transition: transform .2s linear;
}
.bend-div { font-size: 26px; line-height: 32px; text-align: center; filter: drop-shadow(0 0 3px #000); }
.junction-div { font-size: 20px; line-height: 32px; text-align: center; color: #2d9cdb; filter: drop-shadow(0 0 3px #000); }
.locate-btn, .locate-btn:hover {
  font-size: 20px; font-weight: 700; color: var(--accent);
  background: var(--panel-2); border-bottom: none;
}
.locate-btn:hover { background: #243140; }

/* Status bar (under the map) */
.status {
  display: flex; align-items: baseline; gap: 8px;
  border-radius: 10px; padding: 7px 12px; margin-bottom: 8px;
  transition: background .2s;
}
.status #discMain { font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.status #discSub  { font-size: 13px; color: rgba(255,255,255,.85); }
.status-idle  { background: #1d2733; }
.status-clear { background: #14512f; }
.status-warn  { background: #1e5a86; }   /* junction — calm, steady (no pulse) */
.status-alert {
  background: #f5a623; animation: pulse .5s ease-in-out infinite alternate;
}
.status-alert #discMain, .status-alert #discSub { color: #1a1206; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.25); } }

.controls { display: flex; gap: 8px; margin-bottom: 8px; }
.btn { flex: 1; border: 0; border-radius: 10px; padding: 11px; font-size: 15px; font-weight: 700; color: #fff; cursor: pointer; }
.btn-go { background: var(--go); }
.btn-stop { background: var(--stop); }
.btn-ghost { flex: 0 0 auto; background: var(--panel-2); color: var(--txt); }
.btn-sim { width: 100%; background: var(--accent); margin-bottom: 10px; padding: 9px; font-size: 14px; }
.btn:active { transform: translateY(1px); }

.panel { background: var(--panel); border-radius: 12px; padding: 4px 14px; margin-bottom: 16px; }
.panel summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.setting { padding: 8px 0; border-top: 1px solid #1f2a36; }
.setting:first-of-type { border-top: 0; }
.setting label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.setting input[type=range] { width: 78%; vertical-align: middle; }
.setting output { font-weight: 700; margin-left: 8px; }
.setting select { width: 100%; padding: 10px; border-radius: 8px; background: var(--panel-2); color: var(--txt); border: 1px solid #2a3340; }
.setting-row { display: flex; align-items: center; justify-content: space-between; }
.setting-row label { margin: 0; }

.log h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.log ul { list-style: none; padding: 0; margin: 0; max-height: 180px; overflow-y: auto; }
.log li { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #151d27; color: var(--muted); }
.log li b { color: var(--txt); }
.log li.alert b { color: var(--warn); }

.foot { margin-top: 20px; font-size: 11px; color: #4d5b6b; text-align: center; line-height: 1.5; }
