* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; }
#map { position: absolute; top: 0; left: 320px; right: 0; bottom: 0;
  transition: left 0.25s ease; }

/* When panel is collapsed on desktop, map fills the full width */
#panel.collapsed ~ #map { left: 0; }

/* --- Sidebar (panel) --- */
#panel { position: absolute; top: 0; left: 0; width: 320px; bottom: 0;
  padding: 16px; overflow-y: auto; background: #f7f7f7;
  border-right: 1px solid #ddd;
  display: flex; flex-direction: column;
  z-index: 1000; transition: transform 0.25s ease; }
#panel h1 { font-size: 18px; }

/* --- Panel toggle button — fixed, always on-screen, vertically centered --- */
.panel-toggle { position: fixed; top: 50%; left: 0; translate: 0 -50%;
  width: 28px; height: 56px;
  background: #f7f7f7; border: 1px solid #ddd; border-left: none;
  border-radius: 0 6px 6px 0; cursor: pointer; font-size: 13px; line-height: 1;
  color: #666; display: flex; align-items: center; justify-content: center;
  z-index: 1100; transition: left 0.25s ease, background 0.15s, color 0.15s; padding: 0; }
.panel-toggle:hover { background: #1f9e8f; color: #fff; border-color: #1f9e8f; }
.panel-toggle:focus-visible { outline: 2px solid #1f9e8f; outline-offset: 1px; }

/* Collapsed state: panel slides off-screen */
#panel.collapsed { transform: translateX(-320px); }

/* --- Mobile: panel hidden by default --- */
@media (max-width: 768px) {
  #panel { transform: translateX(-320px); width: min(300px, 85vw); }
  #panel.open { transform: translateX(0); }
  #map { left: 0; }
  /* On mobile, flush to the left edge when closed (mirrors desktop-collapsed).
     Slightly bigger touch target. */
  .panel-toggle { left: 0; width: 32px; height: 64px; }
}

/* Overlay behind mobile panel when open (tap to close) */
.panel-backdrop { display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35); z-index: 999; }
#panel.open ~ .panel-backdrop { display: block; }
#panel label { display: block; margin: 12px 0; font-size: 14px; }
#panel input[type=range] { width: 100%; }
.caveat { font-size: 12px; color: #a33; margin-top: 16px; }
#status { font-size: 12px; color: #555; }

/* Language flags pinned to the foot of the sidebar. margin-top:auto pushes the
   bar to the bottom when the panel content is short; it scrolls with the rest
   when content overflows. */
#langBar { margin-top: auto; padding-top: 14px; border-top: 1px solid #e0e0e0; }
.lang-caption { display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: #888; margin-bottom: 6px; }
#langFlags { display: flex; gap: 8px; }
.flag { padding: 0; border: 1px solid #ccc; border-radius: 3px; background: #fff;
  width: 34px; height: 22px; cursor: pointer; overflow: hidden; line-height: 0;
  opacity: 0.55; filter: grayscale(55%);
  transition: opacity 0.12s, filter 0.12s, box-shadow 0.12s; }
.flag svg { display: block; width: 100%; height: 100%; }
.flag:hover { opacity: 0.85; filter: grayscale(0); }
.flag.active { opacity: 1; filter: none; border-color: #1f9e8f;
  box-shadow: 0 0 0 2px rgba(31, 158, 143, 0.35); }
.flag:focus-visible { outline: 2px solid #1f9e8f; outline-offset: 1px; }
#restrictions { margin: 12px 0; border: 1px solid #ddd; padding: 8px; }
#restrictions legend { font-size: 12px; color: #555; }
#panel label.restriction { margin: 4px 0; font-size: 13px; }
.swatch { display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
  border: 1px solid #999; }
.restriction-desc { margin: 2px 0 8px 20px; font-size: 12px; color: #555;
  line-height: 1.4; }
.restriction-desc mark { background: #fff3a0; color: inherit; font-weight: 600;
  padding: 0 1px; }
#restrictionStatus { font-size: 12px; color: #555; margin: 6px 0 0; }
/* Loading spinner shown while zones / density hotspots are being computed.
   Sits over the map, top-center, above Leaflet panes but out of the way. */
.spinner { position: absolute; top: 50%; left: 50%;
  z-index: 1000; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; border: 6px solid rgba(31, 158, 143, 0.25);
  border-top-color: #1f9e8f; animation: spin 0.8s linear infinite;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); background: rgba(255, 255, 255, 0.85); }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Safety disclaimer modal, shown over the whole app on load until acknowledged.
   The overlay uses flex to center the card; [hidden] must override that. */
.modal-overlay { position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.55); padding: 20px;
  display: flex; align-items: center; justify-content: center; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; width: 100%; max-width: 440px; border-radius: 8px;
  padding: 24px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  font-size: 14px; line-height: 1.5; color: #333; }
/* Language selector inside the modal: collapsed, it shows only the current
   language's flag plus a caret; clicking expands to reveal all three. */
.modal-lang { display: flex; justify-content: flex-end; align-items: center;
  gap: 8px; margin-bottom: 14px; }
.modal-lang .flag { display: none; }
.modal-lang .flag.active { display: block; }
.modal-lang.open .flag { display: block; }
.modal-lang-caret { font-size: 10px; color: #999; line-height: 1;
  pointer-events: none; }
.modal-lang.open .modal-lang-caret { visibility: hidden; }
.modal h2 { margin: 0 0 12px; font-size: 20px; }
.modal p { margin: 0 0 12px; }
.modal .modal-lead { font-weight: 600; color: #a33; }
.modal-btn { margin-top: 4px; width: 100%; padding: 10px; font-size: 15px;
  font-weight: 600; color: #fff; background: #1f9e8f; border: none;
  border-radius: 5px; cursor: pointer; }
.modal-btn:hover { background: #1b8a7d; }
.modal-btn:focus-visible { outline: 2px solid #12564e; outline-offset: 2px; }

.density-legend { background: rgba(255, 255, 255, 0.9); padding: 6px 8px;
  border-radius: 4px; font-size: 11px; color: #333; line-height: 1.3;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.density-legend .dl-title { font-weight: 600; margin-bottom: 3px; }
.density-legend .dl-bar { display: flex; }
.density-legend .dl-bar span { display: block; width: 22px; height: 10px; }
.density-legend .dl-ends { display: flex; justify-content: space-between;
  margin-top: 2px; color: #666; }
