/* Stonehaus LandMap — interface.
   Cockpit density: the map is the subject, the chrome stays quiet.

   Locks (do not break these piecemeal):
   · Radius     panels 10px · controls 6px · chips/swatches 4px · pills 999px
   · Colour     one UI accent (brass, --ac) drawn from the Stonehaus cream/black identity.
                Cyan is reserved for map selection only and never appears in chrome.
   · Spacing    4px base unit; gutters 12px; section padding 10px 12px
   · Numerals   every count, measurement and coordinate is set in the mono face
*/

/* Inter, vendored. One variable file covers every weight the interface uses, and nothing here
   reaches a CDN at runtime, so the chrome looks the same with the network unplugged as it does
   with it. SIL Open Font License; the licence sits beside the file. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url("fonts/inter-latin-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* surfaces, darkest to lightest */
  --bg: #0c0e11;
  --s1: #121519;
  --s2: #171b20;
  --s3: #1e232a;
  --s4: #262c34;
  --line: #22272e;
  --line-soft: #1a1e24;

  /* ink */
  --tx: #e9e6df;
  --tx-dim: #9aa1ab;
  --tx-faint: #69707a;

  /* accent: brass, from the Stonehaus cream mark */
  --ac: #d9b45f;
  --ac-dim: #8a7233;
  --ac-wash: rgba(217, 180, 95, .10);

  /* map selection only, never chrome */
  --sel: #38bdf8;

  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;

  --r-panel: 10px;
  --r-ctl: 6px;
  --r-chip: 4px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --sidebar: 300px;
  --header: 54px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--tx);
  font: 12.5px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

#app { display: grid; grid-template-rows: var(--header) 1fr; grid-template-columns: var(--sidebar) 1fr; height: 100vh; }

/* ─────────────────────────────────────────────────────────── icons */
.ic { width: 16px; height: 16px; flex: none; fill: currentColor; display: block; }
.ic-sm { width: 13px; height: 13px; }
.ic-lg { width: 18px; height: 18px; }

/* ─────────────────────────────────────────────────────────── header */
header {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px;
  padding: 0 12px 0 14px; background: var(--s1);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand img { height: 21px; width: auto; display: block; opacity: .95; }
.brand .app {
  font: 500 11px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--tx-faint); padding-left: 10px; border-left: 1px solid var(--line);
}

/* The project picker was a native select. Its closed state took our font; its open list was
   drawn by the OS in the system font on a white sheet, and no style reached it. It is a button
   and a panel now, so the menu is the same chrome as everything else. */
.projwrap { position: relative; flex: none; }
.projwrap > button {
  display: flex; align-items: center; gap: 8px;
  background: var(--s2); border: 1px solid var(--line); color: var(--tx);
  font: 500 12px var(--sans); letter-spacing: .01em;
  padding: 6px 9px 6px 11px; border-radius: var(--r-ctl);
  max-width: 260px; cursor: pointer; transition: border-color .12s, background .12s;
}
.projwrap > button:hover { border-color: var(--s4); background: var(--s3); }
.projwrap > button[aria-expanded="true"] { border-color: var(--ac-dim); background: var(--s3); }
.projwrap > button .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projwrap .caret { color: var(--tx-faint); flex: none; transition: transform .15s; }
.projwrap > button[aria-expanded="true"] .caret { transform: rotate(180deg); }

.projmenu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 45;
  width: max-content; min-width: 100%; max-width: 340px;
  padding: 4px; border-radius: var(--r-panel);
  background: var(--s2); border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0,0,0,.55);
}
.projmenu[hidden] { display: none; }
.projmenu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; color: var(--tx); text-align: left;
  font: 12px var(--sans); padding: 6px 9px; border-radius: var(--r-ctl); cursor: pointer;
}
.projmenu button:hover, .projmenu button:focus-visible { background: var(--s3); outline: none; }
.projmenu button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projmenu button .tick { width: 12px; flex: none; color: var(--ac); opacity: 0; }
.projmenu button[aria-selected="true"] .tick { opacity: 1; }
.projmenu button[aria-selected="true"] { color: var(--ac); }
.projmenu .sep { height: 1px; background: var(--line); margin: 4px 2px; }
.projmenu .new { color: var(--tx-dim); }

