:root {
  --teal: #0f5257;
  --teal-2: #13777e;
  --sun: #f2a541;
  --sun-2: #e08e1b;
  --ink: #1d2626;
  --muted: #66706f;
  --line: #e4e7e6;
  --bg: #ffffff;
  --soft: #f4f6f5;
  --ok: #1f8a4c;
  --danger: #c8372d;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(15, 40, 40, 0.18);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--soft); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; z-index: 0; }

/* Top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 600;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  background: var(--bg); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow);
  font-weight: 700; color: var(--teal); letter-spacing: .2px;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--bg);
  box-shadow: var(--shadow); font-size: 20px; cursor: pointer;
}
.conn { margin-left: auto; width: 12px; height: 12px; border-radius: 50%; background: #bbb; box-shadow: 0 0 0 3px #fff; }
.conn.on { background: var(--ok); }

/* Drawer */
#drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 82vw); z-index: 900;
  background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 0 16px;
}
#drawer button {
  text-align: left; padding: 14px 20px; background: none; border: 0; font-size: 16px; cursor: pointer;
}
#drawer button:hover { background: var(--soft); }
.drawer-head { padding: 8px 20px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.drawer-name { font-weight: 700; font-size: 18px; }
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 850; }

/* Floating buttons */
.fab {
  position: fixed; right: 14px; z-index: 600; border: 0; border-radius: 50%;
  width: 52px; height: 52px; box-shadow: var(--shadow); cursor: pointer; font-weight: 800;
}
.fab-locate { background: var(--bg); font-size: 22px; color: var(--teal); bottom: calc(var(--sheet-h, 45vh) + 14px); }
.fab-sos { background: var(--danger); color: #fff; top: calc(env(safe-area-inset-top, 0px) + 64px); font-size: 14px; }

/* Bottom sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 700;
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 10px 16px calc(16px + var(--safe-b));
}
.sheet::before {
  content: ''; display: block; width: 42px; height: 5px; border-radius: 3px;
  background: var(--line); margin: 0 auto 10px;
}
.sheet.full { top: 0; max-height: none; border-radius: 0; padding-top: calc(env(safe-area-inset-top, 0px) + 16px); }
.sheet.full::before { display: none; }
@media (min-width: 900px) {
  .sheet { left: 16px; right: auto; top: 76px; bottom: 16px; width: 420px; max-height: none; border-radius: var(--radius); }
  .sheet::before { display: none; }
  .sheet.full { left: 50%; transform: translateX(-50%); width: 480px; top: 16px; border-radius: var(--radius); }
  .fab-locate { bottom: 24px; }
}

h1, h2, h3 { margin: 6px 0 10px; line-height: 1.2; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.spacer { height: 10px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 16px; /* 16px stops iOS from zooming */
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal-2); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 700; font-size: 16px;
  background: var(--soft); color: var(--ink); text-decoration: none;
}
.btn.block { width: 100%; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.sun { background: var(--sun); color: #2b1a00; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.danger-text { color: var(--danger) !important; }

.tabs { display: flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 10px 6px; border: 0; border-radius: 9px; background: none; font-weight: 700; cursor: pointer; color: var(--muted); font-size: 14px; }
.tabs button.active { background: var(--bg); color: var(--teal); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* Cards */
.card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--bg); }
.card + .card { margin-top: 10px; }
.card.tap { cursor: pointer; transition: border-color .15s, transform .1s; }
.card.tap:hover { border-color: var(--teal-2); }
.card.tap:active { transform: scale(.99); }
.card.selected { border-color: var(--teal); background: #eef7f6; }
.card.highlight { border-color: var(--sun); background: #fff8ec; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-weight: 800; flex: none;
}
.avatar.sun { background: var(--sun); color: #2b1a00; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.sun { background: #fdeccc; color: #8a5300; }
.badge.danger { background: #fbe4e2; color: var(--danger); }
.dist { font-weight: 800; color: var(--teal); white-space: nowrap; }
.empty { text-align: center; padding: 24px 8px; color: var(--muted); }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd5d4; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(22px); }

.online-banner { border-radius: var(--radius); padding: 14px; color: #fff; background: #7b8584; display: flex; align-items: center; gap: 12px; }
.online-banner.on { background: var(--ok); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.online-banner.on .pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.7); } 100% { box-shadow: 0 0 0 14px rgba(255,255,255,0); } }

/* Status stepper */
.steps { display: flex; gap: 4px; margin: 8px 0 12px; }
.steps div { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps div.done { background: var(--teal-2); }
.status-title { font-size: 18px; font-weight: 800; color: var(--teal); }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; padding: 8px; background: var(--soft); border-radius: 12px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; background: var(--bg); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--teal); color: #fff; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; text-align: center; padding: 2px 8px; }
.msg.fare, .msg.cost { border: 2px solid var(--sun); }
.msg.me.fare, .msg.me.cost { background: #fff8ec; color: var(--ink); }
.msg time { display: block; font-size: 10px; opacity: .6; margin-top: 2px; }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input input { flex: 1; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.quick button { flex: none; border: 1.5px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }

.money { font-variant-numeric: tabular-nums; font-weight: 800; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.stars button { background: none; border: 0; font-size: 32px; cursor: pointer; color: #d3d7d6; padding: 0 2px; }
.stars button.on { color: var(--sun); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }

/* Toast */
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 70px); transform: translateX(-50%) translateY(-20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 2000;
  opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* Map markers */
.mk { display: grid; place-items: center; border-radius: 50%; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.35); border: 3px solid #fff; }
.mk-me { background: #2f6fed; width: 22px !important; height: 22px !important; }
.mk-rider { background: var(--sun); }
.mk-rider.busy { background: #9aa3a2; }
.mk-rider.sel { background: var(--teal); transform: scale(1.2); }
.mk-drop { background: var(--danger); }
.mk-req { background: #8e44ad; }
.leaflet-container { font: inherit; }

/* Auth */
.auth-hero { text-align: center; padding: 6px 0 4px; }
.auth-hero .big { font-size: 46px; }
.auth-hero h1 { color: var(--teal); margin: 4px 0; }

/* Landing page – artwork: /landing.webp (+ /landing.jpg fallback) */
:root { --reu-blue: #0047bc; --reu-blue-dark: #00308f; --reu-yellow: #ffc20e; }
#landing { position: fixed; inset: 0; z-index: 1500; color: #fff; overflow: hidden; background: var(--reu-blue); }
.landing-bg {
  position: absolute; inset: 0;
  background-color: var(--reu-blue);
  background-image: url('/landing.jpg');
  background-image: image-set(url('/landing.webp') type('image/webp'), url('/landing.jpg') type('image/jpeg'));
  background-size: cover; background-position: center top; background-repeat: no-repeat;
}
.landing-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,20,70,.25) 0%, rgba(0,0,0,0) 14%, rgba(0,0,0,0) 60%, rgba(0,35,120,.35) 100%); }
.landing-content {
  position: relative; height: 100%; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 22px calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-width: 560px; margin: 0 auto;
}
.landing-brand { align-self: flex-start; background: #fff; color: var(--reu-blue); font-weight: 800; padding: 8px 16px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,30,90,.3); font-size: 18px; }
.landing-bottom h1 { font-size: clamp(26px, 7.2vw, 40px); line-height: 1.1; margin: 0 0 8px; letter-spacing: -.3px; }
.landing-bottom h1 em { font-style: normal; color: var(--reu-yellow); }
.landing-bottom p { margin: 0 0 14px; font-size: 16px; opacity: .95; }
.landing-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.landing-chips span { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); padding: 5px 10px; border-radius: 999px; font-size: 13px; }
#landing .btn.sun { background: var(--reu-yellow); color: #10224d; box-shadow: 0 8px 24px rgba(255,194,14,.35); }
.landing-login { margin-top: 10px; color: #fff; border-color: rgba(255,255,255,.6) !important; }
/* Phones: keep the text in the blue panel below the yellow wave; chips only where there is room */
@media (max-width: 899px) { .landing-chips { display: none; } }
@media (max-width: 899px) { .landing-bottom h1 { font-size: clamp(24px, 6.6vw, 34px); } }
/* Wide screens: portrait artwork on the right, text on the left */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .landing-bg {
    background-image: url('/landing.jpg'), linear-gradient(110deg, var(--reu-blue-dark), var(--reu-blue));
    background-image: image-set(url('/landing.webp') type('image/webp'), url('/landing.jpg') type('image/jpeg')), linear-gradient(110deg, var(--reu-blue-dark), var(--reu-blue));
    background-size: auto 100%, cover; background-position: right center, center;
  }
  .landing-shade { background: linear-gradient(90deg, rgba(0,30,110,.0) 0%, rgba(0,30,110,0) 55%, rgba(0,40,140,.0) 100%); }
  .landing-content { max-width: none; margin: 0; width: min(560px, 48vw); padding-left: 6vw; justify-content: center; gap: 40px; }
  
}

/* SVG icons (icons.js) */
.i { width: 1.15em; height: 1.15em; vertical-align: -0.2em; display: inline-block; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i .fill, .i-star path { fill: currentColor; stroke: none; }
.i-star { color: var(--sun); }
.stars .i-star { color: inherit; width: 34px; height: 34px; }
.btn .i, .tabs .i, #drawer .i { margin-right: 2px; }
#drawer button { display: flex; align-items: center; gap: 12px; }
#drawer .i { width: 20px; height: 20px; color: var(--teal); }
#drawer .danger-text .i { color: var(--danger); }
.icon-btn .i, .fab .i { width: 22px; height: 22px; vertical-align: middle; }
.mk { color: #fff; }
.mk .i { width: 58%; height: 58%; stroke-width: 2.4; }
.mk-me .i { display: none; }
.badge .i { width: 1.1em; height: 1.1em; vertical-align: -0.22em; }

/* Logo */
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; }
.brand-logo { width: 34px; height: 34px; }
.auth-logo { width: 120px; height: 120px; object-fit: contain; }

/* Landing: logo, name, one-line tagline */
.landing-logo img { display: block; width: clamp(92px, 26vw, 150px); height: auto; filter: drop-shadow(0 6px 16px rgba(0, 30, 90, .35)); }
.landing-name { font-size: clamp(38px, 12vw, 72px) !important; font-weight: 900; font-style: italic; letter-spacing: 1px; line-height: 1 !important; margin: 0 0 6px !important; text-shadow: 0 3px 0 #00256f, 0 6px 18px rgba(0,0,0,.25); }
.landing-name span { color: var(--reu-yellow); }
.landing-tagline { white-space: nowrap; font-weight: 700; margin: 0 0 10px !important; opacity: 1 !important;
  font-size: min(calc((100vw - 44px) / 19), 30px) !important; letter-spacing: .1px; }
.landing-sub { font-size: 15px !important; }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .landing-content { width: min(680px, 52vw); }
  .landing-logo { position: static; }
  .landing-logo img { width: 170px; }
  .landing-tagline { font-size: clamp(18px, 1.95vw, 30px) !important; }
}

/* Commuter area selector */
.area-bar { display: grid; grid-template-columns: 1fr 1fr 1.25fr auto; gap: 6px; margin-bottom: 10px; align-items: center; }
.area-bar select { padding: 9px 8px; font-size: 14px; border-radius: 10px; min-width: 0; }
.area-bar .btn { padding: 8px 10px; height: 100%; }
@media (max-width: 360px) { .area-bar { grid-template-columns: 1fr 1fr; } .area-bar #arMuni { grid-column: 1; } }
