/* Basic Bitch Guide to Vietnam
   iOS-native feel: system font, grouped backgrounds, translucent bars, one purple accent. */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f7f3fb;
  --fill: rgba(120, 120, 128, 0.12);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.32);
  --sep: rgba(60, 60, 67, 0.16);
  --purple: #af52de;
  --purple-ink: #7a2aa5;
  --purple-tint: #f3e6fa;
  --on-purple: #ffffff;
  --green: #248a3d;
  --green-tint: #e3f5e7;
  --orange: #b25000;
  --orange-tint: #fff0dc;
  --red: #d70015;
  --red-tint: #ffe5e3;
  --pink: #d83a7c;
  --blue: #007aff;
  --bar: rgba(249, 249, 251, 0.82);
  --shadow: 0 8px 28px rgba(40, 10, 60, 0.14), 0 1px 3px rgba(40, 10, 60, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tab-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #241a2b;
    --fill: rgba(120, 120, 128, 0.28);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --purple: #bf5af2;
    --purple-ink: #dc9dff;
    --purple-tint: #2f1c3c;
    --on-purple: #ffffff;
    --green: #30d158;
    --green-tint: #11331b;
    --orange: #ff9f0a;
    --orange-tint: #3a2706;
    --red: #ff453a;
    --red-tint: #3d1412;
    --pink: #ff6aa6;
    --blue: #0a84ff;
    --bar: rgba(22, 22, 24, 0.82);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--label); font-family: var(--font); font-size: 17px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