.search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.search .field { display: flex; align-items: center; gap: 8px; background: var(--s2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 0 10px; transition: border-color .12s, background .12s; }
.search .field:focus-within { border-color: var(--ac-dim); background: var(--s3); }
.search .field > .ic { color: var(--tx-faint); }
.search input { flex: 1; background: none; border: 0; outline: none; color: var(--tx); font: 12.5px var(--sans); padding: 7px 0; }
.search input::placeholder { color: var(--tx-faint); }
.search kbd {
  font: 10px var(--mono); color: var(--tx-faint); background: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-chip); padding: 1px 5px;
}
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; display: none;
  background: var(--s2); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 16px 48px rgba(0,0,0,.6); max-height: 400px; overflow: auto; padding: 4px;
}
.results .row { padding: 7px 10px; border-radius: var(--r-ctl); cursor: pointer; }
.results .row:hover, .results .row.on { background: var(--s3); }
.results .row b { font-weight: 500; display: block; }
.results .row small { color: var(--tx-dim); display: block; font-size: 11px; margin-top: 1px; }
.results .row.lead b { color: var(--ac); }
.results .empty { padding: 10px; color: var(--tx-dim); }

.actions { display: flex; align-items: center; gap: 4px; flex: none; }

/* ─────────────────────────────────────────────────────────── controls */
button {
  font: 12px var(--sans); color: var(--tx); background: var(--s2);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 6px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled) { background: var(--s3); border-color: var(--s4); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--ac); border-color: var(--ac); color: #17130a; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #e5c273; border-color: #e5c273; }
button.on { border-color: var(--ac); color: var(--ac); background: var(--ac-wash); }

/* icon-only */
.ibtn { padding: 7px; background: none; border-color: transparent; color: var(--tx-dim); }
.ibtn:hover:not(:disabled) { background: var(--s3); border-color: transparent; color: var(--tx); }
.ibtn.on { color: var(--ac); background: var(--ac-wash); }

/* tiny inline row action */
.xbtn { padding: 3px; background: none; border: 0; color: var(--tx-faint); border-radius: var(--r-chip); }
.xbtn:hover { background: var(--s4); color: var(--tx); }
.xbtn.on { color: var(--ac); }

/* an input with no type attribute is still a text input, so match on what it is not */
input:not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]), select, textarea {
  background: var(--s2); border: 1px solid var(--line); color: var(--tx);
  border-radius: var(--r-ctl); padding: 6px 9px; font: 12.5px var(--sans); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--ac-dim); }

/* keyboard focus is the brass accent, never the browser default */
:focus-visible { outline: 2px solid var(--ac-dim); outline-offset: 1px; border-radius: var(--r-chip); }
button:focus-visible { outline-offset: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input::placeholder, textarea::placeholder { color: var(--tx-faint); }
textarea { font-family: var(--mono); font-size: 12px; min-height: 110px; resize: vertical; }

input[type=range] { -webkit-appearance: none; height: 3px; background: var(--s4); border-radius: 999px; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; border-radius: 999px; background: var(--tx-dim); cursor: pointer; }
input[type=range]:hover::-webkit-slider-thumb { background: var(--ac); }

input[type=checkbox] {
  appearance: none; width: 13px; height: 13px; flex: none; border: 1px solid var(--s4);
  border-radius: 3px; background: var(--s2); cursor: pointer; position: relative;
}
input[type=checkbox]:checked { background: var(--ac); border-color: var(--ac); }
input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 3px; height: 7px;
  border: solid #17130a; border-width: 0 2px 2px 0; transform: rotate(42deg);
}

/* ─────────────────────────────────────────────────────────── sidebar */
aside { background: var(--s1); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
aside::-webkit-scrollbar, .results::-webkit-scrollbar, #card::-webkit-scrollbar, dialog .bd::-webkit-scrollbar { width: 9px; }
aside::-webkit-scrollbar-thumb, .results::-webkit-scrollbar-thumb, #card::-webkit-scrollbar-thumb, dialog .bd::-webkit-scrollbar-thumb { background: var(--s4); border-radius: 999px; border: 3px solid var(--s1); }

section { border-bottom: 1px solid var(--line-soft); }
section > h3 {
  margin: 0; padding: 10px 12px; display: flex; align-items: center; gap: 7px;
  font: 500 10.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--tx-dim); cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--s1); z-index: 2;
}
section > h3:hover { color: var(--tx); }
section > h3 .ic { color: var(--tx-faint); }
section > h3 .chev { margin-left: auto; transition: transform .15s; }
section.closed > h3 .chev { transform: rotate(-90deg); }
section.closed > .body { display: none; }
section > .body { padding: 2px 12px 10px; }
.count { font: 10.5px var(--mono); color: var(--tx-faint); }

