:root {
  --bg: #0d1726;
  --panel: rgba(16, 27, 44, 0.94);
  --panel-solid: #101b2c;
  --line: #22324a;
  --text: #eef3fb;
  --muted: #93a4bf;
  --primary: #2f80ff;
  --good: #22c55e;
  --mid: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; }
[hidden] { display: none !important; }

.panel { background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 10px 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Thanh trên ---------- */
#top { position: fixed; top: calc(var(--safe-top) + 10px); left: 10px; right: 10px; padding: 10px; z-index: 5; }
.searchrow { display: flex; gap: 8px; }
#q { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #0a1322;
  color: var(--text); padding: 0 14px; font-size: 16px; outline: none; }
#q:focus { border-color: var(--primary); }
.icon { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #0a1322; font-size: 20px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: #0a1322; white-space: nowrap; }
.chip.accent { border-color: #2a4d86; background: #10284d; }
.results { margin-top: 8px; max-height: 45vh; overflow-y: auto; border-top: 1px solid var(--line); }
.result { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 10px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; }

/* ---------- Chỉ dẫn rẽ ---------- */
.turn { position: fixed; top: calc(var(--safe-top) + 10px); left: 10px; right: 10px; display: flex; gap: 14px; align-items: center;
  padding: 12px 16px; z-index: 5; background: #0f3d26; border-color: #1f6b44; }
.turn-icon { font-size: 46px; width: 58px; text-align: center; line-height: 1; }
.turn-dist { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.turn-text { font-size: 18px; font-weight: 600; }

/* ---------- Thông báo ---------- */
#banners { position: fixed; left: 10px; right: 10px; top: calc(var(--safe-top) + 140px); z-index: 6; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.banner { pointer-events: auto; position: relative; padding: 9px 34px 9px 12px; border-radius: 12px; font-size: 13.5px; border: 1px solid var(--line); background: var(--panel-solid); }
.banner.warn { background: #3b2a06; border-color: #8a6110; }
.banner.info { background: #0f2340; border-color: #23477d; }
.banner .x { position: absolute; right: 4px; top: 4px; border: 0; background: none; font-size: 18px; color: var(--muted); width: 26px; height: 26px; }

/* ---------- Bảng tuyến ---------- */
.sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px); max-height: 58vh; overflow-y: auto; padding: 12px; z-index: 5; }
.tripline { font-size: 14px; line-height: 1.6; }
.mini { border: 0; background: #23324a; border-radius: 8px; padding: 0 6px; font-size: 11px; color: var(--muted); }
.triptools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.pill { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: #0a1322; font-size: 13.5px; }
.cands { display: flex; flex-direction: column; gap: 8px; }
.cand { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: #0b1424; }
.cand.sel { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cand-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cand-name { font-weight: 650; }
.cand-main { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; margin-top: 4px; }
.big { font-size: 22px; font-weight: 700; }
.mid { font-size: 17px; font-weight: 650; }
.okc { color: var(--good); } .midc { color: var(--mid); } .badc { color: var(--bad); }
.srcs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.reason { margin-top: 4px; color: #c6d2e6; }
.score { min-width: 40px; height: 30px; padding: 0 8px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 750; background: #23324a; }
.score.good { background: #11391f; color: #7ee2a0; }
.score.mid { background: #3b2a06; color: #fcd34d; }
.score.bad { background: #3f1010; color: #fca5a5; }
.leaveby { margin-top: 10px; padding: 9px 12px; border-radius: 12px; background: #0f2340; border: 1px solid #23477d; }
.leaveby.bad { background: #3f1010; border-color: #7f1d1d; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions.col { flex-direction: column; }
.row3 { display: flex; gap: 6px; }
.row3 .btn { flex: 1; padding: 0 6px; font-size: 13px; }
.btn { flex: 1; height: 46px; border-radius: 13px; border: 1px solid var(--line); background: #13213a; font-weight: 650; font-size: 15.5px; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.danger { background: #4a1212; border-color: #7f1d1d; }
.btn.ghost { background: #0a1322; }
.btn:disabled, .pill:disabled { opacity: .5; }

/* ---------- Thanh dẫn đường ---------- */
.navbar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px); padding: 12px; z-index: 5; }
.navstats { display: grid; grid-template-columns: 1.1fr 1.1fr .8fr .8fr; gap: 6px; align-items: end; text-align: center; }
.navstats .big { font-size: 24px; }
#navName { margin-top: 6px; text-align: center; }

.fab { position: fixed; right: 14px; bottom: calc(var(--safe-bottom) + 190px); width: 50px; height: 50px; border-radius: 25px; z-index: 5;
  border: 1px solid var(--line); background: var(--panel-solid); font-size: 24px; }

/* ---------- Hộp thoại ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; padding: 10px; padding-bottom: calc(var(--safe-bottom) + 10px); }
.modal-card { width: 100%; max-width: 560px; padding: 16px; max-height: 88vh; overflow-y: auto; }
.suggest-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.settings fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 8px 12px 10px; }
.settings legend { color: var(--muted); font-size: 12.5px; padding: 0 6px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }
.settings label.stack { flex-direction: column; align-items: stretch; }
.settings input[type=number], .settings input[type=time], .settings input[type=url], .settings input[type=password] {
  background: #0a1322; color: var(--text); border: 1px solid var(--line); border-radius: 9px; height: 36px; padding: 0 8px; font-size: 15px; }
.settings input[type=number] { width: 64px; text-align: center; }
.settings input[type=checkbox] { width: 22px; height: 22px; }
.status { background: #0a1322; border: 1px solid var(--line); border-radius: 10px; padding: 8px; white-space: pre-wrap; font-size: 12.5px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 24px); z-index: 30; background: #1d2d47; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 14px; }

/* ---------- Vị trí của tôi ---------- */
.me-marker { width: 26px; height: 26px; border-radius: 13px; background: rgba(47,128,255,.25); display: flex; align-items: center; justify-content: center; }
.me-arrow { width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 18px solid #2f80ff;
  filter: drop-shadow(0 0 2px #fff); transform: translateY(-2px); }

.maplibregl-ctrl-attrib { font-size: 10px; }
@media (min-width: 900px) { .sheet, .navbar { max-width: 520px; } #top, .turn { max-width: 520px; } }
