/* Neutral, flat UI chrome. Data-driven colors (land-cover swatches, map layer)
   are set elsewhere and intentionally left alone. */
:root {
  --panel-bg: rgba(32, 33, 36, 0.94);
  --panel-bg-soft: rgba(32, 33, 36, 0.85);
  --border: rgba(255, 255, 255, 0.14);
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --accent: #c8ccd0;          /* neutral highlight */
  --accent-strong: #ffffff;
  --control-bg: rgba(255, 255, 255, 0.06);
  --control-hover: rgba(255, 255, 255, 0.13);
  --error: #d98c78;           /* muted, functional */
  --flag: #0a84ff;            /* tile highlight / flag action */
  --validate: #27b862;        /* validation mode "armed" state */
  --validate-lo: #2ecc71;
  --v-good: #3ecf7a;          /* tile verdicts: traffic-light semantics */
  --v-issue: #e8a33d;
  --v-nodata: #e2685c;
  --important: #e8c33d;       /* "important" star, shared with validation.html */
  --shape: #ff9f0a;           /* hand-drawn problem areas */
  --edit-accent: #ff375f;     /* the "Modify" land-cover repaint tool */
  --radius: 2px;
  --map-bg: #17181a;          /* dark neutral so any gap between layers (region/year
                                  switch, a slow load) reads as a quiet void, not a
                                  bright white flash */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--map-bg);
}

#map {
  flex: 1;
  height: 100vh;
  position: relative;
  background: var(--map-bg);
}

/* Wraps the pixel time-series panel and the year-slider controls side by side
   so an open ts-panel never overlaps the slider below it. */
#bottom-controls {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
}

#ts-panel {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px 12px;
  display: none;
  pointer-events: all;
  /* Grow to whatever the content (incl. a resized plot) needs. 94vw (not 60)
     so the panel never fights the plot/time-lapse viewers' own drag-resize caps. */
  width: max-content;
  max-width: 94vw;
}

#ts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 24px;
}

#ts-coords {
  font-size: 0.8rem;
  color: var(--text-dim);
}

#ts-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
#ts-close:hover { color: var(--text); }

#ts-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* Full-width now, so the year strip spans the same width as the (resizable)
   feature plot below it; the blocks flex-grow to fill. */
#ts-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  width: 100%;
}

#ts-load-features {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-start;
  transition: background 0.12s;
}

#ts-load-features:hover:not(:disabled) { background: var(--control-hover); }
#ts-load-features:disabled { opacity: 0.5; cursor: default; }

#ts-features-box {
  margin-top: 10px;
  font-size: 0.75rem;
}
#ts-features-box.hidden { display: none; }

/* Point-analysis action buttons (Load features / Time-lapse), side by side */
#ts-actions { display: flex; gap: 8px; align-self: flex-start; }
#ts-load-chips {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
#ts-load-chips:hover:not(:disabled) { background: var(--control-hover); }
#ts-load-chips:disabled { opacity: 0.5; cursor: default; }

#ts-chips-box { margin-top: 10px; font-size: 0.75rem; }
#ts-chips-box.hidden { display: none; }
.ts-chips-view.collapsed { display: none; }