/* basemap chips */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.chips button {
  justify-content: flex-start; text-align: left; padding: 0 8px; font-size: 11.5px;
  height: 28px; background: var(--s2); border-color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 28px;
}
.chips button:hover { background: var(--s3); }
.chips button.on { background: var(--ac-wash); border-color: var(--ac-dim); color: var(--ac); }

.toolbar-row { display: flex; gap: 4px; margin: 6px 0; }
.toolbar-row > * { flex: 1; justify-content: center; padding: 5px 4px; font-size: 11px; white-space: nowrap; min-width: 0; }
.toolbar-row .ic { margin-right: -1px; }

.switch { display: flex; align-items: center; gap: 7px; padding: 5px 0; color: var(--tx-dim); cursor: pointer; }
.switch:hover { color: var(--tx); }

/* group (overlays + layers) */
.grp { margin-top: 2px; }
.grp > .ghead {
  display: flex; align-items: center; gap: 6px; padding: 5px 0 4px; cursor: pointer;
  color: var(--tx-dim); user-select: none;
}
.grp > .ghead:hover { color: var(--tx); }
.grp > .ghead .name { font: 500 11px var(--sans); letter-spacing: .04em; flex: 1; }
.grp > .ghead .chev { color: var(--tx-faint); transition: transform .15s; }
.grp.closed > .ghead .chev { transform: rotate(-90deg); }
.grp.closed > .glist { display: none; }
.glist { border-left: 1px solid var(--line); margin-left: 6px; padding-left: 8px; }
.gsubhead {
  padding: 8px 0 3px 2px;
  margin-top: 4px;
  font: 600 9.5px/1.2 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--tx-faint);
  border-top: 1px solid var(--line-soft);
}
.gsubhead:first-child { border-top: none; margin-top: 0; padding-top: 4px; }

/* a row: swatch · label · value · hover actions */
.row {
  display: flex; align-items: center; gap: 7px; padding: 3px 0; min-height: 24px;
}
.row .sw { width: 9px; height: 9px; border-radius: var(--r-chip); flex: none; }
.row .sw.line { height: 3px; border-radius: 999px; }
.row .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: var(--tx); }
.row .lbl:hover { color: var(--ac); }
.row.off .lbl { color: var(--tx-faint); }
.row.unavailable { opacity: .55; }
.row.unavailable .lbl { cursor: not-allowed; }
.row .val { font: 10.5px var(--mono); color: var(--tx-faint); flex: none; }
.row .acts { display: none; gap: 1px; flex: none; }
.row:hover .acts { display: flex; }
.row:hover .val { display: none; }
.row input[type=range] { width: 46px; flex: none; display: none; }
.row:hover input[type=range] { display: block; }

/* per-class visibility: a classified row expands into its scheme's classes */
.row .cexp .ic { transition: transform .15s; transform: rotate(-90deg); }
.row .cexp.on .ic { transform: rotate(0); }
.row .cexp { display: block; flex: none; }
.classlist { margin: 0 0 5px 16px; padding-left: 8px; border-left: 1px solid var(--line); }
.classlist.hide { display: none; }
.classlist .chead {
  display: flex; align-items: center; gap: 7px; padding: 2px 0 3px;
  font: 10.5px var(--mono); color: var(--tx-faint);
}
.classlist .chead span:first-child { flex: 1; }
.classlist .chead .lk { cursor: pointer; color: var(--tx-dim); }
.classlist .chead .lk:hover { color: var(--ac); }
.classlist .crow { display: flex; align-items: center; gap: 7px; padding: 2px 0; min-height: 19px; font-size: 11px; }
.classlist .crow .sw { width: 9px; height: 9px; border-radius: var(--r-chip); flex: none; }
.classlist .crow .sw.line { height: 3px; border-radius: 999px; width: 11px; }
.classlist .crow .sw.dot { border-radius: 999px; }
.classlist .crow .sw.area { width: 11px; height: 8px; border-radius: 2px; }
.classlist .crow .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: var(--tx-dim); }
.classlist .crow .lbl:hover { color: var(--ac); }
.classlist .crow.off .lbl { color: var(--tx-faint); }
.classlist .crow.off .sw { opacity: .3; }

.hint { color: var(--tx-faint); font-size: 11px; line-height: 1.45; }
.hint a { color: var(--ac-dim); }

