/* Viewport-pinned, full-bleed under the higher-z sidebar: the map spans from x=0 so collapsing the rail uncovers more map without ever resizing the canvas. */
#maps-host {
  position: fixed;
  inset: 0;
  z-index: 1;
}
#maps-map {
  position: absolute;
  inset: 0;
  isolation: isolate;         /* own stacking context so the panel overlays the on-map controls regardless of geometry */
  background: var(--bg-map);  /* shows through until tiles load */
}
/* keep the bottom-right controls (scale + attribution) clear of the overlay panel */
#maps-host .maplibregl-ctrl-bottom-right { right: 372px; }
.graphic-scale {
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--map-glass-fg);
  padding: 5px 9px 4px;
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.graphic-scale .gs-bar {
  position: relative;
  height: 7px;
  display: flex;
  border: 1px solid var(--map-glass-fg);
}
.graphic-scale .gs-seg { display: block; height: 100%; }
.graphic-scale .gs-seg-a { background: var(--map-glass-fg); }
.graphic-scale .gs-seg-b { background: transparent; }
.graphic-scale .gs-labels { position: relative; height: 11px; margin-top: 3px; }
.graphic-scale .gs-tick { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.graphic-scale .gs-tick:first-child { transform: none; }
.graphic-scale .gs-tick:last-child { transform: translateX(-100%); }

/* High contrast: kill all residual translucency on the over-map glass — drop the
   blur and make the floating hint opaque (bg/border tokens already went opaque). */
html.high-contrast #maps-panel,
html.high-contrast .maps-panel-header,
html.high-contrast .map-toolbar,
html.high-contrast .map-report,
html.high-contrast .map-draw-hint,
html.high-contrast .map-search-hint,
html.high-contrast .graphic-scale {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.map-toolbar {
  position: absolute;
  /* vertically centre the bar on the rail's collapse toggle (sidebar header), not just top-aligned */
  top: 6px;
  left: calc(var(--rail-w) + 12px);  /* clear the overlaying sidebar; rides the animating --rail-w */
  right: 372px;                       /* clear the 360px layers panel + gutter */
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 38px;
  /* symmetric 2px end pads: the search button (right) and the Projects pill (left) carry their own
     inner padding, so the bar itself hugs them tight and sits as far left as it can. */
  padding: 0 2px;
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
  transition: border-color .15s, box-shadow .15s;
}

.map-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.map-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.map-projects-slot { display: flex; align-items: center; gap: 4px; }
.map-projects-btn {
  flex: none;
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--map-glass-fg);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition: background .15s;
}
.map-projects-btn:hover,
.map-projects-btn[aria-expanded="true"] { background: var(--icon-btn-hover); }
.map-projects-btn .lucide { width: 15px; height: 15px; flex: none; }
.map-projects-btn .lucide:last-child { width: 13px; height: 13px; opacity: 0.7; }
.map-projects-label { white-space: nowrap; }

.map-project-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  padding: 0 10px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--map-glass-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-tool-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--map-glass-fg);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.map-tool-btn i { width: 16px; height: 16px; }
.map-tool-btn:hover { background: var(--icon-btn-hover); }
.map-tool-btn.active { background: var(--accent); color: var(--accent-fg); }
.map-tool-clear { color: var(--danger-icon); }
.map-tool-sep { flex: none; width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

/* Compact toolbar: the menu itself is the shared floating popover (.cat-row-menu), so no menu styles live here. */
.map-tools-dd { position: relative; display: inline-flex; }
.map-tools-trigger { width: auto; gap: 6px; padding: 0 10px; }
.map-tools-trigger-label { font-size: 12px; font-weight: 600; }
.map-tools-caret { font-size: 10px; opacity: 0.8; }

.map-search {
  position: relative;
  display: flex;
  align-items: center;
  height: 32px;
  /* equal 3px inset on top/right/bottom; the 24px button exactly fills the 24px content height
     (32 − 2·border − 2·3px), so its rounding sits evenly inside the pill on every side */
  padding: 3px 3px 3px 12px;
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: 999px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.map-search:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-glow);
}
.map-search-input {
  width: 200px;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--map-glass-fg);
  font-size: 13px;
  padding: 0 6px;
  min-width: 0;
}
.map-search-input::placeholder { color: var(--text-muted-cool); }
.map-search-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.map-search-btn i { width: 15px; height: 15px; }
.map-search-btn:hover { background: var(--accent-hover); }
.map-search-btn:disabled { opacity: 0.55; cursor: default; }
.map-search-hint {
  position: absolute;
  top: 44px;
  left: 4px;
  max-width: 300px;
  padding: 6px 11px;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.map-search-hint.is-visible { opacity: 1; transform: translateY(0); }

.map-report {
  position: absolute;
  top: 60px;
  left: calc(var(--rail-w) + 12px);
  z-index: 5;
  width: 320px;
  max-height: calc(100% - 72px);  /* grow down to a 12px bottom gutter (top:60 + 12) — the long report scrolls within */
  overflow-y: auto;
  padding: 12px 14px;
  color: var(--map-glass-fg);
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
  font-size: 12px;
}
.map-report-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.map-report-head strong { font-size: 13px; }
.map-report-titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.map-report-print {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--map-glass-fg);
  cursor: pointer;
}
.map-report-print:hover { background: var(--icon-btn-hover); }
.map-report-print i { width: 15px; height: 15px; }
.map-report-print:disabled { opacity: 0.5; cursor: default; }
.map-report-area { color: var(--text-muted-cool); font-variant-numeric: tabular-nums; }
.map-report-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}
.map-report-progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.map-report-layers { display: flex; flex-direction: column; gap: 10px; }
.map-report-layer { padding-top: 8px; border-top: 1px solid var(--border); }
.map-report-layer:first-child { border-top: 0; padding-top: 0; }
.map-report-layer-name { font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.map-report-stats { display: flex; flex-direction: column; gap: 3px; }
.map-report-stat { display: flex; justify-content: space-between; gap: 12px; }
.map-report-stat span { color: var(--text-muted-cool); white-space: nowrap; }
.map-report-stat b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.map-report-full { color: var(--text-muted-cool); font-weight: 400; }
.map-report-layer-name { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.map-report-layer-title { min-width: 0; }
.map-report-headacts { flex: none; display: inline-flex; align-items: center; gap: 4px; margin: -2px -2px 0 0; }
.map-report-chart,
.map-report-compare,
.map-summary-all,
.map-compare-regions {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted-cool);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.map-report-chart:hover,
.map-report-compare:hover,
.map-summary-all:hover,
.map-compare-regions:hover { background: var(--icon-btn-hover); color: var(--text-strong); }
.map-report-chart :is(i, svg), .map-report-compare :is(i, svg), .map-summary-all :is(i, svg), .map-compare-regions :is(i, svg) { width: 15px; height: 15px; }
.map-summary-all:disabled, .map-summary-checked:disabled { opacity: 0.5; cursor: default; }
.map-report-clip { color: var(--text-muted-cool); font-size: 11px; margin-bottom: 6px; }
.map-report-classes { display: flex; flex-direction: column; gap: 3px; }
.map-report-class {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.map-report-class .maps-legend-sw { width: 12px; height: 12px; border-radius: 3px; }
.map-report-class-pct { color: var(--text-muted-cool); text-align: right; }
.map-report-class-area { color: var(--text-muted-cool); text-align: right; min-width: 54px; }

.map-import-list { display: flex; flex-direction: column; gap: 1px; }
.map-import-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--map-glass-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.map-import-row:hover { background: var(--icon-btn-hover); }
.map-import-cb {
  flex: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--text-muted-cool);
  border-radius: 4px;
}
.map-import-cb.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.map-compare-regions.active { color: var(--accent); }
.map-compare-foot { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.map-compare-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px;
  font: inherit;
  color: var(--map-glass-fg);
  background: transparent;
  border: 1px solid var(--map-glass-border);
  border-radius: 7px;
  cursor: pointer;
}
.map-compare-pick:hover { background: var(--icon-btn-hover); }
.map-compare-pick i { width: 14px; height: 14px; flex: none; color: var(--text-muted); }
.map-compare-run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.map-compare-run:disabled { opacity: 0.5; cursor: default; }
.map-compare-run i { width: 14px; height: 14px; }
.map-summary-checked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--map-glass-fg);
  background: var(--icon-btn-hover);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.map-summary-checked:disabled { opacity: 0.5; cursor: default; }
.map-summary-checked i { width: 14px; height: 14px; }
.map-import-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-import-area { color: var(--text-muted-cool); font-variant-numeric: tabular-nums; flex: none; }
.map-report-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 2px 8px 2px 4px;
  border: 0;
  border-radius: 999px;
  background: var(--icon-btn-hover);
  color: var(--map-glass-fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.map-report-back:hover { background: var(--surface-hover); }

.catalogpick-modal { width: 420px; max-width: 92vw; display: flex; flex-direction: column; }
.catalogpick-header { padding: 4px 4px 10px; }
.catalogpick-header .hint { margin: 4px 0 0; }
.catalogpick-body { max-height: 50vh; overflow-y: auto; }
.catalogpick-list { display: flex; flex-direction: column; gap: 1px; }
.catalogpick-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.catalogpick-row:hover { background: var(--surface-hover, rgba(127, 127, 127, 0.12)); }
.catalogpick-col { color: var(--fg-muted, #8a93a6); font-size: 12px; flex: none; }
.catalogpick-checks { display: flex; flex-direction: column; margin-top: 4px; }
/* Higher specificity than the global `.modal label` (which is display:block) so rows stay one-line + tight. */
.catalogpick-modal .catalogpick-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  margin: 0;
  line-height: 1.25;
  border-radius: 6px;
  cursor: pointer;
}
.catalogpick-modal .catalogpick-check:hover { background: var(--surface-hover, rgba(127, 127, 127, 0.12)); }
/* the generic `.modal input { width:100% }` makes the checkbox fill the row and squeezes out the label — reset it */
.catalogpick-modal .catalogpick-check input { flex: none; width: auto; margin: 0; padding: 0; border: 0; }
.catalogpick-all { border-bottom: 1px solid var(--border, rgba(127, 127, 127, 0.2)); padding-bottom: 6px; margin-bottom: 4px; }
.catalogpick-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; }
.catalogpick-right { display: inline-flex; gap: 8px; }

.map-seg-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: #10151f;
  background: rgba(255, 255, 255, 0.7);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.map-cluster-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  pointer-events: none;
}
.map-cluster-label-dark {
  color: #1e293b;
  text-shadow: none;
}
.map-report-hist { display: flex; flex-direction: column; margin-top: 8px; }
.map-report-hist-bars { display: flex; align-items: flex-end; gap: 1px; height: 36px; }
.map-report-hist-bars > span { flex: 1; min-height: 1px; border-radius: 1px 1px 0 0; }
.map-report-hist-axis {
  position: relative;
  height: 11px;
  margin-top: 3px;
  font-size: 9px;
  color: var(--text-muted-cool);
  font-variant-numeric: tabular-nums;
}
.map-report-hist-axis > span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.map-report-loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted-cool); }
.map-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-spin 0.7s linear infinite;
}
@keyframes map-spin { to { transform: rotate(360deg); } }

