/* Pub S.A.M. Colours and type agreed from the mock-up (spec section 7). */
:root {
  --bg: #12201B; --surface: #1B2D26; --surface2: #24392F; --line: #33493F;
  --text: #F3EFE4; --muted: #A9B5AE; --accent: #F2A93B; --on-accent: #1A1206;
  --live: #8FD3A8; --warn-bg: #3A2E14; --warn: #FFD78A; --done: #7D8A83;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 16px/1.4 Geist, system-ui, -apple-system, Segoe UI, sans-serif;
  display: grid; grid-template-rows: auto minmax(200px, 36vh) 1fr auto; min-height: 100dvh;
}
body[data-view="night"] { grid-template-rows: auto 0 1fr auto; }
h1, .brand b { font-weight: 600; letter-spacing: -0.035em; margin: 0; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; min-height: 56px; }
.logo { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: flex; flex-direction: column; }
.brand b { font-size: 19px; }
.brand span { font-size: 11px; color: var(--muted); }
.top .ghost { margin-left: auto; }

#map { background: #1A2A24; z-index: 0; position: relative; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.8) contrast(0.9) saturate(0.5); }
.leaflet-container { font: inherit; background: #1A2A24; }
.leaflet-control-attribution { display: none; }
.pin { background: var(--accent); color: var(--on-accent); border: 2px solid var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.pin.end { background: var(--text); color: var(--bg); border-radius: 7px; font-size: 11px; }
.pin.done { background: var(--done); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }

#sheet { background: var(--surface); border-radius: 20px 20px 0 0; margin-top: -18px; position: relative; z-index: 1; padding: 20px 18px 16px; display: flex; flex-direction: column; }
body[data-view="night"] #sheet { background: var(--bg); margin-top: 0; }
.view { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.field { display: flex; flex-direction: column; gap: 8px; }
.inline, .field.inline { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.row { display: flex; gap: 8px; }
.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; }

input:not([type=checkbox]) { height: 48px; width: 100%; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); padding: 0 14px; font-size: 16px; }
input::placeholder { color: #8A9891; }
.search { position: relative; flex: 1; min-width: 0; }
.results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1000; list-style: none; margin: 0; padding: 4px; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r); max-height: 300px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.results li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.results li b { display: block; color: var(--text); font-size: 15px; }
.results li:hover, .results li:focus, .results li[aria-selected="true"] { background: var(--line); outline: none; }
.results li.empty { cursor: default; }
.tag { font-size: 11px; font-weight: 600; color: var(--on-accent); background: var(--accent); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 2px; }

.icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .icon { width: 44px; height: 44px; }
.stepper output { width: 36px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: -0.035em; }

.units { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.units button { height: 36px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.units button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 56px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); padding: 6px 4px; }
.seg button b { display: block; font-weight: 600; font-size: 15px; }
.seg button small { display: block; font-size: 12px; opacity: .8; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.seg.dim button[aria-pressed="true"] { background: var(--bg); border-color: var(--accent); color: var(--text); }

.more summary { cursor: pointer; color: var(--muted); font-size: 14px; text-decoration: underline; padding: 4px 0; }
.more[open] { display: flex; flex-direction: column; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.primary, .secondary, .button { height: 56px; border-radius: 14px; font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.primary { border: 0; background: var(--accent); color: var(--on-accent); }
.primary:disabled { opacity: .6; cursor: wait; }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; height: 44px; padding: 0 14px; font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 14px; min-height: 44px; }
.big { height: 60px; font-size: 18px; }
#plan .primary { margin-top: auto; }
#status { margin: 0; font-size: 14px; color: var(--muted); min-height: 1em; }
#status.error { color: var(--warn); }

.summary p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.summary h1 { font-size: 24px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: var(--r); padding: 10px 12px; font-size: 14px; }
#stops { list-style: none; margin: 0; padding: 0; }
.stop { display: flex; gap: 12px; align-items: center; min-height: 52px; cursor: pointer; }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.num.end { border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12px; }
.stop b { display: block; font-size: 16px; font-weight: 600; }
.stop div > span { display: block; font-size: 13px; color: var(--muted); }
.leg { display: flex; align-items: center; gap: 15px; min-height: 32px; padding-left: 13px; }
.leg::before { content: ""; width: 2px; height: 26px; background: var(--line); }
.leg a { font-size: 13px; }
.actions { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px 0 4px; background: var(--surface); border-top: 1px solid var(--line); margin-top: auto; }

.bar { display: flex; gap: 4px; }
.bar span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.bar span.on { background: var(--accent); }
.card { border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.card.here { background: var(--surface); }
.card.here h1 { font-size: 30px; line-height: 1.1; }
.card.next { border: 1px solid var(--line); gap: 8px; }
.card.next b { font-size: 20px; }
.card .button { height: 48px; font-size: 15px; margin-top: 4px; }
#night .big { margin-top: auto; }

.credit { font-size: 11px; color: var(--muted); text-align: center; padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); }
body[data-view="night"] .credit { background: var(--bg); }
.credit a { color: var(--muted); }

/* Wider screens: the sheet becomes a side panel next to the map. */
@media (min-width: 900px) {
  body, body[data-view="night"] { grid-template-columns: 420px 1fr; grid-template-rows: auto 1fr auto; }
  .top { grid-column: 1; }
  #map { grid-column: 2; grid-row: 1 / 4; }
  #sheet { grid-column: 1; grid-row: 2; margin-top: 0; border-radius: 0; overflow-y: auto; }
  .credit { grid-column: 1; }
}

.hint { margin: 0; font-size: 13px; color: var(--muted); }
body[data-view=plan].tap-map #map { cursor: crosshair; }
body[data-view=plan].tap-map #map::after { content: "Tap to set your finish"; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 500; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; pointer-events: none; }

.timing { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.timing label { display: flex; flex-direction: column; gap: 8px; }
.timing input[type=time] { width: 130px; color-scheme: dark; }
#stay { width: 64px; font-size: 17px; }
.stop .eta { color: var(--text); font-weight: 600; }

/* Share page (/r/:id) */
.actions.two { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
a.ghost { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