/* palette + tools */
.pal { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 6px; }
.pal button { justify-content: flex-start; font-size: 11.5px; padding: 5px 7px; background: none; border-color: transparent; }
.pal button:hover { background: var(--s3); }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.tools button {
  flex-direction: column; gap: 4px; padding: 8px 2px; font-size: 10px; color: var(--tx-dim);
  background: none; border-color: transparent; letter-spacing: .01em;
}
.tools button:hover { background: var(--s3); color: var(--tx); }
.tools button.on { color: var(--ac); background: var(--ac-wash); }
.tools button .ic { color: inherit; }

/* ─────────────────────────────────────────────────────────── map */
main { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; }

.maplibregl-ctrl-group { background: var(--s1) !important; border: 1px solid var(--line) !important; border-radius: var(--r-ctl) !important; box-shadow: none !important; overflow: hidden; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button { width: 28px !important; height: 28px !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(.82); }
.maplibregl-ctrl-bottom-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.maplibregl-ctrl-attrib {
  background: rgba(12,14,17,.86) !important; border: 1px solid var(--line); border-radius: var(--r-chip) !important;
  font-size: 10px !important; max-width: 46vw; padding: 1px 6px !important;
}
.maplibregl-ctrl-attrib a, .maplibregl-ctrl-attrib { color: var(--tx-faint) !important; }
.maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) { padding: 0 !important; border: 0; background: none !important; }
.maplibregl-ctrl-scale {
  background: rgba(12,14,17,.86) !important; border: 1px solid var(--line) !important; border-top: 1px solid var(--line) !important;
  color: var(--tx-dim) !important; font: 10.5px var(--mono) !important; border-radius: var(--r-chip); padding: 1px 6px;
}

/* floating map furniture */
.float {
  position: absolute; z-index: 15; background: rgba(18,21,25,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 8px 28px rgba(0,0,0,.42);
}
#status { left: 12px; bottom: 12px; padding: 6px 10px; font: 11px var(--mono); color: var(--tx-dim); max-width: 55%; }
#status b { color: var(--tx); font-weight: 500; }
#status .sep { color: var(--line); margin: 0 6px; }

#hud { left: 12px; top: 12px; padding: 9px 11px; min-width: 190px; display: none; }
#hud.open { display: block; }
#hud .ttl { font: 500 10.5px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--tx-dim); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
#hud .big { font: 15px var(--mono); color: var(--tx); }
#hud .sub { font: 11px var(--mono); color: var(--tx-dim); margin-top: 2px; }
#hud .acts { display: flex; gap: 4px; margin-top: 8px; }
#hud .acts button { flex: 1; justify-content: center; font-size: 11px; padding: 4px 6px; }

/* the bottom-right corner stacks: scale bar and attribution sit lowest, legend clears them */
#legend { right: 12px; bottom: 58px; padding: 8px 11px; max-width: 250px; max-height: 62vh; overflow: auto; display: none; }
#legend.open { display: block; }
#legend .ttl { font: 500 10.5px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--tx-dim); margin-bottom: 5px; }
#legend .row { padding: 2px 0; min-height: 0; font-size: 11px; }
#legend .row.dim { opacity: .32; }
#legend .row.dim .lbl { text-decoration: line-through; }
#legend .lgroup + .lgroup { margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line); }
#legend .lttl { font: 500 10px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ac); margin-bottom: 3px; }
#legend .sw.line { width: 14px; height: 3px; }
#legend .sw.dot { width: 9px; height: 9px; border-radius: 999px; }
#legend .sw.area { width: 12px; height: 9px; border-radius: 2px; }
/* one colour drawn as lines and as points: a bar carrying a dot */
#legend .sw.both { width: 14px; height: 3px; border-radius: 999px; position: relative; overflow: visible; }
#legend .sw.both::after { content: ''; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 999px; background: inherit; box-shadow: 0 0 0 1px var(--bg, #0b0e12); }

#toast {
  left: 50%; top: 14px; transform: translateX(-50%); padding: 8px 14px; z-index: 50;
  display: none; align-items: center; gap: 8px; font-size: 12px;
}
#toast.show { display: flex; }
#toast.err { border-color: #5b2b2b; color: #fca5a5; }
#toast .ic { color: var(--ac); }
#toast.err .ic { color: var(--bad); }

#profile { left: 12px; right: 412px; bottom: 44px; height: 176px; padding: 8px 12px 4px; display: none; }
#profile.open { display: block; }
#profile .hd { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 11px; color: var(--tx-dim); margin-bottom: 2px; }
#profile .hd b { color: var(--tx); font-weight: 500; }
#profile canvas { width: 100%; height: 132px; display: block; }