.map-draw-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 80%;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--map-glass-fg);
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
  pointer-events: none;
}
.map-draw-hint[hidden] { display: none; }

/* Persistent ruler readout — distance + its own clear, independent of the area report. */
.map-measure {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--map-glass-fg);
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
}
.map-measure[hidden] { display: none; }
.map-measure > i { width: 15px; height: 15px; }
.map-measure-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.map-measure-clear:hover { background: var(--map-glass-hover, rgba(127, 127, 127, 0.25)); }
.map-measure-clear i { width: 14px; height: 14px; }

/* Basemap toggle + attribution, pinned to the bottom of the layers panel — sticky
   so it stays visible while the layer list scrolls under it (mirrors the header). */
.maps-panel-foot {
  position: sticky;
  bottom: 0;
  margin-top: auto;  /* float to the panel's bottom when the layer list is short */
  padding: 10px 12px;
  border-top: 1px solid var(--panel-glass-border);
  background: var(--panel-glass);  /* 0.8 alpha masks the content scrolling under it */
  z-index: 5;  /* above scrolling content (palette/clip thumbs) so nothing pokes through */
  display: flex;
  flex-direction: column;
}
.maps-legend-bar {
  height: 11px;
  width: 100%;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}

/* Dual-handle clip slider over the gradient bar (two overlaid range inputs;
   only the thumbs take pointer events, the tracks pass through). */
