/* Map Crew — the app. Explore Utah's palette; dark by default, light on
   request or by the phone's setting. */
:root {
  --bg: #0b111c;
  --bg-2: #0f1828;
  --panel: #15213a;
  --panel-2: #1c2b47;
  --line: #22304a;
  --text: #f5f2ec;
  --muted: #aab3c2;
  --faint: #6f7b8e;
  --amber: #f6b44b;
  --amber-ink: #1d1304;
  --rock: #e2723f;
  --teal: #2dd4bf;
  --blue: #3b9cff;
  --green: #34d399;
  --red: #ef4444;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  --radius: 18px;
  --tabs-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f2ec;
  --bg-2: #ebe6dc;
  --panel: #ffffff;
  --panel-2: #f1ede5;
  --line: #ddd5c7;
  --text: #17202e;
  --muted: #586274;
  --faint: #8a93a3;
  --amber: #c97c0c;
  --amber-ink: #ffffff;
  --rock: #c4551f;
  --teal: #0f8f80;
  --blue: #1f6fd1;
  --green: #12865c;
  --shadow: 0 18px 40px -22px rgba(30, 30, 40, 0.35);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #f5f2ec; --bg-2: #ebe6dc; --panel: #ffffff; --panel-2: #f1ede5; --line: #ddd5c7; --text: #17202e; --muted: #586274; --faint: #8a93a3;
    --amber: #c97c0c; --amber-ink: #ffffff; --rock: #c4551f; --teal: #0f8f80; --blue: #1f6fd1; --green: #12865c; --shadow: 0 18px 40px -22px rgba(30, 30, 40, 0.35);
    color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen { position: relative; flex: 1; min-height: 0; overflow: hidden; outline: none; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; animation: view-in 0.28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 calc(16px + var(--safe-r)) 24px calc(16px + var(--safe-l)); }

/* Header */
.head { padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l)); display: flex; align-items: center; gap: 10px; min-height: calc(56px + var(--safe-t)); background: linear-gradient(180deg, var(--bg-2), transparent); }
.head h1 { font-size: 22px; line-height: 1.15; margin: 0; letter-spacing: 0.01em; flex: 1; min-width: 0; }
.head h1 small { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }

