/* Kemet-Tron UI — tokens follow Visual_Direction brief: calm, map-first, gold only for the primary action. */
:root {
  --bg: #0c0d0f; --surface: #17191c; --raised: #202328; --line: #2f3338;
  --text: #efe6d3; --muted: #aeb2b8; --gold: #d9a441; --gold-ink: #0c0d0f;
  --green: #63c394; --red: #e56b64; --radius: 14px;
  --display: "Marcellus", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h2 { font: 400 24px/1.2 var(--display); margin: 0 0 4px; color: var(--text); }
h3 { font: 600 15px var(--sans); margin: 18px 0 8px; color: var(--text); }
.sub, .meta { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
a { color: var(--gold); }

/* Controls */
button, .btn { display: block; width: 100%; min-height: 54px; padding: 14px 16px; margin-top: 12px;
  background: var(--gold); color: var(--gold-ink); border: 0; border-radius: var(--radius);
  font: 700 16px var(--sans); cursor: pointer; text-align: center; text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border: 1px solid #5a5f66; min-height: 48px; font-weight: 600; }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button.link { background: none; border: 0; color: var(--gold); width: auto; min-height: 48px; padding: 0; margin: 0;
  text-decoration: underline; font-weight: 600; display: inline-block; }
button:disabled { background: #3a3d42; color: #8b8f95; border-color: transparent; cursor: default; }
input, select { width: 100%; min-height: 50px; padding: 12px 14px; margin-top: 6px; border-radius: 12px;
  border: 1px solid #4a4f56; background: var(--bg); color: var(--text); font: 16px var(--sans); }
select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23efe6d3' stroke-width='2'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
input[type="date"], input[type="time"] { color-scheme: dark; }
input[type="checkbox"] { min-height: 0; accent-color: var(--gold); }
label { display: block; margin-top: 14px; color: var(--text); font-size: 14px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Shared pieces */
.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.sel { border-left: 4px solid var(--gold); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.booked, .badge.forming { color: var(--gold); border-color: var(--gold); }
.badge.active, .badge.en_route, .badge.boarded, .badge.completed { color: var(--green); border-color: var(--green); }
.badge.no_show, .badge.cancelled { color: var(--red); border-color: var(--red); }
.status-line { padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; margin-top: 10px; }
.status-line.ok { color: var(--green); border-color: #2c5a45; }
.status-line.err { color: var(--red); border-color: #6b3330; }
.notice { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #6b7078; margin-right: 8px; }
.dot.on { background: var(--green); } .dot.warn { background: var(--red); }
.rider-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.rider-row:last-child { border-bottom: 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns > * { flex: 1 1 110px; margin-top: 10px; min-height: 48px; padding: 10px 8px; font-size: 15px; }
.num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--gold); color: var(--gold); font-weight: 700; font-size: 14px; margin-right: 10px; flex: none; }
.fare { font-size: 18px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.fare small { color: var(--muted); font-size: 13px; font-weight: 400; }
.seg { display: flex; border-bottom: 1px solid var(--line); margin: 12px 0 14px; }
.seg button { flex: 1; background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  margin: 0; min-height: 48px; font-weight: 600; }
.seg button.on { color: var(--text); border-bottom-color: var(--gold); }
.back { background: none; border: 0; color: var(--text); width: 48px; min-height: 48px; padding: 0; margin: -8px 0 0 -12px; }

/* ---------- App shell (rider + driver) ---------- */
body.shell { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; flex: none; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; }
.top svg { width: 20px; height: 30px; color: var(--gold); flex: none; }
.top h1 { font: 400 19px var(--display); letter-spacing: .08em; margin: 0; white-space: nowrap; }
.top .role { color: var(--muted); font-size: 13px; }
.pill { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--raised); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.map-pane { position: relative; flex: 0 0 34%; min-height: 140px; background: #101214; }
.map-pane > .map { position: absolute; inset: 0; }
.fab { position: absolute; right: 12px; bottom: 32px; z-index: 500; width: 48px; min-height: 48px; height: 48px; padding: 0; margin: 0;
  border-radius: 50%; background: var(--surface); color: var(--text); border: 1px solid #5a5f66; display: flex; align-items: center; justify-content: center; }
.fab svg { width: 22px; height: 22px; }
.map-chip { position: absolute; left: 12px; bottom: 32px; z-index: 500; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; color: var(--text); max-width: calc(100% - 84px); }
.panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); position: relative; z-index: 600;
  border-radius: 24px 24px 0 0; margin-top: -20px; border-top: 1px solid var(--line); padding: 20px 16px 20px; }
.stage.no-map .map-pane { display: none; }
.stage.no-map .panel { margin-top: 0; border-radius: 0; border-top: 0; }
nav.tabs { flex: none; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; background: none; color: var(--muted); border: 0; border-radius: 0; margin: 0; min-height: 56px; padding: 6px 4px;
  font: 600 12px var(--sans); display: flex; flex-direction: column; align-items: center; gap: 3px; border-top: 3px solid transparent; }
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.on { color: var(--gold); border-top-color: var(--gold); }

/* Map: darken the OpenStreetMap tiles to sit in the palette; keep attribution readable */
.map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.95) contrast(.88); }
.map.leaflet-container { background: #101214; font: 12px var(--sans); }
.leaflet-control-attribution { background: rgba(12,13,15,.75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.pin svg { width: 34px; height: 42px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.pin-num { width: 30px; height: 30px; border-radius: 50%; background: var(--bg); border: 2px solid var(--gold); color: var(--gold);
  font: 700 14px var(--sans); display: flex; align-items: center; justify-content: center; }
.car-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--text); border: 4px solid var(--gold); box-shadow: 0 0 0 4px rgba(217,164,65,.25); }

/* Unfolded Fold / tablets: persistent map left, task panel right */
@media (min-width: 600px) {
  .stage { flex-direction: row; }
  .map-pane, .stage.no-map .map-pane { display: block; flex: 1 1 50%; min-width: 0; }
  .panel, .stage.no-map .panel { flex: 1 1 50%; min-width: 0; margin: 0; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); padding: 24px 20px; }
  .stage.login .map-pane { display: none; }
  .stage.login .panel { max-width: 460px; margin: 0 auto; border-left: 0; background: var(--bg); }
  .fab, .map-chip { bottom: 16px; }
  .top h1 { font-size: 22px; }
}

/* ---------- Dispatch page (simple scrolling layout) ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 40px; }
header.brand { display: flex; align-items: baseline; gap: 10px; padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
header.brand h1 { font: 400 22px var(--display); letter-spacing: .08em; margin: 0; }
header.brand .sub { font-size: 13px; }
.wrap h2 { font-size: 20px; margin: 4px 0 8px; }
#hub-map { height: 280px; border-radius: var(--radius); border: 1px solid var(--line); margin-top: 10px; }
@media (min-width: 680px) {
  .wrap { max-width: 940px; }
  .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .grid .card { margin-bottom: 0; }
  #login.card { max-width: 460px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .5 } }
}

/* Phone review: keep actions in flow so every field remains reachable. */
body.shell { width: 100%; min-width: 0; }
.shell .top, .shell .stage, .shell .panel, .shell section,
.shell .map-pane, .shell nav.tabs { min-width: 0; max-width: 100%; }
.top { flex-wrap: wrap; gap: 6px 10px; }
.top h1 { min-width: 0; font-size: 20px; letter-spacing: .03em; }
.panel { container-type: inline-size; }
.panel h2 { font-size: 24px; overflow-wrap: break-word; }
.panel .card, .panel strong, .panel .meta { overflow-wrap: anywhere; }
.kv > span:last-child { min-width: 0; }
.cta { position: static; margin: 16px 0 0; padding: 12px 0 4px;
  border-top: 1px solid var(--line); background: var(--surface); }
.cta button { margin-top: 0; }
.cta .notice { margin-top: 8px; }
@container (max-width: 380px) {
  .kv { flex-direction: column; align-items: stretch; gap: 3px; padding: 10px 0; }
  .kv > span:last-child { text-align: left; }
}
@media (max-width: 599px) {
  .map-pane .leaflet-bottom { bottom: 20px; }
  .top { padding-left: 12px; padding-right: 12px; }
  .top h1 { font-size: 17px; letter-spacing: .02em; }
  .pill { font-size: 11px; padding: 4px 7px; }
  .panel h2 { font-size: 22px; }
}
/* Reserve attribution space instead of placing map actions over it. */
.fab, .map-chip { bottom: 58px; }
.leaflet-control-attribution { max-width: 100%; white-space: normal; }

/* Custom rides (Claude) — search results, saved places, ride progress, car marker */
.results { margin-top: 4px; }
.shell button.res, .shell button.place-row { display: flex; width: 100%; min-height: 56px; margin: 0; padding: 10px 2px; background: transparent;
  color: var(--text); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; font-weight: 400; }
.shell button.res { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.shell button.place-row { align-items: center; gap: 12px; }
button.res strong, button.place-row strong { font-weight: 600; font-size: 16px; }
button.res span, button.place-row span { color: var(--muted); font-size: 13px; }
button.place-row svg { width: 22px; height: 22px; color: var(--gold); flex: none; }
button.place-row > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.steps { display: flex; gap: 6px; margin: 2px 0 12px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--gold); }
.car { width: 34px; height: 34px; transition: transform .4s linear; }
.car svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.dest-pin { width: 18px; height: 18px; border-radius: 4px; background: var(--text); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--text); }
details.card > summary { cursor: pointer; font-weight: 600; min-height: 28px; }

/* Driver ride mode (Claude) — map fills the screen; details slide in from the right; floating controls */
.stage.riding { position: relative; display: block; overflow: hidden; }   /* clip the off-canvas panel so the page never widens */
.stage.riding .map-pane { position: absolute; inset: 0; display: block; min-height: 0; }
.stage.riding .panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(88%, 380px); margin: 0; z-index: 900;
  border-radius: 0; border-top: 0; border-left: 1px solid var(--line); padding: 16px 16px 24px;
  transform: translateX(105%); transition: transform .22s ease; }
.stage.riding.drawer-open .panel { transform: none; box-shadow: -10px 0 28px rgba(0, 0, 0, .55); }
.stage.riding .leaflet-bottom { bottom: 96px; }
.nav-banner { position: absolute; top: 10px; left: 10px; right: 70px; z-index: 800; display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
.nav-banner .dist { font: 700 20px var(--sans); color: var(--gold); white-space: nowrap; }
.nav-banner .dist:empty { display: none; }
.nav-banner .txt { font-weight: 600; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.nav-banner .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ride-fabs { position: absolute; right: 10px; top: 10px; z-index: 800; display: flex; flex-direction: column; gap: 10px; }
.shell .fab2 { width: 50px; height: 50px; min-height: 50px; padding: 0; margin: 0; border-radius: 50%; background: var(--surface); color: var(--text);
  border: 1px solid #5a5f66; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0, 0, 0, .45); }
.fab2 svg { width: 24px; height: 24px; }
.fab2.gold { color: var(--gold); border-color: var(--gold); }
.handoff { position: absolute; right: 70px; top: 70px; z-index: 850; width: min(260px, calc(100% - 90px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.handoff .btn { margin-top: 8px; min-height: 48px; }
.ride-bar { position: absolute; left: 10px; right: 10px; bottom: 12px; z-index: 800; }
.ride-bar button { margin: 0; min-height: 58px; font-size: 18px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
.nav-banner { flex-wrap: wrap; }
.nav-banner .prompt { flex: 1 1 100%; border-top: 1px solid var(--line); padding-top: 8px; color: var(--gold); font-weight: 600; }
.stage.riding .map { isolation: isolate; }
@media (min-width: 600px) { .stage.riding .panel { width: 360px; } .nav-banner { right: auto; width: min(430px, calc(100% - 90px)); } .ride-bar { left: auto; width: 320px; right: 76px; } }

/* ---------- Stop confirmation (Claude) ---------- */
.spot-card { border-color: var(--gold); }
.spot-map { height: 200px; border-radius: 12px; margin: 10px 0 0; overflow: hidden; isolation: isolate; }
.pin-num.here { background: var(--gold); border-color: var(--bg); box-shadow: 0 0 0 2px var(--gold); cursor: grab; }

/* ---------- Rider ride mode (Claude) — the driver's map-first layout, once the rider is in the car ---------- */
.stage.riding.rider .leaflet-bottom { bottom: 0; }
.stage.riding.rider .nav-banner .sub { white-space: normal; overflow-wrap: anywhere; }   /* the plate must never be cut off */
.stage.riding.rider .nav-banner .sub + .sub { margin-top: 2px; }

/* ---------- Test agreement (Claude) ---------- */
.agree-text h3 { margin: 18px 0 6px; font-size: 16px; }
.agree-text h3:first-child { margin-top: 0; }
.agree-text p, .agree-text li { font-size: 15px; line-height: 1.5; margin: 6px 0; }
.agree-text ul { padding-left: 20px; margin: 6px 0; }
.check { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 16px; }
.check input { width: 24px; height: 24px; flex: none; margin: 0; padding: 0; }
.stage.agreeing #panel > details { display: none; }   /* the Map choices box has no place on the agreement */

/* ---------- Sign-in PIN (Claude) ---------- */
.pin-gate { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.pin-gate .card { width: min(440px, 100%); margin: auto; }
.pin-gate button { margin-top: 16px; }

/* ---------- Ride request alarm (Claude): the frame flashes about once a second (well under three flashes a second); the card stays readable ---------- */
.ride-alarm { position: fixed; inset: 0; z-index: 2600; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 22px;
  background: #d9a441; color: #0c0d0f; animation: ra-flash .9s steps(1) infinite; }
@keyframes ra-flash { 0% { background: #d9a441; color: #0c0d0f; } 50% { background: #0c0d0f; color: #d9a441; } }
@media (prefers-reduced-motion: reduce) { .ride-alarm { animation: none; } }
.ra-top { font: 800 36px/1.1 var(--sans); letter-spacing: .04em; text-align: center; }
.ra-card { background: var(--surface); color: var(--text); border: 2px solid #0c0d0f; border-radius: 18px; padding: 20px; width: min(520px, 100%); margin: 0 auto; }
.ra-name { font: 700 24px/1.2 var(--sans); margin-bottom: 10px; }
.ra-line { font-size: 18px; font-weight: 600; margin: 8px 0; overflow-wrap: anywhere; }
.ra-line span { display: block; font-size: 13px; color: var(--muted); }
.ra-card button { min-height: 64px; font-size: 20px; margin-top: 14px; }
.ra-card button.ghost { min-height: 52px; font-size: 16px; }

/* ---------- Address move and install page (Claude) ---------- */
.moved-bar { display: block; flex: none; padding: 12px 16px; background: var(--gold); color: #0c0d0f; font-weight: 700; font-size: 15px; text-align: center; text-decoration: none; }
.install-steps { margin: 10px 0 0; padding-left: 0; list-style: none; counter-reset: st; }
.install-steps li { counter-increment: st; position: relative; padding: 10px 0 10px 46px; font-size: 17px; line-height: 1.4; border-bottom: 1px solid var(--line); }
.install-steps li:last-child { border-bottom: 0; }
.install-steps li::before { content: counter(st); position: absolute; left: 0; top: 8px; width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #0c0d0f; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.wait-text { white-space: pre-wrap; font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; }
