:root {
  --bg: #f3f5f8; --card: #fff; --ink: #14202b; --muted: #5d6b78; --line: #dfe5eb;
  --accent: #0b7a5a; --accent-ink: #fff; --sc: #d93a3a; --ccs: #2266cc; --warn: #a15c00; --warn-bg: #fff4e0;
  --good: #0b7a5a; --good-bg: #e3f5ee; --chip: #eef2f6;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141b; --card: #16212b; --ink: #e8eef3; --muted: #93a3b1; --line: #263542;
    --accent: #2fbf8f; --accent-ink: #062018; --warn: #f0b45a; --warn-bg: #33270f; --good: #4fd3a5; --good-bg: #10301f; --chip: #1e2c38;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.top { position: sticky; top: 0; z-index: 1100; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--sat)) 16px 10px; background: #0f1720; color: #fff; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.bolt { color: #ffd34d; }
.icon { background: none; border: 0; font-size: 20px; padding: 4px 8px; cursor: pointer; color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 12px 12px calc(40px + var(--sab)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.trip { position: relative; }
.place { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.place input { flex: 1; border: 0; background: transparent; padding: 10px 2px; font-size: 16px; outline: none; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.from { background: var(--muted); } .dot.to { background: var(--accent); } .dot.via { background: #c58a00; }
.mini { border: 1px solid var(--line); background: var(--chip); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.suggest { position: absolute; left: 10px; right: 10px; z-index: 600; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest button:hover, .suggest button:focus { background: var(--chip); }
.suggest small { color: var(--muted); display: block; }
.row.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; margin-top: 12px; }
.field { display: block; margin-top: 10px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 9px 10px; }
.inline { display: flex; align-items: center; gap: 6px; }
.inline em { font-style: normal; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.check input { margin-top: 3px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.go { width: 100%; margin-top: 14px; padding: 13px; border: 0; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 16px; cursor: pointer; }
.go:disabled { opacity: .6; }
.progress { color: var(--muted); text-align: center; margin: 10px 0 0; }
.err { color: #c62828; }

.options { display: grid; gap: 8px; margin-bottom: 12px; }
.opt { text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.opt.sel { border-color: var(--accent); }
.opt .l1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.opt .name { font-weight: 700; }
.opt .tag { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--good-bg); color: var(--good); margin-left: 6px; }
.opt .big { font-size: 20px; font-weight: 700; }
.opt .delta { font-size: 15px; font-weight: 700; color: var(--good); }
.opt .l2 { color: var(--muted); font-size: 13px; margin-top: 3px; }
.opt .est { color: var(--warn); }
.adapter { background: var(--good-bg); color: var(--good); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-weight: 600; }
.verify { background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.verify b { color: var(--warn); }
.verify ul { margin: 6px 0 0; padding: 0; list-style: none; }
.verify li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(0,0,0,.06); }
.verify li button { border: 1px solid var(--warn); color: var(--warn); background: transparent; border-radius: 8px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }

.mapcard { padding: 0; overflow: hidden; }
#map { height: 300px; background: var(--chip); }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 14px; }
.legend { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.l-soc { background: var(--accent); } .l-elev { background: #9aa9b6; }
#chart { width: 100%; height: 170px; display: block; }
#chart text { font-size: 11px; fill: var(--muted); }

.timeline { padding: 6px 14px; }
.ev { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev .time { font-weight: 700; font-size: 13px; padding-top: 2px; }
.ev .title { font-weight: 700; }
.ev .sub { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; color: #fff; margin-right: 6px; vertical-align: 1px; }
.badge.SC { background: var(--sc); } .badge.CCS { background: var(--ccs); }
.stopgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.stopgrid div { background: var(--chip); border-radius: 9px; padding: 6px 8px; }
.stopgrid .k { font-size: 11px; color: var(--muted); }
.stopgrid .v { font-weight: 700; }
.pricebtn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 13px; }
.pricebtn.est { color: var(--warn); }
.leg { color: var(--muted); font-size: 13px; padding: 8px 0 8px 74px; border-bottom: 1px solid var(--line); }
.leg b { color: var(--ink); font-weight: 600; }
.leg .screen { display: block; margin-top: 2px; }
.leg .wx { display: inline-block; margin-right: 8px; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn { display: inline-block; text-decoration: none; text-align: center; border: 0; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn.ghost { background: var(--chip); color: var(--ink); }
.btn.small { padding: 7px 10px; font-size: 13px; font-weight: 600; margin-top: 8px; }
.foot { color: var(--muted); font-size: 12px; }

.sheet { position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-body { background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 14px 16px calc(20px + var(--sab)); }
.sheet-body.small { max-height: 60vh; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -14px; background: var(--card); padding: 4px 0 8px; }
.group { border-top: 1px solid var(--line); padding: 10px 0 12px; }
.group h4 { margin: 4px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.leaflet-container { font: inherit; }
.pin { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.SC { background: var(--sc); } .pin.CCS { background: var(--ccs); } .pin.end { background: #0f1720; }

#memberBox { display: grid; gap: 8px; margin: 0 0 12px; }
.member { border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.member.yes { background: var(--good-bg); }
.member.no { background: var(--chip); color: var(--muted); }
.member.no b { color: var(--ink); }
.member .mrow { margin-top: 6px; }
.opt .tag, .opt .big, .opt .delta { white-space: nowrap; }
.opt .l1 { flex-wrap: wrap; }

.live { font-size: 13px; margin-top: 6px; }
.live.ok { color: var(--good); } .live.warn { color: var(--warn); } .live.bad { color: #c62828; }
.live .muted, .muted { color: var(--muted); }
.livenote { background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-size: 14px; }
/* never wider than the screen, even on very narrow windows */
.ev > div, .stopgrid > div, .field, .row.two > * { min-width: 0; }
.stopgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.field input, .field select { min-width: 0; }
.ev .title, .ev .sub { overflow-wrap: anywhere; }

#dayBar { margin-bottom: 12px; }
.daytabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.daytab { text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.daytab.sel { border-color: var(--accent); }
.daytab b { display: block; } .daytab span { color: var(--muted); font-size: 12.5px; }
.ovnote { background: var(--chip); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.chips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.chip.sel { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chip small { color: var(--muted); font-weight: 400; }

.avoidnote { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-weight: 600; }

.adapter.neutral { background: var(--chip); color: var(--ink); font-weight: 500; }
.carstatus { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--chip); font-size: 14px; }
.carstatus.good { background: var(--good-bg); color: var(--good); } .carstatus.bad { background: var(--warn-bg); color: var(--warn); }
/* driving screen: big, glanceable, one thing at a time */
.drive { position: fixed; inset: 0; z-index: 1300; background: var(--bg); overflow: auto; }
.drive[hidden] { display: none; }
.drive-body { max-width: 640px; margin: 0 auto; padding: calc(14px + var(--sat)) 16px calc(24px + var(--sab)); }
.dv-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 600; }
.dv-next { margin-top: 18px; color: var(--muted); font-size: 15px; }
.dv-name { font-size: 26px; font-weight: 800; line-height: 1.2; margin: 4px 0 14px; overflow-wrap: anywhere; }
.dv-name .badge { font-size: 13px; vertical-align: 4px; }
.dv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dv-grid > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-width: 0; }
.dv-grid .k { color: var(--muted); font-size: 12.5px; } .dv-grid .v { font-size: 26px; font-weight: 800; } .dv-grid .s { color: var(--muted); font-size: 12px; }
.dv-check { margin-top: 12px; background: var(--chip); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.dv-live { margin-top: 10px; color: var(--good); font-weight: 600; }
.dv-actions { display: grid; gap: 8px; margin-top: 14px; }
.dv-actions .btn { padding: 14px; font-size: 16px; }
.dv-arrive { margin-top: 18px; } .dv-arrive input { font-size: 20px; max-width: 110px; } .dv-arrive .btn { margin-left: 8px; }
.dv-foot { margin-top: 22px; text-align: center; color: var(--muted); }
