:root {
  --ink: #16201c;
  --paper: #f6f5f1;
  --panel: #ffffff;
  --line: #dcd9d0;
  --accent: #2c5f4f;       /* deep field-green — surveying/ordnance-survey feel */
  --accent-soft: #e4ede9;
  --warn: #b5502e;
  --muted: #74776f;
  --mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
  --sans: 'IBM Plex Sans', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

#app {
  display: flex;
  height: 100vh;
}

/* ---------- Icon rail ---------- */
#rail {
  width: 48px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
  z-index: 6;
}
.rail-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.rail-icon:hover { background: var(--accent-soft); color: var(--accent); }
.rail-icon.active { background: var(--accent); color: #fff; }

/* Separates the day-to-day icons (Layers/Sites/Import) from the admin-only ones (Events/Users)
   below it — a plain gap alone doesn't read as "these are a different kind of thing". */
.rail-divider { width: 24px; height: 1px; background: var(--line); margin: 4px 0; flex-shrink: 0; }

/* ---------- Flyout panel ---------- */
/* Collapsed by default (width 0) so the map has the screen; opening it grows the outer width
   while an inner wrapper stays a fixed 300px so content doesn't reflow/word-wrap mid-transition
   — same collapsed-by-default philosophy the mobile bottom sheet already used, now shared by
   both instead of being two different patterns. */
#flyout {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: width 0.22s ease;
  z-index: 6;
}
#flyout.open { width: 300px; }
.flyout-inner {
  width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-handle { display: none; }

#flyout header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

#flyout header h1 {
  font-size: 18px;
  margin: 8px 0 0;
  font-weight: 600;
}

/* Brand lockup — logo + "Plan" inline, sized to sit on the logo's own baseline, so it reads as
   one wordmark ("[PHASE360 logo]Plan") rather than repeating "Phase360" as a separate line the
   logo already says. Used on the login screen and the flyout header. */
.brand-lockup { display: flex; align-items: center; gap: 7px; }
.brand-logo { display: block; height: 24px; width: auto; }
.brand-word {
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}

.site-select {
  width: 100%;
  margin-top: 10px;
  padding: 7px 9px;
  font-family: var(--sans);
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

/* scrollbar-gutter reserves the scrollbar's width whether or not it's actually showing, so the
   content area's available width stays constant instead of narrowing the instant a panel has
   enough content to scroll — without this, that narrowing was just enough to tip a tightly-
   packed row (e.g. the layer row's Freehand/3-pt rect/Rect by size buttons) onto a second line.
   Unsupported browsers just ignore this and fall back to the old behavior, not a regression. */
.tab-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding: 14px 18px; }
.tab-panel.active { display: block; }

/* One card per layer — a real boundary instead of just a bottom border, so a layer's cluster
   of controls (once expanded) reads as clearly separate from the next layer's. */
.layer-row-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
  background: var(--panel);
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.layer-row .swatch {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
  /* A white/near-white category color would otherwise vanish against the panel background —
     every swatch gets a faint outline so it stays visible regardless of its own color. */
  box-shadow: inset 0 0 0 1px rgba(22,32,28,0.2);
}

.layer-row .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* Expand/collapse toggle — collapsed is just checkbox/swatch/name/count, so Style/Furniture/
   draw-tools/legend/rollup (built in .layer-row-body below) only show once asked for. */
.row-expand-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.row-expand-btn:hover { color: var(--accent); }

/* Stacked groups (Configure, Draw, display toggles), not one flat wrapped row — Style…/
   Furniture… (occasional setup) and the draw tools (the frequent add-a-feature workflow) read
   as two distinct jobs, not one undifferentiated button soup. */
.layer-row-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.row-action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.row-action-group-label {
  flex: 1 0 100%;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 2px;
}

.layer-legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  margin: 8px 0 0; font-size: 11px; color: var(--muted);
}
.layer-legend .swatch {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 4px; vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(22,32,28,0.2);
}

/* Legend + infrastructure rollup merged into one table (see renderLayerList) — swatch, category
   name, rollup value (blank for a category with nothing to roll up) as three aligned columns
   instead of the two separately-listed, harder-to-scan blocks this replaced. */
.layer-legend-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 11px;
}
.layer-legend-table td {
  padding: 2px 4px 2px 0;
  color: var(--muted);
  white-space: nowrap;
}
.layer-legend-table td:first-child { width: 14px; padding-right: 6px; }
.layer-legend-table td:nth-child(2) { color: var(--ink); width: 100%; }
.layer-legend-table td:last-child {
  font-family: var(--mono);
  text-align: right;
  padding-right: 0;
}
.layer-legend-table .swatch {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(22,32,28,0.2);
}
.layer-legend-table .legend-total-row td {
  border-top: 1px solid var(--line);
  padding-top: 4px;
  font-weight: 600;
  color: var(--ink);
}

