:root {
  --ink: #000; --paper: #fff; --sky: #e4e8ea; --land: #f4f3ef; --water: #b5c7c6; --rule: #cfd5d8;
  --muted: #5d6266; --accent: #c8102e; --blue: #1f4e8c; --soft: #f1f3f4; --text2: #4b5257;
  --panel-w: 300px; --header-h: 64px;
  --font: 'Schibsted Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --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);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--font); color: var(--ink); background: var(--sky); -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--paper); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* Header */
.top { position: relative; z-index: 30; display: flex; align-items: center; gap: 16px; height: var(--header-h);
  padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; }
.brand .word { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.brand .city { font-size: 18px; color: var(--muted); }
.menu-btn, .base-btn { display: none; }
.search { position: relative; flex: 1 1 420px; max-width: 640px; }
.search-box { display: flex; align-items: center; gap: 8px; border: 1px solid #b9c0c4; border-radius: 12px;
  padding: 4px 4px 4px 12px; background: var(--paper); }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(31,78,140,.18); }
.search-icon { color: var(--text2); flex: 0 0 auto; }
#q { flex: 1 1 auto; min-width: 0; border: 0; outline: none; font-size: 16px; padding: 9px 0; background: transparent; }
#q::-webkit-search-cancel-button { cursor: pointer; }
.seg { display: flex; gap: 2px; background: var(--soft); border-radius: 9px; padding: 3px; flex: 0 0 auto; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 7px 10px; font-size: 13px; font-weight: 600;
  color: var(--text2); min-height: 34px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.14); }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 0; list-style: none; z-index: 40;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 12px 30px rgba(30,40,50,.16); overflow: hidden; }
.results li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; min-height: 48px;
  border-bottom: 1px solid var(--soft); cursor: pointer; }
