:root {
  --header-height: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html, body {
  height: 100%;
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f6fb;
  color: #14213d;
}

body {
  overflow: hidden;
}

.page-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
  padding: calc(12px + var(--safe-top)) calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left));
  background: #ffffff;
  border-bottom: 1px solid #dfe7f3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  box-sizing: border-box;
}

.page-title-wrap {
  min-width: 0;
}

.page-header h1 {
  font-size: 24px;
  line-height: 1.15;
  margin: 2px 0 0;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  color: #5b6b82;
  letter-spacing: 0.08em;
}

.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer-toggle-button {
  position: relative;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #14213d;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.14);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.layer-toggle-icon {
  font-size: 18px;
  line-height: 1;
}

.layer-panel {
  position: absolute;
  top: 12px;
  right: calc(16px + var(--safe-right));
  z-index: 1150;
  width: min(360px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.98);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
  padding: 16px;
  box-sizing: border-box;
  backdrop-filter: blur(8px);
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.layer-panel.is-open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.layer-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.layer-panel-eyebrow {
  font-size: 11px;
  color: #6c7c93;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.layer-panel-title {
  font-size: 18px;
  font-weight: 700;
}

.layer-panel-close {
  border: 0;
  background: #eff3f9;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.layer-group-title {
  font-size: 13px;
  font-weight: 700;
  color: #47566d;
  margin-bottom: 10px;
}

.layer-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  border-top: 1px solid #e6edf7;
}

.layer-option:first-of-type {
  border-top: 0;
}

.layer-option input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.layer-option-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-option-title {
  font-size: 15px;
  font-weight: 700;
}

.layer-option-description {
  font-size: 13px;
  line-height: 1.35;
  color: #66758c;
}

.leaflet-control-attribution {
  font-size: 12px;
  padding-bottom: calc(2px + var(--safe-bottom));
  padding-right: calc(2px + var(--safe-right));
}

.leaflet-popup-content {
  font-size: 14px;
  line-height: 1.45;
  max-width: min(320px, calc(100vw - 72px));
}

.popup-card {
  display: grid;
  gap: 6px;
}

.popup-title {
  font-size: 15px;
  font-weight: 700;
}

@media (max-width: 768px) {
  :root {
    --header-height: 68px;
  }

  .page-header {
    padding: calc(10px + var(--safe-top)) calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left));
    gap: 10px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .layer-toggle-button {
    padding: 12px 13px;
    font-size: 13px;
    flex: 0 0 auto;
  }

  .layer-toggle-text {
    display: none;
  }

  .layer-panel {
    top: 10px;
    right: 10px;
    width: calc(100% - 20px);
    border-radius: 16px;
    padding: 14px;
    max-height: calc(100% - 20px - var(--safe-bottom));
    overflow: auto;
  }

  .layer-panel-title {
    font-size: 16px;
  }

  .layer-option {
    gap: 10px;
  }

  .layer-option-title {
    font-size: 14px;
  }

  .layer-option-description {
    font-size: 12px;
  }

  .leaflet-control-zoom a {
    width: 34px;
    height: 34px;
    line-height: 34px;
    font-size: 18px;
  }
}
