/* LeoMap — driving UI.
   Ink-blue panels for glare, a Swiss direction-sign plate for the next turn,
   and one signal orange that always means "the stop you are driving to". */
:root {
  --ink: #111b26;        /* sheet / panels */
  --ink-2: #1c2a39;      /* raised buttons */
  --ink-3: #26384b;      /* pressed / borders */
  --line: #2f4358;
  --text: #f5f8fb;
  --muted: #a9b8c8;
  --go: #20c06b;         /* delivered */
  --go-ink: #03200f;
  --signal: #ff7a1a;     /* current stop */
  --signal-ink: #1f0d00;
  --sign: #1f55a6;       /* direction-sign blue */
  --warn: #ffc93a;
  --warn-bg: #3b2f0b;
  --bad: #ff6464;
  --bad-bg: #3d1a1f;
  --radius: 16px;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-num: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text);
  font: 500 16px/1.3 var(--f-body); overflow: hidden; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round; }

button, .file { font: inherit; font-weight: 600; color: var(--text); background: var(--ink-2); border: 0;
  border-radius: 12px; padding: 12px 14px; cursor: pointer; text-align: center; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; }
button:active, .file:active { filter: brightness(1.3); transform: scale(.98); }
button:disabled { opacity: .35; filter: none; transform: none; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #7fb2ff; outline-offset: 2px; }
button.big, .file.big { min-height: 58px; padding: 14px 18px; font-size: 18px; font-weight: 700; }
button.primary, .file.primary { background: var(--go); color: var(--go-ink); font-weight: 700; }
button.danger { background: var(--bad-bg); color: #ffc0c0; }
button.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
button.round { width: 52px; height: 52px; min-height: 0; border-radius: 50%; padding: 0;
  background: var(--ink); box-shadow: 0 3px 12px rgba(0,0,0,.45), inset 0 0 0 1px var(--line); }
button.round .i { width: 26px; height: 26px; }
button.round.flat { box-shadow: none; background: var(--ink-2); width: 48px; height: 48px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }
.grow { flex: 2 1 0 !important; }
.grow2 { flex: 3 1 0 !important; }

#map { position: fixed; inset: 0; background: #dfe5ea; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- top: progress + round buttons ---------- */
#topbar { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 500;
  transition: top .2s ease; }
#topbar > * { pointer-events: auto; }
body.has-banner #topbar { top: calc(env(safe-area-inset-top) + var(--banner-h, 100px) + 18px); }
.chip { background: var(--ink); border-radius: 999px; padding: 8px 16px 9px; min-width: 112px;
  box-shadow: 0 3px 12px rgba(0,0,0,.45), inset 0 0 0 1px var(--line); }
.prog-text { display: flex; align-items: baseline; justify-content: center; gap: 4px; font-family: var(--f-num); line-height: 1; }
.prog-text b { font-size: 24px; font-weight: 700; }
.prog-text span { font-size: 17px; font-weight: 600; color: var(--muted); }
.prog-bar { height: 5px; margin-top: 5px; border-radius: 3px; background: var(--ink-3); overflow: hidden; }
.prog-bar i { display: block; height: 100%; width: 0; background: var(--go); border-radius: 3px; transition: width .3s ease; }

/* ---------- next-turn sign ---------- */
#banner { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 8px; right: 8px; z-index: 600; }
.plate { display: flex; gap: 10px; align-items: center; min-height: 58px; padding: 6px 12px 6px 8px;
  background: var(--sign); border-radius: 14px; color: #fff;
  box-shadow: inset 0 0 0 3px var(--sign), inset 0 0 0 5px rgba(255,255,255,.9), 0 6px 18px rgba(0,0,0,.35); }
.arrow { width: 42px; height: 42px; flex: none; }
.arrow svg { width: 100%; height: 100%; }
.bn-text { min-width: 0; flex: 1; }
.bn-then { flex: none; width: 58px; margin: -2px -6px -2px 0; padding: 4px 2px 5px; border-radius: 9px;
  background: rgba(0,0,0,.22); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.then-lbl { font: 700 10px/1 var(--f-body); text-transform: uppercase; letter-spacing: .6px; opacity: .8; }
.then-arrow { width: 28px; height: 28px; }
.then-arrow svg { width: 100%; height: 100%; }
.then-dist { font: 700 13px/1 var(--f-num); }
.bn-dist { font: 700 27px/1 var(--f-num); letter-spacing: .3px; }
.bn-instr { font-size: 15px; font-weight: 700; margin-top: 2px; line-height: 1.2; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }

.fab { position: fixed; right: 12px; bottom: calc(var(--sheet-h, 260px) + 14px); z-index: 500; }
.fab.compass { right: auto; left: 12px; width: 52px; height: 52px; position: fixed; }
.compass svg { width: 34px; height: 34px; }
.compass #compassNeedle { transition: transform .3s ease; transform-origin: 20px 20px; }
.compass span { position: absolute; bottom: 3px; font: 700 10px/1 var(--f-num); color: var(--muted); }
.compass.up span { color: var(--signal); }

/* ---------- bottom sheet ---------- */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 550; background: var(--ink);
  border-radius: 22px 22px 0 0; padding: 0 12px calc(env(safe-area-inset-bottom) + 12px);
  box-shadow: 0 -6px 24px rgba(0,0,0,.4); }
#sheet > .empty { padding-top: 22px; }
.handle { display: flex; width: 100%; min-height: 26px; padding: 9px 0 11px; background: none; border-radius: 0; }
.handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--ink-3); }
.handle:active { transform: none; }