.feature-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
  cursor: pointer;
  background: var(--paper);
}
.feature-card:hover { border-color: var(--accent); }
.feature-card .fid { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.feature-card .fname { font-weight: 600; margin: 2px 0; }
.feature-card .fattr { color: var(--muted); }

/* Sub-header between groups of feature cards (grouped by parent Space) — quieter than
   .section-label since it repeats often down a long list, not just once per panel section. */
.feature-group-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 14px 0 6px;
}
.feature-group-label:first-child { margin-top: 0; }

.section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 4px 0 10px;
}

/* Site plans / Default view in the Layers panel — native <details> disclosures, no JS needed.
   A <summary> reusing .section-label just needs the default marker swapped for a small chevron
   and a pointer cursor to read as clickable. */
.panel-section summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.panel-section summary::-webkit-details-marker { display: none; }
.panel-section summary::before { content: '▸'; font-size: 9px; }
.panel-section[open] summary::before { content: '▾'; }
.panel-section > *:not(summary) { margin-top: 2px; }

/* ---------- Import panel ---------- */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  padding: 22px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }

/* Import panel: GeoJSON site plan vs Excel stallholders are two unrelated jobs sharing one rail
   icon — a plain two-way switch at the top instead of stacking both forms in one long scroll. */
.import-mode-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.import-mode-toggle button {
  flex: 1;
  background: none;
  color: var(--ink);
  border: none;
  border-radius: 0;
  padding: 7px 4px;
  font-size: 11.5px;
  font-weight: 500;
}
.import-mode-toggle button + button { border-left: 1px solid var(--line); }
.import-mode-toggle button.active { background: var(--accent); color: #fff; }

.gj-file {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 4px 0;
}
.gj-file .gj-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.gj-file .gj-file-count { color: var(--muted); font-family: var(--mono); }
.gj-opt { display: block; font-size: 12px; margin-top: 10px; }
.gj-opt select { width: 100%; margin-top: 3px; padding: 5px 6px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 4px; }
.gj-opt-check { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; margin-top: 8px; line-height: 1.3; }
.gj-select-links a { color: var(--accent); text-decoration: none; }
.gj-hint { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.3; }
.gj-group-match { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.gj-group-match b { color: var(--text, inherit); font-weight: 600; }
.gj-group-prune { grid-column: 1 / -1; display: flex; gap: 6px; align-items: flex-start; font-size: 11.5px; line-height: 1.3; }

button.secondary.danger { color: #b5502e; border-color: #b5502e; }
button.secondary.danger:hover { background: #b5502e; color: #fff; }

/* One card per layer-to-create — same visual language as the Layers panel's own cards. */
.gj-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--panel);
}
.gj-group.excluded { opacity: 0.55; }
.gj-group-head { display: flex; align-items: center; gap: 8px; }
.gj-group-head input[type=text] {
  flex: 1; min-width: 0; padding: 4px 6px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 4px;
}
.gj-group-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.gj-group-meta .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(22,32,28,0.2); }
.gj-group-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.gj-group-opts select { width: 100%; padding: 4px 5px; font-size: 11.5px; border: 1px solid var(--line); border-radius: 4px; }

.map-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: center;
  font-size: 12.5px;
  padding: 5px 0;
}
.map-row select {
  width: 100%;
  padding: 5px 6px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.map-row .col-name { font-family: var(--mono); font-size: 11.5px; }

/* Raw preview of the first few parsed rows, shown before mapping/import — a wide sheet scrolls
   inside its own box rather than the flyout panel itself scrolling sideways. */
.import-preview-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-top: 6px;
}
.import-preview { border-collapse: collapse; font-size: 11px; white-space: nowrap; }
.import-preview th, .import-preview td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.import-preview th {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 9.5px;
  color: var(--muted);
  background: var(--paper);
}

button {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  padding: 9px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button:hover { background: #234a3d; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.secondary:hover { background: var(--accent-soft); }
button.secondary.active { background: var(--accent); color: #fff; }
button:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }

.status-line {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}
.status-line.ok { color: var(--accent); }
.status-line.err { color: var(--warn); }

/* ---------- Map ---------- */
/* flex:1 claims all width the rail (fixed) and flyout (0 or 300px) don't use; min-width:0
   overrides a flex item's default min-width:auto, which would otherwise refuse to let this
   shrink below its content's intrinsic width and could squeeze the flyout instead. */
#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }

#map-wrap.picking-mode .maplibregl-canvas {
  cursor: crosshair !important;
}

/* Floating map toolbar — Basemap/Tools/GPS as one icon pill, top-center over the map (clear of
   MapLibre's own zoom/compass controls at top-right and the attribution text bottom-left).
   Replaces the old bottom-left GPS badge + separate Tools dropdown + sidebar Basemap toggle —
   consolidating every "map view" control (as opposed to "event data" controls, which live in
   the rail/flyout) into one place. */
.map-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.toolbar-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  position: relative;
}
.toolbar-icon-btn:hover { background: var(--accent-soft); }
.toolbar-icon-btn.active { background: var(--accent); color: #fff; }

.toolbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; flex-shrink: 0; }