.maps-legend-clip { position: relative; }
.maps-clip-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(13, 18, 30, 0.55);
  pointer-events: none;
  border-radius: 4px;
}
.maps-clip-mask-lo { left: 0; }
.maps-clip-mask-hi { right: 0; }
.maps-clip {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 16px;
  margin: 0;
  transform: translateY(-50%);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
}
.maps-clip::-webkit-slider-runnable-track { background: transparent; height: 16px; }
.maps-clip::-moz-range-track { background: transparent; height: 16px; }
.maps-clip::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  background: #fff;
  border: 1px solid rgba(13, 18, 30, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
}
.maps-clip::-moz-range-thumb {
  pointer-events: auto;
  width: 10px;
  height: 16px;
  border: 1px solid rgba(13, 18, 30, 0.7);
  border-radius: 3px;
  background: #fff;
  cursor: ew-resize;
}
.maps-clip-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--map-glass-fg);
  background: rgba(13, 18, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  pointer-events: none;
}
.maps-legend-hist {
  position: relative;
  height: 36px;
  margin-bottom: 3px;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}
.maps-hist-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: 1px;
}
.maps-hist-bars > span {
  flex: 1;
  min-height: 1px;
  background: rgba(127, 137, 153, 0.45);
  border-radius: 1px 1px 0 0;
}
.maps-hist-bars > span.dim { opacity: 0.3; }
.maps-legend-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted-cool);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.maps-legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.maps-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted-cool);
  font-variant-numeric: tabular-nums;
}
.maps-legend-sw {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}
/* separate full-width buttons instead of a flat strip, overriding .seg-toggle's flex-end + surface fill */
.maps-basemap-bar.seg-toggle {
  display: flex;
  gap: 4px;
  align-self: stretch;
  border: none;
  background: transparent;
}
.maps-basemap-bar .seg-btn {
  flex: 1;
  padding: 4px 4px;
  font-size: 11px;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-input);
  border-radius: 4px;
}
.maps-basemap-bar .seg-btn:hover { background: var(--surface-hover); color: var(--text-strong); }
.maps-basemap-bar .seg-btn:focus,
.maps-basemap-bar .seg-btn:focus-visible { outline: none; }
.maps-basemap-bar .seg-btn.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
#maps-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  z-index: 2;
  background: var(--panel-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--panel-glass-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.maps-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-glass-border);
  position: sticky;
  top: 0;
  background: var(--panel-glass);  /* the 0.8 alpha masks scrolled content; the panel's own blur is enough */
  z-index: 5;  /* above scrolling content (palette/clip thumbs) so nothing pokes through */
}
.maps-panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-strong);
}
/* Project name can be long — keep it on one line, ellipsised, leaving room for Add. */
.maps-project-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.maps-panel-header .primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;  /* white on the accent fill in any theme */
}
.maps-panel-header .primary .lucide {
  width: 15px;
  height: 15px;
  stroke-width: 2.75;
}
.maps-layer-list {
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.maps-empty {
  padding: 16px;
  text-align: center;
}
.maps-attribution {
  padding: 8px 2px 0;
  font-size: var(--fs-xs);
  line-height: 1.35;
  color: var(--text-muted-cool);
  opacity: 0.85;
}
.maps-attribution a { color: inherit; text-decoration: none; }
.maps-attribution a:hover { text-decoration: underline; }
.maps-layer {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover-cool);
  padding: 8px 10px;
}
.maps-layer-dragging {
  opacity: 0.5;
  outline: 1px dashed var(--accent-strong);
  outline-offset: -1px;
}
/* grip · (eye for colourless layers) · name (stretches) · delete. The eye and
   palette for colourable layers live left of the histogram, not here. */
