/* Charge and Do, phone first. Same identity as the prototype: white ground, lake blue,
   claret accent, battery green, Overpass (highway-sign lettering). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #12161b);
  --ink: light-dark(#1b1d21, #eceae4);
  --mute: light-dark(#5f636b, #a3a7ae);
  --line: light-dark(#e3e1da, #2a3038);
  --card: light-dark(#faf9f6, #181d23);
  --acc: light-dark(#8e1f4f, #e57aa5);
  --acc-ink: light-dark(#ffffff, #12161b);
  --batt: light-dark(#2f7d5b, #5fc79a);
  --warn: light-dark(#c8502a, #f08a5d);
  --water: light-dark(#bcd7ea, #1f3a4f);
  --walk: light-dark(#d9d6cc, #3a414b);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Overpass, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, h2 { margin: 0; line-height: 1.15; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--acc); }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.view { min-height: 100%; display: flex; flex-direction: column; }
.pad { padding: 14px 16px; }
.stack > * + * { margin-top: 16px; }
.center { text-align: center; }
.fine { font-size: 13px; color: var(--mute); margin: 0; }
.lede { color: var(--mute); margin: 0; }
.label, .field > label { display: block; font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 6px; }
.small-h { font-size: 14px; color: var(--mute); margin-bottom: 6px; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 0 8px 0 16px; padding-top: env(safe-area-inset-top, 0px); background: var(--bg); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { color: var(--acc); }
.back { margin-left: -8px; width: 44px; height: 44px; border: 0; background: none; font-size: 30px; line-height: 1; cursor: pointer; color: var(--acc); }

/* form */
input[type=text], input[type=number], input[type=time], select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 17px; }
.row { display: flex; gap: 8px; }
.ghost { flex: none; width: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 20px; cursor: pointer; }
.field.place { position: relative; }
.suggest { position: absolute; left: 0; right: 0; z-index: 10; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / .14); }
.suggest button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.suggest button:hover, .suggest button[aria-selected=true] { background: var(--card); }
.suggest small { display: block; color: var(--mute); font-size: 13px; }
.slider { display: flex; align-items: center; gap: 14px; min-height: 48px; }
.slider input { flex: 1; accent-color: var(--acc); height: 32px; }
.slider output { font-size: 28px; font-weight: 800; min-width: 3ch; text-align: right; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg button { flex: none; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); cursor: pointer; white-space: nowrap; font-size: 15px; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
details.car { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; background: var(--card); }
details.car summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 50px; cursor: pointer; }
details.car summary::-webkit-details-marker { display: none; }
details.car summary .label { margin: 0; }
details.car .edit { margin-left: auto; color: var(--acc); font-weight: 600; font-size: 14px; }
#car-sum { font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { font-size: 12px; font-weight: 600; color: var(--mute); }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--acc); }
details.car .fine { padding-bottom: 12px; }
.link { border: 0; background: none; color: var(--acc); padding: 0; cursor: pointer; font-size: inherit; text-decoration: underline; }
.primary { width: 100%; min-height: 54px; border: 0; border-radius: 14px; background: var(--acc); color: var(--acc-ink); font-weight: 800; font-size: 18px; cursor: pointer; }
.primary:disabled { opacity: .6; }
.error { color: var(--warn); font-weight: 600; margin: 0; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent button { width: 100%; text-align: left; min-height: 48px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }

/* building */
.spinner { width: 44px; height: 44px; margin: 40px auto 0; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--acc); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* results */
.layout { flex: 1; display: flex; flex-direction: column; }
.mapwrap { position: sticky; top: 52px; z-index: 2; height: 36vh; min-height: 220px; background: var(--water); border-bottom: 1px solid var(--line); }
#map { position: absolute; inset: 0; }
.panel { flex: 1; }
.controls { display: grid; gap: 12px; border-bottom: 1px solid var(--line); }
.ctl-row { display: flex; gap: 16px; align-items: center; }
.mini { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--mute); }
.mini:first-child { flex: 1; }
.mini input[type=range] { flex: 1; accent-color: var(--acc); }
.mini b { color: var(--ink); font-size: 16px; min-width: 3.2ch; text-align: right; }
.mini select { min-height: 36px; padding: 4px 8px; font-size: 15px; width: auto; }
.worth .label { margin-bottom: 4px; }
.worth .seg button { min-height: 34px; padding: 4px 11px; font-size: 14px; }
.summary { font-size: 14px; color: var(--mute); display: grid; gap: 4px; }
.summary b { color: var(--ink); }
.summary .note { color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 4px; }
.list { list-style: none; margin: 0; padding: 0 0 var(--safe-b); border-top: 1px solid var(--line); }
.opt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.opt:hover, .opt[aria-current=true] { background: var(--card); }
.opt[aria-current=true] { box-shadow: inset 4px 0 0 var(--acc); }
.opt .nm { font-weight: 700; line-height: 1.25; }
.opt .meta { font-size: 13px; color: var(--mute); line-height: 1.35; margin-top: 2px; }
.opt .what { font-size: 14px; margin-top: 4px; }
.opt .what.none { color: var(--mute); font-style: italic; }
.opt .sc { text-align: right; white-space: nowrap; }
.opt .sc b { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }
.opt .sc span { display: block; font-size: 12px; color: var(--mute); }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: var(--acc); color: var(--acc-ink); margin-left: 6px; vertical-align: 2px; }
.badge.g { background: var(--batt); }
.q { display: inline-flex; gap: 2px; margin-top: 4px; }
.q i { width: 6px; height: 6px; border-radius: 2px; background: var(--line); }
.q i.on { background: var(--acc); }
.more { width: calc(100% - 32px); margin: 12px 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }
.empty { margin: 16px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--mute); }

