/* spectrum-platform-next/styles/views-map.css
   ──────────────────────────────────────────────────────────────────────────
   Map view — ported from spectrum-platform-pages/styles.css map section,
   re-skinned onto the next design tokens. Covers Leaflet pin markers, zone
   point pins, zone shapes (rect + polygon with edit handles), the floor-plan
   zoom/pan wrap + controls, measurement overlays, and the plan picker.
   ────────────────────────────────────────────────────────────────────────── */

/* Leaflet base container sits on the dark canvas. */
#map-leaflet-container { background: var(--bg-0); }
.map-leaflet-host { width: 100%; height: 100%; }

/* Dark basemap treatment (js/map-tiles.js `dark: true`). OSM raster tiles are
   light-only; CARTO's keyless dark basemap died 2026-09 (tiles watermarked
   "API KEY REQUIRED"), so the geographic map keeps its dark look via the
   established invert + hue-rotate filter on the BASE tile layer container
   only. Leaflet applies this class to the tile layer's own div (`className`
   option) — markers, zones, and popups live in other panes and keep their
   true colors. hue-rotate(180deg) restores hues after invert so water stays
   blue-ish; brightness/saturate tuned to sit close to the old CARTO dark_all. */
.map-tiles-dark {
  filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.35);
}
/* Contain the map area's internal stacking (Leaflet panes run z 200–700, the
   placement banner z 600, fp zoom controls z 100…) so none of it can paint
   over the sticky event header / global nav (z 100) when the page scrolls.
   (#map-leaflet-container already self-isolates via inline z-index:1.) */
#map-canvas { isolation: isolate; }

/* While placing a pin, drawing a shape, measuring or georeferencing
   (body.map-placing / .map-drawing / .map-measuring) the click must reach the
   plan image — and, since 2026-09-18, the MAP: zone shapes, their
   labels/handles and every pin stop intercepting it.
   (Owner: a zone pin could not be dropped over an existing area — the shape
   swallowed the click. Then: a trace could not be placed inside a zone on the
   geographic map — the source PINS over it swallowed that one.)
   `.pin-marker` / `.trace-pin` are the geographic (Leaflet divIcon) pins —
   `.pin-marker` is the inner column of EVERY one of them (analyzer, Pi, zone and,
   since 2026-09-18, trace), and `.trace-pin` is the trace pin's icon ROOT.
   drawGeoOverlays already builds them with `interactive:false` while a mode is
   armed, which is what frees Leaflet's own dispatch; this rule is what stops
   the pin's INNER divs (which Leaflet's own stylesheet never sees) from
   keeping the divIcon a hit target anyway. */
.map-placing .zone-shape, .map-placing .zone-shape-poly, .map-placing .zone-shape-poly polygon,
.map-placing .zone-shape-poly-label-html, .map-placing .zone-shape-handle, .map-placing .zone-shape-vertex, .map-placing .fp-pin,
.map-placing .pin-marker, .map-placing .trace-pin,
.map-drawing .zone-shape, .map-drawing .zone-shape-poly, .map-drawing .zone-shape-poly polygon,
.map-drawing .zone-shape-poly-label-html, .map-drawing .zone-shape-handle, .map-drawing .zone-shape-vertex, .map-drawing .fp-pin,
.map-drawing .pin-marker, .map-drawing .trace-pin,
.map-measuring .zone-shape, .map-measuring .zone-shape-poly, .map-measuring .zone-shape-poly polygon,
.map-measuring .zone-shape-poly-label-html, .map-measuring .zone-shape-handle, .map-measuring .zone-shape-vertex, .map-measuring .fp-pin,
.map-measuring .pin-marker, .map-measuring .trace-pin {
  pointer-events: none !important;
}
/* …including the glyph, which is the pin's ONE permanent hit target (see the
   pin block below). Its own `pointer-events: auto` sits on the glyph element
   itself, so an `!important` on the parent `.pin-marker` cannot reach it — a
   declaration on the element always beats an inherited one. Without this the
   30px dot would still eat the crosshair click while a mode is armed. */
.map-placing .pin-marker .pin-glyph,
.map-drawing .pin-marker .pin-glyph,
.map-measuring .pin-marker .pin-glyph {
  pointer-events: none !important;
}

/* Crosshair cursors for the active interaction modes. */
.map-placing #map-leaflet-container,
.map-placing .leaflet-container { cursor: crosshair !important; }
.map-drawing #floor-plan-img,
.map-drawing .leaflet-container { cursor: crosshair !important; }
.map-measuring #floor-plan-img,
.map-measuring .leaflet-container { cursor: crosshair !important; }

