/* Palette and shapes follow the "Plan. Stop. Ride." look: warm cream paper, deep teal-navy ink,
   orange for the route and the main action, sage and teal for the land, outlined cards with a
   solid offset shadow, pill buttons and bold headings. */
:root {
  --cream: #F5EFE3;
  --paper: #FFFBF3;
  --ink: #17303A;
  --ink-2: #5B6B6D;
  --ink-3: #8C9895;
  --line: #17303A;
  --hair: #E3DCCD;
  --orange: #F0714A;
  --orange-d: #D95B34;
  --peach: #F3D8B8;
  --sage: #D7E6DA;
  --teal: #7DB5A9;
  --teal-d: #3E7E72;
  --light: #4E9E7E;
  --moderate: #E6A93C;
  --heavy: #D9483B;
  --unknown: #A9B3AE;
  --fuel: #F0714A;
  --food: #3E7E72;
  --radius: 14px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --peek: 74px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-d); }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 392px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-right: 2px solid var(--line);
  z-index: 1000;
  min-height: 0;
}
.sheet-handle { display: none; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 12px; }
.logo-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { flex-shrink: 0; display: block; }
.brand h1 { font-size: 20px; line-height: 1.1; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.brand-sum { display: none; }
.tagline { margin: 3px 0 0; font-size: 10.5px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.brand-tools { display: flex; align-items: center; gap: 8px; }

.lang-switch { display: flex; border: 2px solid var(--line); border-radius: 999px; padding: 2px; background: var(--paper); }
.lang-switch button { border: 0; background: none; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; color: var(--ink-2); }
.lang-switch button.active { background: var(--ink); color: var(--paper); }

.icon-btn { background: var(--paper); border: 2px solid var(--line); border-radius: 50%; width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center; color: var(--ink); font-weight: 800; padding: 0; }
.icon-btn:hover { background: var(--peach); }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 4px 20px 0; padding: 4px; border: 2px solid var(--line); border-radius: 999px; background: var(--paper); }
.tab { flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px 10px; font-weight: 800; font-size: 13px; color: var(--ink-2); }
.tab.active { background: var(--ink); color: var(--paper); }
.tab:disabled { opacity: .45; cursor: not-allowed; }
.tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-left: 6px; vertical-align: 1px; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 14px 20px 8px; min-height: 0; }
.pane { display: flex; flex-direction: column; gap: 14px; }
.pane[hidden] { display: none; }

/* Cards: outlined, solid offset shadow */
.card { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 12px; }
.card[hidden] { display: none; }
.card-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 10px; color: var(--ink); }
h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); margin: 0 0 4px; font-weight: 800; }

