:root{--bg:#0b2a4a;--fg:#fff}
*{box-sizing:border-box}html,body{margin:0;height:100%;font:14px system-ui,sans-serif;background:var(--bg);overscroll-behavior:none}
#map{position:fixed;inset:0}
#bar{position:fixed;top:0;left:0;right:0;display:flex;align-items:center;gap:10px;padding:max(8px,env(safe-area-inset-top)) 12px 8px;color:var(--fg);background:linear-gradient(#0b2a4acc,#0b2a4a00);pointer-events:none}
#bar>*{pointer-events:auto}.title{flex:1;font-size:17px}.title span{background:#fff;color:#0b2a4a;border-radius:4px;padding:0 5px;font-weight:700;font-size:12px}
.pill{font-size:12px;background:#0006;border-radius:99px;padding:4px 10px}.pill.ok{background:#1a7f4acc}
button{font:inherit;border:0;border-radius:8px;padding:6px 10px;background:#fff;color:#0b2a4a;cursor:pointer;margin:2px 0}
#menuBtn{font-size:18px;padding:4px 12px}
#panel{position:fixed;top:56px;right:10px;width:min(300px,calc(100vw - 20px));max-height:calc(100% - 70px);overflow:auto;background:#fffffff2;color:#12263f;border-radius:12px;padding:6px 14px 12px;box-shadow:0 8px 30px #0006}
#panel h3{margin:10px 0 4px;font-size:12px;text-transform:uppercase;letter-spacing:.06em;color:#5a7089}
#panel label{display:block;padding:3px 0}#panel input[type=range]{width:100%}
.legend i{display:inline-block;width:12px;height:12px;border-radius:3px;margin:0 3px 0 8px;vertical-align:-2px}.legend i:first-child{margin-left:0}
.small{font-size:11px;color:#5a7089}
.maplibregl-popup-content{font:13px system-ui;padding:8px 12px;border-radius:8px}

/* ---- position, places, routing ---- */
.row{display:flex;gap:6px;margin:4px 0}.row button{flex:1}
button.primary{width:100%;background:#0b2a4a;color:#fff;font-weight:600;padding:8px 10px;margin:6px 0}
#places-list{margin:4px 0}.place-row{display:flex;align-items:center;gap:4px;padding:2px 0}.place-row .pn{flex:1;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.place-row button{padding:2px 8px;background:#e8eef6}
.me-hit{width:44px;height:44px;display:grid;place-items:center;cursor:grab;touch-action:none;-webkit-tap-highlight-color:transparent}
.me-dot{width:18px;height:18px;border-radius:50%;background:#1a73e8;border:3px solid #fff;box-shadow:0 2px 6px #0006;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s}
.place-pin{font-size:24px;line-height:1;filter:drop-shadow(0 2px 2px #0006);cursor:pointer}
.pop-btn{display:block;width:100%;margin:4px 0 0;text-align:left;background:#eef3fa}
#pos-toast{position:fixed;top:58px;left:50%;transform:translateX(-50%);z-index:20;max-width:92vw;background:#111e;color:#fff;border-radius:12px;padding:8px 12px;font-size:13px;display:flex;flex-wrap:wrap;gap:8px;align-items:center;box-shadow:0 4px 18px #0006}
#pos-toast[hidden]{display:none}#pos-toast button{padding:4px 10px}
#route-card{position:fixed;left:10px;bottom:70px;z-index:15;width:min(380px,calc(100vw - 20px));max-height:42vh;overflow:auto;background:#fffffff4;color:#12263f;border-radius:12px;padding:8px 12px;box-shadow:0 6px 24px #0005}
#route-card[hidden]{display:none}
.rc-head{display:flex;align-items:center;gap:8px}.rc-head b{flex:1;font-size:14px}.rc-time{font-weight:700;color:#7b1fa2}.rc-x{padding:0 8px;font-size:18px;background:transparent}
.rc-sub{font-size:11px;color:#5a7089;margin:2px 0 6px}
.rc-steps{margin:0;padding:0;list-style:none}.rc-steps li{display:flex;align-items:center;gap:6px;padding:4px 2px;border-top:1px solid #e3e9f1;font-size:13px;cursor:pointer}
.rc-steps .dot{width:10px;height:10px;border-radius:50%;flex:none}.rc-steps li i{margin-left:auto;font-style:normal;color:#5a7089;white-space:nowrap}

/* ---- POV / AR view ---- */
#pov-overlay{position:fixed;top:58px;left:10px;z-index:18;max-width:min(320px,calc(100vw - 20px));background:#0b1e33e8;color:#fff;border-radius:12px;padding:8px 12px;font-size:13px;box-shadow:0 4px 18px #0006}
#pov-overlay[hidden]{display:none}.pov-row{display:flex;align-items:center;gap:10px}.pov-row b{font-size:16px;letter-spacing:.04em;margin-left:auto}
#pov-exit{background:#fff;color:#0b2a4a;font-weight:600;padding:4px 10px}#pov-piste{margin-top:4px;opacity:.9}#pov-status{margin-top:4px;color:#ffd180}
#pov-cal{margin-top:6px;font-size:12px}#pov-cal button{padding:2px 8px;margin:0 2px}
body.pov-active .me-hit{display:none}body.pov-active #map canvas{touch-action:none;cursor:grab}

/* ---- sun / shade view ---- */
.sun-list{margin:4px 0 0;padding:0;list-style:none}.sun-list li{display:flex;gap:6px;padding:3px 2px;border-top:1px solid #e3e9f1;font-size:12.5px;cursor:pointer}.sun-list li i{margin-left:auto;font-style:normal;color:#5a7089;white-space:nowrap}

/* ---- altitude gradient tool ---- */
#ramp-card{position:fixed;left:10px;top:58px;z-index:18;width:min(280px,calc(100vw - 20px));max-height:calc(100vh - 140px);overflow:auto;background:#fffffff4;color:#12263f;border-radius:12px;padding:8px 12px;box-shadow:0 6px 24px #0005}
#ramp-card[hidden]{display:none}#ramp-card label{display:block;margin:5px 0;font-size:13px}#ramp-card input[type=range]{width:100%}
#ramp-card .rl-row{display:flex;align-items:center;justify-content:space-between}#ramp-card input[type=color]{width:56px;height:26px;padding:0;border:1px solid #c9d3e0;border-radius:6px}
#ramp-card textarea{width:100%;font:11px monospace;margin-top:4px;resize:none}

/* ---- area picker ---- */
#area-box{margin:2px 0 6px}#area-box b{display:block;font-size:14px}#area-box select[hidden]{display:none}

/* ---- offline packs ---- */
.pack-row{display:flex;gap:8px;align-items:center;justify-content:space-between;padding:6px 2px;border-top:1px solid #e3e9f1}.pack-row.cur{background:#f3f8ff}
.pk-main{font-size:12.5px;line-height:1.35;min-width:0}.pk-size{color:#5a7089;margin-left:4px}.pk-state{color:#5a7089}.pk-state.ok{color:#1a7f4a}.pk-state.err{color:#c62828}
.pk-btns{display:flex;flex-direction:column;gap:3px}.pk-btns button{padding:3px 8px;font-size:12px;background:#e8eef6}.pk-btns button:disabled{opacity:.5}
.pk-bar{height:5px;background:#e3e9f1;border-radius:3px;margin-top:3px;overflow:hidden}.pk-bar i{display:block;height:100%;background:#1a73e8}

/* ---- touch & mouse ergonomics (gestures.js, places.js) ---- */
/* press feedback everywhere, no grey iOS flash, no 300 ms double-tap delay on the chrome */
button,select,label,input,summary,.place-pin,.rc-steps li,.sun-list li{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button{transition:transform .12s cubic-bezier(.2,.8,.2,1),background-color .12s}
button:active{transform:scale(.96)}
button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid #1a73e8;outline-offset:2px}
#panel,#route-card,#ramp-card{overscroll-behavior:contain}
/* the map never selects text or opens the iOS callout on a long-press */
#map{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.maplibregl-canvas-container.maplibregl-interactive.is-hot{cursor:pointer}
.maplibregl-canvas-container.maplibregl-interactive:active{cursor:grabbing}

/* long-press ring: appears after a short beat (quick taps never flash it), fills while you hold, pulses when it fires */
.press-ring{position:fixed;z-index:40;width:68px;height:68px;margin:-34px 0 0 -34px;border-radius:50%;pointer-events:none;opacity:0;
  border:3px solid #fff;box-shadow:0 0 0 1px #0b2a4a33,0 2px 10px #0004,inset 0 0 0 1px #0b2a4a22;transform:scale(.45)}
.press-ring.show{opacity:1;transition:opacity .1s}
.press-ring.grow{transform:scale(1);transition:opacity .1s,transform var(--grow,370ms) cubic-bezier(.3,0,.2,1)}
.press-ring.fired{opacity:0;transform:scale(1.35);border-color:#1a73e8;transition:opacity .24s ease-out,transform .24s cubic-bezier(.2,.8,.2,1)}

/* position dot: lifted while dragged, drops in when placed */
.me-hit.lifted{cursor:grabbing}
.me-hit.lifted .me-dot{transform:scale(1.35);box-shadow:0 0 0 7px #1a73e833,0 8px 16px #0005}
body.dragging-me,body.dragging-me *{cursor:grabbing!important}
@keyframes me-drop{0%{transform:translateY(-26px) scale(1.15);opacity:0}60%{transform:translateY(2px) scale(.96);opacity:1}100%{transform:none}}
@keyframes me-ripple{0%{box-shadow:0 0 0 0 #1a73e866,0 2px 6px #0006}100%{box-shadow:0 0 0 18px #1a73e800,0 2px 6px #0006}}
.me-dot.drop{animation:me-drop .42s cubic-bezier(.2,.8,.2,1),me-ripple .7s .3s ease-out}

/* place pins: 44 px hit area around the glyph */
.place-pin{display:grid;place-items:end center;min-width:44px;min-height:44px}

/* point menu probe (exact spot of the long-press / right-click) */
.probe-dot{width:14px;height:14px;border-radius:50%;background:#fff;border:3px solid #0b2a4a;box-shadow:0 1px 4px #0006;pointer-events:none}
.point-menu b{display:block;margin-bottom:2px;font-size:13px}

/* "Poser" mode: centre pin + bottom action bar (thumb reach, clear of the map controls on the right) */
.drop-reticle{position:fixed;left:50%;top:50%;z-index:12;pointer-events:none}
.dr-pin{position:absolute;left:-16px;top:-43px;transition:transform .16s cubic-bezier(.2,.8,.2,1);filter:drop-shadow(0 3px 3px #0005)}
.dr-shadow{position:absolute;left:-7px;top:-3px;width:14px;height:6px;border-radius:50%;background:#0b2a4a66;transition:transform .16s cubic-bezier(.2,.8,.2,1),opacity .16s}
.drop-reticle.moving .dr-pin{transform:translateY(-12px)}
.drop-reticle.moving .dr-shadow{transform:scale(.6);opacity:.5}
.drop-bar{position:fixed;left:12px;right:72px;bottom:calc(14px + env(safe-area-inset-bottom));z-index:26;max-width:440px;display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  background:#fffffff6;color:#12263f;border-radius:14px;padding:10px 10px 10px 14px;box-shadow:0 8px 28px #0006}
.db-txt{flex:1 1 160px;min-width:0;display:flex;flex-direction:column;gap:1px;font-size:13px}.db-where{font-size:12px;color:#5a7089;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.db-btns{display:flex;gap:6px;margin-left:auto}.db-btns button{margin:0;padding:10px 14px;font-weight:600}
.db-cancel{background:#e8eef6}.db-ok{background:#1a73e8;color:#fff}
body.dropping #route-card,body.dropping #proto-bar{display:none!important}

/* view control (recentre / 3D-2D) */
.view-ctrl button{display:grid;place-items:center;color:#0b2a4a;font:700 12px system-ui,sans-serif;letter-spacing:.02em}
.maplibregl-ctrl-group button:active{background-color:#e8eef6}

/* touch screens: every control at least 44 px, popup actions as real buttons */
@media (pointer: coarse){
  .maplibregl-ctrl-group button{width:44px;height:44px}
  .maplibregl-ctrl-bottom-right{margin-bottom:env(safe-area-inset-bottom)}
  .view-ctrl button{font-size:14px}
  .pop-btn{min-height:44px;padding:10px 12px;font-size:14px}
  #panel button,#route-card button,#pos-toast button,#ramp-card button{min-height:40px}
  .place-row button{min-width:40px}
  #panel label{padding:6px 0}
  #panel input[type=checkbox]{width:20px;height:20px;vertical-align:-4px;margin-right:6px}
  #menuBtn{min-width:44px;min-height:44px}
  .rc-steps li{min-height:44px}
  .rc-x{min-width:44px;min-height:44px}
}
@media (prefers-reduced-motion: reduce){
  .press-ring,.press-ring.grow,.press-ring.fired,.dr-pin,.dr-shadow,.me-dot,button{transition:none}
  .press-ring.grow{transform:scale(1)}
  .me-dot.drop{animation:none}
}
