:root { --bg: #10121a; --panel: rgba(20, 23, 32, 0.92); --fg: #e6e8ee; --muted: #9aa3b5; --accent: #e0b44c;
  --line: #2c3242; font: 13px/1.4 system-ui, sans-serif; color: var(--fg); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; }
#map canvas { display: block; cursor: grab; }
body.measuring #map canvas, body.placing #map canvas { cursor: crosshair; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
select, button, input, textarea { font: inherit; color: var(--fg); background: #1c2130; border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 6px; }
button { cursor: pointer; }
button.on { background: #3a3220; border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
#toolbar { position: fixed; top: 10px; left: 10px; max-width: calc(100vw - 370px); display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.seg button { border-radius: 0; margin-right: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
#overlays summary { cursor: pointer; }
#overlays label { display: block; white-space: nowrap; }
#legend { position: fixed; top: 56px; left: 10px; max-height: 45vh; overflow: auto; min-width: 200px; }
#legend .sw { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border: 1px solid #0006; }
#legend .bar { height: 10px; border-radius: 2px; margin-top: 4px; }
#legend .ticks { display: flex; justify-content: space-between; color: var(--muted); }
#status { position: fixed; left: 10px; bottom: 10px; display: flex; gap: 14px; align-items: center; color: var(--muted); }
#scale-bar { display: inline-block; height: 6px; border: 1px solid var(--fg); border-top: none; vertical-align: middle; }
#panel { position: fixed; top: 10px; right: 10px; bottom: 10px; width: 340px; display: flex; flex-direction: column; }
#panel nav { display: flex; gap: 4px; margin-bottom: 6px; }
#panel-toggle { margin-left: auto; }
#panel section { overflow: auto; flex: 1; }
#panel.collapsed { bottom: auto; }
#panel.collapsed section { display: none; }
.fields h4 { margin: 10px 0 2px; color: var(--accent); font-weight: 600; }
.fields div { display: flex; justify-content: space-between; gap: 8px; }
.fields .alt { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.warn { color: #f0a050; }
.pin-item { padding: 4px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.pin-item:hover b { color: var(--accent); }
form.pin label { display: block; margin: 6px 0; }
form.pin input, form.pin textarea { display: block; width: 100%; }
form.pin select { display: block; width: 100%; }
form.pin .coords { display: flex; gap: 8px; }
form.pin .coords label { flex: 1; }
#markers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.marker { position: absolute; left: 0; top: 0; }
.marker.clickable { pointer-events: auto; cursor: pointer; }
.marker.draft .dot { background: #fff; }
.marker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 1px solid #000; }
.marker.measure .dot { background: #7fd4ff; }
.marker.vent { pointer-events: auto; }
.marker.vent .dot { width: 7px; height: 7px; }
.marker.vent.t0 .dot { background: #e6281e; }
.marker.vent.t1 .dot { background: #f5f5f5; }
.marker.vent.t2 .dot { background: #faa028; }
.marker.vent.t3 .dot { background: #28dce6; }
.marker.vent.cluster .dot { width: 12px; height: 12px; background: #e6281e; opacity: 0.8; }
.marker .label { position: absolute; left: 11px; top: -5px; white-space: nowrap; text-shadow: 0 0 3px #000, 0 0 3px #000; }
#toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #5a2020; padding: 6px 12px;
  border-radius: 4px; display: none; max-width: 80vw; }
#toast.show { display: block; }
#toast.info { background: #2c3242; }
#nav { position: fixed; right: 362px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; padding: 4px; }
#nav button { width: 30px; height: 30px; padding: 0; font-size: 15px; line-height: 1; }
#map canvas { touch-action: none; }   /* drags belong to the map, not to page scrolling */
#nav-north span { display: inline-block; font-weight: 700; transition: transform 0.1s; }
#nav-north.on span { color: var(--accent); }
#nav-3d { font-size: 11px !important; font-weight: 700; }
#help { position: fixed; right: 404px; bottom: 50px; max-width: 420px; padding: 10px 14px; z-index: 20; cursor: pointer; }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; }
#help dt { color: var(--accent); white-space: nowrap; }
#help dd { margin: 0; }
@media (max-width: 700px) { #help { right: 8px; left: 8px; max-width: none; } }
#nav-3d.on { color: var(--accent); }
#exag-box { position: fixed; right: 404px; bottom: 10px; display: flex; align-items: center; gap: 6px; padding: 4px 8px; }
#exag { width: 110px; }
#opacity { width: 90px; height: 30px; }
#searchbox { position: relative; }
#search { width: 250px; height: 30px; }
#suggest { position: absolute; top: 34px; left: 0; min-width: 250px; max-height: 50vh; overflow: auto; padding: 2px; }
#suggest .item { padding: 4px 6px; cursor: pointer; border-radius: 3px; white-space: nowrap; }
#suggest .item.sel, #suggest .item:hover { background: #3a3220; }
#suggest .sub { color: var(--muted); font-size: 12px; margin-left: 6px; }
.marker.search .dot { background: #ff6a4d; }
.marker.probe .dot { background: #fff; width: 6px; height: 6px; }
.profile { display: block; margin-top: 6px; background: #151924; border-radius: 4px; }
.profile .area { fill: rgba(224, 180, 76, 0.18); }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.profile .sea { stroke: #5ab4ff; stroke-dasharray: 3 3; }
.profile .water { fill: rgba(90, 180, 255, 0.18); }
.profile .cursor { stroke: #fff; }
.profile text { fill: var(--muted); font-size: 10px; }
.readout { min-height: 1.4em; }
#sky-toggle { height: 30px; }
#skybar { position: fixed; left: 10px; bottom: 52px; max-width: calc(100vw - 420px); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; white-space: nowrap; }
#skybar input[type=range] { width: 130px; vertical-align: middle; }
.marker.sun .dot { background: #ffd166; width: 12px; height: 12px; box-shadow: 0 0 8px #ffd166; }
.region label { display: block; margin: 6px 0; }
.region input { width: 100%; }

/* Phones (layout.js sets body.compact + .portrait / .landscape): the toolbar folds into ☰, the panel becomes a bottom
   sheet (portrait) or a narrow side panel (landscape), map buttons get finger-sized. */
#menu-toggle { display: none; }
body.compact #menu-toggle { display: block; width: 40px; height: 40px; padding: 0; font-size: 18px; }
body.compact #toolbar { top: 8px; left: 8px; right: 8px; max-width: none; gap: 6px; }
body.compact #toolbar > * { display: none; }
body.compact #toolbar > #menu-toggle, body.compact #toolbar > #searchbox { display: block; }
body.compact #searchbox { flex: 1; min-width: 0; }
body.compact #search { width: 100%; height: 40px; font-size: 16px; }   /* 16 px: phones don't zoom into the field */
body.compact #suggest { min-width: 100%; }
body.compact.menu-open #toolbar { max-height: calc(100vh - 16px); overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
body.compact.menu-open #toolbar > :not([hidden]) { display: block; flex: 1 1 100%; }
body.compact.menu-open #toolbar > #menu-toggle { flex: 0 0 40px; }
body.compact.menu-open #toolbar > #searchbox { flex: 1 1 0; order: 0; }
body.compact.menu-open #toolbar > :not(#menu-toggle):not(#searchbox) { order: 1; }
body.compact.menu-open #toolbar > #views { display: flex; }
body.compact #views button { flex: 1; min-height: 40px; }
body.compact select { min-height: 40px; width: 100%; font-size: 15px; }
body.compact #overlays summary { min-height: 32px; line-height: 32px; }
body.compact #overlays label { padding: 6px 0; }
body.compact #sky-toggle { width: 100%; height: 40px; }
body.compact #opacity { width: 100%; }
body.compact #legend { top: 56px; left: 8px; max-width: calc(100vw - 72px); min-width: 0; max-height: 28vh; font-size: 11px; }
body.compact #status { gap: 8px; padding: 3px 6px; font-size: 12px; }
body.compact #cursor, body.compact #hover { display: none; }
body.compact #nav { right: 8px; gap: 4px; }
body.compact #nav button { width: 40px; height: 40px; font-size: 17px; }
body.compact #nav-in, body.compact #nav-out, body.compact #nav-full, body.compact #nav-export,
body.compact #nav-help { display: none; }   /* zoom: pinch; the rest are desktop tools */
body.compact #help { display: none !important; }
body.compact #panel nav button { min-height: 36px; }
body.compact #exag-box { right: 56px; }

/* portrait: the panel is a bottom sheet, folded to its tab row until opened */
body.portrait #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 45vh; border-radius: 12px 12px 0 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom)); }
body.portrait #panel.collapsed { height: auto; }
body.portrait #nav, body.portrait #exag-box { bottom: 60px; }
body.portrait #status { bottom: 60px; left: 8px; }
body.portrait #skybar { left: 8px; right: 8px; bottom: 100px; max-width: none; }
body.portrait:has(#panel:not(.collapsed)) #nav, body.portrait:has(#panel:not(.collapsed)) #exag-box,
body.portrait:has(#panel:not(.collapsed)) #status { bottom: calc(45vh + 8px); }
body.portrait:has(#panel:not(.collapsed)) #skybar { bottom: calc(45vh + 48px); }

/* landscape phone: a narrow side panel; map buttons left of it */
body.landscape #toolbar { right: calc(min(300px, 42vw) + 16px); }
body.landscape #panel { width: min(300px, 42vw); top: 8px; right: 8px; bottom: 8px; }
body.landscape #nav, body.landscape #exag-box { right: calc(min(300px, 42vw) + 16px); bottom: 8px; }
body.landscape #exag-box { right: calc(min(300px, 42vw) + 64px); }
body.landscape #status { bottom: 8px; left: 8px; }
body.landscape #skybar { left: 8px; bottom: 44px; max-width: calc(100vw - min(300px, 42vw) - 80px); }
body.landscape #legend { max-height: 40vh; }
body.landscape #panel.collapsed { bottom: auto; }
body.compact.menu-open #toolbar { z-index: 30; }
body.compact #views button { font-size: 13px; white-space: nowrap; padding: 3px 2px; }
body.compact #panel section { scrollbar-width: thin; scrollbar-color: #3a4256 transparent; padding-right: 2px; }
body.compact #exag { width: 90px; }
body.portrait #exag-box { right: auto; left: 8px; bottom: 96px; }
body.portrait:has(#panel:not(.collapsed)) #exag-box { bottom: calc(45vh + 44px); }
body.landscape #exag-box { right: auto; left: 8px; bottom: 44px; }
body.landscape #skybar { bottom: 80px; }
body.compact #sky-toggle::after { content: " Sky & seasons"; }
body.compact #status { max-width: calc(100vw - 72px); flex-wrap: wrap; row-gap: 0; }
body.compact #detail-badge { white-space: nowrap; }
