:root {
  --navh: calc(44px + env(safe-area-inset-top));
  --bg: #0c0e0d;
  --panel: #141816;
  --panel-2: #1b201d;
  --line: #29302c;
  --text: #e7ece8;
  --muted: #8d978f;
  --accent: #f5b301;
  --accent-ink: #1a1400;
  --ok: #4fd07a;
  --r-uncommon: #4caf6a;
  --r-rare: #3d8bff;
  --r-epic: #a45cff;
  --r-legendary: #ff8a1f;
  --r-ultra: #ff3b5c;
  --r-none: #9aa3a0;
  --side: 372px;
}
* { box-sizing: border-box; }
html.nav-hidden { --navh: 0px; }

/* ---------- site bar (injected by nav.js on every page) ---------- */
.sitenav {
  position: relative; z-index: 30; height: var(--navh); flex: none; background: #090b0a; border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
html.nav-hidden .sitenav { display: none; }
.sn-in { height: 100%; display: flex; align-items: center; gap: 14px; padding: 0 10px 0 14px; min-width: 0; }
.sn-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; flex: none; font-size: 13.5px; letter-spacing: .02em; }
.sn-mark { width: 24px; height: 24px; border-radius: 6px; }
.sn-mark::before { left: 5px; top: 5px; width: 8px; height: 8px; border-width: 2.5px; }
.sn-mark::after { left: 13px; top: 10px; width: 7px; height: 2.5px; box-shadow: 3px 2px 0 -0.5px var(--accent-ink); }
.sn-tabs { display: flex; gap: 2px; min-width: 0; height: 100%; }
.sn-tab {
  display: inline-flex; align-items: center; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px;
  white-space: nowrap; border-bottom: 2px solid transparent; border-top: 2px solid transparent;
}
.sn-tab:hover { color: var(--text); }
.sn-tab:focus-visible, .sn-hide:focus-visible, .sn-show:focus-visible, .sn-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sn-tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.sn-short { display: none; }
.sn-hide {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.sn-hide:hover { color: var(--text); border-color: var(--muted); }
.sn-chev, .sn-show-ico { width: 8px; height: 8px; border: solid currentColor; border-width: 2px 0 0 2px; transform: translateY(2px) rotate(45deg); }
.sn-show { display: none; }
html.nav-hidden .sn-show {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--muted);
}
html.nav-hidden .sn-show:hover { color: var(--text); border-color: var(--muted); }
.sn-show-ico { transform: translateY(-2px) rotate(225deg); }
html.nav-hidden .sn-show.is-head { margin-left: auto; width: 40px; height: 40px; }
/* scrolling pages: the bar already covers the top safe-area inset, so their own header does not add it again */
html:not(.nav-hidden) .bp-top, html:not(.nav-hidden) .mt-top { padding-top: 0; }
html.nav-hidden .sn-show.is-float {
  position: fixed; z-index: 30; top: calc(6px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
  background: var(--panel); box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
@media (max-width: 860px) {
  :root { --navh: calc(48px + env(safe-area-inset-top)); }
  html.nav-hidden { --navh: 0px; }
  .sn-in { gap: 6px; padding: 0 6px 0 8px; }
  .sn-tabs { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .sn-tabs::-webkit-scrollbar { display: none; }
  .sn-tab { padding: 0 9px; min-height: 40px; flex: 1 0 auto; justify-content: center; }
  .sn-hide { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .sn-hide-t { display: none; }
  html.nav-hidden .sn-show { width: 40px; height: 40px; }
}
@media (max-width: 620px) {
  .sn-brand b { display: none; }
  .sn-tab:not(.sn-same) .sn-long { display: none; }
  .sn-tab:not(.sn-same) .sn-short { display: inline; }
  .sn-tab { padding: 0 7px; font-size: 13px; }
}
@media (max-width: 360px) {
  .sn-tab { padding: 0 4px; font-size: 12.5px; } /* all five tabs fit at 320px (the current one is never scrolled out of view) */
}
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
/* phone-only pieces (bottom-sheet handle, back button, short labels) */
.sheet-handle, .d-back, .lbl-short { display: none; }
a { color: var(--accent); }

.app { display: grid; grid-template-columns: var(--side) 1fr; height: calc(100vh - var(--navh)); height: calc(100dvh - var(--navh)); }

/* ---------- sidebar ---------- */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; gap: 12px; align-items: center; padding: 14px 16px 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent); flex: none; position: relative;
}
.brand-mark::before { content: ""; position: absolute; left: 8px; top: 9px; width: 10px; height: 10px; border: 3px solid var(--accent-ink); border-radius: 50%; }
.brand-mark::after { content: ""; position: absolute; left: 19px; top: 14.5px; width: 9px; height: 3px; background: var(--accent-ink); box-shadow: 4px 3px 0 -0.5px var(--accent-ink); }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .02em; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tabs-in { display: flex; gap: 4px; min-width: 0; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 10px; color: var(--muted); font-weight: 600; }
.tab.is-on { color: var(--text); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 12px; text-align: center; }
.tab.is-on .count { background: var(--accent); color: var(--accent-ink); }

.pane { display: none; flex-direction: column; min-height: 0; flex: 1; }
.pane.is-on { display: flex; }

.search { position: relative; padding: 12px 12px 8px; }
.search input {
  width: 100%; padding: 10px 38px 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search kbd { position: absolute; right: 22px; top: 21px; font: 11px ui-monospace, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

.chips { display: flex; gap: 6px; padding: 0 12px 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 3px 11px; color: var(--muted); font-size: 12.5px; }
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

/* rarity filter chips */
.rchips { gap: 5px; margin-top: -2px; }
.rchip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; font-size: 12px; }
.rchip .dot { width: 9px; height: 9px; flex: none; }
.rchip .n { opacity: .65; font-size: 11px; }
.rchip.is-on { background: var(--panel-2); color: var(--text); border-color: var(--rc); font-weight: 600; }
.rchip.is-off { color: var(--muted); border-style: dashed; }
.rchip.is-off .dot { background: none; box-shadow: inset 0 0 0 1.5px var(--rc); }
.rchip.is-off .rchip-l { text-decoration: line-through; }
.rchip-all { padding: 2px 9px; font-size: 12px; }
.rchip-all.is-alert { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* count of shown keys + "add all to route" */
.bulk { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px; padding: 0 12px 8px 14px; min-height: 30px; box-sizing: content-box; font-size: 12px; color: var(--muted); }
.bulk-l, .bulk-r { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bulk-r { margin-left: auto; justify-content: flex-end; }
.bulk-n { white-space: nowrap; }
.bulk-reset, .bulk-clear { padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.bulk-reset { border-color: var(--accent); color: var(--accent); background: none; }
.bulk-clear { color: #ff9aa9; border-color: #4a2a31; }
.bulk-clear:hover { border-color: var(--r-ultra); color: #ffc2cb; }
.bulk-add { padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.bulk-add:hover { border-color: var(--accent); color: var(--accent); }
.bulk-done { color: var(--accent); font-weight: 600; white-space: nowrap; }

.list { overflow-y: auto; flex: 1; min-height: 0; padding: 0 6px 10px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.group-h { position: sticky; top: 0; background: var(--panel); padding: 8px 8px 4px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); z-index: 1; }
.row { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 8px; }
.row:hover, .row.is-kb { background: var(--panel-2); }
.row.is-active { background: #25221a; outline: 1px solid #5c4a10; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--r-none); }
.r-uncommon { --rc: var(--r-uncommon); } .r-rare { --rc: var(--r-rare); } .r-epic { --rc: var(--r-epic); }
.r-legendary { --rc: var(--r-legendary); } .r-ultra { --rc: var(--r-ultra); } .r-none { --rc: var(--r-none); }
.dot { background: var(--rc, var(--r-none)); }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-add { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 17px; line-height: 1; }
.row-add:hover { border-color: var(--accent); color: var(--accent); }
.row-add.is-in { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; }
.empty { color: var(--muted); padding: 22px 14px; text-align: center; }

.route-tools { padding: 12px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field select { padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 9px 12px; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-accent.is-on { background: none; color: var(--accent); }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.route-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
/* "Clear all" at the top of My route: a summary of what would be cleared + the button */
.route-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 6px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.route-sum { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-head[hidden], .route-foot[hidden] { display: none; }
/* clear / reset buttons: clearly visible but not loud, red on hover */
.btn-clear { color: #ff9aa9; border-color: #4a2a31; white-space: nowrap; }
.btn-clear:hover { border-color: var(--r-ultra); color: #ffc2cb; }
.btn-clear:disabled { opacity: .45; cursor: default; border-color: var(--line); color: var(--muted); }

/* Undo toast (key finder + ingredient page). role="status"; app code hides it after 7 s unless hovered or focused. */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast-box {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px; border-radius: 12px; pointer-events: auto;
  background: #222824; border: 1px solid #3a433d; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.55); font-size: 13.5px;
  animation: toast-in .18s ease-out;
}
.toast-msg { min-width: 0; padding-right: 4px; }
.toast-undo { border: 1px solid var(--accent); background: none; color: var(--accent); border-radius: 8px; padding: 0 14px; min-height: 36px; font-weight: 700; }
.toast-undo:hover { background: var(--accent); color: var(--accent-ink); }
.toast-x { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; width: 36px; min-height: 36px; border-radius: 8px; }
.toast-x:hover { color: var(--text); }
.toast-undo:focus-visible, .toast-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast-box { animation: none; } }
.route-map-h { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 8px 4px; }
.route-map-h b { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.route-map-h span { color: var(--muted); font-size: 12px; }
.stop { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 8px; }
.stop:hover { background: var(--panel-2); }
.stop-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; font-size: 12.5px; }
.stop-n.is-you { background: var(--ok); } .stop-n.is-end { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.stop-x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 0 6px; min-width: 32px; min-height: 32px; border-radius: 6px; }
.stop-x:hover { background: var(--bg); }
.stop-x:hover { color: var(--r-ultra); }
.note { color: var(--muted); font-size: 12px; padding: 4px 8px 8px; }

.credits { padding: 9px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.credits a { color: var(--muted); }

/* ---------- map ---------- */
.mapwrap { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg:empty { display: none; }
.seg button { background: none; border: 0; padding: 7px 13px; color: var(--muted); font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-on { background: var(--accent); color: var(--accent-ink); }
.seg button .n { opacity: .7; font-weight: 500; margin-left: 5px; font-size: 12px; }
.topbar { position: relative; z-index: 12; }
.layers { position: relative; }
.lbtn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 6px 11px; font-weight: 600; color: var(--text); }
.lbtn:hover, .lbtn.is-on { border-color: var(--muted); background: var(--panel-2); }
.lbtn .count { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.lbtn .count[hidden] { display: none; }
.lbtn-ico { width: 14px; height: 14px; position: relative; flex: none; }
.lbtn-ico::before, .lbtn-ico::after { content: ""; position: absolute; left: 1px; width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 2px; transform: rotate(45deg) scaleY(.6); }
.lbtn-ico::before { top: -1px; } .lbtn-ico::after { top: 4px; background: var(--panel); }
.lpanel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 330px; max-height: calc(100dvh - 80px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.65); overflow: hidden;
}
.lpanel[hidden] { display: none; }
.lp-head { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.lp-head b { font-size: 14px; }
.lp-head span { grid-column: 1; color: var(--muted); font-size: 11.5px; }
.lp-x { grid-column: 2; grid-row: 1 / span 2; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 22px; border-radius: 8px; }
.lp-x:hover { background: var(--panel-2); color: var(--text); }
.lp-body { overflow-y: auto; padding: 4px 6px 8px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.lp-group { padding: 9px 8px 3px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.lrow { display: grid; grid-template-columns: 26px 1fr auto 30px; gap: 9px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px; padding: 5px 8px; }
.lrow:hover:not([disabled]) { background: var(--panel-2); }
.lrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lrow[disabled] { cursor: default; opacity: .4; }
.lrow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.lrow-n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lsw { display: inline-grid; place-items: center; min-width: 22px; height: 18px; padding: 0 3px; border-radius: 4px; font-size: 9.5px; font-weight: 800; line-height: 1; background: var(--panel-2); color: var(--text); border: 1px solid rgba(0,0,0,.6); justify-self: start; }
.lsw-grid, .lsw-labels, .lsw-poi, .lsw-place { border-color: var(--line); color: var(--muted); }
.lsw-spawn { min-width: 12px; width: 12px; height: 12px; border-radius: 50%; margin-left: 5px; }
.sw-track { position: relative; width: 30px; height: 17px; border-radius: 999px; background: var(--line); transition: background .15s; }
.sw-track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.lrow.is-on .sw-track { background: var(--accent); }
.lrow.is-on .sw-track::after { transform: translateX(13px); background: var(--accent-ink); }
.lp-foot { display: flex; gap: 8px; justify-content: space-between; padding: 8px 10px; border-top: 1px solid var(--line); }

.map { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #070808; cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
.map.is-drag { cursor: grabbing; }
.map.is-pick { cursor: crosshair; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; --inv: 1; }
.stage.is-anim { transition: transform .45s cubic-bezier(.2,.7,.2,1); }
.stage img { display: block; width: 100%; height: 100%; -webkit-user-drag: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#pins { position: absolute; inset: 0; }

.grid-line { stroke: rgba(255,255,255,.16); stroke-width: 1; vector-effect: non-scaling-stroke; }
.route-line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 3px rgba(0,0,0,.9)); }
.route-line.is-other { stroke-dasharray: 6 8; opacity: .45; }

.pin { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); z-index: 2; }
.pin-dot {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--rc, var(--r-none)); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.8);
  cursor: pointer; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #111; padding: 0;
}
.pin.is-approx .pin-dot { border-style: dashed; }
.pin:hover { z-index: 6; }
.pin:hover .pin-dot { transform: scale(1.25); }
.pin.in-route .pin-dot { left: -12px; top: -12px; width: 24px; height: 24px; background: var(--accent); border-color: #111; }
.pin.is-active { z-index: 7; }
.pin.is-active .pin-dot { left: -13px; top: -13px; width: 26px; height: 26px; border-width: 3px; }
.pin.is-active::before {
  content: ""; position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid var(--accent); animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin.is-active::before { animation: none; } .stage.is-anim { transition: none; } }
.pin-label {
  position: absolute; left: 16px; top: -11px; white-space: nowrap; background: rgba(10,12,11,.92); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 5px; font-size: 12px; font-weight: 600; display: none; pointer-events: none;
}
.pin:hover .pin-label, .pin.is-active .pin-label, .show-labels .pin .pin-label { display: block; }

.mk { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); z-index: 1; pointer-events: none; }
.mk-ico {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); min-width: 18px; height: 18px; padding: 0 3px; border-radius: 4px;
  display: grid; place-items: center; font-size: 10px; font-weight: 800; line-height: 1; white-space: nowrap;
  color: var(--mi, #08110b); background: var(--mc, var(--ok)); border: 1px solid rgba(0,0,0,.6); pointer-events: auto; cursor: pointer;
}
.mk-exfil.is-final .mk-ico { background: #7ee0ff; }
.mk-stairs .mk-ico { background: #cfd6d2; }
.mk-item .mk-ico { background: #ffd966; padding: 0 4px; }
.mk-x01 .mk-ico { background: var(--accent); padding: 0 5px; }
.mk-spawn .mk-ico { background: #7f8a84; border-radius: 50%; min-width: 12px; width: 12px; height: 12px; padding: 0; }
.mk-tip { position: absolute; left: 13px; top: -10px; white-space: nowrap; background: rgba(10,12,11,.92); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; display: none; }
.mk:hover { z-index: 6; } .mk-ico:hover + .mk-tip { display: block; }
.mk.is-open { z-index: 6; }
.mk.is-open .mk-ico { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0,0,0,.6); }
.mk.is-open .mk-tip { display: none !important; }
.mk-poi, .mk-place { z-index: 0; }
.mk-poi span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.82); text-shadow: 0 0 4px #000, 0 0 2px #000; }
.mk-place span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 10.5px; font-weight: 600; font-style: italic; color: rgba(255,255,255,.7); text-shadow: 0 0 4px #000, 0 0 2px #000; }
.mk-radius { fill-opacity: .07; stroke-opacity: .75; stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }

/* marker popup (click a marker) */
.mk-pop { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); z-index: 9; }
.mk-pop-box {
  position: absolute; left: 0; bottom: 16px; transform: translateX(-50%); width: max-content; min-width: 190px; max-width: 270px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 30px 10px 11px;
  box-shadow: 0 8px 26px rgba(0,0,0,.7); cursor: auto; font-size: 12.5px; line-height: 1.4; white-space: normal;
}
.mk-pop-box::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; margin-left: -5px; background: var(--panel); border: 1px solid var(--line); border-width: 0 1px 1px 0; transform: rotate(45deg); }
.mk-pop-box p { margin: 5px 0 0; color: #cfd6d2; }
.mk-pop-box .btn { margin-top: 8px; text-align: left; }
.mk-pop-kind { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.mk-pop-kind .lsw { min-width: 18px; height: 15px; font-size: 8.5px; }
.mk-pop-name { font-weight: 700; font-size: 13.5px; margin-top: 3px; }
.mk-pop-src { margin-top: 6px; color: var(--muted); font-size: 10.5px; }
.mk-pop-x { position: absolute; right: 3px; top: 3px; width: 26px; height: 26px; border: 0; background: none; color: var(--muted); font-size: 18px; border-radius: 6px; }
.mk-pop-x:hover { background: var(--panel-2); color: var(--text); }
.grid-lbl { position: absolute; transform: scale(var(--inv)); transform-origin: 0 0; font: 700 11px ui-monospace, Consolas, monospace; color: rgba(255,255,255,.45); padding: 3px 5px; pointer-events: none; }

.you { position: absolute; width: 0; height: 0; transform: scale(var(--inv)); z-index: 8; pointer-events: none; }
.you i { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(79,208,122,.3); }
.you b { position: absolute; left: 16px; top: -10px; background: var(--ok); color: #06120a; font-size: 11px; padding: 1px 6px; border-radius: 5px; }

.zoom { position: absolute; left: 12px; bottom: 12px; display: grid; gap: 4px; }
.zoom button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.zoom button:hover { border-color: var(--muted); }
.coords { position: absolute; left: 58px; bottom: 12px; background: rgba(10,12,11,.85); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font: 12px ui-monospace, Consolas, monospace; color: var(--muted); }
.coords:empty { display: none; }
.hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ok); color: #06120a; font-weight: 700; padding: 8px 14px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.6); z-index: 9; }

/* ---------- detail ---------- */
.detail {
  position: absolute; right: 12px; top: 62px; bottom: 12px; width: 384px; max-width: calc(100% - 24px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow-y: auto; z-index: 10;
  box-shadow: 0 10px 40px rgba(0,0,0,.6); scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.d-head { position: sticky; top: 0; background: var(--panel); padding: 14px 44px 10px 16px; border-bottom: 1px solid var(--line); z-index: 1; }
.d-head h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.2; }
.d-close { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 22px; border-radius: 8px; }
.d-close:hover { background: var(--panel-2); color: var(--text); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.rar { color: var(--rc); border-color: var(--rc); text-transform: capitalize; font-weight: 600; }
.badge.warn { color: var(--accent); border-color: #5c4a10; }
.d-body { padding: 12px 16px 18px; display: grid; gap: 14px; }
.d-note { margin: 0; color: var(--muted); font-size: 12px; font-style: italic; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.d-sec h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.d-sec p { margin: 0 0 8px; }
.d-sec .src { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.loot { display: flex; flex-wrap: wrap; gap: 6px; }
.loot span { border: 1px solid var(--rc, var(--line)); color: var(--text); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shot { position: relative; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 16 / 10; }
.shot:first-child { grid-column: 1 / -1; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot span { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 8px 4px; font-size: 11px; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.shot:hover { border-color: var(--accent); }
.others { display: grid; gap: 4px; }
.others button { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; }
.others button:hover { border-color: var(--muted); }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.93); z-index: 50; display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; touch-action: none; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; display: grid; justify-items: center; gap: 10px; min-width: 0; }
.lightbox img { max-width: 100%; max-height: 86vh; border-radius: 6px; }
.lightbox figcaption { color: #cfd6d2; font-size: 13px; }
.lb-nav, .lb-close { background: none; border: 0; color: #fff; font-size: 44px; line-height: 1; }
.lb-close { position: absolute; right: 14px; top: 8px; font-size: 34px; }

/* ---------- touch input (any width) ---------- */
@media (hover: none) { .coords { display: none; } }
@media (pointer: coarse) {
  /* bigger invisible hit areas; the visual size stays the same (app.js also picks the nearest pin) */
  .pin-dot::after { content: ""; position: absolute; inset: -12px; border-radius: 50%; }
  .mk-ico::after { content: ""; position: absolute; inset: -9px; }
}

/* ---------- tablet / narrow desktop ---------- */
@media (min-width: 861px) and (max-width: 1100px) {
  :root { --side: 300px; }
  .detail { width: min(340px, calc(100% - 220px)); }
  .seg button { padding: 7px 10px; }
  .seg button .n { display: none; }
}

/* ---------- phones: full-screen map + bottom sheet ---------- */
@media (max-width: 860px) {
  .app { display: block; position: fixed; inset: var(--navh) 0 0 0; height: auto; }
  .mapwrap { position: absolute; inset: 0; }
  .brand, .credits, .search kbd { display: none; }

  /* top bar: one row, clear of the notch */
  .topbar {
    flex-wrap: nowrap; gap: 6px; min-width: 0;
    padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 6px calc(8px + env(safe-area-inset-left));
  }
  html:not(.nav-hidden) .topbar { padding-top: 6px; }
  .seg { flex: none; }
  .seg button { min-height: 40px; padding: 0 11px; }
  .seg button .n { display: none; }
  .layers { position: static; margin-left: auto; flex: none; }
  .lbtn { min-height: 40px; }
  .lpanel {
    left: auto; right: calc(8px + env(safe-area-inset-right)); width: min(360px, calc(100% - 16px)); top: calc(100% + 6px);
    max-height: calc(100dvh - 70px - env(safe-area-inset-top));
  }
  .lrow { padding: 8px; min-height: 44px; }
  .lp-x { width: 40px; height: 40px; }
  .spacer { display: none; }

  /* the sheet */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; height: 124px; max-height: calc(100% - 52px - var(--navh));
    border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 34px rgba(0,0,0,.6);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow: hidden; overscroll-behavior: contain;
  }
  .sidebar.is-snap { transition: height .3s cubic-bezier(.2,.8,.2,1); }
  .sheet-handle {
    display: block; flex: none; width: 100%; height: 28px; border: 0; background: none; padding: 0; position: relative;
    touch-action: none; cursor: grab;
  }
  .sheet-handle::before { content: ""; position: absolute; left: 50%; top: 11px; width: 42px; height: 5px; margin-left: -21px; border-radius: 3px; background: #4a534e; }
  .sheet-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
  .sheet-handle, .tabs, .d-head { touch-action: none; -webkit-user-select: none; user-select: none; }
  .tabs { flex: none; }
  .tabs-in { flex: 1; }
  .tab { flex: 1; min-height: 40px; }
  .search { padding: 4px 12px 8px; }
  .search input { min-height: 44px; font-size: 16px; padding-right: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: none; overscroll-behavior-x: contain; }
  .chips::-webkit-scrollbar { display: none; }
  .chip, .rchip, .rchip-all { flex: none; min-height: 40px; padding-top: 0; padding-bottom: 0; }
  .list { overscroll-behavior: contain; }
  .row { min-height: 52px; }
  .row-add { width: 40px; height: 40px; }
  .stop { min-height: 48px; }
  .stop-x { min-width: 40px; height: 40px; }
  .btn, .btn-sm { min-height: 40px; }
  .bulk { flex: none; padding-bottom: 6px; min-height: 36px; }
  .bulk .bulk-add, .bulk .bulk-reset, .bulk .bulk-clear { min-height: 40px; }
  .field select { min-height: 44px; font-size: 16px; }
  .route-tools, .route-foot, .route-head { flex: none; }
  .route-head .btn { min-height: 40px; }
  /* the sheet is short: the "Clear all" at the top of My route is enough, give the list the room */
  #pane-route .route-foot { display: none; }
  /* the toast sits above the sheet: just under the top bar */
  .toast { bottom: auto; top: calc(var(--navh) + 58px); }
  .toast-undo, .toast-x { min-height: 40px; min-width: 40px; }

  /* key details live inside the sheet */
  .sidebar.has-detail .tabs, .sidebar.has-detail .pane { display: none; }
  .sidebar .detail {
    position: static; flex: 1; min-height: 0; width: auto; max-width: none;
    border: 0; border-radius: 0; box-shadow: none; overscroll-behavior: contain;
  }
  .d-head { padding: 6px 12px 10px 56px; }
  .d-head h2 { font-size: 17px; }
  .d-close { display: none; }
  .d-back {
    display: grid; place-items: center; position: absolute; left: 8px; top: 2px; width: 40px; height: 40px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 22px; line-height: 1;
  }
  .others button { min-height: 40px; }

  /* map controls: top right, clear of the sheet */
  .zoom { left: auto; bottom: auto; top: 10px; right: calc(10px + env(safe-area-inset-right)); }
  .zoom button { width: 40px; height: 40px; }
  .hint { left: calc(10px + env(safe-area-inset-left)); right: 62px; transform: none; text-align: center; padding: 9px 12px; }
  .mk-pop-box { padding-right: 42px; max-width: min(270px, calc(100vw - 24px)); }
  .mk-pop-x { width: 40px; height: 40px; right: 0; top: 0; }

  /* lightbox: full-width image, big close button, nav at the bottom (swipe works too) */
  .lightbox { grid-template-columns: 1fr; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .lightbox figure { pointer-events: none; padding: 0 6px; }
  .lightbox figure > * { pointer-events: auto; }
  .lightbox img { max-width: 100%; max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); object-fit: contain; }
  .lightbox figcaption { text-align: center; padding: 0 12px; }
  .lb-nav { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 36px; }
  .lb-prev { left: calc(16px + env(safe-area-inset-left)); }
  .lb-next { right: calc(16px + env(safe-area-inset-right)); }
  .lb-close { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.14); font-size: 30px; }
}
/* very narrow: short map/floor names, icon-only Layers button */
@media (max-width: 480px) {
  .lbl-long, .lbtn-t { display: none; }
  .lbl-short { display: inline; }
  .lbtn { padding: 6px 10px; }
}
/* wider phone-mode screens (landscape phones, small tablets): the sheet docks on the left */
@media (max-width: 860px) and (min-width: 600px) {
  .sidebar { right: auto; width: min(400px, 52vw); border-radius: 0 16px 0 0; border-left: 0; }
}
/* landscape phones: side arrows instead of bottom ones so the image keeps the height */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 560px) {
  .lightbox { grid-template-columns: 64px 1fr 64px; }
  .lb-nav { position: static; justify-self: center; }
  .lightbox img { max-height: calc(100dvh - 54px); }
}
@media (prefers-reduced-motion: reduce) { .sidebar.is-snap { transition: none; } }

/* zoomed far out: drop the small text so pins stay readable */
.stage.is-far .grid-lbl, .stage.is-tiny .mk-poi, .stage.is-far .mk-place { display: none; }