.gps-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--panel);
}
.gps-dot.live { background: var(--accent); }

/* ---------- Site mark-up mode ----------
   body.markup-mode strips the UI down to the map: no rail/flyout, and no editing tools in the
   toolbar (basemap, the mark-up toggle and the recentre button stay). */
body.markup-mode #rail,
body.markup-mode #flyout,
body.markup-mode #btn-snap-toggle,
body.markup-mode .tools-menu,
body.markup-mode .search-menu { display: none !important; }

.markup-hud {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 6;
  width: min(420px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
}
.markup-row { display: flex; align-items: center; gap: 8px; }
.markup-row button { padding: 6px 12px; font-size: 13px; min-height: 34px; }
.markup-chip {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 14px; background: var(--line); color: var(--ink);
}
.markup-chip.good { background: #d6efdd; color: #1d5b32; }
.markup-chip.ok   { background: #fbe8b8; color: #7a5200; }
.markup-chip.poor { background: #f6d2c6; color: #8a2d12; }
.markup-chip.wait { background: var(--line); color: var(--muted); }
#markup-target-block { margin-top: 8px; }
.markup-hint { font-size: 13px; color: var(--muted); line-height: 1.35; }
.markup-label { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.markup-label span { color: var(--muted); font-size: 11.5px; }
.markup-main { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.markup-arrow { display: inline-block; font-size: 30px; line-height: 1; color: #e8590c; font-weight: 700; transition: transform 0.25s ease; }
.markup-dist { font-family: var(--mono); font-size: 34px; font-weight: 600; line-height: 1; }
.markup-brg { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-left: auto; }
.markup-offsets { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; }
.markup-note { font-size: 12px; margin-top: 6px; line-height: 1.3; }
.markup-note.ok { color: #1d5b32; font-weight: 600; }
.markup-note.warn { color: #8a2d12; }
.markup-clear { margin-top: 6px; padding: 4px 0; font-size: 12.5px; }

@media (max-width: 768px) {
  .markup-hud { bottom: 14px; }
  .markup-dist { font-size: 38px; }
}

.tools-menu { position: relative; }
.tools-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-width: 170px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
}
.tools-dropdown.show { display: block; }
.tools-dropdown button { width: 100%; }

.search-menu { position: relative; }
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
}
.search-dropdown.show { display: block; }
.search-dropdown input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--sans);
}
#search-results { margin-top: 4px; max-height: 240px; overflow-y: auto; }
.search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.3;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  font-weight: 400;
}
.search-result:hover { background: var(--accent-soft); }
.search-result-meta { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }

/* Bottom rather than top — the map toolbar (Basemap/Tools/GPS) already occupies top-center,
   so a top-center hint banner would sit right on top of it. */
.georef-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  display: none;
}
.georef-hint.show { display: block; }

/* ---------- Login screen ---------- */
#login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}
#login-form {
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px 24px;
}
#login-form h1 { font-size: 19px; margin: 4px 0 18px; }
#login-form .brand-lockup { justify-content: center; margin-bottom: 14px; }
#login-form .brand-logo { height: 30px; }
#login-form .brand-word { font-size: 22px; }
#login-form label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
#login-form input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; font-family: var(--sans);
}
#login-form button { width: 100%; margin-top: 4px; }

/* ---------- User badge / admin panel ---------- */
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
button.link {
  background: none; color: var(--accent); padding: 0; font-size: 12px; font-weight: 500;
}
button.link:hover { background: none; text-decoration: underline; }

.inline-form { display: flex; gap: 6px; margin-top: 10px; }
.inline-form input {
  flex: 1; padding: 7px 9px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 4px;
}
.inline-form button { padding: 7px 12px; }

.admin-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.admin-row .role-tag {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); text-transform: uppercase;
}
.admin-row .row-name { font-weight: 600; }
.admin-row .row-meta { color: var(--muted); font-size: 11.5px; }
.admin-row .row-actions { margin-left: auto; display: flex; gap: 8px; }
.admin-row .row-actions button { padding: 4px 9px; font-size: 11.5px; }