/* Tabs */
.tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabs-h) + var(--safe-b)); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); background: color-mix(in srgb, var(--bg-2) 92%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index: 20; }
.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 700; color: var(--faint); cursor: pointer; position: relative; transition: color 0.15s; }
.tabs button svg { width: 25px; height: 25px; transition: transform 0.2s var(--ease); }
.tabs button[aria-selected="true"] { color: var(--amber); }
.tabs button[aria-selected="true"] svg { transform: translateY(-1px) scale(1.06); }
.tabs button .dot { position: absolute; top: 9px; left: calc(50% + 9px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--rock); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; }
.tabs button .dot.live { background: var(--red); animation: pulse 1.6s infinite; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 20px; border-radius: 15px; border: 1px solid transparent; font-weight: 800; font-size: 16.5px; cursor: pointer; text-decoration: none; transition: transform 0.12s var(--ease), background 0.15s, opacity 0.15s; user-select: none; -webkit-user-select: none; }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #f8c160, #f0a33a); color: #1d1304; box-shadow: 0 10px 24px -12px rgba(246, 180, 75, 0.8); }
:root[data-theme="light"] .btn.primary { background: linear-gradient(180deg, #e7951f, #cf7c0d); color: #fff; }
.btn.ghost { background: var(--panel); border-color: var(--line); color: var(--text); }
.btn.danger { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.45); color: #ff9a9a; }
:root[data-theme="light"] .btn.danger { color: #b42318; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14.5px; border-radius: 12px; }
.btn.link { background: none; border: 0; color: var(--amber); padding: 8px; min-height: 40px; }
.row-btns { display: flex; gap: 10px; }
.row-btns > * { flex: 1; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .card + .section, .section + .card { margin-top: 12px; }
.section { margin: 22px 2px 10px; font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.street { display: grid; gap: 10px; cursor: pointer; transition: transform 0.15s var(--ease); }
.street:active { transform: scale(0.985); }
.street .top { display: flex; align-items: flex-start; gap: 12px; }
.street .name { font-size: 20px; font-weight: 800; line-height: 1.2; flex: 1; min-width: 0; }
.street .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }
.facts b { color: var(--text); font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 800; white-space: nowrap; background: var(--panel-2); color: var(--muted); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.not_captured { color: var(--amber); background: rgba(246, 180, 75, 0.13); }
.chip.stale { color: var(--rock); background: rgba(226, 114, 63, 0.14); }
.chip.partly { color: var(--blue); background: rgba(59, 156, 255, 0.14); }
.chip.captured, .chip.ok, .chip.approved { color: var(--green); background: rgba(52, 211, 153, 0.14); }
.chip.rejected, .chip.bad { color: #ff8a8a; background: rgba(239, 68, 68, 0.14); }
.chip.test { color: #c4a5ff; background: rgba(180, 140, 255, 0.15); }
.chip.mine { color: var(--blue); background: rgba(59, 156, 255, 0.16); }
.note { font-size: 14px; color: var(--muted); background: var(--panel-2); border-radius: 12px; padding: 10px 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.big-num { font-size: 34px; font-weight: 900; line-height: 1; }

/* Skeletons */
.skel { background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--radius); }
.skel.card-h { height: 128px; margin-bottom: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty / error states */
.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 12px; color: var(--faint); }
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 6px; }
.empty p { margin: 0 0 16px; }

/* Map */
.map-wrap { position: relative; flex: none; height: 42vh; height: 42dvh; min-height: 220px; margin: 0 calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l)); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0b0f17; }
.map-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-wrap .map-btn { position: absolute; right: 10px; bottom: 10px; }
.map-legend { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; font-size: 11.5px; font-weight: 700; color: #c9d1db; background: rgba(11, 15, 23, 0.78); padding: 6px 9px; border-radius: 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

/* Search */
.search { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; margin: 0 calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l)); }
.search input { flex: 1; border: 0; background: none; min-height: 48px; outline: none; font-size: 17px; }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }

/* Pull to refresh */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 13px; transition: height 0.2s; }
.ptr.on { height: 44px; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.25s; z-index: 40; }
.scrim.open { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: calc(100dvh - 8px - var(--safe-t)); display: flex; flex-direction: column; background: var(--bg-2); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line); box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.8); transform: translateY(105%); transition: transform 0.32s var(--ease); z-index: 41; padding-bottom: var(--safe-b); }
.sheet.open { transform: none; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 4px; flex: none; }
.sheet .sheet-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding: 8px calc(18px + var(--safe-r)) 18px calc(18px + var(--safe-l)); }
.sheet h2 { margin: 6px 0 4px; font-size: 22px; line-height: 1.2; }

