:root { --bg: #102027; --panel: #17262e; --fg: #eceff1; --muted: #90a4ae; --accent: #00e5ff; --line: #263238; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
#map { position: fixed; inset: 0; }
button, select, input { font: inherit; color: var(--fg); background: #263238; border: 1px solid #37474f; border-radius: 10px; padding: 9px 12px; }
button { cursor: pointer; }
button:disabled { opacity: .5; }
button.primary { background: #00838f; border-color: #00acc1; font-weight: 600; }
button.danger { background: #b71c1c; border-color: #e53935; }
button.wide { width: 100%; margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row > .primary, .row > select { flex: 1; }
.row.wrap { flex-wrap: wrap; }

/* search */
#search { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 60px; z-index: 1000; display: flex; align-items: center; gap: 8px; background: rgba(16,32,39,.92); border-radius: 14px; padding: 6px 6px 6px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.brand { font-weight: 700; white-space: nowrap; }
#q { flex: 1; min-width: 0; border: none; background: #263238; }
#search-results { position: absolute; top: 100%; left: 0; right: 0; margin: 6px 0 0; padding: 0; list-style: none; background: var(--panel); border-radius: 12px; max-height: 50vh; overflow: auto; }
#search-results li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.leaflet-top.leaflet-right { top: calc(env(safe-area-inset-top)); }
.leaflet-bottom.leaflet-right { bottom: 84px; }
@media (min-width: 900px) { .leaflet-bottom.leaflet-right { bottom: 0; } }

.fabs { position: fixed; right: 12px; bottom: calc(46vh + 10px); z-index: 1000; display: flex; flex-direction: column; gap: 10px; transition: bottom .25s; }
.fab { width: 48px; height: 48px; border-radius: 50%; font-weight: 700; background: var(--bg); box-shadow: 0 3px 10px rgba(0,0,0,.4); padding: 0; }
body:has(#sheet.collapsed) .fabs { bottom: 120px; }

/* bottom sheet */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001; height: 46vh; background: var(--panel); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.4); display: flex; flex-direction: column; transition: height .25s; padding-bottom: env(safe-area-inset-bottom); max-width: 720px; margin: 0 auto; }
#sheet.collapsed { height: 84px; }
#sheet-handle { background: none; border: none; padding: 8px; display: flex; justify-content: center; }
#sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: #546e7a; }
.tabs { display: flex; gap: 4px; padding: 0 10px; }
.tab { flex: 1; background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 4px 8px; color: var(--muted); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.panel { overflow-y: auto; padding: 4px 14px 14px; flex: 1; }
.ends > div { padding: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-mini { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; }
.pin-mini.a, .pin-a { background: #00acc1; } .pin-mini.b, .pin-b { background: #ff7043; }
.loading, .error { padding: 12px 0; color: var(--muted); } .error { color: #ef9a9a; }

.card { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; cursor: pointer; }
.card.sel { border-color: var(--accent); background: #1c313a; }
.score { flex: 0 0 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #102027; }
.s-great { background: #69f0ae; } .s-good { background: #b2ff59; } .s-mid { background: #ffd740; } .s-bad { background: #ff8a65; }
.card-body { flex: 1; min-width: 0; }
.meta { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.bar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: #263238; }
.flags { font-size: 12px; color: #ffcc80; margin-top: 4px; }
.chart { width: 100%; height: 110px; display: block; margin-top: 6px; touch-action: none; background: #0d1b21; border-radius: 10px; }
.chart.short { height: 70px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 4px; vertical-align: -1px; }

.park { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.park b { color: var(--fg); } .park div { min-width: 0; }
.park-icon { font-size: 22px; filter: drop-shadow(0 1px 2px #000); }

.here { display: flex; gap: 12px; align-items: center; }
.rose { width: 150px; height: 150px; flex: 0 0 150px; }
#here-stats > div { margin: 3px 0; }
.big { font-size: 22px; font-weight: 700; }
#panel-here > button { margin-top: 10px; width: 100%; }

#settings-form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0; }
#settings-form label.check { justify-content: flex-start; }
.cues { padding-left: 18px; font-size: 13px; } .cues li { margin: 4px 0; }
h4 { margin: 14px 0 4px; }

/* map markers */
.me-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(0,229,255,.25); }
.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; color: #fff; font-weight: 700; border: 2px solid #fff; }
.popup-actions { display: flex; flex-direction: column; gap: 6px; }
.popup-actions button, .popup-route { padding: 7px 10px; font-size: 14px; }
.leaflet-popup-content { margin: 10px 12px; }

/* ride HUD */
body.riding #sheet, body.riding #search { display: none; }
body.riding .fabs { bottom: 230px; }
#hud .hud-top { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 1100; display: flex; align-items: center; gap: 14px; background: rgba(16,32,39,.95); border-radius: 16px; padding: 12px 16px; }
#hud-arrow { font-size: 54px; line-height: 1; width: 60px; text-align: center; }
#hud-dist { font-size: 30px; font-weight: 800; }
#hud-instr { color: var(--muted); }
#hud .hud-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; background: rgba(16,32,39,.95); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
.hud-stats { display: flex; justify-content: space-between; font-weight: 700; font-size: 18px; }
#hud .row button { flex: 1; }

#pocket { position: fixed; inset: 0; z-index: 3000; background: #000; display: grid; place-items: center; color: #263238; text-align: center; touch-action: none; user-select: none; }

/* AR */
#ar { position: fixed; inset: 0; z-index: 2000; background: #000; }
#ar video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ar-hud { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(40px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); pointer-events: none; text-shadow: 0 2px 6px #000; }
#ar-label { font-size: 22px; font-weight: 700; text-align: center; background: rgba(0,0,0,.45); padding: 8px 14px; border-radius: 12px; }
#ar-arrow { font-size: 170px; line-height: 1; color: #ffd740; transition: transform .15s linear, color .2s; filter: drop-shadow(0 4px 10px rgba(0,0,0,.7)); }
#ar-arrow.ar-on-track { color: #69f0ae; }
#ar-info { font-size: 20px; font-weight: 700; background: rgba(0,0,0,.45); padding: 6px 12px; border-radius: 10px; }
#ar-info:empty { display: none; }
#ar-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; padding: 0; background: rgba(0,0,0,.6); }

#toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 4000; background: #000c; padding: 10px 16px; border-radius: 12px; max-width: 90vw; text-align: center; }
[hidden] { display: none !important; }

@media (min-width: 900px) {
  #sheet { left: 12px; right: auto; top: 76px; bottom: 12px; width: 400px; height: auto; border-radius: 18px; margin: 0; }
  #sheet.collapsed { height: 84px; bottom: auto; }
  #search { right: auto; width: 400px; }
  .fabs { bottom: 30px !important; }
}