.maps-layer-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
/* Drop .icon-btn's global margin-right so spacing is the flex gap alone. */
.maps-layer-head .icon-btn { margin: 0; }
/* Trash glyph flush to the content's right edge, so it lines up with the % + histogram below. */
.maps-layer-head .maps-l-del { padding-right: 0; }
.maps-l-grip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;   /* same rail width as the colour-section icons, so the name lines up with the histogram */
  height: 24px;  /* sit the glyph on the name's first line */
  color: var(--text-muted-cool);
  cursor: grab;
}
.maps-l-grip:active { cursor: grabbing; }
.maps-l-grip i { width: 14px; height: 14px; }
/* Pen + name + orig as one rename target. The pen is absolutely placed top-left; the name's first line is text-indented to clear it, so wrapped lines (and the orig below) run the full width under it. */
.maps-l-meta {
  flex: 1;
  position: relative;
  min-width: 0;
  padding: 3px 6px 3px 0;  /* no left pad: the name starts flush at the histogram's left edge (rail + gap) */
  border-radius: 5px;
  cursor: pointer;
}
.maps-l-meta:hover { background: var(--icon-btn-hover); }
.maps-l-rename {
  position: absolute;
  top: 3px;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;  /* one line tall, so it sits on the name's first line only */
  padding: 0;
  color: var(--text-muted-cool);
  background: none;
  border: none;
  cursor: pointer;
}
.maps-l-meta:hover .maps-l-rename { color: var(--text-strong); }
.maps-l-rename i { width: 14px; height: 14px; }
.maps-l-name {
  display: block;
  min-width: 0;
  text-indent: 21px;
  font: 600 12px/1.3 inherit;
  color: var(--text-strong);
  word-break: break-word;
}
.maps-l-orig {
  font-size: 11px;
  color: var(--text-muted-cool);
  word-break: break-word;
}
.maps-l-orig > span { display: block; }
.maps-l-rename-input {
  width: 100%;
  font-size: 12px;
  padding: 2px 6px;
  color: var(--text-strong);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: 4px;
}
.maps-l-rename-input:focus { outline: none; border-color: var(--accent); }
.maps-legend-orig, .map-report-layer-orig {
  display: block;
  color: var(--text-muted-cool);
  font-weight: 400;
  word-break: break-word;
}
.maps-l-controls {
  margin-top: 6px;
}
.maps-l-opacity {
  display: grid;
  /* Label sizes to its text so long locales (e.g. ru "Непрозрачность") aren't clipped; the slider
     takes the rest. */
  grid-template-columns: auto 1fr 40px;
  gap: 8px;
  align-items: center;
  margin-left: 36px;  /* start at the histogram's left edge (icon rail + gap) */
  font-size: 11px;
  color: var(--text-secondary);
}
.maps-l-opacity > span:first-child { white-space: nowrap; }
.maps-l-opacity input[type=range] {
  width: 100%;
  min-width: 0;  /* let the slider shrink inside the grid instead of overflowing the label */
}
.maps-l-opval {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
}
.maps-l-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  margin-left: 36px;  /* align with Opacity + the histogram's left edge */
  font-size: 11px;
  color: var(--text-secondary);
}
/* Inside the colour section the slider is already in the right column — drop the icon-rail indent. */
.maps-l-colorright .maps-l-band { margin-left: 0; }
.maps-l-band-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
  white-space: nowrap;
}
.maps-l-band input[type=range] { width: 100%; }
.maps-l-color {
  display: flex;
  gap: 8px;
  /* Bottom-align the icon stack with the histogram's scale: with a third icon the column is taller
     than the legend body, so flex-start let it dangle below the ticks. (Categorical re-centres below.) */
  align-items: flex-end;
  margin-top: 10px;
}
.maps-l-coloricons {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.maps-l-coloricons .icon-btn { margin: 0; }  /* drop the global margin-right so eye + palette share one axis */
.maps-l-about-btn.active { color: var(--accent); }
/* LLM description — a floating popover anchored to the (i) button so it doesn't grow the layer card. */
.maps-l-about-pop {
  position: fixed;
  z-index: 30;
  width: 260px;
  max-width: 70vw;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* "AI" chip stamped on any LLM-generated plate. */
.ai-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px 1px 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.ai-badge svg { width: 11px; height: 11px; }
/* LLM description under the compact time-series chart. */
.maps-ts-about {
  margin: 8px 6px 2px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.maps-ts-about .maps-ts-about-text.is-loading { opacity: 0.7; font-style: italic; }
/* Shared "no tall body" variant: a class raster's chip row and a vector layer's colour swatch are
   both a single short row, not a histogram — flex-end (the default below) would leave a gap above
   them to bottom-align with a taller icon stack. Lay the eye + palette in line and centre them
   instead, so the row sits flush under Opacity. */
.maps-l-color-cat { align-items: center; }
.maps-l-color-cat .maps-l-coloricons { flex-direction: row; gap: 4px; }
/* Right column: histogram body + the time-series slider stacked under it, so the icon column
   (flex-end) bottom-aligns down to the slider. refreshLayerColor only rewrites .maps-l-colorbody,
   leaving the slider — its sibling — wired and in place. */
.maps-l-colorright {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.maps-l-colorbody {
  min-width: 0;
}
/* Palette picker beside the histogram. Relative so its dropdown menu anchors to
   it; no z-index so it scrolls UNDER the sticky bars. */
.maps-l-cmap-mount {
  position: relative;
}

.cmap-dd { position: relative; }
/* In icon mode the mount is the positioned anchor, so the wrap itself is static. */
.cmap-dd-icon { position: static; }
.cmap-dd-icon .cmap-dd-trigger {
  width: 24px;
  height: 24px;
  padding: 0;
  gap: 0;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border-color: transparent;
}
.cmap-dd-icon .cmap-dd-trigger:hover { background: var(--icon-btn-hover); color: var(--text-strong); }
.cmap-dd-icon .cmap-dd-trigger .lucide { width: 16px; height: 16px; }
/* Open to the RIGHT of the icon — it sits in the far-left gutter, so a right-anchored menu would spill off-panel. */
.cmap-dd-icon .cmap-dd-menu { left: 0; right: auto; width: 190px; }

.cmap-dd-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 3px 6px;
  font: inherit;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-strong);
}
.cmap-dd-trigger:hover { background: var(--surface-hover); }
.cmap-dd-sw {
  flex: none;
  width: 34px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
}
.cmap-dd-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.cmap-dd-caret { flex: none; color: var(--text-muted); font-size: 10px; }
.cmap-dd-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-dropdown);
  padding: 3px;
}
.cmap-dd-menu-up {
  top: auto;
  bottom: calc(100% + 2px);
}
/* fixed mode: positioned in viewport coords (top/left/width set in JS) so a scrollable modal can't clip
   the menu; z-index clears the modal it floats over. */