/* Toast and banner */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); background: #0b0f17; color: #f5f2ec; padding: 12px 16px; border-radius: 14px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s var(--ease); z-index: 60; max-width: calc(100vw - 32px); display: flex; gap: 12px; align-items: center; border: 1px solid #22304a; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: none; border: 0; color: #f6b44b; font-weight: 800; cursor: pointer; padding: 4px; }
.banner { flex: none; z-index: 30; }
.banner > div { padding: calc(8px + var(--safe-t)) 16px 8px; font-weight: 700; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: center; text-align: center; }
.banner .offline { background: #3a2a0c; color: #ffd99a; }
.banner .update { background: #10314a; color: #cfe6ff; }
.banner .update button { background: #3b9cff; color: #04121f; border: 0; border-radius: 10px; padding: 6px 12px; font-weight: 800; cursor: pointer; }

/* Onboarding */
.onb { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(24px + var(--safe-t)) calc(22px + var(--safe-r)) calc(22px + var(--safe-b)) calc(22px + var(--safe-l)); overflow-y: auto; background: radial-gradient(120% 70% at 100% 0%, rgba(226, 114, 63, 0.18), transparent 60%), radial-gradient(90% 60% at 0% 100%, rgba(45, 212, 191, 0.12), transparent 60%), var(--bg); }
.onb .brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; font-size: 14px; color: var(--muted); }
.onb .brand img { width: 34px; height: 34px; border-radius: 10px; }
.onb h1 { font-size: clamp(30px, 8.5vw, 40px); line-height: 1.05; margin: 22px 0 10px; letter-spacing: -0.01em; }
.onb h1 em { font-style: normal; color: var(--amber); }
.onb p.lede { color: var(--muted); font-size: 17.5px; margin: 0 0 18px; }
.onb .art { flex: 1; min-height: 140px; display: grid; place-items: center; }
.onb .art svg { width: min(78vw, 300px); height: auto; }
.onb .actions { display: grid; gap: 10px; margin-top: 18px; }
.dots { display: flex; gap: 7px; justify-content: center; margin: 14px 0 4px; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: width 0.25s var(--ease), background 0.25s; }
.dots i.on { width: 22px; background: var(--amber); }
.list { display: grid; gap: 10px; margin: 6px 0; padding: 0; list-style: none; }
.list li { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.list li svg { width: 24px; height: 24px; flex: none; color: var(--amber); margin-top: 1px; }
.list li b { display: block; }
.list li span { color: var(--muted); font-size: 14.5px; }
.perm { display: flex; align-items: center; gap: 12px; }
.perm .txt { flex: 1; min-width: 0; }
.perm .state { font-size: 13px; font-weight: 800; color: var(--green); }
.year { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 38vh; max-height: 38dvh; overflow-y: auto; padding: 4px; }
.year button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 800; font-size: 17px; cursor: pointer; }
.year button[aria-pressed="true"] { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--amber); flex: none; margin: 1px 0 0; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field label { font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: 0.04em; }
.field input, .field textarea { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); padding: 10px 12px; font-size: 17px; width: 100%; }

/* Modes */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.mode { border: 2px solid var(--line); background: var(--panel); border-radius: 16px; padding: 14px 12px; text-align: left; cursor: pointer; display: grid; gap: 6px; transition: border-color 0.15s, transform 0.12s; min-height: 108px; }
.mode:active { transform: scale(0.97); }
.mode svg { width: 30px; height: 30px; color: var(--amber); }
.mode b { font-size: 16.5px; }
.mode span { font-size: 13px; color: var(--muted); }
.mode[aria-pressed="true"] { border-color: var(--amber); background: rgba(246, 180, 75, 0.1); }

/* Capture */
.cap { position: absolute; inset: 0; display: flex; flex-direction: column; background: #000; color: #f5f2ec; }
.cap .cam { position: relative; flex: 1.35; min-height: 0; overflow: hidden; background: #05070b; }
.cap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cap .hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l)); background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent); }
.cap .hud .street-name { font-size: 21px; font-weight: 900; line-height: 1.15; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.cap .hud .plain { font-size: 15.5px; font-weight: 700; color: #e6e9ee; margin-top: 2px; }
.progress { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #34d399, #2dd4bf); border-radius: 4px; transition: width 0.4s var(--ease); }
.cap .pills { position: absolute; left: calc(12px + var(--safe-l)); bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: rgba(11, 15, 23, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px; padding: 6px 11px; font-size: 13.5px; font-weight: 800; display: inline-flex; gap: 6px; align-items: center; }
.pill i { width: 9px; height: 9px; border-radius: 50%; background: #34d399; }
.pill.rec i { background: #ef4444; animation: pulse 1.2s infinite; }
.pill.warn i { background: #f6b44b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); } 70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.turn { position: absolute; right: calc(12px + var(--safe-r)); bottom: 12px; background: rgba(11, 15, 23, 0.86); border-radius: 14px; padding: 8px 12px; font-weight: 800; font-size: 14.5px; display: flex; gap: 8px; align-items: center; max-width: 60%; }
.turn svg { width: 24px; height: 24px; color: #f6b44b; flex: none; }
.cap .pause { position: absolute; left: 12px; right: 12px; top: calc(96px + var(--safe-t)); background: rgba(58, 42, 12, 0.94); color: #ffe2ad; border: 1px solid rgba(246, 180, 75, 0.5); border-radius: 14px; padding: 12px 14px; font-weight: 800; display: flex; gap: 10px; align-items: center; animation: view-in 0.25s var(--ease); }
.cap .pause svg { width: 24px; height: 24px; flex: none; }
.cap .lower { flex: 1; min-height: 190px; display: flex; flex-direction: column; background: #0b0f17; }
.cap .minimap { position: relative; flex: 1; min-height: 90px; }
.cap .minimap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cap .controls { display: flex; gap: 10px; padding: 10px calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l)); background: #0b0f17; }
.cap .controls .btn { flex: 1; min-height: 58px; font-size: 18px; }
.cap .controls { flex-wrap: wrap; }
.cap .controls .btn.cx { flex: 1 0 100%; order: -1; min-height: 44px; font-size: 15px; border-color: rgba(255, 140, 40, 0.55); }
.cap .controls .btn.cx svg { color: #ff8c28; }
.note.cx { border-color: rgba(255, 140, 40, 0.55); }
.note.cx svg { width: 18px; height: 18px; vertical-align: -3px; color: #ff8c28; }
.cx-map { position: relative; height: 170px; margin: 10px 0; border-radius: 14px; overflow: hidden; }
.cx-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cx-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.cx-row b { font-size: 15px; }
.btn.stop { background: #ef4444; color: #fff; box-shadow: 0 10px 26px -12px rgba(239, 68, 68, 0.9); }
.btn.done { background: linear-gradient(180deg, #4ade80, #22c55e); color: #052e12; }
/* While moving: everything but Stop goes away. */
.lock { position: absolute; inset: 0; z-index: 30; background: #05070b; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); text-align: center; animation: view-in 0.2s; }
.lock .msg { font-size: 22px; font-weight: 900; }
.lock .sub { color: #aab3c2; font-size: 16px; }
.lock .btn.stop { width: min(80vw, 340px); min-height: 120px; border-radius: 30px; font-size: 30px; }
.lock .progress { width: min(80vw, 340px); }
.end-card { position: absolute; left: 14px; right: 14px; top: 50%; transform: translateY(-50%); z-index: 25; background: #0f1828; border: 1px solid #22304a; border-radius: 22px; padding: 22px; text-align: center; box-shadow: var(--shadow); animation: view-in 0.3s var(--ease); }
.end-card h2 { margin: 6px 0; font-size: 24px; }

/* Review */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--panel-2); border: 2px solid transparent; cursor: pointer; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-pressed="true"] { border-color: var(--red); }
.thumb[aria-pressed="true"]::after { content: "✕"; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 11px; background: var(--red); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; }
.thumb .st { position: absolute; left: 4px; bottom: 4px; width: 10px; height: 10px; border-radius: 5px; background: var(--faint); border: 2px solid rgba(0, 0, 0, 0.4); }
.thumb .st.up { background: var(--green); }
.thumb .st.failed { background: var(--red); }
.bar { height: 10px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--teal); width: 0; transition: width 0.3s var(--ease); }

/* Me */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 14px; padding: 12px 10px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 900; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .txt { flex: 1; min-width: 0; }
.setting .txt span { display: block; font-size: 13.5px; color: var(--muted); }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; cursor: pointer; transition: background 0.2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: transform 0.2s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 8px 12px; border-radius: 9px; font-weight: 800; font-size: 14px; cursor: pointer; color: var(--muted); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.hist { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; }
.hist .txt { flex: 1; min-width: 0; }

/* Boot */
.boot { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot img { border-radius: 18px; }
.boot-name { font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; font-size: 15px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .scroll, .head { max-width: 640px; margin-left: auto; margin-right: auto; width: 100%; }
  .map-wrap, .search { max-width: 608px; margin-left: auto; margin-right: auto; width: calc(100% - 32px); }
  .sheet { max-width: 560px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
.street .note.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* Permissions */
.perms li { align-items: center; }
.perms .need { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-left: 4px; }
.perms .need.req { color: var(--amber); }
.perms .state { display: inline-flex; align-items: center; gap: 4px; }
.perms .state svg { width: 18px; height: 18px; color: var(--green); margin: 0; }
.perm-state { display: block; font-size: 13px; font-weight: 800; color: var(--amber); margin-top: 2px; }
.perm-state.bad { color: #ff9a9a; }
.steps { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 10px; font-size: 15.5px; color: var(--muted); }
.steps b { color: var(--text); }
.chip.private { color: #d6c6ff; background: rgba(150, 120, 230, 0.16); }
.chip.private svg { width: 13px; height: 13px; }
/* Light theme (chosen, or the phone's): readable reds. */
:root[data-theme="light"] .perm-state.bad, :root[data-theme="light"] .chip.rejected, :root[data-theme="light"] .chip.bad { color: #b42318; }
:root[data-theme="light"] .perm-state { color: #9a5b00; }
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] .btn.danger, :root[data-theme="system"] .perm-state.bad, :root[data-theme="system"] .chip.rejected, :root[data-theme="system"] .chip.bad { color: #b42318; }
  :root[data-theme="system"] .perm-state { color: #9a5b00; }
  :root[data-theme="system"] .chip.private { color: #5b3fb0; }
}
:root[data-theme="light"] .chip.private { color: #5b3fb0; }

/* Landscape on a phone (a mounted phone in the car): a side rail for the
   tabs, maps and the camera on one side and controls on the other, sheets
   from the right; nothing taller than the screen, every button on it. */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --tabs-h: 0px; }
  .app { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .app > .banner { grid-column: 2; grid-row: 1; }
  .app > .screen { grid-column: 2; grid-row: 2; }
  .app > .tabs { grid-column: 1; grid-row: 1 / span 2; width: calc(76px + var(--safe-l)); height: auto; grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(0, 1fr));
    padding: var(--safe-t) 0 var(--safe-b) var(--safe-l); border-top: 0; border-right: 1px solid var(--line); }
  .app:has(> .tabs:not([hidden])) > .screen, .app:has(> .tabs:not([hidden])) > .banner { --safe-l: 0px; }
  .tabs button { font-size: 11px; }
  .tabs button .dot { top: 4px; }
  .banner > div { padding-top: calc(6px + var(--safe-t)); padding-bottom: 6px; }
  .head { min-height: calc(44px + var(--safe-t)); padding-top: calc(6px + var(--safe-t)); padding-bottom: 6px; }
  .head h1 { font-size: 18px; }
  .head h1 small { font-size: 11px; }
  .scroll { padding-bottom: calc(14px + var(--safe-b)); }
  .empty { padding: 16px 12px; }
  .empty svg { width: 40px; height: 40px; margin-bottom: 6px; }
  .search input { min-height: 42px; }

  /* A screen with a map: the map on the right, the rest on the left. */
  .view:has(> .map-wrap) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); animation: none; }
  .view:has(> .map-wrap) > :not(.map-wrap) { grid-column: 1; min-width: 0; }
  .view:has(> .map-wrap) > .scroll { grid-row: 3; }
  .view:has(> .map-wrap) > .map-wrap { grid-column: 2; grid-row: 1 / -1; height: auto !important; min-height: 0; width: auto; max-width: none;
    margin: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) 4px; }
  .view:has(> .map-wrap) > .search, .view:has(> .map-wrap) > .head { margin-right: 6px; max-width: none; }
  .view:has(> .map-wrap) > .scroll { padding-right: 6px; max-width: none; }

  /* Sheets: a side panel from the right, full height, scrolling inside. */
  .sheet { left: auto; top: 0; right: 0; bottom: 0; width: min(560px, 64vw); max-width: none; max-height: none; margin: 0; border-radius: 24px 0 0 24px; border-top: 0; border-left: 1px solid var(--line);
    transform: translateX(105%); padding: var(--safe-t) var(--safe-r) var(--safe-b) 0; }
  .sheet.open { transform: none; }
  .sheet .grab { display: none; }
  .sheet .sheet-body { flex: 1; padding: 14px 18px 18px; }
  .sheet .map-wrap { height: 150px !important; }
  .modes { grid-template-columns: repeat(4, 1fr); }
  .mode { min-height: 92px; padding: 10px; }

  /* Onboarding: smaller art, the buttons kept on screen. */
  .onb { padding: calc(12px + var(--safe-t)) calc(22px + var(--safe-r)) 0 calc(22px + var(--safe-l)); }
  .onb h1 { font-size: 26px; margin: 10px 0 6px; }
  .onb p.lede { font-size: 16px; margin-bottom: 8px; }
  .onb .art { flex: none; min-height: 0; }
  .onb .art svg { width: auto; height: 30dvh; max-height: 150px; }
  .onb .actions { position: sticky; bottom: 0; margin: 10px calc(-22px - var(--safe-r)) 0 calc(-22px - var(--safe-l)); padding: 10px calc(22px + var(--safe-r)) calc(12px + var(--safe-b)) calc(22px + var(--safe-l));
    background: linear-gradient(180deg, transparent, var(--bg) 30%); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .year { max-height: 34dvh; grid-template-columns: repeat(5, 1fr); }

  /* Capture: the camera on the left, the map and the buttons in a side panel. */
  .cap { flex-direction: row; }
  .cap .cam { flex: 1; }
  .cap .hud { padding: calc(8px + var(--safe-t)) 14px 8px calc(14px + var(--safe-l)); }
  .cap .hud .street-name { font-size: 18px; }
  .cap .hud .plain { font-size: 14px; }
  .cap .pause { top: calc(76px + var(--safe-t)); left: calc(12px + var(--safe-l)); }
  .cap .lower { flex: none; width: calc(clamp(220px, 32vw, 320px) + var(--safe-r)); min-height: 0; }
  .cap .minimap { min-height: 0; }
  .cap .controls { flex-direction: column; padding: 10px calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) 12px; }
  .cap .controls .btn { flex: none; min-height: 52px; }
  .cap .controls .btn.cx { flex: none; order: 0; min-height: 44px; }
  .turn { max-width: 55%; }
  .lock { flex-direction: row; flex-wrap: wrap; align-content: center; gap: 10px 28px; padding: calc(12px + var(--safe-t)) calc(24px + var(--safe-r)) calc(12px + var(--safe-b)) calc(24px + var(--safe-l)); }
  .lock .msg, .lock .sub, .lock .progress { flex-basis: 100%; }
  .lock .progress { max-width: 420px; }
  .lock .btn.stop { min-height: min(120px, 40dvh); width: min(60vw, 360px); }
  .end-card { left: calc(14px + var(--safe-l)); right: calc(clamp(220px, 32vw, 320px) + var(--safe-r) + 14px); max-height: calc(100% - 20px); overflow-y: auto; }
  .end-card h2 { font-size: 20px; }
  .toast { bottom: calc(14px + var(--safe-b)); }
}

/* Locked on a route: the route map fills the screen, Stop beside it (to the
   right when the phone is sideways, along the bottom when upright). */
.lock.with-map { display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; text-align: left; align-items: stretch; justify-items: stretch; }
.lock.with-map .lock-map { position: relative; min-height: 0; min-width: 0; background: #0b0f17; }
.lock.with-map .lock-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lock.with-map .lock-side { display: flex; flex-direction: column; gap: 10px; padding: 14px calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); background: #05070b; border-top: 1px solid #1d2533; }
.lock.with-map .msg { font-size: 18px; }
.lock.with-map .sub { font-size: 14px; }
.lock.with-map .progress { width: 100%; max-width: none; }
.lock.with-map .btn.stop { width: 100%; min-height: 104px; font-size: 30px; border-radius: 24px; }
@media (orientation: landscape) {
  .lock.with-map { grid-template-columns: minmax(0, 1fr) clamp(220px, 32vw, 340px); grid-template-rows: minmax(0, 1fr); }
  .lock.with-map .lock-side { border-top: 0; border-left: 1px solid #1d2533; justify-content: center; padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) 16px; }
  .lock.with-map .btn.stop { flex: 0 1 auto; min-height: min(200px, 48dvh); }
}

/* The lock screen's small live view: the capture's own video, moved to a
   corner over the dark lock (no copy of the frames), dimmed; gone at 75 mph+. */
.cap.locked:not(.fast) .cam video { inset: auto; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); width: 28vmin; height: calc(28vmin * 0.75);
  z-index: 31; border-radius: 12px; filter: brightness(0.6) saturate(0.85); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18); pointer-events: none; }
.cap.locked.night:not(.fast) .cam video { filter: brightness(0.4) saturate(0.7); }
.cap.locked.fast .cam video { visibility: hidden; }
.lock .preview-note { position: absolute; left: calc(12px + var(--safe-l)); top: calc(18px + var(--safe-t) + 28vmin * 0.75); font-size: 12px; font-weight: 700; color: #8b95a5; text-align: left; max-width: 40vmin; }
.cap.fast .lock .preview-note { display: none; }
.lock .view-warn { background: rgba(58, 42, 12, 0.9); color: #ffd99a; border: 1px solid rgba(246, 180, 75, 0.45); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 800; }
.pill.lens-pill { color: inherit; font: inherit; font-size: 13.5px; font-weight: 800; cursor: pointer; }
.pill.lens-pill i { background: #9fb7ff; }
@media (orientation: landscape) and (max-height: 560px) {
  .lock .view-warn { flex-basis: auto; }
  .cap.locked:not(.fast) .cam video { width: 30vmin; height: calc(30vmin * 0.5625); }
  .lock .preview-note { top: calc(18px + var(--safe-t) + 30vmin * 0.5625); }
}

/* Something in the way: the latest view's blocked part, outlined. */
.block-hint { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; }
.block-hint .block-mask { position: absolute; inset: 0; width: 100%; height: 100%; }
.block-hint .block-text { position: absolute; left: 12px; right: 12px; bottom: 64px; background: rgba(11, 15, 23, 0.86); color: #ffd99a; border-radius: 14px; padding: 10px 12px; font-weight: 800; font-size: 14.5px; text-align: center; }
/* Check your view (mount or bike, before photos start). */
.check-view { position: absolute; inset: 0; z-index: 28; pointer-events: none; display: grid; place-items: center; }
.check-view .guide { position: absolute; inset: 14% 8% 22% 8%; border: 3px dashed rgba(255, 255, 255, 0.85); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28); }
.check-view .check-text { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); background: rgba(11, 15, 23, 0.9); color: #f5f2ec; border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 14.5px; text-align: center; max-width: 86%; }
.check-view .check-text div { font-size: 18px; font-weight: 900; margin-bottom: 2px; }

/* Home zones */
.cap .pause.home { background: rgba(11, 15, 23, 0.72); color: #cfe3ff; border-color: rgba(59, 156, 255, 0.45); padding: 6px 10px; font-size: 14px; font-weight: 700; }
.cap .pause.home svg { color: #3b9cff; }
.home-card h2 { margin: 6px 0 2px; }
.home-card svg:first-child { color: #3b9cff; width: 36px; height: 36px; }
.setting .txt b svg, [data-card="zone-suggest"] b svg { width: 18px; height: 18px; vertical-align: -3px; color: #3b9cff; }
.cap.locked.home video { visibility: hidden; }

/* 1.9: getting dark, and the sun low ahead of the camera */
.dark-card svg { width: 34px; height: 34px; color: #f6b44b; }
.dark-card .muted { color: #c3ccda; }
.sun-hint { position: absolute; left: 12px; right: 12px; top: calc(96px + var(--safe-t)); z-index: 5; display: flex; gap: 10px; align-items: center; background: rgba(11, 15, 23, 0.86); color: #ffd99a; border: 1px solid rgba(246, 180, 75, 0.45); border-radius: 14px; padding: 10px 12px; font-weight: 800; font-size: 14.5px; }
.sun-hint svg { width: 22px; height: 22px; flex: none; color: #f6b44b; }
@media (orientation: landscape) and (max-height: 560px) { .sun-hint { top: calc(76px + var(--safe-t)); left: calc(12px + var(--safe-l)); } }
.note.sun { border: 1px solid rgba(246, 180, 75, 0.45); }
.note.sun svg { width: 18px; height: 18px; vertical-align: -3px; color: #f6b44b; }
p.warn { color: var(--amber); font-weight: 600; }
svg.share-glyph { width: 18px; height: 18px; vertical-align: -3px; color: var(--blue); }
.speed-pick .seg { margin-bottom: 8px; }
.pill.speed-pill { color: inherit; font: inherit; font-size: 13.5px; font-weight: 800; cursor: pointer; }
.pill.speed-pill i { background: #7fe3c8; }

/* Object detection test view (1.11.1; the view itself is loaded only for the accounts it's for) */
.det-view{position:fixed;inset:0;z-index:60;background:#000;display:flex;flex-direction:column;color:#fff}
.det-canvas{flex:1;min-height:0;width:100%;object-fit:contain;background:#000}
.det-status{position:absolute;top:calc(8px + env(safe-area-inset-top));left:12px;right:110px;font-size:13px;color:#cbd5e1;text-shadow:0 1px 2px #000}
.det-panel{max-height:38dvh;overflow:auto;padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:rgba(10,14,20,.92);font-size:13px}
.det-counts{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px}
.det-meta{color:#cbd5e1;margin:4px 0}
.det-list{width:100%;border-collapse:collapse;margin-top:4px}
.det-list th,.det-list td{text-align:left;padding:2px 6px;border-bottom:1px solid rgba(255,255,255,.08);white-space:nowrap}
.det-stop{position:absolute;top:calc(8px + env(safe-area-inset-top));right:12px;min-width:84px;min-height:56px;font-size:18px}
@media (orientation:landscape){.det-view{flex-direction:row}.det-panel{max-height:none;width:min(42vw,380px)}}
