html, body, #map {
  height: 100%;
  margin: 0;
  font-family: sans-serif;
}

#legend, .map-legend {
  position: absolute;
  right: 14px;
  bottom: 48px; /* sit above the attribution control */
  z-index: 1000;
  width: 220px;
  background: rgba(255,255,255,0.98);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #222;
  font-size: 13px;
}

.map-legend .legend-header { margin: 0 0 8px 0; font-weight: 700; }
.map-legend .legend-header { display: flex; align-items: center; justify-content: space-between; }
.legend-toggle {
  background: transparent;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.legend-toggle:focus { outline: 2px solid rgba(30,144,255,0.3); }
.map-legend.collapsed { width: 36px; padding: 6px; overflow: visible; }
.map-legend.collapsed .legend-grid-compact { display: none; }
.map-legend.collapsed .legend-header { justify-content: center; }
.map-legend.collapsed .legend-toggle { transform: rotate(-90deg); }
.map-legend .legend-rows { display: flex; flex-direction: column; gap: 6px; }
.map-legend .legend-grid-compact { display: grid; grid-template-columns: 84px 60px 60px; gap: 6px; align-items: center; }
.map-legend .legend-grid-row { display: contents; }
.map-legend .legend-grid-cell { padding: 6px 4px; display: flex; align-items: center; justify-content: center; }
.map-legend .legend-grid-cell.label { justify-content: flex-start; font-weight: 600; }
.map-legend .legend-grid-cell[tabindex] { cursor: pointer; border-radius: 6px; }
.map-legend .legend-grid-cell[tabindex]:hover, .map-legend .legend-grid-cell[tabindex]:focus { background: rgba(30,144,255,0.04); outline: none; }
.map-legend .legend-icon { width: 14px; height: 14px; display: inline-block; flex: 0 0 auto; }

.map-legend .legend-grid-cell { min-height: 22px; }
.map-legend .legend-grid-row.small .legend-grid-cell { font-size: 12px; }

/* Circle icons */
.legend-icon.circle { border-radius: 50%; border: 1px solid #333; }
.legend-icon.circle.surveyed { background: #1e90ff; }
.legend-icon.circle.not-surveyed { background: #e74c3c; }

/* Triangle icon (using simple SVG-like CSS) */
.legend-icon.triangle { width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; }
.legend-icon.triangle.surveyed { border-bottom: 16px solid #1e90ff; }
.legend-icon.triangle.not-surveyed { border-bottom: 16px solid #e74c3c; }

/* Small black dot for grade */
.legend-icon.small-circle { width: 12px; height: 12px; border-radius: 50%; background: #000; border: 1px solid #333; }

.legend-icon.red-x { color: #e74c3c; font-weight: 700; font-size: 18px; line-height: 18px; }

/* #legend {
  position: absolute;
  bottom: 20px;
  right: 10px;
  z-index: 1000;
  background: white;
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
  font-size: 14px;
}

#legend .legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

#legend .legend-color {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border-radius: 50%;
  display: inline-block;
}

.surveyed {
  background: #1e90ff;
  border: 1px solid #333;
}

.not-surveyed {
  background: #e74c3c;
  border: 1px solid #333;
} */

/* Improved popup link */
.popup-link {
  display: inline-block;
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #1e90ff;
  text-decoration: underline;
}

.popup-link:hover {
  color: #104e8b;
  text-decoration: none;
}

.leaflet-control-geocoder .leaflet-control-geocoder-icon {
  background-image: url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/icons/geo-alt.svg');
  background-size: 18px 18px;
  background-repeat: no-repeat;
  background-position: center;
  background-color: white;
  border-radius: 4px;
}

/* Red X marker for Not Accessible */
.leaflet-div-icon.red-x {
  color: red;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  line-height: 18px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Triangle marker for Monuments */
.leaflet-div-icon.triangle-monument {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #666; /* Dark gray triangle */
  background: none;
}

@media (max-width: 480px) {
  #legend, .map-legend { width: 160px; bottom: 56px; right: 8px; padding: 8px; }
}