.cmap-dd-menu.cmap-dd-fixed { position: fixed; z-index: 200; }
.cmap-dd-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 3px 5px;
  font: inherit;
  font-size: 11px;
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-strong);
}
.cmap-dd-opt:hover { background: var(--surface-hover); }
.cmap-dd-opt.active { background: var(--accent-soft-bg); }
.cmap-dd-opt .cmap-dd-sw { width: 48px; }

.maps-fm-onecolor-cmap { width: 160px; }

.maps-picker {
  width: min(480px, 92vw);
}

.maps-fm {
  width: min(760px, 94vw);
}
/* neutralise the generic .modal label/input/span rules that would distort this non-form checklist */
.maps-fm label { display: flex; margin: 0; }
.maps-fm label > span { display: inline; margin: 0; font-size: inherit; color: inherit; }
.maps-fm input[type="checkbox"] { width: auto; }
.maps-fm-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 10px;
  margin-top: 8px;
}
.maps-fm-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.maps-fm-colhead {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.maps-fm-list {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 300px;
  overflow-y: auto;
}
.maps-fm-item {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.maps-fm-item:hover { background: var(--surface-hover); }
.maps-fm-item.active { background: var(--accent-soft-bg); color: var(--accent-strong); }
.maps-fm-empty {
  padding: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.maps-fm-scenehead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.maps-fm-assetsel {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.maps-fm-assetsel select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  padding: 2px 4px;
}
.maps-fm-selbtns { display: flex; gap: 4px; flex: none; }
.maps-fm-selbtns button {
  font-size: 11px; padding: 3px 9px;
  background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--border-input); border-radius: 4px;
}
.maps-fm-selbtns button:hover { background: var(--surface-hover); }
.maps-fm-scene {
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.maps-fm-scene label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  min-width: 0;
  cursor: pointer;
}
.maps-fm-scene input { flex: none; }
.maps-fm-scene:hover { background: var(--surface-hover); }
.maps-fm-scene-id {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.maps-fm-scene-dt {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 11px;
}
.maps-fm-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.maps-fm-onecolor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.maps-fm-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.maps-fm-footer .modal-actions {
  margin-left: auto;
}

/* pixel-value popup shared by the catalog COG viewer and Maps; .pv-popup-wrap lands on MapLibre's popup root */
.pv-popup-wrap .maplibregl-popup-content {
  /* extra top room so the close × sits in the corner above the first value */
  padding: 16px 11px 9px;
  border-radius: 6px;
  box-shadow: var(--shadow-dropdown);
  background: var(--surface);
}
/* MapLibre colours the tip triangle white by default. Recolour ONLY the border that
   actually faces the popup body per anchor — colouring all four turns it into a square. */
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--surface);
}
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--surface);
}
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--surface);
}
.maplibregl-popup.pv-popup-wrap.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--surface);
}
.pv-popup-wrap .maplibregl-popup-close-button {
  font-size: 15px;
  color: var(--text-muted);
  padding: 0 4px;
}
.pv-popup {
  min-width: 120px;
  font-size: 12px;
  color: var(--text-strong);
}
.pv-popup .pv-value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding-right: 12px;  /* clear the close button */
}
.pv-popup .pv-number {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
}
.pv-popup .pv-bands {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pv-popup .pv-band {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.pv-popup .pv-band .pv-number {
  font-size: 13px;
  font-weight: 600;
}
.pv-popup .pv-band-name {
  color: var(--text-muted-cool);
  font-variant-numeric: tabular-nums;
}
/* stacked popup, one block per visible layer; capped + scrollable so deep overlay stacks stay usable */
.pv-popup .pv-layers {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 12px;  /* clear the close button */
  max-height: 50vh;
  overflow-y: auto;
}
.pv-popup .pv-layer + .pv-layer {
  border-top: 1px solid var(--border);
  padding-top: 7px;
}
.pv-popup .pv-layer-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted-cool);
  word-break: break-word;
}
.pv-popup .pv-layer-inline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.pv-popup .pv-layer-inline .pv-layer-name { flex: 1; min-width: 0; }
.pv-popup .pv-layer-inline .pv-number { font-size: 14px; }
.pv-popup .pv-layer-coll {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted-cool);
  opacity: 0.72;
  word-break: break-word;
}
.pv-popup .pv-layer .pv-bands { margin-top: 3px; }
.pv-popup .pv-vlayers {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 12px;  /* clear the close button */
  max-height: 50vh;
  overflow-y: auto;
}
.pv-popup .pv-layers + .pv-vlayers {  /* divider when raster values sit above the polygon(s) */
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}
.pv-popup .pv-vitem + .pv-vitem {
  border-top: 1px solid var(--border);
  padding-top: 7px;
}
.pv-popup .pv-vitem .pv-bands { margin-top: 3px; }
.pv-popup .pv-coords {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted-cool);
  font-variant-numeric: tabular-nums;
}