/* True/false-colour segmented toggle for the time-lapse */
.ts-chips-modes {
  display: flex;
  gap: 2px;
  margin: 8px 0 6px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  width: max-content;
}
.ts-chips-modes button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.ts-chips-modes button:hover { color: var(--text); }
.ts-chips-modes button.active { background: var(--accent); color: #202124; }

/* Resizable time-lapse viewer (drag the bottom-right corner) */
.ts-chips-img {
  width: 560px;
  height: 560px;
  min-width: 200px;
  min-height: 200px;
  max-width: 92vw;
  max-height: 68vh;
  overflow: auto;
  resize: both;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* The frames are nearest-neighbour upscaled chips (intentionally blocky), so
   keep edges crisp instead of letting the browser blur them when shown above
   their native size. The sheet holds every frame stacked vertically; the square
   window clips it to one, and JS translates it to the chosen frame. */
.chips-frame { position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
.ts-chips-img img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  will-change: transform;      /* scrubbing repaints this every frame */
}

/* Scrub bar: play/pause, the frame slider, and the frame's date. */
.chips-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.chips-play {
  flex: none;
  width: 30px;
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  font-size: 0.7rem;
  cursor: pointer;
}
.chips-play:hover { background: var(--control-hover); }
.chips-slider { flex: 1; accent-color: var(--accent); cursor: pointer; min-width: 80px; }
.chips-label {
  flex: none;
  min-width: 74px;
  text-align: right;
  font: 600 0.7rem ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
}
/* Frames inside the tree-cover-loss year, matching the burnt-in red border. */
.chips-label.loss { color: #ff6b5e; }

.ts-feat-status {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-feat-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ts-spin 0.8s linear infinite;
}
@keyframes ts-spin { to { transform: rotate(360deg); } }

.ts-feat-error { color: var(--error); }

.ts-feat-toggle {
  cursor: pointer;
  color: var(--text);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.ts-feat-toggle .caret {
  display: inline-block;
  transition: transform 0.15s;
}
.ts-feat-toggle.open .caret { transform: rotate(90deg); }

/* Resizable viewer for the Landsat feature plot: drag the bottom-right corner
   to enlarge. Width scales the plot (readability); height sets how much of the
   tall figure shows before it scrolls. Caps keep the panel on-screen. */
.ts-feat-plot {
  margin-top: 8px;
  width: 960px;
  height: 62vh;
  min-width: 340px;
  min-height: 180px;
  max-width: 92vw;
  max-height: 68vh;
  overflow: auto;
  resize: both;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ts-feat-plot.collapsed { display: none; }
.ts-feat-plot img {
  display: block;
  width: 100%;
  height: auto;
}

.ts-feat-hint {
  color: var(--text-dim);
  font-size: 0.68rem;
  margin-left: 8px;
  display: none;
}
.ts-feat-toggle.open .ts-feat-hint { display: inline; }

.ts-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  flex: 1 0 18px;   /* grow to fill the strip; 18px base keeps the compact default */
}

.ts-color {
  width: 100%;
  height: 40px;
  border-radius: 1px;
  border: 2px solid transparent;
  transition: border-color 0.1s;
}

.ts-block:hover .ts-color {
  border-color: var(--accent);
}

.ts-block.active .ts-color {
  border-color: var(--accent-strong);
}

.ts-year {
  font-size: 0.58rem;
  color: var(--text-dim);
}

#year-slider-container {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 24px 12px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 320px;
  pointer-events: all;
}

#year-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
}

/* Keep the year number perfectly centered; the loading spinner floats to its
   right (absolute) so showing/hiding it never nudges the number. */
#year-label-row {
  position: relative;
  display: inline-flex;
  align-items: center;
}
/* Rotating loader shown while a year's raster is fetched/rendered (see loadYear),
   replacing the old "…" text. Reuses the @keyframes ts-spin defined above. */
.year-spinner {
  position: absolute;
  left: 100%;
  margin-left: 10px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ts-spin 0.8s linear infinite;
}

/* Covers the map during a region switch so the bare satellite basemap can't
   flash through while the new region's land cover is still loading (see
   switchRegion in map.js). Toggled via the .visible class, not
   display/hidden, so the opacity transition actually runs. Sits above every
   map pane (panes top out at 467) but below Leaflet's own controls (1000)
   so the region/year UI stays usable while it's up. */
#region-loading-scrim {
  position: absolute;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 24, 26, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#region-loading-scrim.visible {
  opacity: 1;
}
#region-loading-scrim span {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ts-spin 0.8s linear infinite;
}

/* Region selector and 300m/30m resolution selector: matching segmented toggles.
   Pill-shaped (radius scales with height) with a soft inset track so the
   group reads as one control, and each button gets its own subtle lift +
   shadow when active instead of a flat color swap. */
