:root {
  --ink: #262628;
  --muted: #6b6b70;
  --paper: #f3f1ec;
  --card: #ffffff;
  --dark: rgba(38, 38, 41, 0.92);
  --green: #1fae5b;
  --green-bright: #2bd96b;
  --gold: #f5b400;
  --red: #e8453c;
  --blue: #1a73e8;
  --radius: 22px;
  --serif: 'Gelasio', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #111; color: var(--ink); font-family: var(--sans); overscroll-behavior: none; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.muted-light { color: rgba(255, 255, 255, 0.72); }

.screen { position: fixed; inset: 0; overflow: hidden; }
.screen.paper { background: var(--paper); overflow-y: auto; }
.screen.dark { background: #1c1c1e; color: #fff; }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; gap: 12px; }
.screen.dim { background: rgba(0, 0, 0, 0.35); }

/* ───────── Buttons ───────── */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; max-width: 420px;
  min-height: 60px; border-radius: 999px; border: 0; font-size: 19px; font-weight: 600; text-decoration: none; }
.btn svg { width: 22px; height: 22px; }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 6px 20px rgba(31, 174, 91, 0.35); }
.btn-primary svg { fill: #fff; }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { background: transparent; color: var(--ink); border: 2px solid rgba(38, 38, 40, 0.18); }
.btn-outline-dark { background: transparent; color: var(--ink); border: 2.5px solid var(--ink); font-size: 21px; }
.btn-outline-dark svg { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── Landing ───────── */
#landing { padding: calc(18px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 18px; align-items: center; }
#landing > * { width: 100%; max-width: 460px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink); }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(31, 174, 91, 0.18); }

.place-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06); }
.place-photo { position: relative; height: 190px; background: linear-gradient(135deg, #8ec06c, #4fa06d); display: grid; place-items: center; }
.place-photo span { font-family: var(--serif); font-weight: 700; font-size: 64px; color: #fff; opacity: 0.95; }
.place-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.place-photo small { position: absolute; left: 10px; bottom: 8px; color: #fff; font-size: 11px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.place-body { padding: 16px 18px 18px; }
.place-body h1 { font-family: var(--serif); font-size: 28px; margin: 0 0 4px; line-height: 1.15; }
.place-body p { margin: 0 0 6px; font-size: 15px; }
.meta { font-size: 15px; }
.meta .star { color: var(--gold); }
.open { color: var(--green); font-weight: 600; }
.closed { color: var(--red); font-weight: 600; }
.chip { display: inline-block; margin-top: 6px; background: var(--green); color: #fff; font-weight: 700; padding: 7px 14px; border-radius: 999px; font-size: 15px; }

.landing-map { height: 210px; border-radius: var(--radius); overflow: hidden; background: #e8e6e1; }
.landing-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.fineprint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 2px 0 0; }
.desktop-note { background: var(--card); border-radius: var(--radius); padding: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.desktop-note p { margin: 0; }

/* ───────── Loading ───────── */
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.15); border-top-color: var(--green-bright); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading h2 { font-family: var(--serif); font-size: 26px; margin: 10px 0 0; }

/* ───────── Navigation ───────── */
#camera, #ar { position: absolute; inset: 0; width: 100%; height: 100%; }
#camera { object-fit: cover; background: #333; }
#nav.sim #camera { background: linear-gradient(#9fb9cc 0%, #d7dde0 46%, #8b8f8f 47%, #6e706f 100%); }
.card-dark { background: var(--dark); color: #fff; border-radius: var(--radius); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

.top-row { position: absolute; top: calc(14px + var(--safe-top)); left: 14px; right: 14px; display: flex; gap: 12px; align-items: flex-start; }
.instruction { flex: 1; display: flex; align-items: center; gap: 14px; padding: 14px 18px; min-height: 86px; }
#turn-icon { width: 50px; height: 50px; flex: none; fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s; }
#turn-title { font-size: 25px; font-weight: 700; line-height: 1.1; }
#turn-dist { font-size: 21px; font-weight: 600; margin-top: 2px; }
#turn-dist small { font-family: var(--sans); font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, 0.7); margin-left: 6px; }
.round-btn { width: 56px; height: 56px; border: 0; display: grid; place-items: center; flex: none; margin-top: 15px; }
.round-btn svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
#voice-btn .mute { display: none; }
#voice-btn.off .wave { display: none; }
#voice-btn.off .mute { display: inline; }

.sub-row { position: absolute; top: calc(112px + var(--safe-top)); left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 13px; }
.pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); display: inline-block; }
#accuracy.good i { background: var(--green-bright); }
#accuracy.bad i { background: var(--red); }
.pill.gold { background: var(--dark); font-size: 18px; padding: 6px 14px 6px 8px; }
.pill .coin { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #8a5c00; font-style: normal; font-weight: 800; font-size: 16px; display: grid; place-items: center; }
.pill.bump { animation: bump 0.4s; }
@keyframes bump { 50% { transform: scale(1.25); } }

.turn-hint { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); font-weight: 700; font-size: 18px; pointer-events: none; }
.turn-hint svg { width: 92px; height: 92px; fill: var(--green-bright); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); transition: transform 0.15s linear; }

.map-frame { position: absolute; border-radius: var(--radius); overflow: hidden; background: #e8e6e1; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); border: 3px solid rgba(255, 255, 255, 0.9);
  transition: all 0.35s cubic-bezier(.3, .8, .3, 1); }
.map-frame.compact { left: 14px; bottom: calc(170px + var(--safe-bottom)); width: 34vw; max-width: 170px; height: 34vw; max-height: 170px; }
.map-frame.expanded { left: 10px; right: 10px; bottom: calc(170px + var(--safe-bottom)); top: calc(150px + var(--safe-top)); width: auto; height: auto; max-width: none; max-height: none; }
.map { position: absolute; inset: 0; }
.map-btn { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--dark); display: grid; place-items: center; z-index: 500; }
.map-btn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.map-btn.recenter { top: auto; bottom: 8px; }
.map-user { position: relative; width: 40px; height: 40px; }
.map-user-halo { position: absolute; inset: -10px; border-radius: 50%; background: rgba(26, 115, 232, 0.18); }
.map-user-arrow { position: absolute; inset: 4px; width: 32px; height: 32px; fill: var(--blue); stroke: #fff; stroke-width: 3; stroke-linejoin: round; transition: transform 0.15s linear; }
.map-dest svg { width: 34px; height: 44px; fill: var(--red); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); display: block; }

.bottom { position: absolute; left: 14px; right: 14px; bottom: calc(14px + var(--safe-bottom)); padding: 18px 20px 16px; text-align: center; }
.follow { font-size: 16px; color: rgba(255, 255, 255, 0.85); }
.dest { font-size: 24px; font-weight: 700; margin: 2px 0 4px; }
#remaining { font-size: 15px; }
.x-btn { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; background: transparent; color: rgba(255, 255, 255, 0.6); font-size: 20px; }

.toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(360px + var(--safe-bottom)); background: rgba(0, 0, 0, 0.8); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 15px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }

/* ───────── Arrival (mockup 1) ───────── */
.sheet { position: absolute; inset: calc(16px + var(--safe-top)) 14px calc(16px + var(--safe-bottom)); background: rgba(237, 236, 232, 0.97); border-radius: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px; text-align: center; animation: pop 0.45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.arrive-card { position: relative; background: #fff; border-radius: 22px; padding: 44px 22px 22px; width: 100%; max-width: 340px; }
.arrive-card p { margin: 0; font-size: 17px; }
.arrive-card h2 { font-size: 30px; margin: 4px 0 18px; }
.arrive-card h3 { font-size: 28px; margin: 4px 0 0; }
.badge { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); width: 46px; height: 46px; border-radius: 50%; background: var(--green); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(31, 174, 91, 0.4); }
.badge svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.offer p { margin: 0; }
.offer-big { font-size: 46px; font-weight: 700; line-height: 1.1; margin: 4px 0; }
#offer-shop { font-size: 23px; font-weight: 700; }
.redeem { margin-top: 14px !important; font-size: 13px; color: var(--muted); }
.sheet .btn-outline-dark { max-width: 320px; }

#error h2 { font-size: 34px; margin: 0; }
#error p { max-width: 340px; color: var(--ink); line-height: 1.45; }

/* Map credits: keep them legible but small, especially on the compact map */
.leaflet-control-attribution { font-size: 9px !important; line-height: 1.3; padding: 0 4px !important; background: rgba(255,255,255,.75) !important; }
.map-frame.compact .leaflet-control-attribution { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-frame.compact .gmnoprint, .map-frame.compact .gm-style-cc { transform: scale(.85); transform-origin: right bottom; }

/* ───────── Where to? ───────── */
#search { padding: calc(18px + var(--safe-top)) 18px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; }
#search > * { width: 100%; max-width: 520px; }
.brand { justify-content: flex-start; }
.brand-label { flex: none; }
.link-btn { margin-left: auto; border: 0; background: none; color: var(--green); font-weight: 600; font-size: 14px; padding: 6px 0; }
.where { font-size: 38px; margin: 14px 0 12px; }
.search-box { position: relative; display: flex; align-items: center; background: #fff; border-radius: 18px; box-shadow: 0 6px 24px rgba(0,0,0,.07); }
.search-box svg { position: absolute; left: 16px; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.search-box input { flex: 1; font: inherit; font-size: 17px; border: 0; background: transparent; padding: 18px 46px 18px 50px; border-radius: 18px; min-width: 0; }
.search-box input:focus { outline: 2px solid var(--green); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box .clear { position: absolute; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eee; color: var(--muted); }
.search-status { min-height: 20px; margin: 8px 4px 0; font-size: 14px; color: var(--muted); }
.search-status.err { color: var(--red); }
.results { list-style: none; margin: 4px 0 0; padding: 0; background: #fff; border-radius: 18px; overflow: hidden; }
.results:empty { display: none; }
.results li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #f0eee9; cursor: pointer; }
.results li:last-child { border-bottom: 0; }
.results li:active, .results li:hover { background: #f7f6f2; }
.results .ico { width: 36px; height: 36px; border-radius: 50%; background: #eef7f1; display: grid; place-items: center; flex: none; }
.results .ico svg { width: 18px; height: 18px; fill: var(--green); }
.results .txt { flex: 1; min-width: 0; }
.results .txt b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .txt small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .dist { font-size: 13px; color: var(--muted); flex: none; }
.list-title { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
.pick-map-wrap { position: relative; }
.search-map { height: 300px; border-radius: 18px; overflow: hidden; background: #e8e6e1; }
.pin-card { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 600; background: #fff; border-radius: 16px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.pin-card div { flex: 1; min-width: 0; }
.pin-card b, .pin-card small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-card small { color: var(--muted); font-size: 12.5px; }
.btn-small { min-height: 44px; width: auto; padding: 0 18px; font-size: 16px; flex: none; }

/* ───────── Landing extras ───────── */
.btn-row { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.btn-row .btn { flex: 1; }
.btn-icon { flex: 0 0 60px !important; padding: 0; }
.btn-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; }
.far-note { background: #fff4d6; color: #7a5600; border-radius: 14px; padding: 10px 14px; font-size: 14px; margin: 0; max-width: 420px; text-align: center; }

/* ───────── Share sheet ───────── */
.share-sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 18px; }
.share-card { position: relative; background: var(--paper); border-radius: 26px; padding: 24px 20px 20px; width: 100%; max-width: 380px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.share-card h3 { font-size: 26px; margin: 0; }
.share-card p { margin: 0; font-size: 14px; }
.share-card canvas { width: 240px; height: 240px; border-radius: 16px; background: #fff; }
.x-btn.dark { color: var(--muted); }

/* ───────── WebXR mode (camera drawn by the browser; this layer is the DOM overlay) ───────── */
#nav.xr #camera { display: none; }
#nav.xr #ar { visibility: hidden; }          /* the XR session renders to its own surface */
.xr-status { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: min(86vw, 340px); padding: 16px 18px;
  display: flex; gap: 14px; align-items: center; text-align: left; }
.xr-status b { display: block; font-size: 17px; }
.xr-status small { display: block; color: rgba(255,255,255,.75); font-size: 13.5px; margin-top: 3px; line-height: 1.35; }
.ground-ring { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 4px solid var(--green-bright); display: none;
  transform: perspective(80px) rotateX(55deg); animation: ringpulse 1.4s ease-in-out infinite; }
.xr-status.ground .ground-ring { display: block; }
.xr-tracking { position: absolute; left: 50%; bottom: calc(190px + var(--safe-bottom, 0px)); transform: translateX(-50%);
  width: min(86vw, 340px); padding: 12px 16px; text-align: center; }
.xr-tracking b { display: block; font-size: 15px; }
.xr-tracking small { display: block; color: rgba(255,255,255,.75); font-size: 13px; margin-top: 2px; line-height: 1.35; }
@keyframes ringpulse { 50% { transform: perspective(80px) rotateX(55deg) scale(1.25); opacity: .6; } }

.side-tools { position: absolute; right: 14px; top: calc(160px + var(--safe-top)); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.height-ctl { display: flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 18px; }
.height-ctl button { width: 40px; height: 36px; border: 0; background: none; color: #fff; font-size: 14px; }
.height-ctl span { font-size: 10px; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .05em; }
#nav.xr .height-ctl, #nav.sim .height-ctl { display: none; }
.rescan { width: 48px; height: 48px; border: 0; border-radius: 16px; display: none; place-items: center; }
.rescan svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
body.indoor .rescan { display: grid; }
.sub-row { right: 76px; }

/* ───────── Saathi point scanner ───────── */
.scan-sheet { position: fixed; inset: 0; background: #000; z-index: 60; }
.scan-sheet video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 50%; top: 45%; width: 64vw; height: 64vw; max-width: 300px; max-height: 300px; transform: translate(-50%, -50%);
  border: 4px solid var(--green-bright); border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-hint { position: absolute; left: 0; right: 0; bottom: calc(80px + var(--safe-bottom)); text-align: center; color: #fff; font-weight: 600; padding: 0 24px; }
.scan-sheet .x-btn { top: calc(14px + var(--safe-top)); right: 14px; color: #fff; font-size: 24px; }

/* Indoor search: no street map / recents */
#search.indoor .pick-map-wrap, #search.indoor .list-title, #search.indoor #recent-wrap { display: none !important; }
#start-btn:disabled { opacity: .5; box-shadow: none; }
#error p { white-space: pre-line; }

/* Unified "Where to?" */
.indoor-head, .map-head { display: flex; align-items: center; gap: 10px; }
.indoor-head .list-title, .map-head .list-title { flex: 1; }
.indoor-head .link-btn { margin: 22px 4px 8px; }
.map-head select { width: auto; font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid #dcdad4; background: #fff; margin: 14px 0 0; }
.map-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.map-tabs button { flex: 1; border: 1.5px solid #dcdad4; background: #fff; border-radius: 12px; padding: 9px; font-weight: 600; font-size: 14px; color: var(--ink); }
.map-tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#indoor-results .ico { background: #eef2fb; }
#indoor-results .ico svg { fill: #3b6fd8; }
.map-note { margin: -10px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.spot-card { position: absolute; left: 14px; right: 14px; bottom: calc(180px + var(--safe-bottom)); z-index: 700; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; }
.spot-card span { flex: 1; font-weight: 600; }
.link-btn.light { color: rgba(255,255,255,.8); margin: 0; }

/* Align the trail with the road */
.tool-btn { width: 48px; height: 54px; border: 0; border-radius: 16px; display: grid; place-items: center; align-content: center; gap: 1px; padding: 0; }
.tool-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn small { font-size: 9.5px; color: rgba(255,255,255,.8); text-transform: uppercase; letter-spacing: .04em; }
.align-layer { position: absolute; inset: 0; z-index: 800; touch-action: none; cursor: ew-resize; background: rgba(0,0,0,.08); }
.align-arrows { position: absolute; left: 0; right: 0; top: 40%; display: flex; justify-content: space-between; align-items: center; padding: 0 22px;
  color: #fff; font-weight: 700; text-shadow: 0 2px 6px rgba(0,0,0,.6); font-size: 26px; pointer-events: none; }
.align-arrows span:nth-child(2) { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; }
.align-card { position: absolute; left: 14px; right: 14px; bottom: calc(180px + var(--safe-bottom)); display: flex; gap: 12px; align-items: center; padding: 14px 14px 14px 18px; }
.align-card div { flex: 1; }
.align-card b { display: block; }
.align-card small { display: block; color: rgba(255,255,255,.75); font-size: 13px; margin-top: 2px; }

.ar-mode { font-size: 13px; line-height: 1.45; text-align: center; margin: 0; padding: 9px 14px; border-radius: 12px; background: #fff; color: var(--ink); max-width: 420px; }
.ar-mode.ok { background: #eaf7ef; color: #17643a; }
.ar-mode.warn { background: #fff4d6; color: #6e4d00; }
.ar-mode a { color: inherit; font-weight: 700; }