/* ── Analyzer / Pi / trace / zone pin markers (Leaflet divIcons) ──────────── */
/* A pin is a 30px GLYPH with a wide caption under it, and only the glyph is a
   control. The whole stack is therefore click-transparent and the glyph opts
   back in — one element wide instead of the label's ~140px.
   Three elements own the caption's box and every one of them had to be taken
   out, or the click simply landed on the next one up:
     · `.pin-label` / `.pin-kind` / `.pin-badge`   (the captions themselves)
     · `.pin-marker`                 (the divIcon's inner flex column)
     · the Leaflet icon ROOT         (`.analyzer-pin` / `.zone-pin` /
                                      `.trace-pin`, below)
   `iconSize: null` (sourceIcon / zoneIcon) leaves the root shrink-to-fit
   around the label, and leaflet.css re-arms it with
   `.leaflet-marker-icon.leaflet-interactive { pointer-events: auto }` — so
   neutralising the captions alone moved the hit target one level up and
   reclaimed nothing (measured: elementFromPoint at the label's centre returned
   DIV.pin-marker, then DIV…analyzer-pin, before the root rule went in).
   Dragging is unaffected: L.Marker's Draggable binds to the icon ROOT, and a
   mousedown on the glyph still bubbles to it through the none'd ancestors. */
.pin-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
/* The Leaflet icon root. Scoped through `.leaflet-pane` for specificity (0,3,0)
   — views-map.css is linked BEFORE leaflet.css (engine/vendor-scripts.js
   appends leaflet.css at the end of <head>), so a plain
   `.leaflet-marker-icon.analyzer-pin` (0,2,0) would tie with, and lose to,
   leaflet's own `.leaflet-marker-icon.leaflet-interactive`. */