#region-toggle,
#res-toggle,
#correction-toggle,
#baseversion-toggle,
#composite-toggle {
  display: flex;
  gap: 3px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
#region-toggle + #res-toggle,
#res-toggle + #baseversion-toggle,
#baseversion-toggle + #correction-toggle,
#res-toggle + #correction-toggle,
#correction-toggle + #composite-toggle,
#baseversion-toggle + #composite-toggle,
#res-toggle + #composite-toggle {
  margin-top: 2px;
}
#region-toggle button,
#res-toggle button,
#correction-toggle button,
#baseversion-toggle button,
#composite-toggle button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 4px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
#region-toggle button:hover:not(.active),
#res-toggle button:hover:not(.active),
#correction-toggle button:hover:not(.active),
#baseversion-toggle button:hover:not(.active),
#composite-toggle button:hover:not(.active) {
  color: var(--text);
  background: var(--control-hover);
}
#region-toggle button.active,
#res-toggle button.active,
#correction-toggle button.active,
#baseversion-toggle button.active,
#composite-toggle button.active {
  background: var(--accent);
  color: #202124;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

#year-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.coord-readout {
  background: var(--panel-bg-soft);
  color: var(--text-dim);
  font: 0.7rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 2px 6px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.coord-readout:empty { display: none; }

/* Clicked-point indicator for the land-cover time-series: a clean, precise
   crosshair reticle (div-icon marker). White hairlines + a thin ring, each with a
   soft dark shadow so they stay legible over any background, a small accent dot on
   the exact pixel, and a subtle pop-in. Overrides Leaflet's default white box. The
   animation lives on the inner .ch so it never fights Leaflet's marker transform. */
.click-marker {
  background: none;
  border: none;
}
.click-marker .ch {
  position: absolute;
  inset: 0;
  animation: ch-pop 0.2s ease-out;
}
.click-marker i {
  position: absolute;
  display: block;
}
.ch-h, .ch-v {
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.8));
}
/* hairlines span the icon with a transparent centre gap around the ring */
.ch-h {
  top: 50%; left: 0; right: 0; height: 1.5px; transform: translateY(-50%);
  background: linear-gradient(to right, #fff 0 23%, transparent 23% 77%, #fff 77% 100%);
}
.ch-v {
  left: 50%; top: 0; bottom: 0; width: 1.5px; transform: translateX(-50%);
  background: linear-gradient(to bottom, #fff 0 23%, transparent 23% 77%, #fff 77% 100%);
}
.ch-ring {
  top: 50%; left: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border: 1.25px solid #fff; border-radius: 50%;
  box-shadow: 0 0 1.5px rgba(0, 0, 0, 0.6);
}
.ch-dot {
  top: 50%; left: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  background: #0a84ff; border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.55);
}
@keyframes ch-pop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* Landsat ARD tile labels on the grid cells (div-icon markers). Transparent box
   overriding Leaflet's default white .leaflet-div-icon; text-shadow keeps it
   legible over both the dark satellite and the light OSM basemaps. */
.grid-label {
  background: transparent;
  border: none;
  color: #f0f2f4;
  font: 600 9px/12px -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 2px #000, 0 0 3px #000;
  pointer-events: none;
}

/* ESA WorldCover class legend, directly under the layer control (top-right).
   Scrolls rather than growing if the window is short, so it can never push
   itself off-screen on a laptop display. */
.wc-legend {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  color: var(--text);
  padding: 8px 11px 9px;
  line-height: 1.35;
  max-height: 52vh;
  overflow-y: auto;
}
.wc-legend-title {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.wc-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.66rem;
  white-space: nowrap;
}
.wc-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex: none;
  /* Hairline keeps the near-white snow/moss swatches visible on the dark panel. */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Tree-cover-loss year colorbar (bottom-right, shown only while the layer is on). */
.tcl-legend {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 8px 5px;
  line-height: 1;
}
.tcl-legend-title {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.tcl-legend-bar { display: flex; }
.tcl-swatch { display: block; width: 8px; height: 12px; }
.tcl-legend-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 0.58rem;
  color: var(--text-dim);
}

/* TCL-vs-MapBiomas agreement legend (bottom-right, two categorical rows). */
.yeardiff-legend {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 9px 6px;
  line-height: 1.3;
}
.yd-legend-title {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.yd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
}
.yd-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex: none;
}

/* Layer control (base layers + overlay checkboxes, top-right): restyle
   Leaflet's default white panel to match the rest of the dark UI chrome, with
   a larger, more legible font than Leaflet's cramped default. */
.leaflet-control-layers {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.leaflet-control-layers-toggle {
  filter: invert(1);
}
.leaflet-control-layers-expanded {
  padding: 10px 14px;
  color: var(--text);
}
.leaflet-control-layers-list label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.leaflet-control-layers-list input[type="radio"],
.leaflet-control-layers-list input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.leaflet-control-layers-separator {
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* --- Tile validation ---------------------------------------------------- */

/* Validation-mode toggle + reports link, on their own row under the slider,
   separated from the layer controls above by a hairline. */
#tool-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
/* Validation toggle: the one control that changes what a map click does, so it
   is deliberately the loudest thing in the panel — crosshair icon (matching the
   click-to-pick-a-tile action), and a green "armed" state with a live pulsing
   dot so there is never any doubt whether the mode is on. */
#validate-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--control-bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease,
              border-color 0.18s ease;
}
#validate-toggle .vt-icon { flex: none; transition: transform 0.25s ease; }
#validate-toggle:hover {
  color: var(--text);
  background: var(--control-hover);
  border-color: rgba(255, 255, 255, 0.24);
}
/* Armed. Green reads as "go / live" against the neutral chrome, and is far
   enough from the blue tile highlight that the two never blur together. */
#validate-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--validate-lo) 0%, var(--validate) 100%);
  border-color: var(--validate-lo);
  color: #06210f;
  box-shadow: 0 0 0 1px rgba(46, 204, 113, 0.35),
              0 2px 14px rgba(46, 204, 113, 0.45);
}
#validate-toggle[aria-pressed="true"] .vt-icon { transform: rotate(90deg); }