.results li:last-child { border-bottom: 0; }
.results li[aria-selected="true"], .results li:hover { background: #eef2f6; }
.results .addr { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.results .a1 { font-weight: 600; font-size: 14px; }
.results .a2 { font-size: 12px; color: var(--text2); }
.results .rc { font-size: 12px; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.results .empty { cursor: default; font-size: 14px; color: var(--text2); }

/* Layout */
.layout { position: absolute; inset: var(--header-h) 0 0 0; display: flex; }
.panel { width: var(--panel-w); flex: 0 0 var(--panel-w); background: var(--paper); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; min-height: 0; z-index: 20; }
.panel-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; }
.panel h2 { margin: 0 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); }
.h2row { display: flex; justify-content: space-between; align-items: baseline; }
.h2row span { font-size: 12px; color: var(--text2); }
.panel section > .seg { margin-bottom: 4px; }
.panel .seg button { flex: 1 1 0; }
.row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; cursor: pointer; }
.row.disabled { cursor: default; color: #7b8185; }
.row input { accent-color: var(--blue); width: 20px; height: 20px; margin: 0; flex: 0 0 auto; }
.row .txt { display: flex; flex-direction: column; min-width: 0; }
.row .name { font-weight: 600; font-size: 14px; }
.row .meta { font-size: 11px; color: var(--text2); }
.row.disabled .meta { color: #6b7175; }
.grp { display: block; margin-top: 10px; padding-bottom: 2px; border-bottom: 1px solid #e3e7e9; font-size: 12px; font-weight: 700; }
.ov { border-bottom: 1px solid var(--soft); }
.sw { width: 18px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.sw.line-ink { border: 0; border-top: 2px dashed var(--ink); height: 0; border-radius: 0; }
.sw.hatch-blue { background: repeating-linear-gradient(45deg, #2d6fb6 0 2px, #cfe0f3 2px 5px); }
.sw.teal { background: #5aa9a3; } .sw.gold { background: #c9a227; } .sw.red { background: var(--accent); }
.sw.dots-orange { background: radial-gradient(#e07b28 1.2px, #fde8d4 1.4px) 0 0/5px 5px; }
.sw.line-red { border: 0; border-top: 2px solid var(--accent); height: 0; border-radius: 0; }
.sw.line-grey { border: 0; border-top: 2px solid #7b8185; height: 0; border-radius: 0; }
.sw.line-blue { border: 0; border-top: 2px solid var(--blue); height: 0; border-radius: 0; }
.periods { display: flex; gap: 6px; padding: 0 0 8px 32px; }
.periods button { border: 1px solid var(--rule); background: var(--paper); border-radius: 7px; padding: 6px 8px; font-size: 12px; min-height: 32px; }
.periods button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.attrib { margin: 0; font-size: 11px; line-height: 1.5; color: var(--text2); }
.drawer-head, .drawer-foot { display: none; }
.primary { width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 16px; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--soft); font-size: 24px; line-height: 1; }

/* Map */
.map-wrap { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.map { position: absolute; inset: 0; background: #f4f3ef; overflow: hidden; outline-offset: -3px; font-family: var(--font); }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-ctrl-bottom-right { right: 0; bottom: 0; }
.map.is-dragging { cursor: grabbing; }
.map-base, .map-canvas, .map-svg, .tiles { position: absolute; inset: 0; width: 100%; height: 100%; }
.map.is-aerial { background: #3d4a3c; }
.tiles { pointer-events: none; overflow: hidden; }
.tiles img { position: absolute; left: 0; top: 0; transform-origin: 0 0; opacity: 0; transition: opacity .2s; user-select: none; }
.tiles img.loaded { opacity: 1; }
.map-canvas { pointer-events: none; }
.map-svg { pointer-events: none; overflow: visible; }
.hood-line { fill: none; stroke: var(--ink); stroke-width: 1.6px; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; display: none; }
.hoods-on .hood-line { display: inline; }
.hood-labels { display: none; font: 600 11px var(--font); letter-spacing: .06em; text-transform: uppercase; text-anchor: middle; }
.hoods-on .hood-labels { display: inline; }
.hood-labels text { fill: var(--ink); paint-order: stroke; stroke: rgba(255,255,255,.92); stroke-width: 3.5px; }
.hood-labels text.in-area { font-weight: 800; }
.is-aerial .hood-line { stroke: #fff; }
.sel-path { fill: none; stroke: var(--ink); stroke-width: 3.5px; vector-effect: non-scaling-stroke; stroke-linejoin: round;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1px #fff); }
.is-aerial .sel-path { stroke: #ffd400; }

.zoom { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 0; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; z-index: 5; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.zoom button { width: 44px; height: 44px; border: 0; border-bottom: 1px solid var(--soft); background: var(--paper); font-size: 22px;
  display: grid; place-items: center; }
.zoom button:last-child { border-bottom: 0; }
.legend { position: absolute; left: 16px; bottom: 16px; z-index: 5; background: rgba(255,255,255,.96); border: 1px solid var(--rule);
  border-radius: 12px; padding: 10px 12px; text-align: left; cursor: default; max-width: 320px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.legend .lt { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.legend .li { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.legend .it { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); }
.legend .it i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.12); }
.legend .note { font-size: 11px; color: var(--text2); margin-top: 6px; }
.status { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); margin: 0; background: var(--ink); color: var(--paper);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; z-index: 6; }
.status:empty { display: none; }

/* Card */
.card { position: absolute; right: 76px; top: 16px; width: 360px; max-height: calc(100% - 32px); overflow-y: auto; z-index: 8;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 16px 40px rgba(30,40,50,.18); }
.card .grab { display: none; }
.c-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 16px 16px 0; }
.c-head .hood { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); }
.c-head h3 { margin: 2px 0 2px; font-size: 20px; line-height: 1.2; }
.c-head .ref { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }
.tiles3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 16px; }
.tile { background: var(--soft); border-radius: 10px; padding: 10px; }
.tile .k { font-size: 11px; color: var(--text2); }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.tile .v small { font-size: 12px; font-weight: 500; color: var(--text2); }
.rows { margin: 0; padding: 0 16px; }
.rows div { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-top: 1px solid var(--soft); }
.rows dt { font-size: 13px; font-weight: 600; }
.rows dd { margin: 0; font-size: 13px; text-align: right; }
.rows .src { grid-column: 1 / -1; font-size: 11px; color: var(--text2); }
.rows .pending dd { color: #6b7175; }
.c-foot { display: flex; gap: 8px; padding: 14px 16px 16px; align-items: center; }
.c-foot a { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 12px;
  background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 700; }
.c-foot button { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); font-weight: 600; }
.c-note { padding: 0 16px 14px; font-size: 11px; color: var(--text2); line-height: 1.45; }
.scrim { display: none; }

/* Mobile */
@media (max-width: 1023.98px) {
  :root { --header-h: 0px; }
  .top { position: absolute; left: 0; right: 0; top: 0; height: auto; display: grid; grid-template-columns: 48px 1fr auto;
    grid-template-areas: "menu search search" ". mode base"; gap: 8px; padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
    background: transparent; border: 0; pointer-events: none; }
  .top > * { pointer-events: auto; }
  .top > .brand { display: none; }
  .menu-btn { grid-area: menu; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--ink);
    box-shadow: 0 4px 12px rgba(0,0,0,.25); }
  .search { display: contents; }
  .search-box { grid-area: search; height: 48px; border-radius: 24px; box-shadow: 0 4px 12px rgba(0,0,0,.15); padding-right: 12px; }
  .search-box .seg.mode { position: absolute; left: 68px; top: calc(66px + var(--safe-t)); box-shadow: 0 2px 8px rgba(0,0,0,.15); background: #e9ecee; }
  .search-box .seg.mode button { min-height: 36px; }
  .base-btn { grid-area: base; display: block; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--rule);
    background: var(--paper); font-weight: 600; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
  .results { grid-column: 1 / -1; position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r));
    top: calc(116px + var(--safe-t)); }
  .layout { inset: 0; }
  .panel { position: fixed; left: 0; top: 0; bottom: 0; width: min(340px, 88vw); z-index: 50; transform: translateX(-102%);
    transition: transform .28s ease; box-shadow: 8px 0 30px rgba(0,0,0,.2); padding-top: var(--safe-t); padding-left: var(--safe-l); visibility: hidden; }
  .panel.open { transform: none; visibility: visible; }
  .drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--rule); }
  .drawer-foot { display: block; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--rule); background: var(--paper); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45; transition: opacity .28s; }
  .scrim[hidden] { display: none; }
  .zoom { top: auto; bottom: calc(124px + var(--safe-b)); right: calc(12px + var(--safe-r)); }
  .maplibregl-ctrl-bottom-right { bottom: calc(84px + var(--safe-b)); right: calc(6px + var(--safe-r)); }
  .zoom button:last-child { display: none; }
  .legend { left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); max-width: none; cursor: pointer; padding: 8px 10px; }
  .legend .li { flex-wrap: nowrap; overflow: hidden; gap: 6px; }
  .legend .it { font-size: 11px; white-space: nowrap; }
  .legend .note { display: none; }
  .card { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 62%; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding-bottom: var(--safe-b); transform: translateY(0); transition: transform .3s ease; box-shadow: 0 -10px 30px rgba(30,40,50,.2); }
  .card.closing { transform: translateY(105%); }
  .card .grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: #c3c9cd; margin: 8px auto 0; }
  .c-head { padding-top: 8px; }
  .c-head h3 { font-size: 18px; }
  .rows { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .rows div { grid-template-columns: 1fr; }
  .rows dd { text-align: left; font-weight: 600; }
  .rows dt { font-weight: 500; color: var(--text2); font-size: 12px; }
  .rows .src { display: none; }
  .sheet-open .zoom, .sheet-open .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