/* map bits */
.pin-label { font: 700 12px Overpass, system-ui, sans-serif; background: var(--bg); color: var(--ink); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); white-space: nowrap; }
.range-mark { font: 800 12px Overpass, system-ui, sans-serif; color: #fff; background: var(--warn); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.end-mark { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 4px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* detail */
.sheet { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--bg); padding-bottom: var(--safe-b); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; margin: 4px 0 14px; }
.kpis b { display: block; font-size: 30px; font-weight: 800; line-height: 1; }
.kpis span { font-size: 13px; color: var(--mute); }
.kpis .x { color: var(--warn); } .kpis .k { color: var(--batt); } .kpis .f { color: var(--acc); }
.warn { font-size: 14px; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); margin: 8px 0; }
.warn.hot { border-color: var(--warn); }
.tl { display: flex; height: 36px; border-radius: 10px; overflow: hidden; font-size: 12px; font-weight: 700; margin-top: 16px; }
.tl div { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; padding: 0 4px; }
.tl .d { background: var(--walk); color: var(--mute); }
.tl .c { background: var(--batt); color: #fff; }
.tl .e { background: var(--batt); color: #fff; opacity: .6; }
.batt { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin-top: 14px; }
.batt b { display: block; font-size: 20px; font-weight: 800; color: var(--batt); }
.batt span { font-size: 12px; color: var(--mute); }
.batt svg { grid-column: 1 / -1; width: 100%; height: 34px; margin-top: 4px; }
.steps { list-style: none; margin: 18px 0 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 4.6em 26px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps .t { font-weight: 800; text-align: right; white-space: nowrap; }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.steps .dot.c { background: var(--batt); } .steps .dot.p { background: var(--acc); }
.steps .s { font-size: 13px; color: var(--mute); }
.actions { display: grid; gap: 8px; margin-top: 18px; }
.actions a { display: flex; align-items: center; justify-content: center; min-height: 50px; border-radius: 12px; font-weight: 800; text-decoration: none; }
.actions a.primary-a { background: var(--acc); color: var(--acc-ink); }
.actions a.secondary-a { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.alts { margin-top: 18px; }
.alts h2 { font-size: 16px; margin-bottom: 6px; }
.alts li { font-size: 14px; }

/* wide screens: list beside a full-height map, detail in the panel */
@media (min-width: 900px) {
  .layout { flex: none; flex-direction: row-reverse; height: calc(100dvh - 52px); }
  .mapwrap { position: relative; top: 0; flex: 1; height: auto; border-bottom: 0; }
  .panel { flex: none; width: 440px; overflow-y: auto; border-right: 1px solid var(--line); }
  .sheet { inset: 52px auto 0 0; width: 440px; border-right: 1px solid var(--line); }
  .sheet .bar { top: 0; }
  .seg.scroll { flex-wrap: wrap; margin: 0; padding: 0; }
  .view#v-trip form { max-width: 520px; margin: 0 auto; width: 100%; }
}