/* Pulsing dot, only while armed. */
.vt-dot { display: none; }
#validate-toggle[aria-pressed="true"] .vt-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #06210f;
  animation: vt-pulse 1.4s ease-in-out infinite;
}
@keyframes vt-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.72); }
}
/* Respect a reduced-motion preference: keep the colour, drop the animation. */
@media (prefers-reduced-motion: reduce) {
  #validate-toggle[aria-pressed="true"] .vt-dot { animation: none; }
  #validate-toggle .vt-icon { transition: none; }
}
/* Saved-reports browser, bottom-right map control. The panel is placed above
   the button and the whole control is right-aligned, so opening it grows the
   stack upward (Leaflet pins the bottom-right corner at bottom:0). */
.reports-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.reports-btn {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  padding: 6px 15px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.reports-btn:hover { background: var(--control-hover); }
.reports-btn.active { background: var(--flag); border-color: var(--flag); color: #fff; }

.reports-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  color: var(--text);
  width: 300px;
  max-width: 88vw;
  overflow: hidden;
}
.reports-panel.hidden { display: none; }
.reports-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.reports-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.reports-refresh {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.reports-refresh:hover { color: var(--text); }

/* Region filter and the no-data toggle share a row under the title, so a long
   region name can't squeeze the reload button out of the header. */
.reports-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.reports-region {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 3px 8px;
  cursor: pointer;
  /* The popup list is drawn by the browser on its OWN surface, not on the
     panel, so --control-bg (rgba white 0.06) leaves it white while the options
     inherit near-white --text. color-scheme flips the native chrome to dark,
     and the explicit option colours below cover browsers that ignore it. */
  color-scheme: dark;
}
.reports-region:hover { background: var(--control-hover); }
.reports-region option {
  background: #202124;      /* opaque: a translucent value shows the white popup through */
  color: var(--text);
}

/* Outlines every reviewed tile on the map, coloured by verdict. */
.reports-onmap {
  flex: 0 0 auto;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.reports-onmap:hover { color: var(--text); background: var(--control-hover); }
.reports-onmap.active {
  background: var(--v-good);
  border-color: var(--v-good);
  color: #08240f;
}

/* No-data rows are hidden by default; this reveals them and shows how many. */
.reports-nodata {
  flex: 0 0 auto;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.reports-nodata:hover { color: var(--text); background: var(--control-hover); }
.reports-nodata.active {
  background: var(--v-nodata);
  border-color: var(--v-nodata);
  color: #2a0f0c;
}

/* Caps the list so a long backlog scrolls instead of covering the map. */
.reports-list { max-height: 46vh; overflow-y: auto; }
.report-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.report-item:last-child { border-bottom: none; }
.report-item:hover { background: rgba(255, 255, 255, 0.05); }
.report-item.open { background: rgba(10, 132, 255, 0.14); }
.report-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Trash stays dim until the row is hovered, so a dense list doesn't read as a
   row of delete buttons; it turns red only on direct hover. */
.report-del {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  line-height: 0;
  opacity: 0;
  flex: none;
  transition: opacity 0.12s, color 0.12s;
}
.report-item:hover .report-del { opacity: 0.75; }
.report-del:hover { opacity: 1; color: var(--error); }
.report-del.hidden { display: none; }

/* Flag star. Unlike the trash it stays lit once set — a flagged report has to
   be findable by eye while scrolling, not only on hover. */
.report-star {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 1px;
  font-size: 0.8rem;
  line-height: 1;
  opacity: 0;
  flex: none;
  transition: opacity 0.12s, color 0.12s;
}
.report-item:hover .report-star { opacity: 0.7; }
.report-star:hover, .report-star.on { opacity: 1; color: var(--important); }
.report-star:disabled { cursor: default; }
/* Inset bar rather than a background, so it survives the hover and .open tints. */
.report-item.important { box-shadow: inset 3px 0 0 var(--important); }

.report-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.report-confirm.hidden { display: none; }
.report-confirm-q { font-size: 0.66rem; color: var(--error); flex: 1 0 100%; }
.report-yes, .report-no {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 10px;
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
}
.report-yes { background: var(--error); border-color: var(--error); color: #201110; }
.report-yes:hover:not(:disabled) { filter: brightness(1.1); }
.report-yes:disabled { opacity: 0.6; cursor: default; }
.report-no { background: var(--control-bg); color: var(--text); }
.report-no:hover { background: var(--control-hover); }
.report-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.report-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.report-dot.v-good   { background: var(--v-good); }
.report-dot.v-issue  { background: var(--v-issue); }
.report-dot.v-nodata { background: var(--v-nodata); }
.report-tile {
  font: 600 0.74rem ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
}
.report-when { font-size: 0.62rem; color: var(--text-dim); white-space: nowrap; }
.report-meta { font-size: 0.63rem; color: var(--text-dim); margin-top: 2px; }
/* Collapsed: two lines max. Expanding the item lifts the clamp. */
.report-note {
  font-size: 0.7rem;
  line-height: 1.4;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.report-item.open .report-note {
  -webkit-line-clamp: unset;
  overflow: visible;
  white-space: pre-wrap;
}
.report-details { margin-top: 6px; }
.report-details.hidden { display: none; }
.report-detail-row {
  font: 0.62rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
}
.reports-empty, .reports-err { padding: 16px 12px; font-size: 0.7rem; color: var(--text-dim); }
.reports-err { color: var(--error); }
.reports-full {
  display: block;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--text-dim);
  text-decoration: none;
}
.reports-full:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

/* While validating, a crosshair cursor signals that clicking picks a tile. */
.validating .leaflet-grab,
.validating .leaflet-interactive { cursor: crosshair; }

/* Validation panel sits BESIDE the year-slider box, not above it: stacked, it
   grew upward over the map and hid the very tiles being judged. `order` does the
   swap so the markup stays as-is. Bottom-aligned so both panels share a baseline
   however tall the validation form gets. */
#right-stack {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;       /* children re-enable it; gaps stay click-through */
  min-width: 0;
}
#year-slider-container { order: 1; }
#val-panel { order: 2; }

#val-panel {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 10px 16px 12px;
  display: none;              /* shown once a tile is selected */
  pointer-events: all;
  /* Fixed width now that it sits beside the slider rather than stretching to it.
     Capped height with its own scroll so a long issue form (note + drawn areas)
     still can't climb up over the map. */
  width: 300px;
  flex: none;
  max-height: 52vh;
  overflow-y: auto;
}
#val-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}
#val-tile {
  font: 600 0.95rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}
#val-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
#val-close:hover { color: var(--text); }
#val-meta {
  font-size: 0.66rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 10px;
}
/* Verdict row: traffic-light semantics, so the judgement is readable at a
   glance both here and in the reports list. */
#val-actions.hidden { display: none; }
#val-ask { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 6px; }
#val-verdicts { display: flex; gap: 6px; }
.val-verdict {
  flex: 1;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: #10231a;
  transition: filter 0.12s, opacity 0.12s;
}
.val-verdict:hover { filter: brightness(1.12); }
.val-verdict.busy { opacity: 0.55; cursor: default; }
.val-verdict[data-verdict="good"]   { background: var(--v-good); }
.val-verdict[data-verdict="issue"]  { background: var(--v-issue); color: #2a1704; }
.val-verdict[data-verdict="nodata"] { background: var(--v-nodata); color: #2a0f0c; }

/* "Give me a tile" + the per-region progress readout. */
#val-pick {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease;
}
#val-pick:hover { background: var(--control-hover); }
#val-pick[hidden] { display: none; }

/* Stacked coverage bar: verdict segments over an unjudged track. */
#val-bar {
  display: flex;
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
#val-bar:empty { display: none; }
.vb-seg { display: block; height: 100%; transition: width 0.3s ease; }
.vb-good { background: var(--v-good); }
.vb-issue { background: var(--v-issue); }
.vb-nodata { background: var(--v-nodata); }

#val-next-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
#val-next {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#val-next:hover { background: var(--control-hover); }
#val-progress { font-size: 0.62rem; color: var(--text-dim); text-align: right; }

#val-form { display: flex; flex-direction: column; gap: 8px; }
#val-form.hidden { display: none; }
#val-form label { font-size: 0.7rem; color: var(--text-dim); }
.val-req { color: var(--flag); font-weight: 600; }
#val-note,
#val-reporter {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 9px;
  font: 0.75rem/1.45 inherit;
  resize: vertical;
}
#val-note:focus,
#val-reporter:focus { outline: none; border-color: var(--flag); }
#val-reporter { resize: none; }
/* Draw-an-area controls inside the issue form. */
#val-draw-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#val-draw, #val-draw-finish, #val-draw-cancel {
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 11px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}
#val-draw:hover, #val-draw-cancel:hover { background: var(--control-hover); }
#val-draw-finish {
  background: var(--shape);
  border-color: var(--shape);
  color: #2a1704;
}
#val-draw-finish:disabled { opacity: 0.45; cursor: not-allowed; }
#val-draw.hidden, #val-draw-finish.hidden, #val-draw-cancel.hidden { display: none; }
#val-draw-hint { font-size: 0.62rem; color: var(--text-dim); }