/* Collapsible sections */
.fold { padding: 0; }
.fold summary { list-style: none; display: flex; align-items: center; gap: 11px; padding: 12px 14px; cursor: pointer; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: ""; width: 8px; height: 8px; border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg); margin: 0 4px 4px auto; transition: transform .15s; flex-shrink: 0; }
.fold[open] summary::after { transform: rotate(-135deg); margin-bottom: -2px; }
.fold-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--peach); display: grid; place-items: center; flex-shrink: 0; }
.fold-icon svg { width: 16px; height: 16px; fill: var(--ink); }
.fold-text { display: flex; flex-direction: column; min-width: 0; }
.fold-title { font-weight: 800; font-size: 14.5px; }
.fold-sum { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-body { padding: 2px 14px 14px; border-top: 2px dashed var(--hair); }
.fold-body > :first-child { margin-top: 12px; }

/* Inputs */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 9px; }
input[type=text], input[type=number], input[type=datetime-local] {
  width: 100%;
  color: var(--ink);
  padding: 9px 11px;
  border: 2px solid var(--hair);
  border-radius: 10px;
  background: #fff;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
}
input::placeholder { color: var(--ink-3); font-weight: 500; }
input:focus { outline: none; border-color: var(--ink); }
.unit-input { display: flex; align-items: center; position: relative; }
.unit-input input { padding-right: 64px; }
.unit-input span { position: absolute; right: 11px; top: 50%; transform: translateY(-35%); font-size: 11px; font-weight: 700; color: var(--ink-3); pointer-events: none; }
.unit-input.narrow input { padding-right: 32px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row { display: flex; align-items: center; }
.gap { gap: 16px; }
.check { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 600; margin: 2px 0; cursor: pointer; }
.check input { accent-color: var(--ink); width: 16px; height: 16px; margin: 0; }
.checks { margin: 2px 0 4px; }
.hint { font-size: 12px; color: var(--ink-2); margin: 8px 0 0; }
.hint.tight { margin: 2px 0 0; }
.muted { color: var(--ink-2); font-weight: 500; text-transform: none; letter-spacing: 0; }
.empty { margin: 30px 10px; text-align: center; color: var(--ink-2); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 13.5px; text-decoration: none; border: 2px solid var(--line); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translate(2px, 2px); box-shadow: none !important; }
.btn-primary { width: 100%; background: var(--orange); color: var(--ink); padding: 13px 16px; font-size: 15px; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #F4825E; }
.btn-primary:disabled { background: var(--hair); color: var(--ink-3); border-color: var(--ink-3); box-shadow: none; cursor: not-allowed; }
.btn-primary.stale { animation: nudge 1.6s ease-in-out 2; }
@keyframes nudge { 50% { transform: translateY(-2px); } }
.btn-dark { background: var(--ink); color: var(--paper); box-shadow: var(--shadow-sm); }
.btn-dark:hover { background: #22414C; }
.btn-outline { background: var(--paper); color: var(--ink); }
.btn-outline:hover { background: var(--peach); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.link-btn:hover { color: var(--orange-d); }

.sidebar-action { padding: 12px 20px 14px; border-top: 2px solid var(--line); background: var(--cream); }
.sidebar-action[hidden] { display: none; }
.error { margin-bottom: 10px; padding: 9px 12px; border-radius: 10px; border: 2px solid var(--heavy); background: #FCE6E1; color: #8A2017; font-size: 13px; font-weight: 600; word-break: break-word; }
.error[hidden] { display: none; }

/* Waypoints: a dashed line joins the stops, like a route */
.wp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; margin: 7px 0; position: relative; }
.wp:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 30px; height: 22px; border-left: 2px dashed var(--ink-3); }
.wp-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--paper); background: var(--ink); flex-shrink: 0; border: 2px solid var(--line); }
.wp-dot.end { background: var(--orange); color: var(--ink); }
.wp-dot.mid { background: var(--paper); color: var(--ink); }
.wp-dot.fuel { background: var(--fuel); }
.wp-dot.food { background: var(--food); }
.wp-dot svg { width: 13px; height: 13px; fill: var(--paper); }
.wp-dot.fuel svg { fill: var(--ink); }
.wp-input { flex: 1; position: relative; min-width: 0; }
.wp-input input { margin-top: 0; }
.wp .icon-btn { width: 30px; height: 30px; font-size: 13px; }
.wp-drag { flex-shrink: 0; width: 26px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: var(--ink-2); font-size: 17px; line-height: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.wp-drag:hover { background: var(--peach); color: var(--ink); }
.wp.dragging { z-index: 20; background: var(--paper); border-radius: 12px; outline: 2px solid var(--line); outline-offset: 3px; box-shadow: var(--shadow-sm); }
.wp.dragging::before { display: none; }
.wp.dragging .wp-drag { cursor: grabbing; }
#waypoints.reordering { user-select: none; -webkit-user-select: none; }
.wp:has(.wp-stay):not(:last-child)::before { height: 64px; }
.wp-stay { flex: 0 0 100%; display: flex; align-items: center; gap: 6px; margin: 0; padding-left: 33px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.wp-stay input { width: 64px; margin: 0; padding: 4px 8px; font-size: 13px; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--paper); border: 2px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); z-index: 30; max-height: 270px; overflow-y: auto; }
.suggest[hidden] { display: none; }
.suggest li { padding: 7px 9px; cursor: pointer; font-size: 13px; font-weight: 700; border-radius: 8px; }
.suggest li small { display: block; color: var(--ink-2); font-size: 11.5px; font-weight: 500; }
.suggest li.active, .suggest li:hover { background: var(--peach); }
.suggest li.searching { cursor: default; color: var(--ink-2); font-style: italic; font-weight: 500; }
.suggest li.searching:hover { background: none; }

/* Brand chips */
.chips { position: relative; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 5px; border: 2px solid var(--hair); border-radius: 10px; background: #fff; margin: 4px 0 2px; }
.chips:focus-within { border-color: var(--ink); }
.chips input[type=text] { flex: 1; min-width: 90px; border: 0; margin: 0; padding: 4px 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; font-weight: 700; }
.chip button { border: 0; background: none; color: inherit; font-size: 14px; line-height: 1; padding: 0 5px; border-radius: 50%; }
.chip button:hover { background: rgba(255,255,255,.18); }

/* Trip results */
#summary { display: flex; flex-direction: column; gap: 14px; }
#summary[hidden] { display: none; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stats div { background: var(--paper); border: 2px solid var(--line); border-radius: 12px; padding: 8px 11px; }
.stats div[hidden] { display: none; }
.stats .stat-main { background: var(--ink); color: var(--paper); }
.stats .stat-main dt { color: var(--peach); }
.stats .stat-main dd { font-size: 20px; }
.stats dt { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.stats dd { margin: 1px 0 0; font-size: 15.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.export { display: flex; gap: 8px; }
.export .btn { flex: 1; }
#gmaps-note { margin-top: -6px; }
#gmaps-note:empty { display: none; }

.routes { display: flex; flex-direction: column; gap: 7px; }
.route-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 11px; border: 2px solid var(--hair); border-radius: 12px; background: #fff; color: var(--ink); }
.route-opt:hover { border-color: var(--ink-3); }
.route-opt.active { border-color: var(--line); background: var(--peach); }
.route-opt .ro-main { flex: 1; min-width: 0; }
.route-opt .ro-name { font-weight: 800; font-size: 13px; }
.route-opt .ro-sub { font-size: 12px; color: var(--ink-2); }
.route-opt .ro-time { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.route-opt .ro-delta { display: block; text-align: right; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.routes .hint { margin: 0; }
.pick-stops { width: 100%; margin-top: 10px; }

/* Roadmap: clock, a rail of dots, then what happens there */
.road-row { display: grid; grid-template-columns: 44px 24px minmax(0, 1fr) auto; column-gap: 8px; font-size: 13px; }
.road-row.dragging { position: relative; z-index: 20; background: var(--paper); border-radius: 12px; outline: 2px solid var(--line); outline-offset: 3px; box-shadow: var(--shadow-sm); }
.road-row.dragging .wp-drag { cursor: grabbing; }
#roadmap.reordering { user-select: none; -webkit-user-select: none; }
.road-time { padding-top: 3px; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.road-rail { position: relative; display: flex; justify-content: center; }
.road-rail::after { content: ""; position: absolute; top: 24px; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); background: var(--line); }
.road-row:last-of-type .road-rail::after { display: none; }
.road-dot { position: relative; z-index: 1; width: 24px; height: 24px; flex: none; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 11px; font-weight: 800; }
.road-dot svg { width: 12px; height: 12px; fill: currentColor; }
.road-row.start .road-dot { background: var(--ink); color: var(--paper); }
.road-row.end .road-dot { background: var(--orange); color: var(--ink); }
.road-row.fuel .road-dot { background: var(--ink); color: var(--paper); }
.road-row.refuel .road-dot { background: var(--fuel); border-style: dashed; }
.road-row.food .road-dot { background: var(--food); color: var(--paper); }
.road-body { min-width: 0; padding: 2px 0 14px; }
.road-row:last-of-type .road-body { padding-bottom: 2px; }
.road-title { cursor: pointer; font-weight: 700; overflow-wrap: anywhere; }
.road-title:hover { color: var(--orange-d); }
.road-sub { font-size: 12px; color: var(--ink-2); }
.roadmap > .hint { margin: 10px 0 0; }
.cands { list-style: none; padding: 0; margin: 6px 0 0; }
.cands li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--hair); }
.cands li > div { flex: 1; min-width: 0; cursor: pointer; }
.cands li > div:hover b { color: var(--orange-d); }
.cands b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cands small { display: block; color: var(--ink-2); font-size: 11.5px; }
.choose-btn { flex-shrink: 0; border: 2px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 800; }
.choose-btn:hover { background: var(--orange); }

/* Footer */
.sidebar-foot { padding: 8px 20px 12px; font-size: 11.5px; color: var(--ink-2); }
.powered { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--paper); text-decoration: none; border: 2px solid var(--line); border-radius: 999px; padding: 8px 14px; margin-bottom: 7px; font-size: 13.5px; font-weight: 600; background: var(--ink); box-shadow: var(--shadow-sm); }
.powered strong { font-weight: 800; color: var(--peach); }
.powered::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.powered:hover { background: var(--ink-2); }
.credits a { color: var(--ink-2); }

/* ---------- Map ---------- */
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.leaflet-container { font: inherit; background: #E3EBDD; }
.leaflet-control-zoom.leaflet-bar { border: 2px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.leaflet-control-zoom a { background: var(--paper); color: var(--ink); font-weight: 800; }
.leaflet-control-zoom a:hover { background: var(--peach); }
.leaflet-control-attribution { background: rgba(255,251,243,.85) !important; font-size: 10px; }
.leaflet-popup-content-wrapper { background: var(--paper); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); }
.leaflet-popup-tip { background: var(--paper); border: 2px solid var(--line); }
.leaflet-tooltip { border: 2px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); font-weight: 600; color: var(--ink); background: var(--paper); }

.pin { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--line); box-shadow: 0 2px 0 rgba(23,48,58,.35); display: grid; place-items: center; color: var(--paper); font-weight: 800; font-size: 12px; background: var(--ink); }
.pin.end { background: var(--orange); color: var(--ink); }
.pin.mid { background: var(--paper); color: var(--ink); }
.pin.fuel { background: var(--fuel); }
.pin.food { background: var(--food); }
.pin svg { width: 14px; height: 14px; fill: var(--paper); }
.pin.fuel svg { fill: var(--ink); }
.cursor { width: 20px; height: 20px; border-radius: 50%; background: var(--orange); border: 3px solid var(--ink); box-shadow: 0 0 0 4px rgba(240,113,74,.3); }
.poi { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; border: 2px solid var(--line); }
.poi svg { width: 13px; height: 13px; fill: var(--paper); }
.poi.fuel { background: var(--fuel); }
.poi.fuel svg { fill: var(--ink); }
.poi.food { background: var(--food); }
.refuel-pin { color: var(--ink); font-weight: 800; font-size: 11px; border-radius: 999px; padding: 1px 7px; border: 2px solid var(--line); white-space: nowrap; }
.refuel-pin { background: var(--fuel); }
.map-popup button { display: block; width: 100%; margin: 4px 0; padding: 7px 11px; border: 2px solid var(--line); background: var(--paper); border-radius: 999px; text-align: left; font-weight: 700; }
.map-popup button:hover { background: var(--peach); }
.popup-title { font-weight: 800; }
.poi-label.leaflet-tooltip { padding: 1px 7px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; border-width: 1.5px; box-shadow: none; }
.poi-label.leaflet-tooltip::before { display: none; }
.trnc-label { display: grid !important; place-items: center; text-align: center; font: 800 11px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; }
.popup-sub { color: var(--ink-2); font-size: 12px; }

/* Layer toggles on the map */
.map-chips { position: absolute; top: 12px; left: 12px; z-index: 800; display: flex; gap: 7px; flex-wrap: wrap; max-width: calc(100% - 80px); }
.map-chips[hidden] { display: none; }
.chip-toggle { margin: 0; cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px 6px 10px; border: 2px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-sm); font-size: 13px; }
.chip-toggle b { font-weight: 800; }
.chip-toggle svg { width: 15px; height: 15px; fill: currentColor; }
.chip-toggle input:checked + span { background: var(--ink); color: var(--paper); }
.chip-toggle input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- Timeline panel ---------- */
#timeline {
  position: absolute;
  left: 14px; right: 14px; bottom: 14px;
  z-index: 900;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px 16px 10px;
}
#timeline[hidden] { display: none; }
.timeline-head { display: flex; align-items: center; gap: 12px; }
.play-btn { width: 38px; height: 38px; background: var(--orange); font-size: 13px; }
.play-btn:hover { background: #F4825E; }
/* Stop markers sit in a row above the bar, weather icons below it. */
.slider-wrap { flex: 1; position: relative; height: 70px; }
.traffic-bar { position: absolute; left: 0; right: 0; top: 29px; height: 8px; border-radius: 4px; background: var(--unknown); border: 1.5px solid var(--line); }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 26px; }
.tk { position: absolute; top: 0; width: 22px; height: 22px; transform: translateX(-50%); border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; padding: 0; cursor: pointer; }
.tk::after { content: ""; position: absolute; top: 19px; left: 50%; width: 2px; height: 7px; transform: translateX(-50%); background: var(--line); }
.tk svg { width: 11px; height: 11px; fill: var(--paper); }
.tk:hover { transform: translateX(-50%) scale(1.15); z-index: 2; }
.tk.fuel { background: var(--fuel); }
.tk.fuel svg { fill: var(--ink); }
.tk.fuel.planned { background: var(--ink); }
.tk.fuel.planned svg { fill: var(--paper); }
.tk.food { background: var(--food); }
.tk.adjustable { cursor: ew-resize; touch-action: none; }
.tk.dragging { z-index: 3; }
.tk.dragging::before { content: attr(data-km); position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 1px 7px; border: 2px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 11px; font-weight: 800; white-space: nowrap; }
.tk.near { top: 5px; width: 16px; height: 16px; border-width: 1.5px; }
.tk.near::after { top: 13px; height: 8px; width: 1.5px; }
.tk.near svg { width: 9px; height: 9px; }
#slider { position: absolute; left: 0; right: 0; top: 19px; height: 28px; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
#slider::-webkit-slider-runnable-track { height: 28px; background: transparent; }
#slider::-moz-range-track { height: 28px; background: transparent; }
#slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: 2px; border-radius: 50%; background: var(--orange); border: 3px solid var(--ink); cursor: grab; }
#slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--orange); border: 3px solid var(--ink); cursor: grab; }
.weather-strip { position: absolute; left: 0; right: 0; top: 47px; height: 22px; }
.wx { position: absolute; top: 0; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px 1px 4px; border: 1.5px solid var(--hair); border-radius: 999px; background: var(--cream); color: var(--ink); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer; }
.wx:hover { border-color: var(--line); background: var(--peach); }
.wx-i { font-size: 13px; line-height: 1; }
.wx-pin { display: inline-flex; align-items: center; gap: 2px; padding: 2px 7px 2px 5px; background: var(--paper); border: 2px solid var(--line); border-radius: 999px; font: 800 12px/1.2 var(--font); color: var(--ink); white-space: nowrap; cursor: pointer; }
.wx-pin .wx-i { font-size: 15px; }
.pos-label { min-width: 104px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.4fr); gap: 10px; margin-top: 8px; }
.tcard { background: var(--cream); border-radius: 12px; padding: 9px 12px; min-width: 0; }
.tcard .big { font-size: 15.5px; font-weight: 800; overflow-wrap: anywhere; }
.tcard .sub { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.fuel-gauge { height: 8px; border-radius: 4px; background: #fff; border: 1.5px solid var(--line); overflow: hidden; margin: 3px 0 5px; }
#c-fuel-bar { height: 100%; width: 100%; background: var(--teal); transition: width .1s; }
.nearby { list-style: none; padding: 0; margin: 0; font-size: 12px; max-height: 92px; overflow-y: auto; }
.nearby li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
.nearby li:hover .nm { color: var(--orange-d); }
.nearby .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.nearby .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; border: 1.5px solid var(--line); }
.nearby .k.fuel { background: var(--fuel); }
.nearby .k.food { background: var(--food); }
.nearby .d { color: var(--ink-2); flex-shrink: 0; }
.nearby .add-btn { border: 2px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 800; font-size: 12px; line-height: 1; width: 20px; height: 20px; border-radius: 50%; padding: 0; flex-shrink: 0; }
.nearby .add-btn:hover { background: var(--orange); }
.nearby .on-route { color: var(--teal-d); font-weight: 800; padding: 0 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 7px; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.sw { display: inline-block; width: 14px; height: 6px; border-radius: 3px; margin-right: 5px; vertical-align: middle; border: 1px solid var(--line); }
.sw.light { background: var(--light); }
.sw.moderate { background: var(--moderate); }
.sw.heavy { background: var(--heavy); }
.attest { margin-left: auto; }
.lvl-light { color: var(--light); }
.lvl-moderate { color: #B07A06; }
.lvl-heavy { color: var(--heavy); }

/* Toasts */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--paper); border: 2px solid var(--line); padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; box-shadow: 3px 3px 0 var(--orange); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; }
.toast::before { content: "✓ "; color: var(--orange); font-weight: 800; }
.toast.show { opacity: 1; transform: none; }

/* Help */
.help { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border: 2px solid var(--line); border-radius: 18px; padding: 0; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
/* The dialog stays inside the screen and scrolls by itself; the title with the close button stays put. */
.help-body { padding: 0 20px 8px; }
.help::backdrop { background: rgba(23,48,58,.45); }
.help-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 8px; background: var(--paper); }
.help-head h2 { font-size: 20px; font-weight: 800; margin: 0; }
.help-steps { margin: 0; padding-left: 20px; }
.help-steps li { margin: 0 0 10px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.help-steps li::marker { color: var(--orange-d); font-weight: 800; }
.help-steps b { color: var(--ink); }

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcard.wide { grid-column: span 2; }
}

/* ---------- Small screens: slider details open from one line ---------- */
.tl-more { display: none; }
@media (max-width: 1024px), (max-height: 500px) {
  .tl-more { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; margin-top: 2px; padding: 2px 2px; border: 0; background: none; color: var(--ink); text-align: left; font-size: 12.5px; font-weight: 700; }
  .tl-mini { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tl-more svg { flex: none; width: 15px; height: 15px; transition: transform .18s ease; }
  #timeline.open .tl-more svg { transform: rotate(180deg); }
  #timeline:not(.open) .cards, #timeline:not(.open) .legend { display: none; }
  #timeline { padding: 8px 10px 4px; }
  #timeline.open { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); overflow-y: auto; overscroll-behavior: contain; }
  .slider-wrap { height: 66px; }
  .timeline-head { gap: 8px; }
  .play-btn { width: 34px; height: 34px; }
  .pos-label { min-width: 0; font-size: 12px; }
}

/* ---------- Phones: the map fills the screen, the panel is a bottom sheet ----------
   The class comes from layout.js. */
html.sheet-mode body { display: block; overflow: hidden; }
html.sheet-mode #map-wrap { position: fixed; inset: 0; }
html.sheet-mode #sidebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  width: auto; height: 58vh; height: 58dvh;
  border-right: 0; border-top: 2px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 18px rgba(23,48,58,.18);
  transition: height .24s cubic-bezier(.2,.8,.3,1);
  padding-bottom: env(safe-area-inset-bottom);
}
html.sheet-mode #sidebar.dragging { transition: none; }
html.sheet-mode #sidebar.collapsed .tabs, html.sheet-mode #sidebar.collapsed .sidebar-body, html.sheet-mode #sidebar.collapsed .sidebar-action, html.sheet-mode #sidebar.collapsed .sidebar-foot { display: none; }

html.sheet-mode .sheet-handle { display: grid; place-items: center; width: 100%; height: 18px; border: 0; background: none; padding: 0; flex-shrink: 0; touch-action: none; cursor: grab; }
html.sheet-mode .sheet-handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--ink-3); }
html.sheet-mode .brand { padding: 0 14px 8px; gap: 8px; touch-action: none; min-height: 40px; }
html.sheet-mode .brand h1 { font-size: 16px; }
html.sheet-mode .logo { width: 28px; height: 28px; }
html.sheet-mode .tagline { display: none; }
html.sheet-mode .brand-sum:not([hidden]) { display: block; margin: 1px 0 0; font-size: 11.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.sheet-mode .logo-title, html.sheet-mode .logo-title > div { min-width: 0; }
html.sheet-mode .brand-tools { gap: 6px; flex: none; }
html.sheet-mode .brand-tools .icon-btn { width: 34px; height: 34px; }
html.sheet-mode .wp-drag { width: 36px; height: 40px; }

/* The Trip tab has nothing to show until there is a route. */
html.sheet-mode body:not(.has-route) .tabs { display: none; }
html.sheet-mode .tabs { margin: 0 14px; padding: 3px; flex-shrink: 0; }
html.sheet-mode .tab { padding: 6px 10px; }
html.sheet-mode .sidebar-body { padding: 10px 14px 6px; overscroll-behavior: contain; }
html.sheet-mode .sidebar-body .card { padding: 12px; margin-bottom: 10px; }
html.sheet-mode .card-title { font-size: 15px; margin-bottom: 6px; }
html.sheet-mode #pane-plan .hint[data-i18n="wp.hint"] { display: none; }
html.sheet-mode .sidebar-action { padding: 8px 14px; border-top-width: 1.5px; }
html.sheet-mode .sidebar-action .btn { padding: 11px 16px; }
/* Keeps "Pick stops" within reach while the list of routes scrolls. */
html.sheet-mode .pick-stops { position: sticky; bottom: 0; z-index: 1; }

/* A slim bar, so the panel stays about the ride; the data credits sit under it at full height. */
html.sheet-mode .sidebar-foot { padding: 0; flex-shrink: 0; }
html.sheet-mode .powered { margin: 0; padding: 6px 12px; border-width: 0; border-top: 2px solid var(--line); border-radius: 0; box-shadow: none; font-size: 12.5px; }
html.sheet-mode .credits { display: none; padding: 4px 14px 6px; font-size: 10.5px; }
html.sheet-mode #sidebar[data-sheet="full"] .credits { display: block; }

html.sheet-mode input[type=text], html.sheet-mode input[type=number], html.sheet-mode input[type=datetime-local] { font-size: 16px; } /* no zoom-on-focus in iOS */

html.sheet-mode .stats { gap: 6px; }
html.sheet-mode .export { gap: 6px; }
html.sheet-mode .export .btn { padding: 9px 12px; font-size: 13px; }

html.sheet-mode .leaflet-control-zoom { display: none; }
/* The sheet covers the map's bottom edge, so the credits move up under the chips. */
html.sheet-mode .leaflet-bottom.leaflet-right { bottom: auto; top: calc(50px + env(safe-area-inset-top)); }
html.sheet-mode .leaflet-control-attribution { font-size: 9px; border-radius: 6px 0 0 6px; opacity: .8; }

html.sheet-mode .map-chips { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; max-width: none; gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding: 0 3px 4px 0; scrollbar-width: none; }
html.sheet-mode .map-chips::-webkit-scrollbar { display: none; }
html.sheet-mode .chip-toggle span { padding: 5px 10px 5px 8px; font-size: 12px; white-space: nowrap; }

html.sheet-mode #timeline { left: 6px; right: 6px; bottom: calc(66px + env(safe-area-inset-bottom)); border-radius: 16px; box-shadow: var(--shadow-sm); }
html.sheet-mode .cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin-top: 4px; padding-bottom: 4px; scrollbar-width: none; }
html.sheet-mode .tcard { flex: 0 0 76%; scroll-snap-align: start; padding: 7px 10px; }
html.sheet-mode .tcard.wide { grid-column: auto; }
html.sheet-mode .tcard .big { font-size: 14.5px; }
html.sheet-mode .legend { display: none !important; }
html.sheet-mode #toasts { bottom: calc(70px + env(safe-area-inset-bottom)); }
html.sheet-mode body.has-route #toasts { bottom: auto; top: calc(56px + env(safe-area-inset-top)); }


/* Very narrow phones: the map toggles lose their words, the language switch shrinks. */
@media (max-width: 359px) {
  html.sheet-mode .chip-toggle b { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  html.sheet-mode .chip-toggle span { padding: 6px 9px; }
  html.sheet-mode .lang-switch button { padding-left: 6px; padding-right: 6px; }
  html.sheet-mode .brand h1 { font-size: 14.5px; }
}

/* Phones held sideways: the sheet docks on the left, beside the map. */
html.sideways #sidebar { right: auto; width: min(340px, 46vw); border-right: 2px solid var(--line); border-radius: 0 16px 0 0; }
html.sideways .sidebar-action .btn { padding: 8px 14px; }
html.sideways #timeline { bottom: calc(6px + env(safe-area-inset-bottom)); left: calc(min(340px, 46vw) + 6px); }
html.sideways #toasts { left: 73%; }
html.sideways .tcard { flex-basis: 58%; }


/* About dialog */
.about-photo { display: block; width: 100%; height: auto; border-radius: 12px; border: 2px solid var(--line); margin: 4px 0 12px; }
.about-text { margin: 0 0 10px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
#about-btn { color: var(--orange-d); }