.card-head { display: flex; gap: 12px; align-items: flex-start; }
.seq { flex: none; min-width: 58px; height: 58px; padding: 0 8px; display: grid; place-items: center;
  background: var(--signal); color: var(--signal-ink); border-radius: 12px;
  font: 700 34px/1 var(--f-num); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.seq.done { background: var(--go); color: var(--go-ink); }
.seq.fail { background: var(--bad); color: #2a0508; }
.head-main { min-width: 0; flex: 1; padding-top: 1px; }
.name { font-size: 20px; font-weight: 700; line-height: 1.15; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.addr { font-size: 17px; color: #d8e2ec; margin-top: 3px; line-height: 1.2; overflow-wrap: anywhere; }

.warnline { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 10px;
  border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 700; font-size: 15px;
  box-shadow: inset 3px 0 0 var(--warn); line-height: 1.25; }
.warnline .i { width: 20px; height: 20px; margin-top: 0; }
.warnline.bad { background: var(--bad-bg); color: #ffb0b0; box-shadow: inset 3px 0 0 var(--bad); }
.warnline small { display: block; font-weight: 500; color: #f1dca0; font-size: 14px; }
.warnline.bad small { color: #f3c3c3; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:not(:has(> :not(:empty))) { display: none; }
.chips > :empty { display: none; }
.meta { display: contents; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 8px;
  background: var(--ink-2); color: #dbe4ee; font-size: 15px; font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pill .i { width: 17px; height: 17px; stroke-width: 2.2; color: var(--muted); }
.pill.big-count { background: #2a2350; color: #e2dcff; }
.pill.big-count .i { color: #c7bcff; }
.pill.note { white-space: normal; }
.route-info { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 8px; background: var(--sign);
  color: #fff; font: 700 17px/1.1 var(--f-num); letter-spacing: .2px; }
.status { padding: 4px 9px; border-radius: 8px; font-size: 15px; font-weight: 700; }
.status.done { background: #12442a; color: #94f2c0; }
.status.fail { background: var(--bad-bg); color: #ffb3b3; }

.nav-row { display: flex; gap: 8px; margin-top: 12px; }
.step { width: 64px; flex: none; min-height: 64px; padding: 0; background: var(--ink-2); }
.step .i { width: 30px; height: 30px; stroke-width: 2.8; }
.done-btn { flex: 1; min-height: 64px; font-size: 22px; font-weight: 700; letter-spacing: .2px; border-radius: 14px; }
.done-btn .i { width: 28px; height: 28px; stroke-width: 3; }
.done-btn.undo { background: var(--ink-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--go); font-size: 18px; }

.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.act { flex-direction: column; gap: 3px; min-height: 58px; padding: 7px 2px 6px; font-size: 13px; font-weight: 600;
  background: transparent; color: #d6e0ea; border-radius: 12px; }
.act .i { width: 24px; height: 24px; }
.act:active { background: var(--ink-2); }
.act span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.act-fail { color: #ff9c9c; }
.act-fail.on { background: var(--bad-bg); }

/* collapsed sheet: just the stop and the big buttons */
body.sheet-min .addr, body.sheet-min .chips, body.sheet-min .actions { display: none; }
body.sheet-min .name { -webkit-line-clamp: 1; }
body.sheet-min .seq { height: 48px; min-width: 50px; font-size: 30px; }
body.sheet-min .card-head { align-items: center; }
body.sheet-min .warnline small { display: none; }

.empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--ink-2); color: var(--signal); }
.empty-mark .i { width: 30px; height: 30px; }
.empty-title { margin: 6px 0 0; font-size: 20px; font-weight: 700; }
.empty-sub { margin: 0 0 10px; color: var(--muted); max-width: 30ch; }
.empty button { width: 100%; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(4, 9, 15, .62);
  display: flex; align-items: flex-end; justify-content: center; }
.panel { background: var(--ink); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* Taller than the screen: scroll the panel instead of squeezing its rows. */
.panel > * { flex-shrink: 0; }
.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--ink-3); margin: 0 auto 6px; flex: none; }
.panel h2 { margin: 0 0 2px; font-size: 22px; font-weight: 700; }
.panel p { margin: 0; }
.menu-list { display: flex; flex-direction: column; background: var(--ink-2); border-radius: 14px; overflow: hidden; }
.mrow { justify-content: flex-start; gap: 14px; min-height: 58px; padding: 0 16px; background: transparent;
  border-radius: 0; font-size: 18px; }
.mrow + .mrow { box-shadow: inset 0 1px 0 var(--line); }
.mrow .i { color: var(--muted); }
.mrow.danger { background: transparent; color: #ff9c9c; }
.mrow.danger .i { color: #ff9c9c; }
a.mrow { display: flex; align-items: center; color: var(--text); text-decoration: none; font-weight: 600; }

/* ---------- about ---------- */
.about-head { display: flex; align-items: center; gap: 14px; }
.about-head img { border-radius: 14px; flex: none; }
.about-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--ink-2); }
.about-lbl { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.about-name { font: 700 24px/1.15 var(--f-num); }
.about-studio { font-weight: 700; color: var(--signal); margin-bottom: 6px; }
.about-link { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none; font-weight: 600; }
.about-link .i { color: var(--muted); width: 20px; height: 20px; }
.about-link.kofi, .about-link.kofi .i { color: #ff8a8a; }
.legal { font-size: 13px; color: var(--muted); }
.legal summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; }
.legal ul { margin: 4px 0 8px; padding-left: 18px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; color: var(--muted); }
input, select { font: inherit; font-size: 18px; font-weight: 500; color: var(--text); background: #0a121a;
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 50px; }
input:focus, select:focus { outline: none; border-color: #5f9bff; }
label.seq-field { flex: 0 0 84px !important; }
label.seq-field input { font: 700 22px/1 var(--f-num); color: var(--signal); text-align: center; padding: 8px 4px; }
label.check { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; font-size: 17px;
  color: var(--text); min-height: 56px; padding: 6px 2px; }
label.check input { appearance: none; -webkit-appearance: none; flex: none; width: 54px; height: 32px; min-height: 0;
  padding: 0; border-radius: 16px; background: var(--ink-3); border: 0; position: relative; transition: background .15s; }
label.check input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform .15s; }
label.check input:checked { background: var(--go); }
label.check input:checked::after { transform: translateX(22px); }

.form { gap: 12px; padding-bottom: 0; }
.geo-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--ink-2); }
.geo-state { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: #d6e0ea; }
.geo-state::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.geo-state.ok::before { background: var(--go); }
.geo-state.warn { color: var(--warn); }
.geo-state.warn::before { background: var(--warn); }
.geo-state.bad { color: #ffb0b0; }
.geo-state.bad::before { background: var(--bad); }
#editPick { background: var(--sign); color: #fff; }
.form-foot { position: sticky; bottom: 0; margin: 4px -16px 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: var(--ink); box-shadow: 0 -1px 0 var(--line); }
.form-foot .icon-only { flex: 0 0 52px !important; padding: 0; }

/* ---------- list ---------- */
.overlay.full { display: block; background: var(--ink); overflow: auto; overscroll-behavior: contain; }
.list-head { position: sticky; top: 0; z-index: 2; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: var(--ink); box-shadow: 0 1px 0 var(--line), 0 6px 14px rgba(0,0,0,.25); }
.list-top { display: flex; align-items: center; gap: 12px; }
.list-top h2 { margin: 0; font-size: 24px; font-weight: 700; }
.list-info { margin-left: auto; font: 700 20px/1 var(--f-num); color: var(--muted); }
.list-info b { color: var(--text); font-size: 24px; }
.prog-bar.wide { height: 6px; margin: 10px 0 10px; }
.search { position: relative; display: block; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 22px; height: 22px; }
.search input { padding-left: 42px; min-height: 48px; font-size: 17px; }
.filters { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.filters button { flex: 1 0 auto; min-height: 42px; padding: 6px 10px; border-radius: 999px; font-size: 15px;
  background: var(--ink-2); color: #d6e0ea; gap: 6px; white-space: nowrap; }
.filters button b { font: 700 15px/1 var(--f-num); color: var(--muted); }
.filters button.on { background: var(--text); color: var(--ink); }
.filters button.on b { color: var(--ink); }
.filters button[data-filter="problem"] b:not(:empty) { color: var(--warn); }
.filters button.on[data-filter="problem"] b { color: #8a5a00; }
.warn { margin: 10px 14px 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: #ffe19a;
  font-size: 15px; box-shadow: inset 3px 0 0 var(--warn); }
.list-empty { text-align: center; color: var(--muted); padding: 30px 20px; margin: 0; }

#listItems { list-style: none; margin: 0; padding: 6px 8px calc(env(safe-area-inset-bottom) + 24px); }
#listItems li { display: flex; gap: 12px; align-items: center; padding: 10px 6px 10px 8px; border-radius: 14px; position: relative; }
#listItems li + li::before { content: ""; position: absolute; top: 0; left: 66px; right: 8px; height: 1px; background: var(--ink-2); }
#listItems li.cur { background: #2a1a0c; box-shadow: inset 0 0 0 2px var(--signal); }
#listItems li.cur::before, #listItems li.cur + li::before { display: none; }
#listItems li:active { background: var(--ink-2); }
.l-seq { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--ink-2); font: 700 22px/1 var(--f-num); color: var(--text); }
li.cur .l-seq { background: var(--signal); color: var(--signal-ink); }
li.done .l-seq { background: #12442a; color: #94f2c0; }
li.fail .l-seq { background: var(--bad-bg); color: #ffb3b3; }
.l-seq .i { width: 22px; height: 22px; stroke-width: 3; }
#listItems .l-main { flex: 1; min-width: 0; }
#listItems .l-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#listItems .l-addr { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#listItems .l-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 14px; color: var(--muted); }
#listItems .l-sub:empty { display: none; }
#listItems .l-eta { font-family: var(--f-num); font-weight: 600; font-size: 15px; }
#listItems .l-flag { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 700; min-width: 0; }
#listItems .l-flag.bad { color: #ff9c9c; }
#listItems .l-flag .i { width: 16px; height: 16px; }
#listItems li.done .l-name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
#listItems li.done .l-addr, #listItems li.done .l-sub { opacity: .7; }
#listItems .l-here { font-size: 13px; font-weight: 700; color: var(--signal); }
#listItems .l-edit { flex: none; width: 48px; height: 48px; min-height: 0; padding: 0; background: transparent; color: var(--muted); }

/* ---------- import ---------- */
.bar { height: 12px; background: #0a121a; border-radius: 6px; overflow: hidden; }
#impBar { height: 100%; width: 0; background: var(--go); transition: width .2s; }
.imp-stage { margin-top: 6px; font-weight: 600; color: #d6e0ea; }
.log { margin: 0; padding-left: 18px; font-size: 14px; color: var(--muted); max-height: 30vh; overflow: auto; }
.log:empty { display: none; }
.log li.err { color: #ffb3b3; }
.log li.ok { color: #94f2c0; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--sheet-h, 260px) + 16px);
  z-index: 950; background: var(--text); color: var(--ink); font-weight: 600; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); width: max-content; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
.toast button { min-height: 40px; padding: 6px 12px; background: var(--ink); color: var(--text); }
.toast.pick { background: var(--sign); color: #fff; }
.toast.pick button { background: rgba(255,255,255,.18); }

/* ---------- map markers ---------- */
.pin { width: 26px; height: 26px; opacity: .85; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); position: relative;
  background: var(--sign); border: 2.5px solid #fff; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.pin span { transform: rotate(45deg); color: #fff; font: 700 13px/1 var(--f-num); }
.pin.done { background: #7d8a96; }
.pin.done span { font-size: 13px; }
.pin.fail { background: #d83a3a; }
/* The current stop sits beside its point (tip at the address) and is see-through, so the
   house numbers on the map stay readable. */
.pin.cur { background: var(--signal); width: 32px; height: 32px; border-width: 2.5px; opacity: .8; }
.pin.cur span { font-size: 16px; color: var(--signal-ink); }
.pin.warn::after { content: "!"; position: absolute; top: -7px; right: -7px; transform: rotate(45deg);
  width: 16px; height: 16px; border-radius: 50%; background: var(--warn); color: #2a1d00; border: 2px solid #fff;
  font: 800 11px/12px var(--f-body); text-align: center; }
.me { width: 34px; height: 34px; }
.me svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }

@media (max-width: 370px) {
  .act { font-size: 12px; }
  .step { width: 56px; }
  .name { font-size: 19px; }
  .bn-dist { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