/* In-page report preview: the printable report lives in an isolated iframe so
   printing it prints only the report; a footer offers Print / Save / Cancel. */
.mrp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}
.mrp-dialog {
  display: flex;
  flex-direction: column;
  width: min(700px, 94vw);
  max-height: 92vh;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.mrp-stage { position: relative; }
.mrp-frame {
  width: 100%;
  height: 82vh;  /* tall enough that a one-page report doesn't scroll */
  border: 0;
  background: #fff;
  display: block;
}
/* Opaque app-surface panel over the (empty white) iframe while the summary's pages assemble. */
.mrp-building {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
}
.mrp-building[hidden] { display: none; }
.mrp-building-label { color: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }
.mrp-building .map-report-progress {
  width: min(280px, 60%);
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(127, 137, 153, 0.25);
}
.mrp-building .map-report-progress span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .2s; }
.mrp-btn:disabled { opacity: 0.5; cursor: default; }
.mrp-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--map-glass-bg);
  border-top: 1px solid var(--map-glass-border);
}
.mrp-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-input);
}
.mrp-btn:hover { background: var(--surface-hover); color: var(--text-strong); }
.mrp-btn.mrp-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.mrp-btn.mrp-primary:hover { background: var(--accent-hover); }

.maps-ts-menu {
  position: absolute;
  z-index: 6;
  width: 240px;
  max-height: 60%;
  display: flex;
  flex-direction: column;
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.maps-ts-menu-head {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--map-glass-border);
}
.maps-ts-menu-body { overflow-y: auto; }
.maps-ts-msg { padding: 12px; font-size: 12px; color: var(--text-secondary); }
/* Centred loading state in the chart body: status line + a slim progress bar under it.
   flex:1 only bites in the maximized (row-flex) body; in the compact body min-height centres it. */
