/* =====================================================================
   Design tokens — the single source of colour for the whole app.
   js/config.js reads the --fx-*, --hue-* and status tokens at start-up,
   so MapLibre styles, chips, legend and inspector all use these values.
   See docs/UI_DESIGN.md.
   ===================================================================== */
:root {
  /* neutrals (slate, slight green bias) */
  --bg: #F3F5F4;
  --surface: #FFFFFF;
  --surface-2: #EDF1EF;
  --line: #D8DFDC;
  --line-soft: #E6EBE9;
  --text: #16201D;
  --text-2: #4A5752;
  --text-3: #626F6A;      /* spec #7A8782 darkened: ≥ 4.5:1 on --surface and --bg for 12px text */
  /* brand / interactive */
  --accent: #1F5C63;
  --accent-soft: #E1EEEF;
  --focus: #1F5C63;
  /* planning effect */
  --fx-ban: #B3261E;
  --fx-penalty: #D9601A;
  --fx-permit: #B7860B;
  --fx-cost: #6B4FA0;
  --fx-flag: #8A5A2B;
  --fx-info: #5B6B66;
  --fx-base: #16201D;
  /* category hues (sidebar swatch + default map colour) */
  --hue-nature: #3F7F4E;
  --hue-water: #2B6CB0;
  --hue-heritage: #7B4B94;
  --hue-ground: #8A5A2B;
  --hue-crossings: #455A64;
  --hue-network: #6B7B76;
  --hue-zones: #9A7B4F;
  --hue-check: #9AA5A1;
  /* status (alerts only) */
  --ok: #2E7D4F;
  --warn: #B7860B;
  --danger: #B3261E;

  --shadow: 0 1px 2px rgba(22,32,29,.06), 0 4px 16px rgba(22,32,29,.08);
  --r: 8px;
  --r-sm: 5px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font: 14px/20px var(--sans);
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.small { font-size: 12px; line-height: 16px; }
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }
.t-ok { color: var(--ok); }
.t-warn { color: #8A6508; }       /* --warn is too light for text on white; darker step of the same hue */
.t-danger { color: var(--danger); }
.t-info { color: var(--text-2); }
.dot { color: var(--text-3); }

/* visible focus everywhere (keyboard only) */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input[type=search]:focus-visible { outline-offset: 0; }

.btn-link { background: none; border: 0; padding: 2px 0; color: var(--accent); font-size: 12px; line-height: 16px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

#app { display: grid; grid-template-columns: 360px minmax(0, 1fr) auto; grid-template-rows: 68px minmax(0, 1fr); height: 100vh; }
#workspace-header { grid-column: 1 / -1; grid-row: 1; z-index: 25; display: flex; min-width: 0; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 2px 12px rgba(22,32,29,.045); }
.workspace-brand { box-sizing: border-box; width: 360px; flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-right: 1px solid var(--line); min-width: 0; }
.workspace-brand .brand-copy { display: grid; gap: 1px; min-width: 0; }
.mode-tabs { display: flex; align-items: stretch; gap: 4px; padding: 0 18px; min-width: 0; }
.mode-tabs button { display: grid; align-content: center; gap: 1px; min-width: 126px; padding: 8px 14px 6px; border: 0; border-bottom: 3px solid transparent; background: none; text-align: left; color: var(--text-2); }
.mode-tabs button strong { font-size: 14px; line-height: 18px; font-weight: 650; }
.mode-tabs button small { color: var(--text-3); font-size: 11px; line-height: 14px; white-space: nowrap; }
.mode-tabs button:hover { color: var(--text); background: var(--bg); }
.mode-tabs button[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-soft); }
.mode-tabs button:focus-visible { outline-offset: -3px; }
#workspace-health { display: flex; align-items: center; margin-left: auto; padding-left: 10px; }
.workspace-health-link { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid #EDD5D0; border-radius: 15px;
  background: #FFF5F3; color: #A43B31; font-size: 11px; line-height: 14px; white-space: nowrap; }
.workspace-health-link b { font-variant-numeric: tabular-nums; font-weight: 700; }
.workspace-health-link:hover, .workspace-health-link.active { border-color: var(--danger); background: #FCE8E5; }
#workspace-user { position: relative; display: flex; align-items: center; justify-content: flex-end; padding: 0 18px; min-width: 0; }

/* =============================== sidebar =============================== */
#panel { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.panel-head { padding: 14px 16px 10px; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, #153C43, #276C67); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 2px 8px rgba(22,58,60,.2); }
.logo svg { width: 31px; height: 31px; display: block; }
h1 { font-size: 16px; line-height: 21px; margin: 0; font-weight: 700; letter-spacing: -.025em; }
.sub { margin: 0; color: var(--text-3); font-size: 11.5px; line-height: 15px; }
.issues-link { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; border: 1px solid #EDD5D0; border-radius: 15px;
  background: #FFF5F3; color: #A43B31; padding: 3px 7px; font-size: 11px; line-height: 14px; font-weight: 650; }
.issues-link:hover, .issues-link.active { border-color: var(--danger); background: #FCE8E5; }

.side-tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.side-tabs [role=tab] { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 8px 7px;
  color: var(--text-2); font-weight: 550; font-size: 14px; }
.side-tabs [role=tab]:hover { color: var(--text); }
.side-tabs [role=tab][aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.panel-coverage { display: flex; align-items: center; gap: 10px; min-height: 39px; padding: 6px 16px; border-bottom: 1px solid var(--line-soft);
  background: #FAFCFB; color: var(--text-2); font-size: 11px; line-height: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.panel-coverage b { color: var(--text); font-size: 12px; font-weight: 700; }
.coverage-divider { width: 1px; height: 14px; background: var(--line); }
.coverage-clear { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--ok); }
.clear-dot, .issues-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }
.pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.panel-tools { display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px; }
.panel-tools input[type=search] { flex: 1; min-width: 0; height: 30px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 13px; background: var(--bg); color: var(--text); }
.panel-tools input[type=search]::placeholder { color: var(--text-3); }
.filter-note { display: flex; justify-content: space-between; align-items: center; margin: 0 16px 6px; padding: 4px 8px;
  background: color-mix(in srgb, var(--danger) 8%, white); border-radius: 6px; font-size: 12px; color: var(--text-2); }

.layer-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 0 12px; }
.empty { padding: 14px 16px; color: var(--text-3); }

/* ---------------- layer tree: group › sub-group › layer ----------------
   Left edge = indentation only (chevron, tree guide lines, category dot).
   Right edge = fixed columns shared by every level, so they line up:
   [effect swatches 50] [count 34] [alert 18] [show control 22]. */
.group { border-top: 1px solid var(--line); }
.group:first-child { border-top: 0; }
/* level 1: full-width band, caps */
.group-h { margin: 0; display: flex; align-items: center; height: 36px; padding: 0 10px 0 6px; background: var(--surface-2); }
.group-head { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 100%; background: none; border: 0; padding: 0 0 0 2px;
  text-align: left; font-size: 11px; line-height: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.group-head:hover .group-label { text-decoration: underline; text-underline-offset: 3px; }
.group-head .chev { color: var(--text-2); transition: transform .12s; flex: none; }
.group.open .group-head .chev { transform: rotate(90deg); }
.group-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-note, .state-note { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-3); font-size: 11px; white-space: nowrap; }
.group-body { padding: 2px 0 6px; }
/* tree guide: a thin vertical line under the parent's chevron / label */
.tree { margin-left: 14px; border-left: 1px solid var(--line); }
/* level 2: sub-group, indented one step, sentence case semibold */
.sub-head { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 10px; margin-top: 2px; }
.sub-label { flex: 1; min-width: 0; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-2); }
.sub-head .state-note { flex: none; margin-right: auto; }
.sub-head .sub-label:has(+ .state-note) { flex: none; }
.sub .tree { margin-left: 16px; }
/* a hidden group / sub-group: rows stay editable, but read as "not on the map right now" */
.group-off .group-label, .sub-off .sub-label { color: var(--text-3); }
.layer.dim .row { opacity: .5; }
.layer.dim .row:hover, .layer.dim .row:focus-within { opacity: .85; }

/* level 3: layer row */
.layer .row { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 10px; }
.layer .row:hover { background: var(--bg); }
.layer.expanded { background: var(--bg); margin-bottom: 4px; }
.rowbtn { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; align-self: stretch; background: none; border: 0; padding: 0; text-align: left; }
.rowbtn .name { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 450; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer.off .rowbtn .name { color: var(--text-2); }
.count { width: 34px; flex: none; text-align: right; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: 0; font-weight: 400; text-transform: none; }
.count .of { color: var(--text-3); }
.group-h .count, .sub-head .count { color: var(--text-2); }
.alert-slot { width: 18px; flex: none; display: inline-flex; justify-content: center; }
.alert { display: inline-flex; background: none; border: 0; padding: 2px; border-radius: 4px; }
.alert-danger { color: var(--danger); }
.alert-warn { color: var(--warn); }
.alert-info { color: var(--text-3); }
.layer.nodata .name { color: var(--text-3); }

/* effect swatches: the map's hatch + edge, one per effect the layer's features have */
.fxs { display: inline-flex; gap: 3px; justify-content: flex-end; align-items: center; width: 50px; flex: none; }
.fxsw { width: 15px; height: 11px; border-radius: 2px; box-sizing: border-box; flex: none; cursor: help; }
.fxsw:focus-visible, .fx-more:focus-visible { outline-offset: 1px; }
.fx-more { font-size: 11px; color: var(--text-3); cursor: help; }
.layer.off .fxs { opacity: .6; }

/* one control, one size, one column: a 16 px checkbox (tri-state on groups) */
.ctl { width: 22px; flex: none; display: inline-flex; justify-content: flex-end; align-items: center; }
.cb { appearance: none; -webkit-appearance: none; margin: 0; width: 16px; height: 16px; border-radius: 4px; flex: none; cursor: pointer;
  border: 1.5px solid #8A9792; background: var(--surface) center / 12px 12px no-repeat; transition: background-color .1s, border-color .1s; }
.cb:hover { border-color: var(--accent); }
.cb:checked { background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.cb:indeterminate { background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' stroke='white' stroke-width='1.9' stroke-linecap='round'/%3E%3C/svg%3E"); }
.cb:disabled { border-color: var(--line); background-color: var(--surface-2); cursor: default; }
.cb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.layer.off .swatch { opacity: .55; }

/* shared tooltip (hover + keyboard focus) */
.tip { position: fixed; z-index: 50; max-width: 280px; padding: 6px 9px; border-radius: 6px; background: var(--text); color: #fff;
  font-size: 12px; line-height: 16px; white-space: pre-line; pointer-events: none; box-shadow: var(--shadow); }

/* effect chip: the only coloured element in a row */
.chip { display: inline-flex; align-items: center; flex: none; height: 18px; padding: 0 7px; border-radius: 9px;
  font-size: 11px; line-height: 18px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 88%, black); }
.chip.fx-permit { color: #7F5E07; } /* ochre / orange need a darker text step for 4.5:1 */
.chip.fx-penalty { color: #A3450F; }
/* layer with several per-feature effects: one neutral chip, each word in its effect colour */
.chip-mix { background: var(--surface-2); color: var(--text-2); gap: 4px; padding: 0 6px; }
.chip-mix b { font-weight: 600; color: color-mix(in srgb, var(--c) 88%, black); }
.chip-mix b.fx-permit { color: #7F5E07; }
.chip-mix b.fx-penalty { color: #A3450F; }
.chip-mix .sep { color: var(--text-3); font-weight: 400; }
.chip-mix i { font-style: normal; font-weight: 500; color: var(--text-3); }

/* "?" explainer */
.help-btn { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; line-height: 18px; font-weight: 650; color: var(--text-2); padding: 0; }
.help-btn:hover, .help-btn[aria-expanded=true] { border-color: var(--accent); color: var(--accent); }
.fx-help { margin: 0 16px 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); font-size: 12px; line-height: 16px; }
.fxh-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.fxh-head .icon-btn { font-size: 16px; padding: 0 4px; }
.fx-help ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 5px; }
.fx-help li { display: grid; grid-template-columns: 78px 1fr; gap: 8px; align-items: start; color: var(--text-2); }
.fx-help li .chip { justify-self: start; }
.fx-help p { margin: 0; }
.layer.off .chip { opacity: .75; }

/* restricted rows */
.layer.restricted .name { color: var(--text-3); font-weight: 450; }
.lock { color: var(--text-3); }
.req { flex: none; background: none; border: 0; padding: 2px 2px; font-size: 12px; color: var(--accent); font-weight: 500; }
.req:hover { text-decoration: underline; }

/* expand area (tertiary) */
.more { padding: 2px 10px 10px 25px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; overflow-wrap: anywhere; font-size: 12px; line-height: 16px; color: var(--text-2); }
.more p { margin: 0; }
.full-title { color: var(--text); font-size: 12px; }
.meta { color: var(--text-3); font-size: 12px; line-height: 16px; }
.meta code { font-size: 11px; }
.conf i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: 4px; vertical-align: 1px; }
.alert-line { font-weight: 500; }
.note { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.op { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.op input { flex: 1; accent-color: var(--accent); }
.mini-h { font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 2px 0; }
.tables { display: grid; gap: 2px; }
.tbl { display: flex; align-items: center; gap: 6px; }
.tbl input { margin: 0; accent-color: var(--accent); }
.tbl .tname { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .tn { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.tbl.missing .tname { text-decoration: line-through; }
.legend { list-style: none; margin: 2px 0 4px 20px; padding: 0; display: grid; gap: 1px; }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend li span:not(.sw) { flex: 1; }
.legend em { color: var(--text-3); font-style: normal; font-size: 11px; font-variant-numeric: tabular-nums; }
.sw { width: 14px; height: 10px; border-radius: 2px; background: color-mix(in srgb, var(--c) 45%, white); border: 1.5px solid var(--c); flex: none; }
.sw.hollow { background: transparent; }
.sw-line { height: 3px; border: 0; background: var(--c); border-radius: 2px; }
.sw-point { width: 9px; height: 9px; border-radius: 50%; background: var(--c); border: 1px solid #fff; box-shadow: 0 0 0 1px var(--c); }
.actions { display: flex; gap: 14px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 550; }
.tag-warn { background: color-mix(in srgb, var(--warn) 16%, white); color: #7A5B00; }
.tag-danger { background: color-mix(in srgb, var(--danger) 12%, white); color: var(--danger); }

/* background: segmented control pinned at the bottom of the Layers tab */
.basemaps { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 10px 16px; }
.basemaps-label { font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.fade { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; flex: none; }
.fade input { margin: 0; accent-color: var(--accent); }
.seg { display: flex; flex: 1; background: var(--surface-2); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 5px; padding: 3px 4px; font-size: 12px; line-height: 18px; color: var(--text-2); font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked=true] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(22,32,29,.15); }

/* Regions tab */
.region-list { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }
.pane-h { font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 650; margin: 12px 0 8px; }
.region-cards { display: grid; gap: 8px; }
.region-card { display: grid; gap: 2px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.region-card:hover, .region-both:hover, .muni-list button:hover { border-color: var(--accent); }
.region-card[aria-pressed=true], .region-both[aria-pressed=true], .muni-list button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.rc-title { font-size: 14px; font-weight: 600; color: var(--text); }
.rc-char { font-size: 12px; line-height: 16px; color: var(--text-2); }
.rc-meta { font-size: 12px; line-height: 16px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.region-both { display: flex; justify-content: space-between; align-items: baseline; width: 100%; margin-top: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 7px 12px; font-weight: 500; }
.muni-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.muni-list button { display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; background: none; border: 1px solid transparent;
  border-radius: 6px; padding: 5px 8px; }
.mu-name { font-weight: 500; }
.mu-sub { grid-column: 1; font-size: 12px; line-height: 16px; color: var(--text-3); }
.mu-area { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pane-foot { margin: 14px 0 0; font-size: 12px; color: var(--text-3); }

/* ================================ map ================================ */
#map-wrap { grid-column: 2; grid-row: 2; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.map-overlay { position: absolute; z-index: 2; }
.top-left-status { top: 10px; left: 10px; background: color-mix(in srgb, var(--danger) 10%, white); color: var(--danger); padding: 5px 9px; border-radius: 6px; display: none; }
.top-left-status.show { display: block; }
.coords { position: absolute; left: 10px; bottom: 10px; z-index: 2; display: flex; gap: 12px; background: rgba(255,255,255,.92);
  padding: 3px 9px; border-radius: 6px; box-shadow: var(--shadow); font-family: var(--mono); font-size: 11px; line-height: 16px; color: var(--text-2); }
.coords b { font-family: var(--sans); font-weight: 600; color: var(--text); font-size: 10.5px; margin-right: 3px; }
.maplibregl-ctrl-scale { border-color: var(--text-2); color: var(--text); background: rgba(255,255,255,.85); }
.map-legend { position: absolute; left: 10px; bottom: 40px; z-index: 2; width: 220px; max-height: calc(100% - 120px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); font-size: 12px; line-height: 16px; }
.lg-head { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 7px 10px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; color: var(--text-2); }
.lg-n { margin-left: auto; color: var(--text-3); font-weight: 500; }
.lg-body { padding: 0 10px 8px; display: grid; gap: 8px; }
.lg-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.lg-block ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.lg-block li { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.lg-chev { color: var(--text-3); font-size: 10px; width: 10px; }
.map-legend.collapsed { width: auto; }
.lg-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.lsw { width: 20px; height: 13px; border-radius: 2px; flex: none; box-sizing: border-box; }
.lsw-sm { width: 14px; height: 10px; }
.lg-block li.lg-angles { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.lg-angles > span { display: inline-flex; align-items: center; gap: 4px; }
.lg-mode { font-size: 11px; font-weight: 500; color: var(--text-3); }
.mode-row { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; }
.mode-label { font-size: 12px; color: var(--text-2); flex: none; }
.seg-sm { flex: none; margin-left: auto; }
.seg-sm button { flex: none; padding: 1px 9px; font-size: 12px; line-height: 18px; }
.lg-seg { display: inline-flex; background: var(--surface-2); border-radius: 5px; padding: 1px; }
.lg-seg button { border: 0; background: none; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 4px; color: var(--text-2); font-weight: 500; }
.lg-seg button[aria-checked=true] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(22,32,29,.15); }

/* ============================== inspector ============================== */
#inspector { grid-column: 3; grid-row: 2; width: 400px; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.insp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; border-bottom: 1px solid var(--line); }
.insp-head h2 { font-size: 11px; line-height: 14px; margin: 0; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 650; }
.icon-btn { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--text-3); padding: 2px 6px; border-radius: 4px; }
.icon-btn:hover { color: var(--text); background: var(--bg); }
.insp-body { flex: 1; overflow-y: auto; padding: 10px 14px 24px; }
.insp-point { display: grid; gap: 2px; padding: 2px 0 10px; }
.insp-point .where { font-size: 15px; line-height: 20px; font-weight: 600; }
.insp-point .coords-line { color: var(--text-3); font-size: 11px; }
.insp-point .sum { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 6px; font-size: 12px; }
.sum-item { display: inline-flex; align-items: center; gap: 3px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sec { font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 650; margin: 16px 0 8px; }
.none { color: var(--text-3); padding: 6px 0; margin: 0; }
.loading { color: var(--text-3); }
.error { color: var(--danger); }

.check-req { border: 1px solid var(--line); border-left: 3px solid var(--hue-check); border-radius: 6px; padding: 6px 10px; background: var(--bg); }
.check-req summary { cursor: pointer; display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.cr-title { font-weight: 600; color: var(--text); }
.check-req ul { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 3px; font-size: 12px; }
.check-req li { display: flex; justify-content: space-between; gap: 8px; }

.hit { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.hit-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px 3px; font-size: 12px; line-height: 16px; }
.hit-head .lname { font-weight: 600; color: var(--text-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat { padding: 6px 10px 6px; border-top: 1px solid var(--line-soft); }
.hit-head + .feat { border-top: 0; }
.feat:hover { background: #FBF8E6; }
.feat.extra { display: none; }
.hit.show-all .feat.extra { display: block; }
.f-primary { display: flex; align-items: center; gap: 8px; }
.fname { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; }
.dist { color: var(--text-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.f-meaning { color: var(--text-2); font-size: 12px; line-height: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.show-more { margin: 2px 10px 6px; }
details.attrs { margin-top: 3px; }
details.attrs summary { cursor: pointer; font-size: 12px; line-height: 16px; color: var(--text-3); width: max-content; border-radius: 4px; }
details.attrs summary:hover { color: var(--accent); }
details.attrs table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 2px; }
details.attrs th { text-align: left; color: var(--text-3); font-weight: 400; padding: 1px 8px 1px 0; vertical-align: top; width: 38%;
  font-family: var(--mono); font-size: 11px; word-break: break-all; }
details.attrs td { padding: 1px 0; word-break: break-word; }
details.attrs tr.tech td, details.attrs tr.tech th { color: var(--text-3); font-size: 11px; }
.prov { padding: 6px 10px 7px; border-top: 1px solid var(--line-soft); background: var(--bg);
  font-size: 11px; line-height: 16px; color: var(--text-3); }
.prov a { font-weight: 500; }
.tbl-err { color: var(--danger); padding: 2px 10px; margin: 0; font-size: 12px; }
.hit .small { padding: 0 10px; margin: 2px 0; }
.rock-profile { margin: 8px 9px 10px; padding: 12px; border: 1px solid #D8C9B9; border-radius: 10px;
  background: linear-gradient(145deg, #FBF7EF, #F1E7D9); color: #30271F; }
.rock-profile-head { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: baseline; }
.rock-profile-head b { font-size: 16px; line-height: 21px; }
.rock-profile-eyebrow { grid-column: 1 / -1; color: #705840; font-size: 10px; line-height: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.rock-profile-scale { color: #705840; font-size: 11px; }
.rock-profile-main { display: grid; grid-template-columns: 64px 1fr; gap: 13px; margin: 11px 0; }
.rock-column { position: relative; height: 154px; border: 1px solid #BFA993; border-radius: 5px; overflow: hidden;
  background: repeating-linear-gradient(20deg, #E7CEAA 0 9px, #E1C49F 9px 13px); }
.rock-column-soil, .rock-column-range, .rock-column-solid { position: absolute; left: 0; right: 0; }
.rock-column-soil { top: 0; height: var(--rock-top); background: repeating-linear-gradient(20deg, #E7CEAA 0 9px, #E1C49F 9px 13px); z-index: 1; }
.rock-column-range { top: var(--rock-top); height: calc(var(--rock-bottom) - var(--rock-top));
  background: repeating-linear-gradient(-40deg, #9A7658 0 5px, #C8AA88 5px 12px); z-index: 1; }
.rock-column-solid { top: var(--rock-bottom); bottom: 0; background: #5A4136; z-index: 1; }
.rock-column-probe { position: absolute; left: 0; right: 0; top: var(--rock-probe); border-top: 3px solid #0E7078; z-index: 3; }
.rock-column-probe::after { content: ''; position: absolute; right: -1px; top: -6px; width: 8px; height: 8px; border-radius: 50%; background: #0E7078; }
.rock-column-tick { position: absolute; left: 3px; z-index: 2; padding: 0 2px; border-radius: 2px; background: #FBF7EFCC; color: #503D2C; font: 10px/13px var(--mono); }
.rock-column-tick.t0 { top: 1px; }.rock-column-tick.t1 { top: 50%; }.rock-column-tick.t2 { bottom: 1px; }
.rock-profile-copy { display: grid; align-content: center; gap: 6px; font-size: 12px; line-height: 16px; }
.rock-profile-copy b { font-size: 14px; line-height: 18px; }
.rock-profile-rock { color: #705840; }
.rock-probe-label { display: grid; grid-template-columns: 1fr auto; gap: 5px; align-items: baseline; font-size: 12px; font-weight: 600; }
.rock-probe-label output { color: #0E7078; font-variant-numeric: tabular-nums; }
.rock-probe-label input { grid-column: 1 / -1; width: 100%; accent-color: #0E7078; }
.rock-chance { display: flex; align-items: center; gap: 10px; margin: 9px 0 12px; padding: 9px; background: #FFFFFFC9; border-radius: 7px; }
.rock-chance strong { font-size: 29px; line-height: 32px; font-variant-numeric: tabular-nums; color: #6B3E25; }
.rock-chance span { font-size: 11px; line-height: 15px; color: #574737; }
.rock-classes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rock-classes > div { display: grid; gap: 3px; align-content: start; padding: 8px; border: 1px solid #DACAB8; background: #FFFFFFA8; border-radius: 6px; font-size: 11px; line-height: 14px; }
.rock-classes small { color: #705840; font-size: 10px; }.rock-classes b { font-size: 12px; line-height: 15px; }
.rock-hint, .rock-caveat { margin: 9px 0 0; color: #574737; font-size: 11px; line-height: 15px; }
.rock-caveat { border-top: 1px solid #DACAB8; padding-top: 7px; }
.live-body { padding: 2px 10px 6px; }
pre.gfi { white-space: pre-wrap; font-size: 11px; margin: 4px 0; max-height: 240px; overflow: auto; }

/* ============================ details drawer ============================ */
.drawer { position: fixed; inset: 0; z-index: 40; background: rgba(22,32,29,.28); display: flex; justify-content: flex-end; }
.drawer-inner { width: min(900px, 94vw); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 18px 8px; }
.drawer-head h2 { margin: 0; font-size: 18px; line-height: 24px; display: flex; align-items: center; gap: 10px; }
.drawer-head p { margin: 0; }
.d-group { font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: 2px !important; }
.d-title { color: var(--text-2); font-size: 13px; margin: 2px 0 4px !important; }
.facts { display: grid; grid-template-columns: 90px 1fr; gap: 3px 10px; margin: 10px 0 0; font-size: 12px; line-height: 16px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 10px; color: var(--text-2); font-weight: 550; }
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }
.tabs button span { margin-left: 5px; background: var(--surface-2); border-radius: 8px; padding: 0 5px; font-size: 11px; color: var(--text-2); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 22px 40px; }
.markdown { max-width: 780px; font-size: 14px; line-height: 1.55; }
.markdown h1 { font-size: 20px; } .markdown h2 { font-size: 16px; margin-top: 22px; border-bottom: 1px solid var(--line-soft); padding-bottom: 3px; }
.markdown h3 { font-size: 14px; }
.markdown table { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; vertical-align: top; }
.markdown th { background: var(--bg); }
.markdown code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 0 3px; border-radius: 3px; }
.markdown pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text-2); }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
.grid th { text-align: left; color: var(--text-3); font-weight: 550; border-bottom: 1px solid var(--line); padding: 4px 8px 4px 0; }
.grid td { border-bottom: 1px solid var(--line-soft); padding: 4px 8px 4px 0; vertical-align: top; }
.grid tr.pass td:first-child { color: var(--ok); font-weight: 700; }
.grid tr.fail td { color: var(--danger); }
.grid tr.running td { color: #7A5B00; }
.grid tr.notes td { border-bottom: 1px solid var(--line); }
.grid pre { margin: 0; white-space: pre-wrap; font-size: 11px; color: var(--text-2); }
.grid .url { word-break: break-all; }
.nowrap { white-space: nowrap; }
.bad { color: var(--danger); }
.muted { color: var(--text-3); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 12px; overflow-x: auto; }

.toast { position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 8px 14px;
  border-radius: 8px; box-shadow: var(--shadow); z-index: 30; font-size: 13px; }

/* narrower desktops (≤1360px): slimmer inspector so the map keeps room */
@media (max-width: 1360px) {
  #inspector { width: 360px; }
}
@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 58px 45vh minmax(0, 1fr) auto; }
  #workspace-header { grid-column: 1; grid-row: 1; }
  .workspace-brand { width: auto; max-width: 230px; border-right: 0; padding: 6px 10px; }
  .workspace-brand .sub { display: none; }
  .mode-tabs { margin-left: auto; padding: 0 3px; gap: 0; }
  .mode-tabs button { min-width: 70px; padding: 6px 8px 4px; text-align: center; }
  .mode-tabs button small { display: none; }
  #workspace-health { padding-left: 2px; }
  .workspace-health-link { width: 27px; height: 27px; justify-content: center; padding: 0; gap: 2px; }
  .workspace-health-link .health-label { display: none; }
  .workspace-health-link .issues-dot { width: 5px; height: 5px; }
  #workspace-user { padding: 0 8px 0 2px; }
  #map-wrap { grid-column: 1; grid-row: 2; }
  #panel { grid-column: 1; grid-row: 3; border-right: 0; border-top: 1px solid var(--line); }
  #inspector { position: fixed; top: calc(58px + 45vh); bottom: 0; left: 0; right: 0; z-index: 12;
    width: auto; border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(22,32,29,.18); }
}
@media (max-width: 520px) {
  .workspace-brand { gap: 6px; padding-right: 0; }
  .workspace-brand .logo { width: 26px; height: 26px; border-radius: 7px; }
  .workspace-brand .logo svg { width: 23px; height: 23px; }
  .workspace-brand h1 { font-size: 12px; white-space: nowrap; }
  .mode-tabs button { min-width: 60px; padding-inline: 5px; }
  .mode-tabs button strong { font-size: 12px; }
  #workspace-user { padding-right: 5px; }
}
@media (max-width: 360px) {
  .workspace-brand h1 { display: none; }
}

/* Safety net: an expanded attribution never covers more than a strip of the map. */
.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner { display: block; max-height: 4.5em; overflow-y: auto; }

/* Attribution: collapsed to the (i) button; the full text shows on hover/focus only,
   so it never covers the legend or the map. */
.maplibregl-ctrl-attrib:not(:hover):not(:focus-within) .maplibregl-ctrl-attrib-inner { display: none; }
.maplibregl-ctrl-attrib:hover, .maplibregl-ctrl-attrib:focus-within { max-width: min(640px, 70vw); }
