:root {
  --ink: #1d2a24;
  --paper: #f6f7f4;
  --forest: #23402f;
  --line: #cfd6cf;
  --ember: #d6402a;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Header */
.topbar {
  background: var(--forest);
  color: #fff;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  border-bottom: 3px solid var(--ember);
  z-index: 1000;
}
.topbar h1 { margin: 0; font-size: clamp(1rem, 2.6vw, 1.4rem); font-weight: 650; }
.topbar .sub { margin: 2px 0 0; font-size: clamp(.75rem, 1.8vw, .9rem); opacity: .8; }

/* Map fills the remaining space */
#map { flex: 1 1 auto; min-height: 0; width: 100%; background: #dfe5e0; }

/* Panels (layer control + legend) */
.panel {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
  font-size: .9rem;
  max-width: min(280px, 80vw);
}
.panel > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 650;
  list-style: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "▾"; float: right; margin-left: 12px; }
.panel:not([open]) > summary::after { content: "▸"; }
.panel .body { padding: 2px 12px 10px; max-height: 45vh; overflow-y: auto; }
.panel summary:focus-visible, .panel input:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* Layer checklist */
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.layer-row input { width: 18px; height: 18px; accent-color: var(--forest); flex: none; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.35); }
.swatch.square { border-radius: 2px; }

.opacity-row { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.opacity-row label { display: block; font-size: .8rem; margin-bottom: 4px; }
.opacity-row input { width: 100%; accent-color: var(--forest); }

/* Legend */
.legend-item { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.legend-item img { width: 28px; height: 18px; object-fit: fill; border: 1px solid rgba(0,0,0,.3); flex: none; }

.status {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: var(--forest); color: #fff; padding: 6px 14px; border-radius: 20px;
  font-size: .85rem; z-index: 1100; max-width: 90vw; text-align: center;
}
.status.hide { display: none; }
.status.error { background: #8e2415; }

.leaflet-popup-content table { border-collapse: collapse; font-size: .85rem; }
.leaflet-popup-content td { padding: 2px 8px 2px 0; vertical-align: top; }
.leaflet-popup-content td:first-child { font-weight: 650; }


/* popup message */
/* Hint pop-up */
.hint {
  position: absolute;
  left: 50%;
  top: calc(80px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ember);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  padding: 10px 12px 10px 14px;
  font-size: .92rem;
  max-width: min(420px, 90vw);
  z-index: 1200;
  animation: hint-in .25s ease-out;
}
.hint.hide { display: none; }
.hint button {
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  padding: 2px 6px;
}
@keyframes hint-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
/* code cloased of pop up message */


/* Responsiveness */
@media (max-width: 600px) {
  .panel { font-size: .85rem; max-width: 70vw; }
  .panel .body { max-height: 32vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
