:root {
  --ink: #1b2421;
  --muted: #5e675f;
  --green: #12352c;
  --green-2: #1f6a56;
  --cream: #f4f0e6;
  --paper: #fbf8f2;
  --line: #e4dccb;
  --amber: #e07a1f;
  --red: #9d2c2c;
  --red-bg: #fdecec;
  --gold: #fff6df;
  --blue: #315f9b;
  --shadow: 0 10px 30px rgba(18, 53, 44, 0.08);
  font-family: "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(31, 106, 86, 0.18), transparent 32%),
    #d9d1c2;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-2); }

#toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: 12px;
  transform: translateX(-50%) translateY(-140%);
  max-width: min(92vw, 420px);
  background: var(--green);
  color: white;
  padding: 12px 14px;
  border-radius: 14px;
  transition: transform 0.2s ease;
}
#toast.show { transform: translateX(-50%) translateY(0); }

#app { min-height: 100dvh; }
.shell { max-width: 480px; min-height: 100dvh; margin: 0 auto; background: var(--cream); position: relative; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: var(--green);
  color: #f6f1e7;
}
.brand { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.who { opacity: 0.8; font-size: 13px; margin-top: 4px; }
.gps-pill { border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.gps-pill.on { background: #d9f3e4; color: #0d5a38; }
.gps-pill.off { background: #ffd9d4; color: #8d2018; }

.screen { padding: 16px 16px 108px; }
.nav {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: #fffaf3;
  border-top: 1px solid var(--line);
}
.nav button {
  border: 0;
  background: transparent;
  padding: 8px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.nav button.active { background: #e7f3ee; color: var(--green); }

h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 8px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.lead { font-size: 16px; color: var(--muted); }

.stack { display: grid; gap: 12px; }
.card, .choice {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 14px; }
.choice {
  width: 100%;
  text-align: left;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.choice strong { display: block; font-size: 18px; }
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #e7f3ee;
  color: var(--green);
  font-weight: 800;
  flex: 0 0 auto;
}

.btn, .btn-ghost, .btn-danger {
  border-radius: 14px;
  min-height: 52px;
  padding: 12px 14px;
  font-weight: 800;
  border: 0;
  width: 100%;
}
a.btn, a.btn-ghost, a.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}
.btn { background: var(--green); color: white; }
.btn.amber { background: var(--amber); color: #23160b; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn:disabled { opacity: 0.55; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 12px;
  min-height: 48px;
}
textarea { min-height: 90px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button, .role-pick label {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}
.chips button.on, .role-pick input:checked + span { background: var(--green); color: white; border-color: var(--green); }
.role-pick { display: flex; gap: 8px; }
.role-pick label { font-weight: 700; }
.role-pick input { position: absolute; opacity: 0; }
.role-pick span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: white; }

.hero {
  padding: 8px 0 4px;
}
.fare {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}
.fare b { font-size: 34px; letter-spacing: -1px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.note {
  background: var(--gold);
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  padding: 12px;
}
.note .kicker, .kicker { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; color: #8a5a16; }
.banner-bad {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.call {
  display: inline-block;
  background: var(--red);
  color: white;
  text-decoration: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}
.map-box { height: 280px; width: 100%; position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #e7e1d4; }
.map-box.leaflet-container { height: 280px; width: 100%; }
.map-box.zone-view, .map-box.zone-view.leaflet-container { height: 340px; }
.map-box .leaflet-tile,
.map-box .leaflet-marker-icon { max-width: none !important; max-height: none !important; }
.pin span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  color: white;
  font-size: 11px;
  font-weight: 800;
  border: 2px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
}
.pin span b { transform: rotate(45deg); font-style: normal; }
.results { display: grid; gap: 6px; }
.results button { text-align: left; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 6px; border-radius: 99px; background: #e4dccb; display: block; }
.steps i.on { background: var(--green-2); }
.big-wait { font-size: 40px; font-weight: 800; color: var(--green); }
.stars { display: flex; gap: 8px; }
.stars button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: white; font-size: 20px; }
.auth-screen, .gate {
  min-height: 100dvh;
  padding: 28px 20px 40px;
  background:
    linear-gradient(180deg, rgba(18,53,44,.92), rgba(18,53,44,.78)),
    var(--green);
  color: #f6f1e7;
}
.auth-screen .card, .gate .card { color: var(--ink); }
.tiny { font-size: 12px; color: var(--muted); }
.search-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.search-line .btn, .search-line .btn-ghost { width: auto; min-width: 72px; }

.enter-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 18%, rgba(224, 122, 31, 0.38), transparent 34%),
    rgba(18, 53, 44, 0.94);
}
.enter-gate.show { display: grid; }
.enter-card {
  width: min(100%, 380px);
  background: var(--paper);
  color: var(--ink);
  border-radius: 28px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.enter-card h2 { font-size: 26px; }
.enter-card p { margin: 0; color: var(--muted); }
.enter-pin {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 28px;
  animation: enter-pulse 1.4s ease-in-out infinite;
}
.enter-track {
  height: 12px;
  margin-top: 18px;
  border-radius: 999px;
  background: #e7e1d4;
  overflow: hidden;
}
.enter-track span {
  display: block;
  height: 100%;
  width: 12%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-2), var(--amber));
  transition: width 0.25s ease;
}
@keyframes enter-pulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 0 0 rgba(224, 122, 31, 0.45); }
  50% { transform: translateY(-4px); box-shadow: 0 0 0 14px rgba(224, 122, 31, 0); }
}
.exhaust {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  align-items: end;
  justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(18, 53, 44, 0.46);
}
.exhaust.show { display: flex; }
.exhaust-card {
  width: min(480px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}
.exhaust-card h2 { font-size: 24px; }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; }
.stepper button {
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  font-size: 24px;
  font-weight: 800;
}
.pay-qr { width: min(240px, 72vw); height: auto; justify-self: center; background: white; padding: 8px; border-radius: 16px; }
.zone-key { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; font-weight: 700; }
.zone-key i { display: inline-block; width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }
.zone-key .box { border: 3px dashed #315f9b; background: rgba(49, 95, 155, 0.18); }
.zone-key .ring { border: 3px solid #e07a1f; border-radius: 50%; background: rgba(224, 122, 31, 0.18); }
.zone-key .box.driver { border-color: #9d2c2c; background: rgba(157, 44, 44, 0.16); }
.zone-key .ring.driver { border-color: #1f6a56; background: rgba(31, 106, 86, 0.16); }
.bubble img { display: block; width: min(220px, 100%); margin-top: 6px; border-radius: 10px; }
.camera-layer {
  position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; background: #000;
}
.camera-layer.show { display: flex; }
.camera-layer video { flex: 1; width: 100%; object-fit: cover; background: #111; }
.camera-bar { display: flex; gap: 8px; padding: 12px; background: #12352c; }
.chat-log { max-height: 38vh; overflow: auto; display: grid; gap: 8px; }
.bubble { background: white; border-radius: 12px; padding: 8px 10px; }
.bubble p { margin: 4px 0 0; }
.bubble.mine { background: #e7f3ee; }
label.btn input, label.btn-ghost input { display: none; }
.stepper strong { text-align: center; font-size: 22px; }