a { color: var(--purple-ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- lock screen ---------- */
.lock { position: fixed; inset: 0; background: var(--purple); color: var(--on-purple); display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) var(--gutter-r) calc(24px + var(--safe-b)) var(--gutter-l); }
.lock-inner { width: min(360px, 100%); display: grid; gap: 14px; text-align: center; }
.lock-mark { font: 800 64px/1 var(--font-round); letter-spacing: -0.04em; }
.lock h1 { margin: 0; font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
.lock-sub { margin: 0 0 10px; opacity: 0.85; font-size: 15px; }
.lock input { width: 100%; height: 50px; border-radius: 14px; border: 0; padding: 0 16px; font: inherit; background: rgba(255,255,255,0.95); color: #000; }
.lock .btn-primary { background: #fff; color: #7a2aa5; }
.lock-err { min-height: 1.3em; margin: 0; font-size: 15px; }

/* ---------- shell ---------- */
.app { min-height: 100%; }
.view {
  padding: calc(var(--safe-t) + 8px) var(--gutter-r) calc(var(--tab-h) + var(--safe-b) + 96px) var(--gutter-l);
  max-width: 640px; margin: 0 auto;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tab-h) + var(--safe-b));
  padding: 0 var(--gutter-r) var(--safe-b) var(--gutter-l);
  display: grid; grid-template-columns: repeat(3, 1fr); align-items: center;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabbar button { display: grid; justify-items: center; gap: 2px; color: var(--label-2); font-size: 10.5px; font-weight: 500; padding-top: 4px; }
.tabbar svg { width: 26px; height: 26px; }
.tabbar button[aria-current="page"] { color: var(--purple); }
.fab {
  position: fixed; z-index: 45; right: calc(var(--gutter-r) + 2px); bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  width: 56px; height: 56px; border-radius: 28px; background: var(--purple); color: var(--on-purple);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.fab svg { width: 28px; height: 28px; stroke-width: 2; }
body.map-on .fab { bottom: calc(var(--tab-h) + var(--safe-b) + 164px); }
a.btn, a.btn-primary, a.btn-tint, a.tile { text-decoration: none; color: inherit; }
a.btn-primary { color: var(--on-purple); }
.fab:active { transform: scale(0.94); }

/* ---------- type ---------- */
.eyebrow { font-size: 13px; font-weight: 600; color: var(--purple-ink); text-transform: uppercase; letter-spacing: 0.04em; }
.large-title { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 0; text-wrap: balance; }
.title2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.headline { font-size: 17px; font-weight: 600; margin: 0; }
.sub { color: var(--label-2); font-size: 15px; margin: 0; }
.foot { color: var(--label-2); font-size: 13px; margin: 0; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 4px 8px; }
.section-h h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.section-h button { color: var(--purple-ink); font-size: 15px; }
.vibe { margin: 6px 0 0; font-size: 15px; color: var(--label-2); }
.vibe b { color: var(--purple-ink); font-weight: 600; }

/* ---------- hero ---------- */
.hero { margin-top: 16px; background: var(--purple); color: var(--on-purple); border-radius: 22px; padding: 18px; display: grid; gap: 4px; }
.hero .k { font-size: 13px; font-weight: 600; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.hero .t { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.hero .t.long { font-size: 21px; }
.hero .s { font-size: 15px; opacity: 0.9; }
.hero .then { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.25); font-size: 15px; opacity: 0.9; }
.hero .count { font-variant-numeric: tabular-nums; }

/* ---------- grouped lists ---------- */
.list { background: var(--surface); border-radius: 14px; overflow: hidden; }
.row { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; width: 100%; text-align: left; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 62px; right: 0; border-top: 0.5px solid var(--sep); }
.row .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--purple-tint); color: var(--purple-ink); font-size: 18px; }
.row .ic svg { width: 20px; height: 20px; }
.row .txt { min-width: 0; display: grid; gap: 1px; }
.row .txt b { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .txt span { color: var(--label-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .meta { color: var(--label-2); font-size: 14px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }
.row .meta svg { width: 14px; height: 14px; color: var(--label-3); }
.row.done .txt b { text-decoration: line-through; color: var(--label-2); }
.row.factrow .txt b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .tick { width: 26px; height: 26px; border-radius: 13px; border: 2px solid var(--label-3); display: grid; place-items: center; }
.row.done .tick { background: var(--purple); border-color: var(--purple); color: #fff; }
.row .tick svg { width: 16px; height: 16px; stroke-width: 3; }
.row.urgent .ic { background: var(--orange-tint); color: var(--orange); }

/* ---------- badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--fill); color: var(--label-2); }
.badge.ok { background: var(--green-tint); color: var(--green); }
.badge.mid { background: var(--orange-tint); color: var(--orange); }
.badge.bad { background: var(--red-tint); color: var(--red); }
.badge.vibe { background: var(--purple-tint); color: var(--purple-ink); }

/* ---------- unsolicited fact ---------- */
.fact { margin-top: 10px; background: var(--surface); border-radius: 22px; padding: 18px; display: grid; gap: 12px; }
.fact .k { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; color: var(--pink); text-transform: uppercase; letter-spacing: 0.04em; }
.fact .k .myth { background: var(--red-tint); color: var(--red); padding: 2px 7px; border-radius: 6px; letter-spacing: 0.02em; }
.fact .hook { font-size: 21px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; margin: 0; text-wrap: pretty; }
.fact .body { font-size: 16px; margin: 0; }
.fact .body b { color: var(--purple-ink); }
.fact .where { font-size: 13px; color: var(--label-2); }
.fact .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact .score { font-size: 13px; color: var(--label-2); text-align: center; }

/* ---------- buttons ---------- */
.btn-primary, .btn, .btn-tint {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; border-radius: 14px;
  font-size: 16px; font-weight: 600; padding: 0 16px; width: 100%;
}
.btn-primary { background: var(--purple); color: var(--on-purple); }
.btn { background: var(--fill); color: var(--label); }
.btn-tint { background: var(--purple-tint); color: var(--purple-ink); }
.btn-primary:active, .btn:active, .btn-tint:active { opacity: 0.75; }
.btn svg, .btn-primary svg, .btn-tint svg { width: 19px; height: 19px; }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- segmented ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 10px; padding: 2px; margin: 14px 0 4px; }
.seg button { height: 32px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--label); }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.12); font-weight: 600; }

/* ---------- trip days ---------- */
.days { display: grid; gap: 10px; margin-top: 12px; }
.day { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 16px; padding: 12px 14px; text-align: left; }
.day .num { width: 54px; height: 54px; border-radius: 14px; background: var(--purple-tint); color: var(--purple-ink); display: grid; place-content: center; text-align: center; line-height: 1; }
.day .num small { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.day .num b { font-size: 22px; font-weight: 700; }
.day.today .num { background: var(--purple); color: var(--on-purple); }
.day.past { opacity: 0.55; }
.day .txt b { display: block; font-size: 16px; font-weight: 600; }
.day .txt span { font-size: 14px; color: var(--label-2); }
.timeline { list-style: none; margin: 14px 0 0; padding: 0; background: var(--surface); border-radius: 14px; }
.timeline li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 11px 14px; position: relative; font-size: 16px; }
.timeline li + li::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 0.5px solid var(--sep); }
.timeline .t { color: var(--purple-ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.timeline li.past { color: var(--label-2); }
.timeline li.next .t::after { content: " ●"; color: var(--purple); }

/* ---------- detail (modal) ---------- */
.detail { display: grid; gap: 12px; }
.detail .vi { color: var(--label-2); font-size: 15px; margin-top: -6px; }
.detail .line { font-size: 17px; margin: 0; }
.kv { background: var(--surface-2); border-radius: 14px; padding: 4px 14px; }
.kv div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 9px 0; font-size: 15px; }
.kv div + div { border-top: 0.5px solid var(--sep); }
.kv dt { color: var(--label-2); margin: 0; }
.kv dd { margin: 0; }
details.notes summary { color: var(--purple-ink); font-size: 15px; font-weight: 600; list-style: none; cursor: pointer; padding: 4px 0; }
details.notes summary::-webkit-details-marker { display: none; }
details.notes dl { margin: 8px 0 0; display: grid; gap: 8px; font-size: 14px; }
details.notes dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--label-2); }
details.notes dd { margin: 0; }

/* ---------- modal sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; align-items: end; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.35); animation: fade .2s ease-out; }
.modal-sheet {
  position: relative; background: var(--bg); border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px var(--gutter-r) calc(24px + var(--safe-b)) var(--gutter-l); width: 100%; max-width: 640px; margin: 0 auto;
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.modal-x { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 15px; background: var(--fill); color: var(--label-2); display: grid; place-items: center; }
.modal-x svg { width: 16px; height: 16px; stroke-width: 2.4; }
#modalBody { padding-top: 8px; }
.sheet-grab { display: grid; place-items: center; height: 18px; }
.sheet-grab span { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); }
@keyframes up { from { transform: translateY(40%); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* help sheet tiles */
.tiles { display: grid; gap: 10px; margin-top: 14px; }
.tile { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; text-align: left; background: var(--surface); border-radius: 16px; padding: 14px; }
.tile .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--purple-tint); color: var(--purple-ink); }
.tile .ic svg { width: 24px; height: 24px; }
.tile b { display: block; font-size: 17px; }
.tile span { font-size: 14px; color: var(--label-2); }
.tile.hot { background: var(--purple); color: var(--on-purple); }
.tile.hot .ic { background: rgba(255,255,255,0.2); color: #fff; }
.tile.hot span { color: rgba(255,255,255,0.85); }
.tile.sos .ic { background: var(--red-tint); color: var(--red); }

/* ---------- poster (show to staff / driver) ---------- */
.poster { position: fixed; inset: 0; z-index: 80; background: #fff; color: #000; overflow-y: auto;
  padding: calc(12px + var(--safe-t)) max(22px, env(safe-area-inset-right, 0px)) calc(20px + var(--safe-b)) max(22px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 16px; }
.poster > :nth-child(2) { margin-top: auto; }
.poster > :last-child { margin-bottom: auto; }
.poster .done-top { position: sticky; top: 0; align-self: flex-end; height: 36px; padding: 0 16px; border-radius: 18px; background: #eee; color: #000; font-weight: 600; flex: none; }
.poster h2 { margin: 0; font-size: 24px; color: #b0102a; letter-spacing: 0.01em; }
.poster p { margin: 0; font-size: 22px; line-height: 1.4; }
.poster .big { font-size: 34px; font-weight: 700; line-height: 1.2; }
.poster .en { font-size: 15px; color: #555; border-top: 1px solid #ddd; padding-top: 12px; }
.poster .close { justify-self: center; height: 44px; padding: 0 22px; border-radius: 22px; background: #eee; color: #000; font-weight: 600; }

/* phrases */
.phrase { padding: 12px 14px; display: grid; gap: 2px; position: relative; width: 100%; text-align: left; }
.phrase + .phrase::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 0.5px solid var(--sep); }
.phrase .en { font-size: 13px; color: var(--label-2); }
.phrase .vi { font-size: 18px; font-weight: 600; }
.phrase .say { font-size: 13px; color: var(--label-2); font-style: italic; }

/* ---------- map ---------- */
.mapview { position: fixed; inset: 0; z-index: 10; }
.map { position: absolute; inset: 0; }
.map-top { position: absolute; z-index: 5; top: calc(var(--safe-t) + 8px); left: 0; right: 0; padding: 0 var(--gutter-r) 0 var(--gutter-l); pointer-events: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; pointer-events: auto; padding-bottom: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--bar); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  font-size: 15px; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.12); display: inline-flex; align-items: center; gap: 6px; }
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chip[aria-pressed="true"] { background: var(--purple); color: var(--on-purple); }
.sheet {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); background: var(--bg);
  border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.12); max-width: 640px; margin: 0 auto;
  height: 70vh; transform: translateY(calc(70vh - 150px)); transition: transform .3s cubic-bezier(.2,.8,.2,1); touch-action: none;
  display: flex; flex-direction: column;
}
.sheet[data-detent="half"] { transform: translateY(calc(70vh - 45vh)); }
.sheet[data-detent="full"] { transform: none; }
.sheet.dragging { transition: none; }
.sheet .sheet-grab { height: 22px; cursor: grab; flex: none; }
.sheet-body { padding: 0 var(--gutter-r) 20px var(--gutter-l); overflow-y: auto; touch-action: pan-y; flex: 1; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.stop-pick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 0 12px; }
.stop-pick button { flex: none; font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 999px; background: var(--fill); }
.stop-pick button[aria-pressed="true"] { background: var(--label); color: var(--bg); }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); display: grid; place-items: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); cursor: pointer; }
.pin span { transform: rotate(45deg); color: #fff; font: 700 13px/1 var(--font); }
.pin.sel { width: 40px; height: 40px; }
.pin.home { background: #1c1c1e; }
.maplibregl-ctrl-group { border-radius: 10px !important; }
.maplibregl-ctrl-top-right { top: calc(var(--safe-t) + 52px) !important; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.toast { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 84px);
  background: var(--label); color: var(--bg); border-radius: 14px; padding: 12px 16px; font-size: 15px; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.toast button { color: var(--purple); font-weight: 700; }
.empty { color: var(--label-2); text-align: center; padding: 18px; font-size: 15px; }
.note { margin-top: 12px; font-size: 13px; color: var(--label-2); padding: 0 4px; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