/* ─────────────────────────────────────────────────────────── info card */
#card {
  position: absolute; top: 12px; right: 12px; width: 384px; max-height: calc(100% - 24px);
  display: none; flex-direction: column; z-index: 20; overflow: hidden;
}
#card.open { display: flex; }
#card .hd { padding: 11px 12px 10px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-start; }
#card .hd .t { flex: 1; min-width: 0; }
#card .hd h2 { margin: 0; font: 600 13.5px var(--sans); line-height: 1.3; }
#card .hd .sub { color: var(--tx-dim); font-size: 11px; margin-top: 3px; line-height: 1.45; }
#card .hd .sub .num { color: var(--tx); }
#card .quick { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#card .quick button { font-size: 11px; padding: 4px 8px; }
#card .quick.waiting { pointer-events: none; opacity: .45; }
#card .tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
#card .tabs button {
  font-size: 11px; padding: 4px 9px; border-radius: var(--r-chip); background: none;
  border-color: transparent; color: var(--tx-dim); white-space: nowrap;
}
#card .tabs button:hover { background: var(--s3); color: var(--tx); }
#card .tabs button.on { background: var(--ac-wash); color: var(--ac); }
#card .pane { padding: 4px 12px 14px; overflow-y: auto; }
#card h4 {
  margin: 13px 0 5px; font: 500 10px var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--tx-faint); padding-bottom: 4px; border-bottom: 1px solid var(--line-soft);
}
#card h4:first-child { margin-top: 8px; }