/* ---------- User add/edit modal ---------- */
#user-modal-backdrop, #feature-modal-backdrop, #rect-dim-modal-backdrop, #layer-style-modal-backdrop, #duplicate-site-modal-backdrop, #furniture-catalog-modal-backdrop,
#toilet-catalog-modal-backdrop, #generator-catalog-modal-backdrop, #restore-backup-modal-backdrop, #imagery-modal-backdrop {
  position: fixed; inset: 0; background: rgba(22,32,28,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.user-modal {
  width: min(340px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--panel); border-radius: 8px; padding: 22px;
}
.user-modal h2 { font-size: 16px; margin: 0 0 14px; }
.user-modal label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.user-modal input:not([type="checkbox"]), .user-modal select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 8px;
  border: 1px solid var(--line); border-radius: 4px; font-size: 13px; font-family: var(--sans);
}
.muted-hint { color: var(--muted); font-weight: 400; }
.site-check-list { max-height: 130px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; margin-top: 4px; }
.site-check-list label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin: 4px 0; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- Georeferencing modal ---------- */
#georef-modal-backdrop {
  position: fixed; inset: 0; background: rgba(22,32,28,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 25;
  padding: 24px;
}
.georef-modal {
  width: min(720px, 100%);
  max-height: 90vh;
  background: var(--panel);
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
}
.georef-modal h2 { font-size: 17px; margin: 0 0 6px; }
.georef-instructions { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }

#georef-image-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  max-height: 55vh;
  cursor: crosshair;
  line-height: 0;
}
#georef-image { display: block; max-width: 100%; user-select: none; }
#georef-image-markers { position: absolute; inset: 0; pointer-events: none; }
.point-marker {
  position: absolute;
  width: 22px; height: 22px;
  margin-left: -11px; margin-top: -11px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.map-point-marker {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Edit-shape mode: draggable vertex and rotate handles (see startEditFeature in app.js) */
.edit-vertex-handle {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #b5502e;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: grab;
}
.edit-vertex-handle:active { cursor: grabbing; }

.edit-rotate-handle {
  width: 18px; height: 18px;
  cursor: grab;
  /* Diamond shape via a rotated pseudo-element, since maplibregl.Marker owns the outer
     element's transform (for positioning) and would clobber a transform set here directly. */
  display: flex; align-items: center; justify-content: center;
}
.edit-rotate-handle::after {
  content: '';
  width: 13px; height: 13px;
  background: #2c5f4f;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transform: rotate(45deg);
}

/* Feature-popup action buttons — icon-only (see the actions row in renderMapLayers) instead of
   text labels, so 4-5 actions fit in a MapLibre popup without crowding it; a real class instead
   of inline styles so the mobile breakpoint below can bump their size. */
.popup-action-btn {
  width: 26px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; border-radius: 5px;
}

/* ---------------------------------------------------------------------------
   Mobile: the rail becomes a bottom icon bar and the flyout becomes a bottom sheet,
   instead of a side rail + side panel. Planned on desktop, used in the field on a
   phone — the map needs the screen, and event data is reachable on demand rather
   than always-on. Same collapsed-by-default philosophy as desktop, just a different
   axis (height instead of width) and triggered by the same rail-icon clicks.
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #rail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto; height: 56px;
    flex-direction: row;
    justify-content: space-around;
    border-right: none;
    border-top: 1px solid var(--line);
    z-index: 16;
  }
  .rail-icon { width: 42px; height: 42px; font-size: 19px; }

  #flyout {
    position: fixed;
    left: 0; right: 0; bottom: 56px;
    width: auto;
    max-height: 26px; /* just enough to show the handle — collapsed by default */
    border-right: none;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.15);
    z-index: 15;
    transition: max-height 0.22s ease;
  }
  #flyout.open { height: 75vh; max-height: 75vh; }
  .flyout-inner { width: auto; }

  .sheet-handle {
    display: block;
    width: 40px; height: 5px;
    margin: 10px auto 6px;
    border-radius: 3px;
    background: var(--line);
    flex-shrink: 0;
  }

  /* Clear the collapsed bottom sheet + rail (56px + a peeking handle sliver). */
  .georef-hint { bottom: 76px; }

  /* Touch-target pass, scoped to what's actually used in the field: tapping a feature's
     popup is the primary mobile interaction, so its action buttons get the most room; the
     hint-banner's inline text-link actions (Undo/Cancel/Finish) and the layer-row draw/Style
     buttons get a smaller bump since they're used less often on a phone. */
  .popup-action-btn { width: 36px; height: 36px; font-size: 15px; }
  .georef-hint .link, .draw-hint .link { padding: 6px 4px; font-size: 13px; }
  .layer-row button { padding: 6px 10px; font-size: 12px; }
}