.val-shape-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 3px 0;
}
.val-shape-rm {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.62rem;
  cursor: pointer;
  text-decoration: underline;
}
.val-shape-rm:hover { color: var(--error); }

/* Crosshair while outlining, so it's clear the map click is being captured. */
.drawing .leaflet-grab,
.drawing .leaflet-interactive { cursor: crosshair; }

/* Problem areas glow so they stand out over busy imagery. drop-shadow (not
   box-shadow) follows the actual vector outline rather than its bounding box,
   and applying it to the pane halos every shape at once. The slow pulse draws
   the eye to a reviewed report without being distracting. */
/* Reviewed-tile overlay ("on map"). A dark rim under the coloured stroke keeps
   green/orange/red legible over bright true-colour imagery, where a thin
   saturated line washes out. No animation: this can be hundreds of rectangles
   at once, and a pulsing filter over all of them is expensive. */
.leaflet-reviewedPane {
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9))
          drop-shadow(0 0 6px rgba(0, 0, 0, 0.5));
}

.leaflet-shapePane {
  filter: drop-shadow(0 0 3px rgba(255, 159, 10, 1))
          drop-shadow(0 0 9px rgba(255, 159, 10, 0.75));
  animation: shape-glow 2.4s ease-in-out infinite;
}
@keyframes shape-glow {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(255, 159, 10, 1))
            drop-shadow(0 0 9px rgba(255, 159, 10, 0.75));
  }
  50% {
    filter: drop-shadow(0 0 5px rgba(255, 200, 90, 1))
            drop-shadow(0 0 18px rgba(255, 159, 10, 0.95));
  }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet-shapePane { animation: none; }
}