table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 4px 0; vertical-align: top; font-size: 12px; line-height: 1.4; }
table.kv td:first-child { color: var(--tx-dim); width: 43%; padding-right: 10px; }
table.kv td:last-child { font-variant-numeric: tabular-nums; }
table.kv tr + tr td { border-top: 1px solid var(--line-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px;
  background: var(--s3); border: 1px solid var(--line); font-size: 10.5px; color: var(--tx-dim);
}
.pill.ok { color: var(--ok); border-color: #1f4d38; background: rgba(74,222,128,.08); }
.pill.warn { color: var(--warn); border-color: #5c4718; background: rgba(251,191,36,.08); }
.pill.bad { color: var(--bad); border-color: #5b2b2b; background: rgba(248,113,113,.08); }
.pill.ac { color: var(--ac); border-color: var(--ac-dim); background: var(--ac-wash); }

/* ─────────────────────────────────────────────────────────── popup */
.maplibregl-popup-content {
  background: var(--s1); color: var(--tx); border: 1px solid var(--line);
  border-radius: var(--r-panel); font: 12px var(--sans); padding: 10px 12px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55); max-width: 360px;
}
.maplibregl-popup-close-button { color: var(--tx-faint); font-size: 15px; padding: 2px 6px; }
.maplibregl-popup-close-button:hover { background: none; color: var(--tx); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--s1); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--s1); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--s1); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--s1); }
.popup b { display: block; font-weight: 500; color: var(--ac); margin-bottom: 5px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.popup table { width: 100%; border-collapse: collapse; }
.popup td { padding: 2px 0; font-size: 11.5px; vertical-align: top; }
.popup td:first-child { color: var(--tx-dim); padding-right: 10px; white-space: nowrap; }
.popup hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* ─────────────────────────────────────────────────────────── dialog */
dialog {
  background: var(--s1); color: var(--tx); border: 1px solid var(--line);
  border-radius: var(--r-panel); padding: 0; width: 600px; max-width: 94vw;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(6,8,10,.62); backdrop-filter: blur(2px); }
dialog .hd { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 600 13px var(--sans); }
dialog .bd { padding: 14px; max-height: 68vh; overflow: auto; }
dialog .ft { padding: 11px 14px; border-top: 1px solid var(--line); display: flex; gap: 7px; justify-content: flex-end; background: var(--s1); }
dialog label { display: block; margin: 11px 0 4px; color: var(--tx-dim); font-size: 11px; letter-spacing: .02em; }
dialog label:first-child { margin-top: 0; }
dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
dialog .stat { background: var(--s2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 8px 10px; }
dialog .stat label { margin: 0 0 3px; }
dialog .stat b { font: 15px var(--mono); color: var(--tx); font-weight: 500; }
dialog table.data { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 4px; }
dialog table.data th {
  text-align: left; font: 500 10px var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--tx-faint); padding: 5px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--s1);
}
dialog table.data td { padding: 4px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
dialog table.data td.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
dialog table.data tr:hover td { background: var(--s2); }
dialog input[type=color] { height: 30px; padding: 2px; cursor: pointer; }
dialog input[type=file] { font-size: 11.5px; padding: 7px; }
dialog input[type=file]::file-selector-button {
  background: var(--s3); border: 1px solid var(--line); color: var(--tx);
  border-radius: var(--r-chip); padding: 3px 9px; margin-right: 9px; font: 11.5px var(--sans); cursor: pointer;
}

.geo-handle { width: 13px; height: 13px; border-radius: 999px; background: var(--ac); border: 2px solid #0c0e11; cursor: move; box-shadow: 0 1px 5px rgba(0,0,0,.5); }

.bod-anchor { width: 15px; height: 15px; border-radius: 999px; background: #0c0e11; border: 2px solid var(--ac); cursor: move; box-shadow: 0 1px 5px rgba(0,0,0,.6); }
.bod-handle { width: 13px; height: 13px; background: var(--ac); border: 2px solid #0c0e11; cursor: grab; box-shadow: 0 1px 5px rgba(0,0,0,.5); }

/* the sidebar narrows before it disappears, so a half-width window stays usable */
@media (max-width: 1180px) {
  :root { --sidebar: 258px; }
  #card { width: 340px; }
  .tools { grid-template-columns: repeat(3, 1fr); }
}
/* The panel is the only route to the tools, the overlay catalogue and the layer tree, so the
   header toggle only exists where the panel stops being a column. Above the breakpoint the
   panel is always there and the button would be a second way to do nothing. */
#btnPanel { display: none; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  /* A narrow window used to delete the panel outright, which took all fourteen tools, every
     overlay group and the whole layer tree with it and left no way back. It becomes a drawer
     over the map instead: opened from the header, dismissed by the scrim or Escape. */
  #btnPanel { display: inline-flex; }
  aside { position: fixed; top: var(--header); left: 0; bottom: 0; width: min(320px, 86vw);
          z-index: 46; transform: translateX(-100%); transition: transform .18s ease;
          box-shadow: 2px 0 18px rgba(0, 0, 0, .5); }
  body.panel-open aside { transform: none; }
  body.panel-open #panelScrim { position: fixed; top: var(--header); left: 0; right: 0; bottom: 0;
                                z-index: 45; background: rgba(0, 0, 0, .45); }
  #card { width: calc(100% - 24px); }
  #profile { right: 12px; }
  .search { max-width: none; }
  .brand .app { display: none; }
}

/* ─────────────────────────────────────────────────────────── authentication & user nav */
.user-nav {
  display: flex; align-items: center; justify-content: center;
  margin-left: 6px; flex: none;
}
.btn-signin {
  background: var(--s2); border: 1px solid var(--line); color: var(--tx);
  font: 500 12px var(--sans); padding: 5px 12px; border-radius: var(--r-ctl);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn-signin:hover { background: var(--s3); border-color: var(--ac-dim); }
.dev-badge {
  font: 600 10px var(--mono); color: var(--warn); background: rgba(251, 191, 36, .12);
  border: 1px solid rgba(251, 191, 36, .25); padding: 2px 6px; border-radius: var(--r-chip);
}

/* ─────────────────────────────────────────────────────────── modal scrim & auth alert */
html.auth-pending, html.auth-pending body {
  background: #000;
  color-scheme: dark;
}
html.auth-pending #app {
  display: none !important;
}
#authGate {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483000;
  background: #000;
  color-scheme: dark;
  display: grid;
  place-items: center;
  overflow: auto;
}
#authGate[hidden] {
  display: none !important;
}
.auth-modal-scrim {
  position: fixed; inset: 0; z-index: 2147483000;
  background: #000;
  color-scheme: dark;
  display: flex; align-items: center; justify-content: center;
}
.auth-modal {
  background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-panel);
  width: 440px; max-width: calc(100vw - 32px); padding: 20px; box-shadow: 0 20px 48px rgba(0,0,0,.65);
  color-scheme: dark;
}
.auth-modal .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.auth-modal .hd h3 { font: 600 15px var(--sans); margin: 0; color: var(--tx); }
.auth-modal .bd p { font: 13px/1.5 var(--sans); color: var(--tx-dim); margin: 0 0 8px; }
.auth-modal .bd p.sub { font-size: 12px; color: #a8a39a; margin-bottom: 16px; }
.auth-modal .ft { display: flex; justify-content: flex-end; }