.leaflet-pane .leaflet-marker-icon.analyzer-pin,
.leaflet-pane .leaflet-marker-icon.zone-pin,
.leaflet-pane .leaflet-marker-icon.trace-pin {
  pointer-events: none;
}
.pin-marker .pin-glyph {
  pointer-events: auto;     /* the pin's one hit target: drag handle + tooltip */
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--text-muted);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.pin-marker.analyzer.online  .pin-glyph,
.pin-marker.pi.online        .pin-glyph { background: var(--ok); }
.pin-marker.analyzer.stale   .pin-glyph,
.pin-marker.pi.stale         .pin-glyph { background: var(--warn); border-color: #fff; }
.pin-marker.analyzer.offline .pin-glyph,
.pin-marker.pi.offline       .pin-glyph { background: var(--danger-strong); }
.pin-marker.zone             .pin-glyph { background: var(--zone-color, #a855f7); }
/* A TRACE pin is one antenna of an analyzer, and it must be tellable from the
   analyzer at a glance — so its glyph carries the KIND (the same --pin accent the
   sidebar's trace rows use), not the status colours the analyzer/Pi glyphs use. A
   trace has no last_seen of its own anyway: the status it shows is its analyzer's,
   and it is on the row's pill and the pin's tooltip. */
.pin-marker.trace            .pin-glyph { background: var(--pin); }
/* The name, the kind flag and the provenance badge are CAPTIONS, not controls.
   Redundant now that `.pin-marker` and the icon root are both none (a child
   inherits it), and kept deliberately: it is the declaration that says WHY these
   three are not controls, and it is what keeps them captions if the stack above
   them is ever re-armed. `.pin-label` is a wide text box under a 30px dot, so while the
   stack took pointer events a pin covered far more of the map than it looked
   like — measured on prod event 26, where document.elementFromPoint returned
   DIV.pin-label (or DIV.pin-marker) at all twelve points sampled inside a zone
   area, never the polygon and never the map, so a click meant for the zone had
   nowhere to land. This holds whether or not a mode is armed; the block at the
   top of this file is the while-armed half. */
.pin-marker .pin-label,
.pin-marker .pin-kind,
.pin-marker .pin-badge { pointer-events: none; }
.pin-marker .pin-label {
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  background: rgba(10, 14, 22, .92);
  color: #fff;
  border-radius: var(--r-sm);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The KIND flag ("Trace") — a small chip under the name saying what the pin is.
   Separate from `.pin-badge`, which means placement provenance ("Manual" /
   "GPS ±6.4 m"); one caption cannot honestly carry both. */
.pin-marker .pin-kind {
  padding: 0 5px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--pin);
  background: rgba(10, 14, 22, .92);
  border: 1px solid var(--pin);
  border-radius: var(--r-pill);
  white-space: nowrap;
}

/* ── Floor-plan zoom + pan ─────────────────────────────────────────────────── */
.fp-zoom-wrap {
  position: absolute;
  inset: 0;
  transform-origin: center;
  will-change: transform;
  touch-action: none;     /* let our pointer handlers own pan/zoom on touch */
}
.fp-zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(10, 14, 22, .85);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.fp-zoom-controls button {
  background: transparent;
  border: none;
  color: var(--text-2);
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-weight: 600;
}
.fp-zoom-controls button:hover { background: rgba(255, 255, 255, .08); color: var(--text-1); }
#floor-plan-img { touch-action: none; user-select: none; -webkit-user-drag: none; }

.fp-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .55);
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  z-index: 8;
  cursor: pointer;
}
.fp-pin-label {
  position: absolute;
  margin-top: 2px;
  transform: translate(-50%, 6px) scale(var(--inv-zoom, 1));
  transform-origin: top center;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(10, 14, 22, .9);
  color: #fff;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 8;
}
.fp-pin.trace-fp-pin { width: 10px; height: 10px; }

/* ── Zone shapes: rect ───────────────────────────────────────────────────────
   Drawn in the zone's colour (--zone-color, set per shape from js zoneColor())
   — the SAME colour as the zone card's swatch and the zone's pins. */
.zone-shape {
  position: absolute;
  border: 2px solid var(--zone-color, #a855f7);
  background: color-mix(in srgb, var(--zone-color, #a855f7) 16%, transparent);
  box-sizing: border-box;
  border-radius: 2px;
}
.zone-shape-label {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
  background: rgba(10, 14, 22, .65);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  transform-origin: top left;
  transform: scale(var(--inv-zoom, 1));
}
.zone-shape-preview {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(59, 130, 246, .20);
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 2px;
}
.zone-shape-rect { pointer-events: auto; cursor: pointer; }
.zone-shape-rect.zone-shape-selected {
  border-color: var(--warn);
  background: rgba(251, 191, 36, .18);
  cursor: move;
  z-index: 5;
}
.zone-shape-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--warn);
  border: 1px solid #110;
  border-radius: 2px;
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  pointer-events: auto;
  z-index: 6;
  touch-action: none;
}
.zone-shape-handle-nw { cursor: nwse-resize; }
.zone-shape-handle-ne { cursor: nesw-resize; }
.zone-shape-handle-sw { cursor: nesw-resize; }
.zone-shape-handle-se { cursor: nwse-resize; }

/* ── Zone shapes: polygon (SVG) ────────────────────────────────────────────── */
/* No browser focus ring on the overlay SVGs. Chrome focuses an inline <svg>
   root on a click and paints its focus ring (the SVG's bounding box) as soon
   as a key press — Esc leaving draw mode — makes :focus-visible match:
   measured live 2026-09-18 (ev30) as a blue rectangle around a zone polygon
   that outlived "Draw on map". These overlays are not keyboard controls
   (nothing inside them takes focus); the ring stays on the real controls
   (base.css :focus-visible → --ring). */
.zone-shape-poly:focus, .zone-shape-poly:focus-visible,
.zone-shape-poly-preview:focus, .zone-shape-poly-preview:focus-visible,
.measure-svg:focus, .measure-svg:focus-visible,
.leaflet-container svg:focus, .leaflet-container svg:focus-visible,
.leaflet-interactive:focus, .leaflet-interactive:focus-visible { outline: none; }
.zone-shape-poly polygon {
  fill: color-mix(in srgb, var(--zone-color, #a855f7) 18%, transparent);
  stroke: var(--zone-color, #a855f7);
  stroke-width: 2;
  pointer-events: auto;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}
.zone-shape-poly.zone-shape-selected polygon {
  fill: rgba(251, 191, 36, .20);
  stroke: var(--warn);
  cursor: move;
}
.zone-geo-shape { cursor: pointer; }
.zone-geo-shape-selected { cursor: default; }
.zone-geo-shape-pending { opacity: .55; }
.zone-geo-vertex-icon { background: none; border: 0; }
.zone-geo-vertex {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, .6);
  cursor: grab;
}
.zone-geo-popup .leaflet-popup-content { margin: 10px 12px; }
.zone-shape-poly-label-html {
  position: absolute;
  background: rgba(10, 14, 22, .75);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--zone-color, #a855f7) 40%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .30);
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  pointer-events: none;
}
.zone-shape-vertex {
  fill: var(--warn);
  stroke: #110;
  stroke-width: 1;
  pointer-events: auto;
  cursor: grab;
  vector-effect: non-scaling-stroke;
}
.zone-shape-vertex:active { cursor: grabbing; }
.zone-shape-poly-preview { position: absolute; pointer-events: none; }
.zone-shape-poly-preview polyline,
.zone-shape-poly-preview circle { vector-effect: non-scaling-stroke; }

/* ── Measurement overlays (floor SVG) ──────────────────────────────────────── */
.measure-svg { position: absolute; pointer-events: none; }
.measure-svg polyline,
.measure-svg polygon {
  fill: rgba(251, 191, 36, .18);
  stroke: var(--warn);
  stroke-width: 2;
  stroke-dasharray: 4, 3;
  vector-effect: non-scaling-stroke;
}
.measure-svg polygon { stroke-dasharray: none; }
.measure-svg.measure-scale polyline { stroke: var(--accent); stroke-dasharray: 6, 2; }
.measure-preview { position: absolute; pointer-events: none; }
.measure-label {
  position: absolute;
  background: rgba(10, 14, 22, .88);
  color: var(--warn);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: .2px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  pointer-events: none;
  z-index: 9;
}
.measure-label-scale { color: var(--accent); }
.measure-label-uncalibrated { color: var(--danger); }
.measure-tip { background: rgba(10, 14, 22, .9); color: var(--warn); border: none; }

/* ── Plan picker rows (rename / reorder inline) ────────────────────────────── */
.plan-picker-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 10px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-1);
  font-size: 12px;
}
.plan-picker-row:hover { background: var(--bg-raised); }
.plan-picker-row.current { color: var(--accent); background: var(--bg-raised); }
.plan-picker-row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-picker-row-up,
.plan-picker-row-down,
.plan-picker-row-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  line-height: 1;
}
.plan-picker-row-up:hover:not([disabled]),
.plan-picker-row-down:hover:not([disabled]),
.plan-picker-row-edit:hover { color: var(--text-1); background: var(--bg-2); }
.plan-picker-row-up[disabled],
.plan-picker-row-down[disabled] { opacity: .25; cursor: default; }
.plan-picker-row.editing { gap: 4px; padding: 6px 8px; }
.plan-picker-row-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  color: var(--text-1);
  font-size: 12px;
  padding: 3px 6px;
  border-radius: var(--r-sm);
}
.plan-picker-row-input:focus { outline: none; border-color: var(--accent-strong); }
.plan-picker-row-save,
.plan-picker-row-cancel,
.plan-picker-row-delete {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.plan-picker-row-save { color: var(--accent); border-color: var(--accent-soft); }
.plan-picker-row-delete { color: var(--danger); border-color: var(--danger-dim); }
.plan-picker-row-delete:hover { background: var(--danger-dim); color: #ffb4b4; }

/* PDF multi-page upload grid (in the upload modal). */
.fp-page-grid-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.fp-page-grid-header button {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}
.fp-thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.fp-page-thumb {
  border: 2px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 6px;
  background: var(--bg-raised);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fp-page-thumb.selected { border-color: var(--accent); }
.fp-page-thumb img { width: 100%; height: 70px; object-fit: contain; background: var(--bg-0); border-radius: 3px; }
.fp-page-thumb .fp-page-label { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.fp-page-thumb input[type="text"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-size: 11px;
  padding: 3px 5px;
  border-radius: var(--r-sm);
}

/* Mobile: collapse the sidebar under the map. */
@media (max-width: 720px) {
  .map-body { flex-direction: column !important; }
  .map-sidebar {
    width: 100% !important;
    max-height: 42vh;
    border-left: none !important;
    border-top: 1px solid var(--border-subtle);
  }
  #map-canvas { min-height: 48vh; }
}

/* Touch: keep the Place button's 44px hit area without its 44px box.
   The sidebar is NOT hidden on a phone (it goes full width under the map,
   above), so this button really is tapped. It is the only `.btn` in the
   sidebar, and its inline `height:22px;min-height:0` — needed so it matches the
   ONLINE pill — beats components.css's `(pointer:coarse),(max-width:760px)
   .btn{min-height:var(--tap-min)}` rule (WCAG 2.5.5 / Apple HIG). Growing the
   box back would undo the owner's ask, so the hit area is restored with a
   transparent overlay instead: the pseudo-element belongs to the button, so a
   tap on it activates the button. It spans only the button's width and ~11px
   above/below, which stays inside the card — no neighbouring control is in
   reach. `position` is not set inline, so no !important is needed. */
@media (pointer: coarse), (max-width: 760px) {
  .map-sidebar .source-row .btn { position: relative; }
  .map-sidebar .source-row .btn::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--tap-min);
    transform: translateY(-50%);
  }
}

/* ── Licensed incumbents (FCC ULS) — R2 legal-map layer ─────────────────────
   Neutral steel-blue shield pin, deliberately distinct from analyzer / Pi /
   zone / trace / spot-scan pins. Advisory display only. */
.incumbent-pin { background: none; border: none; }
.inc-shield {
  width: 18px;
  height: 20px;
  background: linear-gradient(180deg, #55759b, #3d5a7a);
  color: #dbe7f4;
  font: 700 10px/16px var(--font-mono);
  text-align: center;
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .55));
}

/* Dark-theme popup for incumbent markers (Leaflet's default is white). */
.inc-leaflet-popup .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.inc-leaflet-popup .leaflet-popup-tip { background: var(--bg-card); }
.inc-leaflet-popup .leaflet-popup-close-button { color: var(--text-muted); }
.inc-popup { font-size: 11px; line-height: 1.5; max-width: 220px; }
.inc-popup-name { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.inc-popup-line { color: var(--text-2); font-family: var(--font-mono); }
.inc-popup-advisory { margin-top: 6px; color: var(--warn); font-size: 10px; }
.inc-popup-note { color: var(--text-faint); font-size: 10px; }

/* ── Floor-plan upload: per-page crop editor ─────────────────────────────────
   Opened inline inside the upload modal (a nested modal would share the
   document Escape handler and close the whole dialog). The modal grows to the
   editor width while a page is being cropped; the stage shows the ORIGINAL
   rendered page with a dimmed mask outside the crop rect + 8 resize handles.
   Rect geometry is kept in image px and rendered as percentages, so it is
   independent of the displayed size. */
.modal.modal--crop { width: min(940px, 90vw); }
@media (max-width: 640px) { .modal.modal--crop { width: 100%; } }

.fp-crop-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.fp-crop-stage:focus-visible { box-shadow: 0 0 0 2px var(--ring); }
.fp-crop-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 300px);
  background: #fff;
  pointer-events: none;
  -webkit-user-drag: none;
}
.fp-crop-overlay { position: absolute; inset: 0; cursor: crosshair; }
.fp-crop-rect {
  position: absolute;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  cursor: move;
  box-sizing: border-box;
}
.fp-crop-rect[hidden] { display: none; }
.fp-crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--accent);
  border: 1px solid #fff;
  border-radius: 2px;
  box-sizing: border-box;
}
.fp-crop-handle[data-handle="n"]  { left: 50%;  top: 0;    cursor: ns-resize; }
.fp-crop-handle[data-handle="s"]  { left: 50%;  top: 100%; cursor: ns-resize; }
.fp-crop-handle[data-handle="e"]  { left: 100%; top: 50%;  cursor: ew-resize; }
.fp-crop-handle[data-handle="w"]  { left: 0;    top: 50%;  cursor: ew-resize; }
.fp-crop-handle[data-handle="nw"] { left: 0;    top: 0;    cursor: nwse-resize; }
.fp-crop-handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.fp-crop-handle[data-handle="ne"] { left: 100%; top: 0;    cursor: nesw-resize; }
.fp-crop-handle[data-handle="sw"] { left: 0;    top: 100%; cursor: nesw-resize; }
@media (pointer: coarse) {
  .fp-crop-handle { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
}

/* Thumbnail crop badge (upload dialog page cards). */
.fp-crop-badge {
  font-size: 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Page readiness badge (plan picker) ──────────────────────────────────────
   A page is a floor in Spatial only once it has a scale AND a north. The badge
   states which of the two is missing, on the row where the page is chosen. It
   is a STATUS, so components/badge.js — a pill is a toggle (SPA control
   standard), and these rows are buttons already. Colours come from the badge
   variants (ok / warn / danger / neutral); only the fit is set here. */
.plan-picker-readiness { margin-left: auto; flex-shrink: 0; cursor: default; }
.plan-picker-page-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── "No scale on this page" strip (above the sheet, floor-plan mode) ────────
   Does not auto-dismiss: it states the one thing that silently keeps a page
   out of Spatial. Sits in the flow above the map, never over it. */
.map-setup-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  flex-shrink: 0;
  z-index: 2;
}
.map-setup-strip[hidden] { display: none; }
.map-setup-strip-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-1);
}
@media (max-width: 700px) {
  .map-setup-strip { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
}
