/* =============================================================================
   Kilifi Atlas — walterland.app
   Sahara-fieldwork theme: cream backgrounds, burnt-umber accents,
   structured typography, polished cards.
   ============================================================================= */

:root {
  --bg-app:        #F3ECDD;
  --bg-panel:      #F7EFE0;
  --bg-panel-alt:  #EDE3CC;
  --border:        #D0BD96;
  --border-soft:   #E4D6B8;
  --text:          #211C12;
  --text-soft:     #4A4232;
  --text-faint:    #8A7C60;
  --brand:         #211C12;
  --brand-soft:    #4A4232;
  --accent:        #C2641E;
  --accent-deep:   #B14A22;
  --ochre:         #E8A53A;
  --shadow-card:   0 1px 2px rgba(33, 28, 18, 0.06), 0 6px 16px rgba(33, 28, 18, 0.10);
}

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

html, body { height: 100%; min-height: 100%; }

body {
  font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */

#sidebar {
  width: 340px;
  flex-shrink: 0;
  padding: 20px 22px 24px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#sidebar > * { flex-shrink: 0; }

/* ---- Hero / brand ---- */
.hero { padding-bottom: 4px; }
.brand-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.brand-mark {
  font-size: 16px;
  color: var(--accent);
  line-height: 1;
}
.brand {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hero h1 {
  font-family: 'Archivo', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 6px;
  letter-spacing: -0.6px;
}
.tagline {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ---- Layer groups ---- */
.group h2, .legend h2 {
  font-family: 'Space Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-faint);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-soft);
}

.group label {
  display: block;
  font-size: 11.5px;
  padding: 3px 6px 3px 4px;
  margin: 0 -6px 0 -4px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.35;
  border-radius: 4px;
  transition: background 0.1s ease;
}
.group label:hover {
  background: var(--bg-panel-alt);
}
.group input {
  margin-right: 8px;
  vertical-align: -1px;
  accent-color: var(--accent);
  cursor: pointer;
}
.muted {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 400;
  margin-left: 3px;
}

/* ---- Layers disclosure (collapsed by default — keeps landing page clean) ---- */
.layers-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  overflow: hidden;
}
.layers-panel summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-soft);
  background: var(--bg-panel-alt);
  transition: background 0.15s ease;
}
.layers-panel summary::-webkit-details-marker { display: none; }
.layers-panel summary:hover { background: #efe4cc; }
.layers-panel summary::after {
  content: '+';
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.layers-panel[open] summary::after { transform: rotate(45deg); }
.layers-panel[open] summary { border-bottom: 1px solid var(--border-soft); }
.layers-count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.4px;
  text-transform: none;
  margin-left: auto;
  margin-right: 10px;
}
.layers-label { flex: 0 0 auto; }
.layers-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Legend ---- */
.legend h3 {
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-soft);
  margin: 10px 0 4px;
}
.legend h3:first-of-type { margin-top: 0; }
.legend ul { list-style: none; }
.legend li {
  display: flex;
  align-items: center;
  font-size: 10.5px;
  padding: 3px 0;
  color: var(--text-soft);
  line-height: 1.3;
}
.legend .swatch, .analysis-map-key .swatch {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  margin-right: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}
.legend .swatch.point, .analysis-map-key .swatch.point {
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(33, 28, 18, 0.18);
}
.legend .health-public { background: #1f78b4; }
.legend .swatch.point.health-private { background: #fffbf0; border: 2px solid #6a3d9a; }
.legend .health-unknown { background: #6c757d; }
.legend .school { background: #0f6b62; }
.legend .power { background: #c46d3d; }
.line-swatch {
  width: 22px;
  height: 0;
  margin-right: 8px;
  flex-shrink: 0;
  border-top: 5px solid #fffaf0;
  box-shadow: 0 0 0 1px rgba(33, 28, 18, 0.12);
  position: relative;
}
.line-swatch::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  border-top: 2px solid currentColor;
}
.line-33kv { color: #ff8c00; }
.line-132kv { color: #c1121f; }

/* ---- Footer ---- */
#sidebar footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#sidebar footer small {
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.55;
}
#sidebar footer small strong { color: var(--brand); font-weight: 600; }

/* =============================================================================
   MAP
   ============================================================================= */

#map {
  flex: 1;
  min-width: 0;
  height: 100vh;
  min-height: 420px;
  position: relative;
}

/* =============================================================================
   POPUP CARDS — restructured as definition lists with type pills
   ============================================================================= */

.maplibregl-popup { z-index: 50; }

.maplibregl-popup-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(91, 58, 29, 0.18), 0 1px 3px rgba(91, 58, 29, 0.1);
  border: 1px solid var(--border);
  max-width: 290px;
  overflow: hidden;
}

.popup-card { font-size: 12px; line-height: 1.5; color: var(--text); }

.popup-card .pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: rgba(196, 109, 61, 0.13);
  padding: 3px 8px;
  border-radius: 3px;
  margin: 12px 14px 0;
}

.popup-card h3 {
  margin: 6px 14px 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.1px;
  line-height: 1.3;
}

.popup-card .subtitle {
  margin: 0 14px 10px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.4;
}

.popup-card dl {
  margin: 0;
  padding: 10px 14px 12px;
  background: var(--bg-panel-alt);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  gap: 4px 14px;
  font-size: 11.5px;
}
.popup-card dt {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11px;
}
.popup-card dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.popup-card dd b { color: var(--brand); font-weight: 700; }

.popup-card .status {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-align: left;
}
.popup-card .yes { color: #2d6a31; background: #e0eedb; }
.popup-card .no  { color: #8b3000; background: #f3dccb; }

.maplibregl-popup-close-button {
  font-size: 18px;
  padding: 4px 8px;
  color: var(--text-faint);
  border-radius: 0 0 0 4px;
}
.maplibregl-popup-close-button:hover {
  background: transparent;
  color: var(--brand);
}

/* =============================================================================
   MAP CONTROLS
   ============================================================================= */

.maplibregl-ctrl-group {
  border-radius: 6px !important;
  box-shadow: var(--shadow-card) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button {
  background: var(--bg-panel) !important;
  border-bottom: 1px solid var(--border-soft) !important;
}
.maplibregl-ctrl-scale {
  background: rgba(255, 251, 240, 0.85) !important;
  border-color: var(--border) !important;
  font-size: 10px !important;
  color: var(--text-soft) !important;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 720px) {
  html, body {
    min-height: 100svh;
    overflow: hidden;
  }

  body {
    flex-direction: column;
    height: 100svh;
  }

  #map {
    order: 1;
    flex: 0 0 52svh;
    width: 100%;
    height: 52svh;
    min-height: 300px;
  }

  #sidebar {
    order: 2;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    gap: 14px;
    overflow-y: auto;
  }

  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding-bottom: 0;
  }

  .brand-row { margin-bottom: 2px; }
  .brand { font-size: 10px; letter-spacing: 1.2px; }
  .hero h1 { font-size: 22px; margin-bottom: 0; }
  .tagline { font-size: 12px; line-height: 1.4; }

  .cta {
    padding: 13px 14px;
  }

  .cta-title {
    font-size: 17px;
  }

  .cta-sub {
    margin-bottom: 9px;
  }

  .start-here {
    padding: 11px 12px 11px 14px;
  }

  .group h2, .legend h2 {
    margin-bottom: 6px;
  }

  .group label {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 7px 8px;
    margin: 0 -8px;
    font-size: 12.5px;
  }

  .group input {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    flex: 0 0 auto;
  }

  .legend li {
    min-height: 24px;
    font-size: 11.5px;
  }

  .maplibregl-ctrl-top-right,
  .maplibregl-ctrl-top-left {
    top: 10px !important;
  }

  .maplibregl-ctrl-top-right {
    right: 10px !important;
  }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: 10px !important;
  }

  .maplibregl-popup-content {
    max-width: min(292px, calc(100vw - 28px));
  }
}

@media (max-width: 430px) {
  #map {
    flex-basis: 50svh;
    height: 50svh;
    min-height: 280px;
  }

  #sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero h1 {
    font-size: 20px;
  }

  .cta-sub,
  .start-here ol {
    font-size: 11px;
  }
}

