html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, system-ui, Segoe UI, sans-serif;
  background: #1a1a1a;
}

#map {
  position: absolute; inset: 0;
}

/* ── Side panel ────────────────────────────────────────────────────────── */
.panel {
  position: absolute; top: 12px; left: 12px; z-index: 1000;
  width: 290px;
  max-height: calc(100vh - 24px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.panel-header {
  position: relative;
  padding: 12px 16px 10px;
  background: linear-gradient(135deg, #2d6a4f, #1a3a2a);
  color: #f0f4ef;
}

.panel-toggle {
  position: absolute;
  top: 6px; right: 8px;
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.18);
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-toggle:hover {
  background: rgba(255,255,255,0.32);
}
.panel.collapsed .panel-toggle {
  transform: rotate(-90deg);
}

/* When collapsed, hide everything except the H1 and the toggle */
.panel.collapsed .panel-body,
.panel.collapsed .panel-header .back-to-maps,
.panel.collapsed .panel-header .subtitle,
.panel.collapsed .panel-header .zoom-readout {
  display: none;
}

.panel.collapsed .panel-header {
  padding: 10px 44px 10px 14px;
}
.panel.collapsed .panel-header h1 {
  margin: 0;
  font-size: 14px;
}
.panel-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-header .subtitle {
  margin: 4px 0 0;
  font-size: 11px;
  opacity: 0.85;
}
.zoom-readout {
  margin: 6px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.back-to-maps {
  display: inline-block;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
.back-to-maps:hover {
  color: #fff;
  text-decoration: underline;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 14px;
}

.layer-group {
  margin-bottom: 14px;
}
.layer-group h2 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #777;
  margin: 0 0 6px;
}

/* ── Toggle buttons ────────────────────────────────────────────────────── */
.layer-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.layer-btn:hover {
  border-color: #2d6a4f;
  background: #f0f7f0;
}
.layer-btn.on {
  background: #2d6a4f;
  color: #fff;
  border-color: #1a3a2a;
  font-weight: 600;
}
.layer-btn.on .dot {
  box-shadow: 0 0 0 2px #fff;
}
.layer-btn.disabled-zoom {
  opacity: 0.45;
  cursor: not-allowed;
}
.layer-btn.disabled-zoom:hover {
  border-color: #ddd;
  background: #fafafa;
}
.layer-btn small {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.7;
  font-weight: normal;
}
.layer-btn.on small { opacity: 0.85; }

.dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.3);
  text-align: center;
  line-height: 12px;
  font-size: 10px;
}
.dot-grad {
  background: linear-gradient(90deg, #fee08b, #a6d96a, #1a9850);
}

/* ── Basemap chips ─────────────────────────────────────────────────────── */
.basemap-row {
  display: flex; gap: 4px;
}
.base-btn {
  flex: 1;
  padding: 6px 0;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid #bbb;
  background: #f6f6f6;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.base-btn:hover { background: #e9e9e9; }
.base-btn.on {
  background: #2d6a4f;
  color: #fff;
  border-color: #1a3a2a;
}

/* ── Legend ────────────────────────────────────────────────────────────── */
.legend .legend-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  padding: 2px 0;
}
.legend .sw {
  width: 22px; height: 12px;
  border: 1px solid #333;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Fruiting weather panel ────────────────────────────────────────────── */
.weather-panel {
  border-top: 1px solid #eee;
  padding-top: 10px;
  margin-top: 6px;
}
.weather-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: #2d6a4f;
  list-style: none;
  user-select: none;
  display: flex; align-items: center; gap: 6px;
}
.weather-panel summary::-webkit-details-marker { display: none; }
.weather-panel summary::before {
  content: "▶";
  font-size: 9px;
  transition: transform 0.15s;
}
.weather-panel[open] summary::before { transform: rotate(90deg); }
.weather-body {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.55;
  color: #333;
}
.weather-body h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 8px 0 4px;
  color: #2d6a4f;
}
.weather-body h3:first-child { margin-top: 0; }
.weather-body ul { margin: 0; padding-left: 18px; }
.weather-body li { margin: 2px 0; }

/* ── Popups ────────────────────────────────────────────────────────────── */
.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  min-width: 220px;
}
.popup-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}
.popup-score {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 11px;
  background: #1a9850;
  color: #fff;
  margin-left: 4px;
}
.popup-meta {
  margin-top: 6px;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 8px;
  font-size: 11px;
}
.popup-meta .k {
  color: #777;
  font-weight: 500;
}
.popup-meta .v {
  color: #222;
}

/* ── GPS locate button ─────────────────────────────────────────────────── */
.gps-btn {
  position: absolute;
  bottom: 24px; right: 24px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.25);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
  z-index: 1000;
  color: #555;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.gps-btn:hover {
  background: #f5f5f5;
  color: #2d6a4f;
}
.gps-btn:active {
  transform: scale(0.95);
}
.gps-btn.locating {
  color: #2d6a4f;
  animation: gps-pulse 1.4s infinite ease-in-out;
}
.gps-btn.found {
  background: #2d6a4f;
  color: #fff;
  border-color: #1a3a2a;
}
@keyframes gps-pulse {
  0%, 100% { transform: scale(1.0); }
  50%      { transform: scale(1.12); }
}

/* ── Toast notifications ───────────────────────────────────────────────── */
.toast {
  position: absolute; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #1a3a2a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 2000;
}
.toast.show { opacity: 1; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .panel { width: calc(100vw - 24px); max-height: 50vh; }
}