/* Land-cover repaint tool ("Modify"), top-right map control. The button sits
   ABOVE the panel in DOM order: Leaflet's top-right corner is pinned with
   top:0, so a taller control grows downward instead of covering the layer
   switcher above it (opposite of .reports-control, which is bottom-right). */
.edit-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.edit-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.edit-btn, .edit-compare {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  padding: 6px 15px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.edit-btn:hover:not(:disabled), .edit-compare:hover { background: var(--control-hover); }
.edit-btn.active { background: var(--edit-accent); border-color: var(--edit-accent); color: #fff; }
.edit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* Lit while previewing the untouched layer -- same visual language as
   .edit-btn.active, so "you're looking at something other than normal" reads
   consistently across the tool. Hidden (not disabled) when there's nothing
   to compare -- see updateEditContext()'s comment for why. */
.edit-compare.active { background: var(--edit-accent); border-color: var(--edit-accent); color: #fff; }
.edit-compare.hidden { display: none; }

.edit-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  color: var(--text);
  width: 230px;
  max-width: 88vw;
  overflow: hidden;
}
.edit-panel.hidden { display: none; }
.edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.edit-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.edit-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.edit-close:hover { color: var(--text); }
.edit-context {
  padding: 7px 12px 0;
  font-size: 0.62rem;
  color: var(--text-dim);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
/* "Where are my edits?" -- surfaces edited years/resolutions that aren't the
   one on screen right now, since neither region, year nor resolution
   persists across a page refresh. */
.edit-edited-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  padding: 7px 12px 0;
}
.edit-edited-summary.hidden { display: none; }
.edit-edited-label { font-size: 0.6rem; color: var(--text-dim); }
.edit-edited-chip {
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
}
.edit-edited-chip:hover { background: var(--control-hover); }
/* The chip matching what's on screen right now reads as a location marker,
   not a button to press -- same accent as the compare toggle. */
.edit-edited-chip.here {
  background: var(--edit-accent);
  border-color: var(--edit-accent);
  color: #fff;
  cursor: default;
}
.edit-layer-row {
  display: flex;
  gap: 6px;
  padding: 7px 12px 0;
}
.edit-undo {
  flex: 1 1 auto;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
}
.edit-undo:hover:not(:disabled) { background: var(--control-hover); }
.edit-undo:disabled { opacity: 0.35; cursor: not-allowed; }
.edit-draw-row {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
}
.edit-draw-btn, .edit-finish, .edit-redo {
  flex: 1 1 auto;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 5px 8px;
  cursor: pointer;
}
.edit-draw-btn:hover, .edit-finish:hover, .edit-redo:hover { background: var(--control-hover); }
.edit-draw-btn.hidden, .edit-finish.hidden, .edit-redo.hidden { display: none; }
.edit-hint {
  padding: 0 12px 8px;
  font-size: 0.62rem;
  color: var(--text-dim);
}
.edit-paint { padding: 0 12px 10px; }
.edit-paint.hidden { display: none; }
.edit-label {
  display: block;
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.edit-class {
  width: 100%;
  box-sizing: border-box;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 4px 6px;
  margin-bottom: 6px;
  cursor: pointer;
  /* Same reasoning as .reports-region: the native popup renders on its own
     surface, not the panel, so it needs its own dark styling. */
  color-scheme: dark;
}
.edit-class option { background: #202124; color: var(--text); }
.edit-years-mode {
  width: 100%;
  box-sizing: border-box;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 4px 6px;
  margin-bottom: 6px;
  cursor: pointer;
  color-scheme: dark;
}
.edit-years-mode option { background: #202124; color: var(--text); }
.edit-years-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.edit-years-range.hidden { display: none; }
.edit-year-from, .edit-year-to {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 4px 6px;
  cursor: pointer;
  color-scheme: dark;
}
.edit-year-from option, .edit-year-to option { background: #202124; color: var(--text); }
.edit-years-to-label { flex: none; font-size: 0.62rem; color: var(--text-dim); }
.edit-years-hint {
  font-size: 0.6rem;
  color: var(--v-issue);
  margin-bottom: 8px;
  line-height: 1.4;
}
.edit-years-hint.hidden { display: none; }
.edit-note {
  width: 100%;
  box-sizing: border-box;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 4px 6px;
  margin-bottom: 8px;
}
.edit-actions { display: flex; }
.edit-apply {
  flex: 1 1 auto;
  background: var(--edit-accent);
  border: 1px solid var(--edit-accent);
  border-radius: 6px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 8px;
  cursor: pointer;
}
.edit-apply:hover:not(:disabled) { filter: brightness(1.1); }
.edit-apply:disabled { opacity: 0.6; cursor: default; }
.edit-status {
  padding: 0 12px 10px;
  font-size: 0.64rem;
  min-height: 1.2em;
}
.edit-status.ok { color: var(--v-good); }
.edit-status.err { color: var(--v-nodata); }

/* Crosshair while outlining an edit area, same treatment as .drawing. */
.edit-drawing .leaflet-grab,
.edit-drawing .leaflet-interactive { cursor: crosshair; }

.leaflet-editPane {
  filter: drop-shadow(0 0 3px rgba(255, 55, 95, 1))
          drop-shadow(0 0 9px rgba(255, 55, 95, 0.75));
  animation: edit-glow 2.4s ease-in-out infinite;
}
@keyframes edit-glow {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(255, 55, 95, 1))
            drop-shadow(0 0 9px rgba(255, 55, 95, 0.75));
  }
  50% {
    filter: drop-shadow(0 0 5px rgba(255, 130, 160, 1))
            drop-shadow(0 0 18px rgba(255, 55, 95, 0.95));
  }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet-editPane { animation: none; }
}

/* "n areas" badge on a report row that carries drawn geometry. */
.report-areas {
  font-size: 0.58rem;
  font-weight: 700;
  color: #2a1704;
  background: var(--shape);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

#val-form-actions { display: flex; gap: 8px; }
#val-submit,
#val-cancel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, filter 0.12s;
}
#val-submit { background: var(--flag); border-color: var(--flag); color: #fff; }
#val-submit:hover:not(:disabled) { filter: brightness(1.12); }
/* The visible half of "force the user to write something": no text, no save. */
#val-submit:disabled { opacity: 0.4; cursor: not-allowed; }
#val-cancel { background: var(--control-bg); color: var(--text); }
#val-cancel:hover { background: var(--control-hover); }

#val-status { font-size: 0.68rem; margin-top: 8px; }
#val-status:empty { display: none; }
#val-status.ok { color: #6cc08b; }
#val-status.err { color: var(--error); }

/* Use a normal arrow cursor over the map instead of Leaflet's grab hand
   (these override Leaflet's own .leaflet-grab rules, loaded earlier). */
.leaflet-grab { cursor: default; }
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-interactive { cursor: default; }
