:root {
  --bg: #0E1512;
  --surface: #18231D;
  --surface-2: #131D18;
  --line: #263329;
  --line-strong: #4A5D52;
  --text: #EAF2EC;
  --text-soft: #C9D8CE;
  --muted: #9DB3A5;
  --accent: #3DDC84;
  --on-accent: #052E16;
  --accent-dim: #12301F;
  --warn: #FACC15;
  --warn-dim: #2A2414;
  --danger: #FCA5A5;
  --danger-dim: #2A1818;
  --star: #FACC15;
  --nav-h: 68px;
  font-family: 'Noto Sans Lao', 'Noto Sans Thai', system-ui, sans-serif;
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { margin: 0; font-size: 26px; line-height: 1.3; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- app frame (phone-width column, centred on desktop) ---------- */
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; position: relative; }
.page { padding: calc(env(safe-area-inset-top) + 20px) 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 18px; }
.page.no-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 22px; flex: 1; }
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 900;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-top: 1px solid var(--line);
}
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; }
.nav a.active { color: var(--accent); font-weight: 700; }

/* ---------- controls ---------- */
.btn {
  min-height: 52px; padding: 0 18px; border-radius: 16px; border: 1.5px solid var(--line-strong); background: transparent;
  color: var(--text); font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 18px; min-height: 60px; border-radius: 20px; }
.btn.block { width: 100%; }
.btn.danger { border-color: #5C2626; color: var(--danger); }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.input {
  width: 100%; min-height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 12px 14px; font-size: 16px;
}
.input::placeholder { color: #7F978A; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea.input { min-height: 72px; resize: vertical; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button {
  min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; line-height: 1.25;
}
.seg button .sub { font-size: 12px; color: var(--muted); }
.seg button[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-dim); color: var(--accent); font-weight: 700; }
.seg button[aria-pressed="true"] .sub { color: var(--text-soft); }
.svc { min-height: 88px !important; gap: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--accent-dim); color: var(--accent); }
.pill.yellow { background: var(--warn-dim); color: var(--warn); }
.pill.red { background: var(--danger-dim); color: var(--danger); }
.pill.grey { background: #1C2822; color: var(--text-soft); }
.label { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: -6px; }

/* route card: pickup → dropoff */
.route { padding: 4px 16px; }
.stop { display: flex; align-items: center; gap: 12px; padding: 12px 0; width: 100%; background: none; border: none; text-align: left; cursor: pointer; color: var(--text); }
.stop + .stop { border-top: 1px solid var(--line); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 0 4px rgba(61,220,132,.18); }
.dot.sq { border-radius: 4px; background: var(--text); box-shadow: 0 0 0 4px rgba(234,242,236,.12); }
.stop .cap { font-size: 13px; color: var(--muted); }
.stop .val { font-size: 16px; font-weight: 600; }
.stop .val.empty { color: #7F978A; font-weight: 400; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.toggle-row { display: flex; align-items: center; gap: 12px; }
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; border-radius: 999px; border: none; padding: 0; background: var(--line-strong); cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 25px; background: var(--on-accent); }

/* sticky price/submit bar on the order form */
.submit-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 5;
  background: rgba(14, 21, 18, .94); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 22px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.price-line { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.price-line .fee { font-size: 20px; font-weight: 700; }

/* active order banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--accent-dim); border: 1px solid #1F5236; color: var(--text); text-decoration: none; cursor: pointer; width: 100%; text-align: left; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.6); } 70% { box-shadow: 0 0 0 12px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }

/* ---------- map ---------- */
.map { background: #131D18; }
.leaflet-container { background: #131D18; font: inherit; }
.leaflet-tile-pane { filter: brightness(.72) contrast(1.08) saturate(.7) hue-rotate(-8deg); }
.leaflet-control-attribution { background: rgba(14,21,18,.7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-control-zoom { display: none; }
.mk { display: grid; place-items: center; }
.mk-pick { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.mk-drop { width: 20px; height: 20px; border-radius: 5px; background: #fff; border: 3px solid var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.mk-rider { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(61,220,132,.25); }

/* full-screen map picker */
.picker { position: fixed; inset: 0; z-index: 1000; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }
.picker .map { flex: 1; position: relative; }
.picker-top { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 12px; right: 12px; z-index: 600; display: flex; flex-direction: column; gap: 10px; }
.picker-top .chips .chip { background: rgba(24,35,29,.95); }
.center-pin { position: absolute; left: 50%; top: 50%; z-index: 500; transform: translate(-50%, -100%); pointer-events: none; display: flex; flex-direction: column; align-items: center; }
.center-pin .head { width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.5); display: grid; place-items: center; }
.center-pin .head::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--on-accent); }
.center-pin.drop .head { background: #fff; }
.center-pin.drop .head::after { background: var(--bg); border-radius: 2px; }
.center-pin .stem { width: 2px; height: 10px; background: #fff; margin-top: -2px; }
.locate { position: absolute; right: 12px; bottom: 14px; z-index: 600; }
.sheet { background: var(--bg); border-top: 1px solid var(--line); border-radius: 24px 24px 0 0; margin-top: -20px; position: relative; z-index: 700; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); display: flex; flex-direction: column; gap: 12px; }

/* order view */
.order-map { height: 38vh; min-height: 240px; position: relative; }
.order-map .back { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 12px; z-index: 600; }
.order-map .eta { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 68px; right: 12px; z-index: 600; background: rgba(24,35,29,.95); border-radius: 14px; padding: 8px 14px; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.order-body { padding: 20px 18px calc(env(safe-area-inset-bottom) + 28px); display: flex; flex-direction: column; gap: 16px; margin-top: -20px; position: relative; z-index: 650; background: var(--bg); border-radius: 24px 24px 0 0; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.steps div { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.steps div::before { content: ''; height: 6px; border-radius: 3px; background: var(--line); }
.steps div.done { color: var(--accent); }
.steps div.done::before, .steps div.now::before { background: var(--accent); }
.steps div.now { color: var(--text); font-weight: 700; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-dim); border: 2px solid var(--accent); color: var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 700; flex-shrink: 0; }
.radar { position: absolute; left: 50%; top: 50%; z-index: 550; pointer-events: none; transform: translate(-50%, -50%); }
.radar span { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; border: 2px solid var(--accent); animation: radar 2.4s ease-out infinite; opacity: 0; }
.radar span:nth-child(2) { animation-delay: .8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }
@keyframes radar { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(4.5); opacity: 0; } }
.success { width: 84px; height: 84px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; margin: 8px auto 0; box-shadow: 0 0 0 12px rgba(61,220,132,.15); }
.stars { display: flex; justify-content: center; gap: 4px; }
.stars button { width: 52px; height: 52px; border: none; background: none; cursor: pointer; color: var(--line-strong); display: grid; place-items: center; }
.stars button.on { color: var(--star); }
.proof { width: 100%; max-height: 300px; object-fit: cover; border-radius: 16px; display: block; }
.proof-ph { height: 140px; border-radius: 16px; border: 1.5px dashed var(--line-strong); display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 6px 0; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; }

/* history */
.order-item { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; width: 100%; }

/* login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px 22px; gap: 18px; }
.logo { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); display: grid; place-items: center; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%); z-index: 2000; background: var(--surface); border: 1px solid var(--line-strong); padding: 12px 18px; border-radius: 14px; max-width: calc(100vw - 32px); width: max-content; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast.error { border-color: #5C2626; color: var(--danger); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo { background: #1C2433; color: #93C5FD; padding: 8px 14px; border-radius: 12px; font-size: 13px; }