/* =============================================================================
   SEARCH
   ============================================================================= */

.search-wrap { position: relative; }

#search-input {
  width: 100%;
  font: 500 12.5px 'Hanken Grotesk', sans-serif;
  color: var(--text);
  background: #fffdf6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 100, 30, 0.14);
}
#search-input::placeholder { color: var(--text-faint); }

#search-results {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fffdf6;
  box-shadow: var(--shadow-card);
  max-height: 288px;
  overflow-y: auto;
}
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  padding: 7px 12px;
  font-family: inherit;
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover, .search-hit:focus { background: var(--bg-panel-alt); }
.search-hit strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}
.search-hit small {
  display: block;
  font-size: 10.5px;
  color: var(--text-faint);
}

/* =============================================================================
   VIEW CONTROLS — basemap chips + terrain toggle
   ============================================================================= */

.basemap-switch {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.basemap-switch .chip {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 4px;
  cursor: pointer;
  background: #fffdf6;
  color: var(--text-soft);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.basemap-switch .chip:hover { border-color: var(--accent); }
.basemap-switch .chip:has(input:checked) {
  background: var(--brand);
  color: #F3ECDD;
  border-color: var(--brand);
}
.basemap-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ---- Feature counts on layer toggles ---- */
.group label .count {
  float: right;
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* =============================================================================
   MAP ACTIONS — share link + image export
   ============================================================================= */

.map-actions {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  display: flex;
  gap: 6px;
}
.map-actions button {
  font: 700 10.5px 'Space Mono', monospace;
  letter-spacing: 0.4px;
  color: var(--text);
  background: rgba(247, 239, 224, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.map-actions button:hover {
  background: #fffdf6;
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* ---- Hover tooltip ---- */
.hover-tip { pointer-events: none; z-index: 40; }
.hover-tip .maplibregl-popup-content {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: rgba(255, 253, 246, 0.95);
  border-radius: 5px;
  max-width: 260px;
}
.hover-tip .maplibregl-popup-tip { display: none; }

@media (max-width: 720px) {
  .map-actions { top: auto; bottom: 34px; left: 10px; }
  .map-actions button { padding: 6px 9px; font-size: 10px; }
}

/* Map-first exploration: retain the atlas palette and cartographic symbols. */
body { height: 100%; min-height: 0; overflow: hidden; }
#sidebar { width: 280px; padding: 16px; gap: 12px; }
#map { height: 100%; min-height: 0; }
.brand-row { margin-bottom: 5px; }
.brand { font: 600 11px 'Hanken Grotesk', sans-serif; letter-spacing: 0; text-transform: none; color: var(--text-soft); }
.hero h1 { font-size: 23px; }
.tagline { font-size: 12px; }
.task-label { font-weight: 600; margin-bottom: -7px; }
#map-task { width: 100%; min-height: 40px; font: 600 13px 'Hanken Grotesk', sans-serif; border: 1px solid var(--border); border-radius: 4px; color: var(--text); background: #fffdf6; padding: 8px; }
.map-hint { font-size: 12px; color: var(--text-soft); }
.layers-panel summary, .legend-panel > summary, .sources-panel > summary { font: 700 13px 'Hanken Grotesk', sans-serif; letter-spacing: 0; text-transform: none; padding: 10px; cursor: pointer; }
.legend-panel, .sources-panel { border-top: 1px solid var(--border-soft); }
.legend { padding: 0 10px 8px; }
.sources-panel p { font-size: 12px; color: var(--text-soft); margin: 8px 10px; }
.sources-panel a, .surveyor-link { color: #904317; }
.surveyor-link { font-size: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.group h2 { font: 700 12px 'Hanken Grotesk', sans-serif; text-transform: none; letter-spacing: 0; color: var(--text-soft); }
.group label { font-size: 12px; padding-top: 6px; padding-bottom: 6px; }
#active-layer-count { font-weight: 400; font-size: 11px; margin-left: auto; margin-right: 8px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-title h2 { font-size: 14px; }
.section-title button { border: 0; background: none; color: #904317; cursor: pointer; padding: 7px; }
#location-info { border-top: 2px solid var(--accent); padding-top: 8px; }
#feature-info .popup-card { padding-bottom: 10px; }
#feature-info .popup-card h3, #feature-info .popup-card .subtitle, #feature-info .popup-card .pill { margin-left: 0; margin-right: 0; }
#feature-info .popup-card dl { padding: 8px; gap: 4px 8px; }
#location-summary > p { font-size: 12px; margin: 8px 0; color: var(--text-soft); }
#location-summary h3 { font-size: 13px; margin-top: 12px; }
.nearby-hit { display: block; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border-soft); text-align: left; padding: 8px 0; font: 500 12px 'Hanken Grotesk', sans-serif; cursor: pointer; color: var(--text); }
.nearby-hit small { display: block; font-weight: 400; color: var(--text-soft); }
#save-summary { width: 100%; border: 1px solid var(--border); border-radius: 4px; background: #fffdf6; color: var(--text); padding: 9px; margin-top: 12px; cursor: pointer; font: 600 12px 'Hanken Grotesk', sans-serif; }
#map-status { position: absolute; bottom: 38px; left: 10px; z-index: 25; max-width: calc(100% - 20px); background: #fffdf6; border: 1px solid var(--border); padding: 8px 12px; border-radius: 4px; font-size: 12px; }
#map-status[hidden], [hidden] { display: none !important; }
.map-actions { max-width: calc(100% - 54px); flex-wrap: wrap; }
.map-actions button { font: 600 12px 'Hanken Grotesk', sans-serif; letter-spacing: 0; min-height: 36px; padding: 7px 10px; }
button:disabled, input:disabled, select:disabled { opacity: .55; cursor: wait; }
button:focus-visible, summary:focus-visible, select:focus-visible, a:focus-visible, input:focus-visible, .chip:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
body.panel-hidden #sidebar { display: none; }
#search-results .empty-search { padding: 12px; font-size: 12px; color: var(--text-soft); }
@media (max-width: 720px) {
  body { height: 100%; min-height: 0; }
  #map { flex: 1 1 auto; width: 100%; height: auto; min-height: 220px; }
  #sidebar { width: 100%; flex: 0 0 250px; max-height: 45%; padding: 12px 16px; gap: 10px; }
  #sidebar:focus-within { flex-basis: 45%; }
  .hero { display: block; }
  .hero .brand-row { display: none; }
  .hero h1 { font-size: 19px; margin-bottom: 3px; }
  .tagline { font-size: 12px; }
  .map-actions { top: 8px; bottom: auto; left: 8px; gap: 4px; }
  .map-actions button { min-height: 36px; font-size: 11px; padding: 6px 8px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 0 !important; }
  .maplibregl-ctrl-top-right { top: 0 !important; right: 0 !important; }
  .maplibregl-popup-content { max-height: 270px; overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 720px) { .maplibregl-ctrl-bottom-left { bottom: 48px !important; } }

/* Nearby requests use the existing compact atlas panel, not a conversation feed. */
.search-wrap > label { display: block; font-weight: 600; margin-bottom: 5px; }
.map-search-row { display: flex; gap: 5px; }
.map-search-row #search-input { min-width: 0; flex: 1; width: 0; padding-left: 9px; }
#explore-request { flex: 0 0 auto; border: 1px solid var(--brand); background: var(--brand); color: #fffdf6; border-radius: 4px; font: 600 12px 'Hanken Grotesk',sans-serif; padding: 8px 11px; }
#request-status { font-size: 12px; color: var(--text-soft); margin-top: 6px; overflow-wrap: anywhere; }
#request-status:empty { display: none; }
.request-help { font-size: 11px; color: var(--text-soft); margin-top: 5px; }
.request-help summary { cursor: pointer; color: #904317; padding: 3px 0; }
.request-help p { margin: 7px 0; }
#location-summary .request-interpretation { color: var(--brand); font-weight: 700; font-size: 14px; }
.request-alternative, .request-choice { display: block; width: 100%; border: 1px solid var(--border); color: #904317; background: #fffdf6; padding: 9px; margin-top: 8px; text-align: left; font: 600 12px 'Hanken Grotesk',sans-serif; cursor: pointer; border-radius: 4px; }
#request-legend { margin-bottom: 8px; }
#request-legend p { font-size: 11px; line-height: 1.45; margin: 5px 0; }
#request-legend .area-key { display: inline-block; width: 19px; border-top: 2px dashed #904317; vertical-align: middle; margin-right: 7px; }
#request-legend .origin-key { display: inline-block; width: 10px; height: 10px; border: 2px solid #B14A22; border-radius: 50%; background: #fffdf6; margin-right: 7px; }
.nearby-hit[aria-pressed="true"] { background: var(--bg-panel-alt); padding-left: 6px; border-left: 2px solid var(--accent); }

.map-image-download { color: #75442c; background: #fffaf0; border: 1px solid #c8bda4; border-radius: 4px; padding: 9px 11px; font-size: 11px; text-decoration: underline; }

#map-export-preview { max-width: min(92vw, 1000px); max-height: 90vh; border: 1px solid #c8bda4; border-radius: 6px; background: #fffaf0; color: #1a160e; padding: 16px; }
#map-export-preview::backdrop { background: rgba(26,22,14,.58); }
#map-export-preview h2 { font-size: 16px; margin: 0 0 6px; }
#map-export-preview p { font-size: 12px; margin: 0 0 12px; }
#map-export-preview img { display: block; max-width: 100%; max-height: 65vh; object-fit: contain; margin: 0 auto 12px; }
#map-export-preview button { display: block; margin-left: auto; background: #1a160e; color: #fffaf0; border: 0; border-radius: 4px; padding: 10px 14px; }

#map-export-preview { margin: auto; position: fixed; inset: 0; }

#map-export-preview .map-image-download { display: inline-block; margin: 0 12px 0 0; }

#location-summary details { margin-top: 12px; font-size: 12px; color: var(--text-soft); }
#location-summary details summary { cursor: pointer; padding: 5px 0; }
#location-summary details p { font-size: 12px; margin: 6px 0; }

/* Analysis uses the atlas's cartographic hierarchy and compact panel. */
#analysis-panel { border-top: 2px solid var(--accent); padding-top: 10px; }
#analysis-panel h2 { font: 700 15px 'Archivo',sans-serif; margin-bottom: 8px; }
#analysis-panel p { margin: 8px 0; font-size: 12px; }
#analysis-panel .analysis-answer { font-weight: 700; font-size: 14px; }
.analysis-controls { display: grid; gap: 8px; margin: 10px 0; }
.analysis-controls label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; }
.analysis-controls input, .analysis-controls select { min-height: 36px; width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fffdf6; color: var(--text); font-family: inherit; font-size: 12px; font-weight: 500; }
.analysis-controls select[multiple] { min-height: 110px; }
#analysis-panel button, #analysis-panel .analysis-export { min-height: 36px; padding: 8px; cursor: pointer; font: 600 12px 'Hanken Grotesk',sans-serif; color: var(--text); border: 1px solid var(--border); border-radius: 4px; background: #fffdf6; }
#analysis-panel .analysis-run { background: var(--brand); color: #fffdf6; }
#analysis-panel .section-title button { border: 0; background: none; color: #904317; }
#analysis-panel .analysis-record { border: 0; border-bottom: 1px solid var(--border-soft); width: 100%; text-align: left; border-radius: 0; padding: 8px 0; font-weight: 500; }
#analysis-panel .analysis-record small { display: block; font-weight: 400; color: var(--text-soft); }
#analysis-panel .analysis-record[aria-pressed=true] { background: var(--bg-panel-alt); border-left: 2px solid var(--accent); padding-left: 6px; }
.analysis-exports { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.analysis-method { font-size: 12px; margin: 10px 0; overflow-wrap: anywhere; }
.analysis-method summary { cursor: pointer; color: #904317; padding: 6px 0; }
.analysis-method dl { display: grid; grid-template-columns: auto 1fr; gap: 6px; margin: 8px 0; font-size: 11px; }
.analysis-method dd { min-width: 0; overflow-wrap: anywhere; }
.analysis-results-table { width: 100%; border-collapse: collapse; font-size: 11px; text-align: left; margin: 8px 0; }
.analysis-results-table th, .analysis-results-table td { padding: 7px 3px; border-bottom: 1px solid var(--border-soft); }
.analysis-results-table th { font-weight: 700; }
#analysis-panel .analysis-choice { display: block; width: 100%; text-align: left; margin: 6px 0; }
#analysis-panel .analysis-count { font-variant-numeric: tabular-nums; }
body.text-map-mode #map { display: none; }
body.text-map-mode #sidebar { width: min(100%,700px); max-height: 100%; margin: auto; }
body.text-map-mode .map-hint, body.text-map-mode .task-label, body.text-map-mode #map-task, body.text-map-mode .layers-panel, body.text-map-mode .legend-panel { display: none; }

.analysis-map-key { position:absolute; right:10px; bottom:42px; z-index:4; width:210px; max-width:calc(100% - 74px); padding:10px 12px; border:1px solid var(--border); border-radius:4px; background:rgba(255,253,246,.95); font-size:11px; line-height:1.45; pointer-events:none; }
.analysis-map-key h3 { font:700 12px 'Archivo',sans-serif; margin:0 0 5px; }
.analysis-map-key ul { list-style:none; margin:0; padding:0; }
.analysis-map-key li { margin:4px 0; display:flex; align-items:center; }
body.text-map-mode .analysis-map-key { position:static; max-width:100%; }
@media(max-width:720px) { .analysis-map-key { width:185px; bottom:48px; padding:7px 9px; font-size:10px; } }

.analysis-extra-filter { display:grid; grid-template-columns:1fr auto; gap:6px; align-items:end; margin:8px 0; }