.maps-ts-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 130px;
  padding: 24px;
}
.maps-ts-loading-text { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.maps-ts-bar {
  width: 200px;
  max-width: 70%;
  height: 4px;
  border-radius: 999px;
  background: rgba(127, 137, 153, 0.25);
  overflow: hidden;
}
.maps-ts-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.maps-ts-col {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.maps-ts-col:hover,
.maps-ts-col.open { background: var(--surface-hover); }
.maps-ts-col-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.maps-ts-caret { flex: none; font-size: 10px; color: var(--text-muted); }
.maps-ts-submenu { max-height: 70%; }
.maps-ts-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.maps-ts-opt:hover { background: var(--surface-hover); }
.maps-ts-opt-name { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.maps-ts-opt-meta { font-size: 11px; color: var(--text-muted); }

.maps-ts-panel {
  position: absolute;
  right: 372px;            /* clear the layers panel, same gutter as the toolbar */
  top: 60px;               /* top-right, just under the map toolbar */
  z-index: 6;
  width: 400px;
  max-width: calc(100% - var(--rail-w) - 396px);
  background: var(--map-glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-glass-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
/* Expanded to fill the map area left of the layers panel (it can't paint over
   that sibling's stacking context) so a dense series reads in detail. */
.maps-ts-panel.maximized {
  bottom: 12px;
  left: calc(var(--rail-w) + 12px);
  width: auto;
  max-width: none;
  display: flex;
  flex-direction: column;
}
.maps-ts-panel.maximized .maps-ts-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  gap: 14px;
}
.maps-ts-panel.maximized .maps-ts-plot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
/* Fill the plot box vertically (viewBox + preserveAspectRatio keeps the ratio, centred) so a
   short stats/legend column doesn't leave a tall empty band above the chart. */
.maps-ts-panel.maximized .maps-ts-chart { width: 100%; height: 100%; max-height: 100%; }
.maps-ts-stats {
  flex: none;
  width: 184px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.maps-ts-stat { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 12px; }
.maps-ts-stat span { color: var(--text-muted-cool); }
.maps-ts-stat b { font-weight: 600; }
.maps-ts-side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow-y: auto;
  padding-left: 12px;
  border-left: 1px solid var(--map-glass-border);
}
.maps-ts-railsep { width: 30px; height: 1px; margin: 3px 0; background: var(--map-glass-border); }
.maps-ts-iconbtn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--map-glass-border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.maps-ts-iconbtn:hover { color: var(--text-strong); background: var(--icon-btn-hover); }
.maps-ts-iconbtn.on { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.maps-ts-iconbtn i { width: 15px; height: 15px; }
.maps-ts-cmp-line { fill: none; stroke-width: 1.75; stroke-linejoin: round; }
.maps-ts-cmp-faded { opacity: 0.4; }
.maps-ts-cmp-smooth { fill: none; stroke-width: 2.25; stroke-linejoin: round; }
.maps-ts-cmp-trend { fill: none; stroke-width: 1.5; stroke-dasharray: 5 4; }
.maps-ts-cmp-corr { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--map-glass-border); }
.maps-ts-cmp-corr h4 {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.maps-ts-legend { display: flex; flex-direction: column; gap: 2px; }
.maps-ts-legend-top { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; padding: 0 2px; }
.maps-ts-legrow {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 2px 4px;
  font: inherit;
  font-size: 12px;
  color: var(--map-glass-fg);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.maps-ts-legrow:hover { background: var(--icon-btn-hover); }
.maps-ts-legrow.is-base { background: var(--accent-soft-bg, rgba(59, 130, 246, 0.18)); }
.maps-ts-legrow.is-base .maps-ts-legname { font-weight: 600; }
.maps-ts-legdot { flex: none; width: 9px; height: 9px; border-radius: 2px; }
.maps-ts-legname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maps-ts-legrow b { flex: none; margin-left: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.maps-ts-legend-top .maps-ts-legrow b { margin-left: 4px; }
.maps-ts-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.maps-ts-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--map-glass-border);
}
.maps-ts-titlewrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.maps-ts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.maps-ts-coords { font-size: 11px; color: var(--text-muted); }
.maps-ts-close,
.maps-ts-expand {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.maps-ts-close:hover,
.maps-ts-expand:hover { background: var(--surface-hover); color: var(--text-strong); }
.maps-ts-close i, .maps-ts-expand i { width: 16px; height: 16px; }
.maps-ts-body { padding: 10px 12px 12px; }
.maps-ts-chart { width: 100%; height: auto; display: block; }
.maps-ts-grid { stroke: var(--map-glass-border); stroke-width: 1; }
.maps-ts-axis { stroke: var(--text-muted); stroke-width: 1; opacity: 0.7; }
.maps-ts-ytext, .maps-ts-xtext { fill: var(--text-muted); font-size: 10px; }
.maps-ts-ytext { text-anchor: end; }
.maps-ts-line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; }
.maps-ts-line-faded { opacity: 0.35; }
.maps-ts-smooth { fill: none; stroke: #e8833a; stroke-width: 2; stroke-linejoin: round; }
.maps-ts-trend { stroke: var(--text-secondary); stroke-width: 1.5; stroke-dasharray: 5 4; }
.maps-ts-mean { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; }
.maps-ts-median { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 1 3; }
.maps-ts-band { stroke: none; }
.maps-ts-band.band-1s { fill: rgba(99, 102, 241, 0.12); }
.maps-ts-band.band-range { fill: rgba(127, 137, 153, 0.10); }
.maps-ts-band.band-pct { fill: rgba(16, 185, 129, 0.12); }
.maps-ts-marker { fill: none; stroke: var(--accent); stroke-width: 2; }
.maps-ts-outlier { fill: none; stroke: #ef4444; stroke-width: 2; }
.maps-ts-changept { stroke: #a855f7; stroke-width: 1.25; stroke-dasharray: 4 3; }
.maps-ts-cross[hidden] { display: none; }
.maps-ts-cross line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.maps-ts-dots circle { fill: var(--accent); }
.maps-ts-tools { display: flex; gap: 6px; margin-bottom: 8px; }
.maps-ts-tool {
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--map-glass-border);
  border-radius: 999px;
  cursor: pointer;
}
.maps-ts-tool:hover { color: var(--text-strong); }
.maps-ts-tool.on { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.maps-ts-hits circle { fill: transparent; pointer-events: all; cursor: crosshair; }
.maps-ts-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--map-glass-fg);
  background: var(--map-glass-bg);
  border: 1px solid var(--map-glass-border);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}
.maps-ts-tip[hidden] { display: none; }
.maps-ts-meta { margin-top: 6px; font-size: 11px; color: var(--text-muted); text-align: right; }
.maps-ts-foot {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--map-glass-border);
}
.maps-ts-sep { height: 1px; margin: 4px 8px; background: var(--map-glass-border); }

/* ============================================================================
   Projects gallery ("All projects") — a card grid of saved Maps views, each
   backed by the preview snapshot captured on Save. Rendered into #table-host:
   a toolbar in #toolbar (Map button + sort + search) and the grid in #table-body.
   ========================================================================== */
/* The toolbar is a single rounded pill echoing the floating .map-toolbar, but on a solid
   surface (no glass blur — there's no map behind it here). Sits under the standard page head. */
.proj-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;            /* fills the padded #toolbar row, below the page head */
  height: 46px;
  margin: 2px 0 0;
  padding: 0 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-dropdown);
}
.proj-bar-sep { flex: none; width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.proj-bar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.proj-bar-map {
  flex: none;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.proj-bar-map:hover { background: var(--surface-hover); color: var(--accent); }
.proj-bar-map .lucide { width: 16px; height: 16px; color: var(--accent); }

.proj-sort { display: inline-flex; gap: 2px; }
.proj-sort-btn {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.proj-sort-btn:hover { background: var(--surface-hover); color: var(--text-strong); }
.proj-sort-btn.active { background: var(--accent); color: var(--accent-fg); }
.proj-sort-arrow { opacity: .85; }

.proj-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-pill);
  background: var(--surface);
  transition: border-color .15s;
}
.proj-search:focus-within { border-color: var(--accent); }
.proj-search .lucide { width: 15px; height: 15px; color: var(--text-muted); flex: none; }
.proj-search-input {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-strong);
  width: 180px;
}
.proj-search-input::placeholder { color: var(--text-muted); }

.proj-root { min-height: 0; }
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
  padding: var(--space-3) var(--page-pad-x) var(--space-7);
}
.proj-empty { color: var(--text-muted); padding: var(--space-7) var(--page-pad-x); font-size: var(--fs-md); }

/* Only rendered when the gallery holds both the user's own projects and ones shared with them. */
.proj-group-title {
  margin: 0;
  padding: var(--space-5) var(--page-pad-x) 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.proj-group-title + .proj-grid { padding-top: var(--space-2); }

.proj-card {
  position: relative;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-dropdown);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.proj-card:hover { border-color: var(--accent); }
.proj-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.proj-card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background-color: var(--surface-sunken, var(--surface));
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
  /* Round the outer corners to the card's inner radius so the square child corner can't bleed past
     it (the classic border + radius + overflow:hidden "eaten corner" artifact). */
  border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0;
}
.proj-card-thumb-empty {
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.proj-card-thumb-empty .lucide { width: 34px; height: 34px; opacity: .5; }

/* Solid accent pill with white text — bold, on-brand, high contrast over the map thumbnail.
   Also the copy-link control (a <button>): click it to copy the share URL. */
.proj-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  font: inherit;
  line-height: 1;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--accent-fg);
  background: var(--accent);
  border-radius: var(--r-pill);
  padding: 4px 9px 4px 7px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.proj-card-badge:hover { background: var(--accent-hover); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.proj-card-badge .lucide { width: 12px; height: 12px; color: var(--accent-fg); }

.proj-card-body { padding: var(--space-3) var(--space-4) var(--space-4); border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px); }
.proj-card-name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  color: var(--text-strong);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-card-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }

/* Action buttons float over the thumbnail's top-right, revealed on hover/focus. */
.proj-card-acts {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.proj-card:hover .proj-card-acts,
.proj-card:focus-within .proj-card-acts { opacity: 1; }
.proj-card-act {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.proj-card-act:hover { background: var(--accent); }
.proj-card-act.danger:hover { background: var(--danger); }
.proj-card-act .lucide { width: 15px; height: 15px; }

/* ── Vector layers: add buttons, row controls, folder-browser picker ─────── */
.maps-add-group { display: inline-flex; gap: 6px; align-items: center; }
.maps-panel-header .ghost {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  border-radius: 8px; color: var(--text-secondary); background: transparent;
  border: 1px solid var(--panel-glass-border); cursor: pointer;
}
.maps-panel-header .ghost:hover { background: var(--surface-hover, rgba(127, 127, 127, 0.12)); color: var(--text-strong); }
.maps-panel-header .ghost .lucide { width: 15px; height: 15px; stroke-width: 2.5; }

.maps-l-veccolor {
  display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center;
  margin-top: 8px; margin-left: 36px; font-size: 11px; color: var(--text-secondary);
}
/* Vector card reuses .maps-l-color's layout (eye + fill toggle in .maps-l-coloricons, the colour
   swatch in .maps-l-colorright) with the -cat compact variant, since like a class raster it has
   no tall body to bottom-align against. */
.maps-l-colorright .maps-l-veccolor { margin: 0; }
.maps-l-vecfill.active { color: var(--accent); }
.maps-l-veccolor > span:first-child { white-space: nowrap; }
.maps-l-veccolor input[type=color] {
  width: 100%; min-width: 0; height: 22px; padding: 0; border: none; background: none; cursor: pointer;
}

.vecpick-modal { width: 560px; max-width: 94vw; display: flex; flex-direction: column; }
.vecpick-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 2px 2px 14px; }
.vecpick-header h2 { margin: 0; }
/* Segmented control, not two loose buttons — a padded track with the active bucket filled, so it
   clearly reads as a switch and doesn't blend into the title. */
.vecpick-buckets { display: inline-flex; gap: 2px; flex: none; padding: 3px; border-radius: 9px; background: var(--surface-sunken, rgba(127, 127, 127, 0.14)); }
.vecpick-buckets .pill-btn { border: none; box-shadow: none; background: transparent; padding: 5px 13px; border-radius: 6px; font-size: 12px; color: var(--text-muted, #8a93a6); }
.vecpick-buckets .pill-btn:hover { color: var(--text, inherit); background: var(--surface-hover, rgba(127, 127, 127, 0.12)); }
.vecpick-buckets .pill-btn.primary { background: var(--accent, #2563eb); color: #fff; }
/* Location bar: a folder icon + clickable path segments, so it obviously means "you are here". */
.vecpick-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-bottom: 12px; padding: 6px 9px; font-size: 12px; color: var(--text-muted, #8a93a6); background: var(--surface-sunken, rgba(127, 127, 127, 0.08)); border: 1px solid var(--border, rgba(127, 127, 127, 0.18)); border-radius: 8px; }
.vecpick-crumbs::before {
  content: ""; flex: none; width: 15px; height: 15px; margin-right: 3px; background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.vecpick-crumb { background: none; border: none; padding: 2px 6px; color: var(--accent, #2563eb); cursor: pointer; border-radius: 6px; font-weight: 500; }
.vecpick-crumb:hover { background: var(--surface-hover, rgba(127, 127, 127, 0.14)); text-decoration: underline; }
.vecpick-crumb:last-of-type { color: var(--text, inherit); font-weight: 600; cursor: default; }
.vecpick-crumb:last-of-type:hover { background: none; text-decoration: none; }
.vecpick-sep { color: var(--text-muted, #8a93a6); }
.vecpick-body { max-height: 52vh; overflow-y: auto; }
.vecpick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.vecpick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.vecpick-row:hover { background: var(--surface-hover, rgba(127, 127, 127, 0.12)); }
.vecpick-icon { display: inline-flex; color: var(--fg-muted, #8a93a6); }
.vecpick-icon .lucide { width: 16px; height: 16px; }
.vecpick-folder .vecpick-icon { color: var(--accent, #2563eb); }
.vecpick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vecpick-add { flex: none; font-size: 11px; font-weight: 600; color: var(--accent, #2563eb); opacity: 0; }
.vecpick-file:hover .vecpick-add { opacity: 1; }
.vecpick-empty, .vecpick-more { padding: 12px 8px; }
.vecpick-footer { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border, rgba(127, 127, 127, 0.14)); }
.vecpick-footer .pill-btn { flex: none; white-space: nowrap; }
.vecpick-footer .hint { flex: 1; min-width: 0; font-size: 11px; text-align: center; }
.vecpick-addall { font-weight: 600; color: var(--accent, #2563eb); }
.vecpick-addall .vecpick-icon { color: var(--accent, #2563eb); }
.vecpick-addfolder { font-weight: 600; color: var(--accent, #2563eb); }
.vecpick-addfolder .vecpick-icon { color: var(--accent, #2563eb); }
