:root {
  color-scheme:light;
  --paper:#fff; --canvas:#f3f5f8; --map:#f7f8fa; --room:#dde4ed; --boundary:#8494a9; --hall:#fff; --hall-line:#aab8ca; --structure:#c3cedb;
  --ink:#18283d; --quiet:#526276; --line:#dce3ed; --accent:#2563eb; --route:#2563eb;
  --blue-pale:#eaf1ff; --selected:#dbeafe; --shadow:0 6px 24px #172a4515;
  --unresolved-line:#aab8c980; --site-street:#d3dce7; --site-path:#7b8fa6; --lobby:#eef4fa; --court:#e3ece5;
  --safe-t:max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top,0px), var(--tg-safe-area-inset-top,0px));
  --safe-b:max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom,0px), var(--tg-safe-area-inset-bottom,0px));
  --safe-l:max(env(safe-area-inset-left), var(--tg-content-safe-area-inset-left,0px), var(--tg-safe-area-inset-left,0px));
  --safe-r:max(env(safe-area-inset-right), var(--tg-content-safe-area-inset-right,0px), var(--tg-safe-area-inset-right,0px));
  font:16px/1.4 system-ui,sans-serif;
  color:var(--ink); background:var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#222934; --canvas:#151a22; --map:#191f28; --room:#38485d; --boundary:#8a9ab1; --hall:#22303f; --hall-line:#71849e; --structure:#293442;
  --ink:#f2f5fb; --quiet:#becbdd; --line:#3a4655; --accent:#2563eb; --route:#79aaff;
  --blue-pale:#263f68; --selected:#234e87; --shadow:0 8px 24px #0005;
  --unresolved-line:#465a7266; --site-street:#3d4c61; --site-path:#a1b3c9; --lobby:#29394a; --court:#263b38;
}
* { box-sizing:border-box }
[hidden] { display:none !important }
body,h1,h2,h3,p { margin:0 }
body { overflow:hidden }
h1,h2 { font-size:1.04rem; letter-spacing:-.02em; line-height:1.2 }
h3 { font-size:.86rem }
small { display:block; font-size:.75rem; line-height:1.35; color:var(--quiet) }
button,input,select,textarea { font:inherit; color:inherit }
button,select { min-height:44px; border:1px solid var(--line); background:var(--paper); border-radius:12px; padding:7px 11px }
button { cursor:pointer; touch-action:manipulation; font-weight:600 }
button:hover:not(:disabled) { border-color:var(--route) }
button:disabled { opacity:.42; cursor:default }
button:focus-visible,select:focus-visible,input:focus-visible,textarea:focus-visible,[data-room]:focus-visible { outline:2px solid var(--route); outline-offset:2px }
.icon-bank,.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); pointer-events:none }
.icon { width:20px; height:20px; flex:none; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; vertical-align:middle }
.icon-button { display:inline-grid; place-items:center; width:44px; flex:0 0 44px; padding:0 }
.primary { display:inline-flex; align-items:center; justify-content:center; gap:7px; color:#fff; background:var(--accent); border-color:var(--accent); font-weight:690; white-space:nowrap }
.primary:hover:not(:disabled) { background:#1d4ed8 }
.app { display:grid; grid-template-rows:auto minmax(0,1fr) auto; height:min(100dvh,var(--app-height,100dvh)); background:var(--canvas) }
.top { z-index:2; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,min(64%,255px)); gap:10px 8px; align-items:center;
  padding:calc(10px + var(--safe-t)) max(12px,var(--safe-r)) 10px max(12px,var(--safe-l));
  background:var(--paper); border-bottom:1px solid var(--line) }
.brand { min-width:0; display:flex; align-items:center; gap:8px }
.brand > svg { width:32px; height:32px; padding:7px; border-radius:11px; background:var(--blue-pale); color:var(--route) }
.brand h1 span { display:block; font-size:.66rem; font-weight:550; letter-spacing:.01em; color:var(--quiet) }
.location { display:flex; gap:5px; min-width:0; justify-content:flex-end }
.location-control { position:relative; min-width:0 }
.center-control { flex:none }
.building-control { max-width:calc(100% - 75px) }
.location-control > button { display:block; min-width:0; max-width:100%; overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; padding-inline:8px; font-size:.75rem; font-weight:650 }
.location-control > button::after { content:' ▾'; color:var(--quiet) }
.location-menu { position:absolute; z-index:5; top:calc(100% + 6px); right:0; min-width:166px;
  width:max-content; max-width:calc(100vw - 42px); max-height:min(330px,52vh); overflow:auto;
  overscroll-behavior:contain; padding:4px; background:var(--paper); border:1px solid var(--line); border-radius:12px;
  box-shadow:var(--shadow); scrollbar-width:none }
.location-menu::-webkit-scrollbar { display:none }
.location-menu button { display:block; width:100%; text-align:left; color:var(--ink); background:var(--paper);
  padding:7px 10px; font-size:.82rem; border:0; border-radius:8px; overflow-wrap:anywhere }
.location-menu button:is(:hover,:focus-visible,[aria-selected="true"]) { background:var(--blue-pale) }
.location-menu button[aria-selected="true"] { color:var(--route) }
.search-bar { grid-column:1/-1; display:flex; gap:7px; width:100%; min-width:0 }
.search { display:flex; align-items:center; gap:9px; flex:1; min-width:0; text-align:left; color:var(--quiet); background:var(--canvas); border-color:transparent; font-size:.9rem }
.search span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.map-shell { position:relative; isolation:isolate; min-height:0; overflow:hidden; background:var(--map) }
.map { position:absolute; inset:0 max(56px,calc(var(--safe-r) + 47px)) 0 var(--safe-l);
  touch-action:none; overscroll-behavior:contain; user-select:none; cursor:grab }
.map.dragging,.map.dragging [data-room] { cursor:grabbing }
.map > p { padding:55px 18px; color:var(--quiet) }
.map > svg { width:100%; height:100%; display:block; --map:inherit; --ink:inherit; --room:inherit; --boundary:inherit; --accent:inherit }
.map svg [data-layer="digital"] > polygon[fill="#FFFFFF"] {
  fill:var(--hall); stroke:var(--hall-line); stroke-width:.65px; vector-effect:non-scaling-stroke
}
.map [data-room] { cursor:pointer }
.map [data-room].picked > :is(polygon,path[fill-rule]) { fill:var(--selected); stroke:var(--route); stroke-width:1.7; vector-effect:non-scaling-stroke }
.map [data-room].category-match > polygon { fill:var(--selected); stroke:var(--route) }
.map [data-room].category-muted { opacity:.48 }
.map .map-label-hidden { visibility:hidden }
.map [data-layer="digital"] > g:not(.room) > path { stroke-width:1.18 }
.map .room > text { font-weight:690; pointer-events:none }
.map .room.picked > text { font-weight:800; fill:var(--ink) }
.map .vertical > path { stroke-width:1.35 }
.territory :is(.site-street,.site-footway,.site-covered) { fill:none; stroke-linejoin:round; stroke-linecap:round; vector-effect:non-scaling-stroke }
.territory .site-street { stroke:var(--site-street); stroke-width:10 }
.territory .site-footway { stroke:var(--site-path); stroke-width:2.4 }
.territory .site-court { fill:var(--court); stroke:var(--hall-line); stroke-width:1; vector-effect:non-scaling-stroke }
.territory .room > :is(polygon,path[fill-rule]) { stroke-width:1; vector-effect:non-scaling-stroke }
.territory .site-entry-marker { transform:rotate(calc(-1 * var(--map-turn,0deg))) scale(var(--marker-scale,1)) }
.territory .site-entry .entry-hit { fill:transparent }
.territory .site-entry .entry-dot { fill:var(--accent); stroke:var(--paper); stroke-width:1.5 }
.territory .site-entry .entry-sign { fill:none; stroke:#fff; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round }
.territory .site-entry.uncertain .entry-dot { fill:var(--paper); stroke:var(--route); stroke-dasharray:3 2 }
.territory .site-entry.uncertain .entry-sign { stroke:var(--route) }
.territory .site-entry.picked .entry-dot { stroke:var(--ink); stroke-width:2.5 }
.territory .site-post text { fill:var(--route); font-weight:800; paint-order:stroke; stroke:var(--map); stroke-width:2; vector-effect:non-scaling-stroke }
.territory .route-visited > :is(polygon,path[fill-rule]) {
  fill:color-mix(in srgb,var(--room) 85%,var(--route)); stroke:var(--route); stroke-width:1.15
}
.territory [data-room]:hover > :is(polygon,path[fill-rule]) { fill:var(--selected) }
.map-credit { position:absolute; bottom:5px; left:12px; color:var(--quiet); font-size:.65rem; background:var(--map) }
.map .route-path { fill:none; stroke:var(--route); stroke-width:4; stroke-linecap:round; stroke-linejoin:round; vector-effect:non-scaling-stroke }
.map .route-path.approximate { stroke-dasharray:6 5 }
.map .route-marker { transform:rotate(calc(-1 * var(--map-turn,0deg))) scale(var(--marker-scale,1)) }
.route-marker-label { text-anchor:middle; font-size:11px; font-weight:750; fill:var(--ink);
  paint-order:stroke; stroke:var(--paper); stroke-width:3; stroke-linejoin:round }
.map [data-overview-step] { pointer-events:all; cursor:pointer }
.map svg text { font-family:system-ui,sans-serif }
.overview-segment-hit { fill:none; stroke:transparent; stroke-width:18px;
  vector-effect:non-scaling-stroke; pointer-events:stroke }
.overview-segment.covered .route-path { stroke-dasharray:8 3 2 3 }
.overview-segment.vertical .route-path { stroke-width:3; stroke-dasharray:2 3 }
.overview-segment:focus-visible .route-path { stroke-width:6 }
.overview-hit { fill:transparent }
.overview-number { fill:var(--paper); stroke:var(--route); stroke-width:1.6 }
.overview-marker.covered .overview-number { fill:var(--blue-pale) }
.overview-marker.outdoor .overview-number { fill:var(--accent); stroke:var(--paper) }
.overview-marker.approximate .overview-number { stroke:var(--route); stroke-dasharray:2 2 }
.overview-marker text { fill:var(--ink); font-size:11px; font-weight:750; text-anchor:middle }
.overview-marker.outdoor text { fill:#fff }
.overview-marker.start .overview-number,.overview-marker.finish .overview-number { fill:var(--accent); stroke:var(--paper) }
.overview-marker.start text,.overview-marker.finish text { fill:#fff }
.overview-marker.elevator .overview-number { fill:var(--blue-pale) }
#step-points { margin-top:3px; color:var(--ink); font-size:.72rem; overflow-wrap:anywhere }
#overview-endpoints { font-weight:650; margin:4px 0 }
.map-label,.map-filter { display:flex; gap:6px; align-items:center; position:absolute; left:max(12px,var(--safe-l)); border:1px solid var(--line); background:var(--paper); color:var(--quiet); box-shadow:var(--shadow); border-radius:12px }
.map-label { top:12px; padding:6px 8px; font-size:.72rem; font-weight:630; pointer-events:none; max-width:calc(100% - 78px) }
.map-label .icon { width:16px; height:16px }
#map-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.north { display:flex; gap:3px; border-left:1px solid var(--line); padding-left:6px; flex:none }
.north span:first-child { transform:rotate(var(--map-turn,0deg)); color:var(--ink) }
.map-filter { bottom:12px; max-width:calc(100% - 78px); gap:0 }
.map-filter > span { padding-left:10px; font-size:.76rem }
.map-filter button { background:transparent; border:0; font-size:.76rem }
.map-filter .icon { width:17px }
.map-rail { position:absolute; right:max(9px,var(--safe-r)); top:12px; bottom:12px; display:flex; flex-direction:column; justify-content:space-between; gap:8px; width:46px; pointer-events:none }
.map-rail:has(.floor-control[hidden]) { justify-content:flex-end }
.floor-control,.zoom { pointer-events:auto; background:var(--paper); border:1px solid var(--line); border-radius:13px; box-shadow:var(--shadow); overflow:hidden }
.floor-control { min-height:0; max-height:calc(100% - 190px); display:flex }
#floor-list { width:100%; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain;
  scrollbar-width:thin; scrollbar-color:var(--boundary) transparent }
.map-rail button { display:grid; place-items:center; padding:2px; height:44px; width:44px; border:0; border-radius:0; font-size:.75rem }
.map-rail button + button { border-top:1px solid var(--line) }
#floor-list button { width:100% }
.map-rail button[aria-current="true"] { background:var(--accent); color:#fff }
.street-stage { position:absolute; left:12px; right:64px; top:46%; transform:translateY(-50%); padding:14px; border-radius:16px;
  background:var(--paper); color:var(--ink); text-align:center; box-shadow:var(--shadow); font-size:.87rem }
.bottom { position:relative; z-index:2; background:var(--paper); border-radius:20px 20px 0 0; box-shadow:var(--shadow); overflow:hidden }
.sheet { padding:0 max(12px,var(--safe-r)) max(10px,var(--safe-b)) max(12px,var(--safe-l)); }
.selection { padding-top:6px; padding-bottom:max(12px,var(--safe-b)) }
.selection:not([hidden]) + .route-sheet { display:none }
.sheet-handle,.sheet-grab span { height:4px; width:34px; background:var(--boundary); border-radius:5px; margin:auto }
.sheet-grab { display:grid; place-items:center; width:100%; border:0; height:21px; min-height:21px; padding:0 }
.sheet-head,.picker-head { display:flex; align-items:center; gap:6px; justify-content:space-between; }
.sheet-head h2,.picker-head h2,.selection-title { flex:1; min-width:0 }
.selection-title h2 { overflow-wrap:anywhere; font-size:1.15rem }
.selection-title p { font-size:.84rem; margin-top:3px; overflow-wrap:anywhere }
.selection-title small { margin-top:3px }
.sheet-head > .icon-button,.picker-head > .icon-button { border-color:transparent; background:var(--canvas) }
#favorite-room[aria-pressed="true"] { color:var(--route); background:var(--blue-pale) }
#favorite-room[aria-pressed="true"] svg { fill:var(--selected) }
.selection-actions { display:grid; gap:7px; grid-template-columns:1fr auto; margin-top:7px }
#open-floors { grid-column:1/-1 }
.route-dock { padding-top:8px; display:flex; gap:8px; flex-direction:column }
.quick-categories,.categories { display:flex; gap:6px; overflow:auto; scrollbar-width:thin; scrollbar-color:var(--boundary) transparent;
  overscroll-behavior-inline:contain; padding:0 2px 3px; --peek-left:0px; --peek-right:0px;
  mask-image:linear-gradient(to right,transparent,#000 var(--peek-left),#000 calc(100% - var(--peek-right)),transparent) }
.quick-categories.has-after,.categories.has-after { --peek-right:17px }
.quick-categories.has-before,.categories.has-before { --peek-left:11px }
.quick-categories button,.categories button { flex:none; white-space:nowrap; background:var(--canvas); border-color:transparent; font-size:.79rem; border-radius:20px }
.categories button[aria-pressed="true"],.quick-categories button[aria-pressed="true"] { color:var(--route); background:var(--blue-pale); border-color:var(--route) }
#route-panel { max-height:54dvh; overflow-y:auto; overscroll-behavior:contain }
.route-fields { display:grid; grid-template-columns:minmax(0,1fr) 44px; gap:4px 7px; margin-block:7px }
.route-fields > button:not(.icon-button) { display:flex; gap:10px; align-items:center; text-align:left; padding-block:4px; min-width:0; background:var(--canvas); border-color:transparent }
#swap-route { grid-column:2; grid-row:1/3; align-self:center }
.endpoint { flex:0 0 12px; height:12px; border:2px solid var(--route); border-radius:50% }
.endpoint.to { background:var(--route); border-radius:4px }
.field { min-width:0 }
.value { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.85rem }
.route-fields .value { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2;
  white-space:normal; overflow-wrap:anywhere; line-height:1.25 }
.route-actions { display:flex; gap:7px }
.route-actions select { flex:1; min-width:0; font-size:.85rem }
.route-actions .primary { flex:0 0 auto }
.route-indoor { display:flex; align-items:center; min-height:36px; gap:7px; font-size:.82rem; }
.route-indoor input { margin:0; accent-color:var(--accent); width:17px; height:17px }
.route-views { display:flex; flex-wrap:wrap; gap:5px; margin-block:6px }
.route-views button { flex:1; min-width:max-content; min-height:38px; font-size:.81rem }
.route-views button[aria-pressed="true"] { color:var(--route); background:var(--blue-pale); border-color:var(--route) }
.route-views small { width:100%; overflow-wrap:anywhere }
.access-row { display:flex; align-items:center; justify-content:space-between; gap:5px; font-size:.75rem; color:var(--quiet); padding-top:6px }
.access-row input { accent-color:var(--accent) }
#status,#step-text,#feedback-saved,#feedback-error { font-size:.81rem }
#status { padding:7px 9px; margin-top:6px; background:var(--blue-pale); border-radius:9px }
.steps { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; gap:8px; align-items:center; margin-top:7px }
.steps button { padding:0 }
.review-actions { display:flex; justify-content:space-between; gap:4px }
.review-actions button { background:transparent; border:0; font-size:.78rem; color:var(--quiet); padding-inline:2px }
.review-actions .icon { width:15px }
#try-outdoor { margin-top:5px; font-size:.8rem }
dialog { background:var(--paper); color:var(--ink); overscroll-behavior:contain }
dialog::backdrop { background:#0b152c70 }
.bottom-dialog { position:fixed; inset:auto 0 0; margin:0 auto; width:100%; max-width:570px; max-height:min(86dvh,var(--dialog-height,100dvh));
  border:1px solid var(--line); border-bottom:0; border-radius:20px 20px 0 0; padding:12px max(12px,var(--safe-r)) max(10px,var(--safe-b)) max(12px,var(--safe-l));
  box-shadow:var(--shadow); overflow:auto }
.bottom-dialog[open] { display:flex; flex-direction:column; gap:7px; animation:sheet-in .18s ease-out }
@keyframes sheet-in { from { opacity:.65 } to { opacity:1 } }
.picker-head,.query-row,.picker-tools,.categories,.result-meta { flex:none }
.query-row,.picker-tools,.result-meta { display:flex; gap:6px; align-items:center }
.query-field { display:flex; align-items:center; gap:6px; flex:1; min-width:0; min-height:44px; padding:0 8px; background:var(--canvas); border:1px solid var(--line); border-radius:12px }
.query-field:focus-within { border-color:var(--route) }
.query-field input { border:0; outline:0; background:transparent; flex:1; min-width:0; font-size:16px; padding:7px 0 }
#query-keyboard { font-size:.77rem; padding-inline:7px }
.picker-tools { justify-content:space-between }
.picker-tools > *, .result-meta > button { font-size:.75rem }
.picker-tools .icon,.result-meta .icon { width:15px }
.result-meta { justify-content:space-between }
#search-note { font-size:.77rem; color:var(--quiet) }
.picker-scroll { min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:var(--boundary) transparent }
:is(#floor-list,.quick-categories,.categories,.picker-scroll,#feedback-form,.bottom-dialog) { scrollbar-width:none }
:is(#floor-list,.quick-categories,.categories,.picker-scroll,#feedback-form,.bottom-dialog)::-webkit-scrollbar { display:none }
#expand-search { margin:4px 0; width:100% }
#results,#overview-list { list-style:none; padding:0; margin:0 }
#results button,#overview-list button,.history-entry > button:first-child { width:100%; text-align:left; min-height:48px; border:0; border-bottom:1px solid var(--line); border-radius:0; }
#results strong,.history-entry strong { font-size:.88rem; font-weight:650 }
#results small { margin-top:3px }
mark { color:var(--ink); background:var(--blue-pale); border-radius:3px }
.history-entry { display:flex; align-items:center; gap:4px }
.history-entry > button:last-child:not(:first-child) { width:44px; flex:none; padding:0; color:var(--quiet) }
.history-group h3 { margin:9px 0 3px }
.history-group + .history-group { margin-top:8px }
#feedback-form { display:grid; gap:7px; overflow:auto }
#feedback-note { background:var(--canvas); border:1px solid var(--line); border-radius:11px; padding:8px; resize:vertical; font-size:16px }
#overview-list button[aria-current="step"] { color:var(--route); background:var(--blue-pale) }
@media (min-width:720px) {
  .top { grid-template-columns:180px minmax(0,1fr) auto;
    padding-inline:max(22px,var(--safe-l)) max(22px,var(--safe-r)) }
  .search-bar { grid-column:2; grid-row:1; max-width:550px; justify-self:center }
  .location { grid-column:3; grid-row:1 }
  .building-control { max-width:190px }
  .bottom { width:min(600px,100%); justify-self:center; align-self:end }
  .map-rail { right:max(18px,var(--safe-r)) }
  .map { inset-inline:max(66px,var(--safe-l)) max(66px,calc(var(--safe-r) + 47px)) }
  .route-dock { flex-direction:row; align-items:center }
  .route-dock > .primary { margin-left:auto }
  .bottom-dialog { bottom:12px; border-radius:20px; border-bottom:1px solid var(--line) }
}
@media (max-width:719px) {
  .map.outdoor-map { inset-inline:var(--safe-l) var(--safe-r) }
  .map-shell:has(.outdoor-map) .map-rail { width:auto }
  .map-shell:has(.outdoor-map) .zoom { display:flex }
  .map-shell:has(.outdoor-map) .zoom button+button { border-top:0; border-left:1px solid var(--line) }
}
@media (max-height:510px) {
  .bottom-dialog { bottom:0; gap:3px; padding-top:4px; max-height:min(100dvh,var(--dialog-height,96dvh)) }
  .bottom-dialog[open] { gap:3px }
  .map-label,.map-rail { top:6px }
  .map-rail { bottom:6px; width:auto }
  .zoom { display:flex }
  .zoom button + button { border-top:0; border-left:1px solid var(--line) }
  .floor-control { max-height:calc(100% - 52px); width:46px; align-self:end }
  .map-shell { min-height:0 }
}
@media (prefers-reduced-motion:reduce) { .bottom-dialog[open] { animation:none } }
