:root {
  --bg: #0e1116;
  --panel: #161b22;
  --card: #1c2330;
  --line: #2a3342;
  --text: #e8edf5;
  --muted: #8b96a8;
  --accent: #35d0a5;
  --accent2: #1a8f70;
  --danger: #ff6b6b;
  --amber: #ffc857;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--text); }
#app { display: flex; height: 100vh; }

#panel {
  width: 400px; min-width: 340px; overflow-y: auto; padding: 18px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
header h1 { font-size: 20px; letter-spacing: .3px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; position: relative; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; text-transform: uppercase; letter-spacing: .5px; }
label:first-child { margin-top: 0; }
:where(#app) select, :where(#app) input[type=text] {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #12171f; color: var(--text); font-size: 14px; outline: none;
}
:where(#app) select:focus, :where(#app) input[type=text]:focus { border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
:where(#app) input[type=number] { width: 90px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #12171f; color: var(--text); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }

.geo { position: relative; }
.results {
  position: absolute; z-index: 30; top: 100%; left: 0; right: 0; max-height: 220px; overflow-y: auto;
  background: #10151d; border: 1px solid var(--line); border-radius: 8px; display: none;
}
.results div { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #1a212c; }
.results div:hover { background: #1a2230; }
.results .picked { color: var(--accent); }

details.card summary { cursor: pointer; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
details.card[open] summary { margin-bottom: 6px; }
label.check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); margin-top: 10px; }
label.check input { width: auto; }
:where(#app) input[type=time] { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #12171f; color: var(--text); font-size: 14px; }

.planwarn { background: #2b2417; border: 1px solid var(--amber); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 12px; color: var(--amber); }
.planwarn div { padding: 2px 0; }
.stop .warnchip { font-size: 10px; background: #2b2417; color: var(--amber); border-radius: 20px; padding: 2px 8px; }
.stop .hubbadge { font-size: 10px; background: #0f2e26; color: var(--accent); border-radius: 20px; padding: 2px 8px; }
.stop .time { font-size: 12px; color: var(--accent); }

button.primary, a.primary {
  background: var(--accent); color: #04241b; font-weight: 700;
  border: none; padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
button.primary:disabled { opacity: .5; cursor: wait; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; margin-top: 6px; }
button.ghost:hover { color: var(--text); }
a.linkbtn { display: block; text-align: center; text-decoration: none; margin-top: 14px; }
a.linkbtn.ghost { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 10px;
  padding: 12px; font-weight: 600; margin-top: 8px; }
.navbtns a.linkbtn:first-child { margin-top: 14px; }

.error { background: #2b1a1a; border: 1px solid var(--danger); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 10px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; text-align: center; }
.stats b { display: block; font-size: 15px; color: var(--accent); }
.stats span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 14px 0 8px; }

.stop { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.stop .row1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.stop b { font-size: 14px; }
.badge { font-size: 11px; background: #0f2e26; color: var(--accent); border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
.stop .socline { margin-top: 6px; height: 8px; border-radius: 6px; background: #12171f; overflow: hidden; position: relative; }
.stop .socline .zone { position: absolute; top: 0; bottom: 0; background: rgba(53, 208, 165, .18); }
.stop .socline .fill { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 6px; }
.stop .meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.stop .conn { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stop .warn { color: var(--amber); }
.stop .chips { margin-top: 5px; display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font-size: 10px; background: #121a24; border: 1px solid var(--line); border-radius: 20px; padding: 2px 8px; color: var(--muted); }
.stop .backup { font-size: 12px; color: var(--muted); margin-top: 7px; background: #12171f; border-radius: 8px; padding: 6px 8px; }
.stop .backup .swp { font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: none; color: var(--accent); cursor: pointer; }
.sparsewarn { background: #2b2417; border: 1px solid var(--amber); color: var(--amber); padding: 8px 10px; border-radius: 10px; font-size: 12px; margin-bottom: 8px; }
button.ghost.wide { width: 100%; margin-top: 8px; padding: 9px; font-size: 13px; }
.savedhead { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; cursor: pointer; }
#tripList { margin-top: 8px; }
.trip { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-top: 1px solid var(--line); font-size: 13px; }
.trip .tname { flex: 1; cursor: pointer; }
.trip .tname:hover { color: var(--accent); }
.trip .troute { color: var(--muted); font-size: 11px; display: block; }
.trip button { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; }
.trip button:hover { color: var(--text); }
.trip button.del:hover { color: var(--danger); border-color: var(--danger); }
.stop .actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.stop .actions button { font-size: 11px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; }
.stop .actions button:hover { color: var(--text); border-color: var(--muted); }
.stop .actions button.avoid { color: var(--danger); }
.stop .actions button.lock { color: var(--amber); }
.stop .altlist { margin-top: 6px; font-size: 12px; color: var(--muted); display: none; }
.stop .altlist.show { display: block; }
.stop .altlist div { padding: 3px 0; cursor: pointer; }
.stop .altlist div:hover { color: var(--accent); }

#legs div { padding: 3px 0; border-bottom: 1px dashed #232c3b; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
footer.hint { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
footer.hint a { color: var(--accent); }

#map { flex: 1; }
.leaflet-container { background: #10151d; }

/* Phones/tablets: map first (not pinned - it would eat the screen), everything scrolls
   with the page, no nested scroll areas; one finger always scrolls the page and the
   map pans with two fingers (static/app.js). A floating button jumps back to the map. */
@media (max-width: 820px) {
  html, body { height: auto; overflow-x: clip; overscroll-behavior-x: none; }
  #app { flex-direction: column; height: auto; }
  #map { order: -1; flex: none; height: 38vh; min-height: 220px; position: relative;
         border-bottom: 1px solid var(--line); }
  #panel { width: 100%; min-width: 0; max-height: none; overflow: visible; border-right: none; }
}
.stop .booking { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #10251f;
  border: 1px solid #1f4d40; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.stop .booking .bwhen { color: var(--accent); font-weight: 600; }
.stop .booking .bidle { color: var(--amber); }
.stop .booking.none { background: none; border-style: dashed; color: var(--muted); }
.info { display: inline-block; margin-left: 4px; color: var(--accent); cursor: help; font-size: 12px;
  text-transform: none; letter-spacing: 0; }
[data-tip] { cursor: help; }
button[data-tip] { cursor: pointer; }
.tipbox { position: absolute; z-index: 5000; max-width: min(280px, calc(100vw - 16px)); padding: 8px 10px;
  border-radius: 8px; background: #0b1220; color: var(--text); border: 1px solid var(--accent2);
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.45); pointer-events: none;
  text-transform: none; letter-spacing: 0; font-weight: 400; }
.stats [data-tip] span { white-space: nowrap; }
.carpick { gap: 8px; } .carpick select { width: 100%; }

/* floating "back to map" button (phones, after planning) */
.mapfab { position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 5400;
  border: none; border-radius: 999px; padding: 11px 16px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #04241b; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.mapfab[hidden] { display: none; }
/* one-finger hint on the map (phones) */
.maphint { position: absolute; inset: 0; z-index: 800; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 14, .55); color: #fff; font-size: 15px; font-weight: 600; text-align: center; padding: 16px;
  pointer-events: none; opacity: 0; transition: opacity .2s; }
.maphint.show { opacity: 1; }

/* 📍 inside the From input */
.geo { position: relative; }
input.with-loc { padding-right: 42px; }
.locbtn { position: absolute; right: 4px; top: 4px; width: 34px; height: calc(100% - 8px); max-height: 34px;
  border: none; border-radius: 6px; background: #1c2330; cursor: pointer; font-size: 16px; line-height: 1; }
.locbtn:hover { background: #26303f; }
.previewlink { display: block; text-align: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
/* iOS Safari zooms into inputs with text < 16px: keep 16px on phones (no user-zoom lock) */
@media (max-width: 820px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ---------- multi-day ---------- */
.dayrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.dayrow label { margin: 0; flex: 1; }
.dayrow select { width: auto; min-width: 8rem; }
#dayOpts { margin-top: 8px; display: grid; gap: 6px; }
#dayOpts .dayopt { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
#dayOpts .dayopt input { width: auto; }
.splithint { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: rgba(255,200,87,.1); border: 1px solid rgba(255,200,87,.4); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.splithint button.ghost { margin: 0; color: var(--text); border-color: #ffc857; }
.daytabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.daytabs .multisum { flex-basis: 100%; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.daytab { flex: 1 1 6rem; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: 8px 10px; font-weight: 700; cursor: pointer; text-align: left; }
.daytab small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.daytab.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.nightcard { border: 1px dashed #7fb2ff; background: rgba(127,178,255,.08); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.nightcard > div { margin-top: 4px; }
.nightcard .hotels a { color: var(--accent); }
.stop.morning { border-left: 3px solid #ffc857; }
