:root {
  color-scheme: light;
  /* Shared palette so the panel, popup, and vector layers stay visually aligned. */
  --ink: #0f1c1a;
  --muted: #516162;
  --panel-bg: rgba(246, 245, 239, 0.88);
  --panel-border: rgba(15, 28, 26, 0.12);
  --accent: #2e6b5d;
  --accent-soft: rgba(46, 107, 93, 0.16);
  --point: #d86b3e;
  --point-soft: rgba(216, 107, 62, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(
    circle at 10% 10%,
    #f6f0e7,
    #e6eee9 55%,
    #dfe7ef 100%
  );
}

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

.panel {
  position: fixed;
  left: 24px;
  top: 24px;
  /* The panel floats above the map instead of consuming layout space, which keeps
     the mapping canvas full-screen on both desktop and mobile. */
  width: clamp(280px, 16.666vw, 440px);
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px 18px 12px;
  box-shadow: 0 20px 40px rgba(15, 28, 26, 0.18);
  backdrop-filter: blur(8px);
  overflow-x: hidden;
  overflow-y: auto;
}

.panel__header {
  margin-bottom: 16px;
}

.brand {
  font-family: "Fraunces", serif;
  font-size: 24px;
  letter-spacing: 0.4px;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

.panel__section {
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
  margin-top: 12px;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 8px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
}

.layer-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.layer-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.layer-section {
  display: grid;
  gap: 8px;
}

.layer-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(46, 107, 93, 0.1);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.layer-section-chevron {
  color: var(--muted);
  font-size: 10px;
  transition: transform 150ms ease;
}

.layer-section:not(.is-collapsed) .layer-section-chevron {
  transform: rotate(90deg);
}

.layer-section-body {
  display: grid;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--panel-border);
}

.layer-section.is-collapsed .layer-section-body {
  display: none;
}

.layer-subsection {
  display: grid;
  gap: 8px;
  padding-left: 8px;
}

.layer-subsection-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 2px 0;
}

.layer-row {
  position: relative;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease;
}

.layer-row.is-dragging {
  opacity: 0.48;
}

.layer-row.is-drop-before,
.layer-row.is-drop-after {
  border-color: rgba(46, 107, 93, 0.46);
  background: rgba(46, 107, 93, 0.08);
}

.layer-row.is-drop-before::before,
.layer-row.is-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(246, 245, 239, 0.9);
}

.layer-row.is-drop-before::before {
  top: -6px;
}

.layer-row.is-drop-after::after {
  bottom: -6px;
}

.layer-row.is-zoom-disabled {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.28);
}

.layer-header {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 38px 18px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.layer-drag-handle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
}

.layer-drag-handle:active {
  cursor: grabbing;
}

.layer-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layer-drag-grip {
  width: 13px;
  height: 18px;
  opacity: 0.72;
  background-image: radial-gradient(
    circle,
    currentColor 1.3px,
    transparent 1.6px
  );
  background-size: 6px 6px;
}

.layer-toggle input {
  accent-color: var(--accent);
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.layer-toggle input:disabled {
  cursor: default;
}

.layer-interaction-badge {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.layer-interaction-badge.is-clickable {
  color: var(--accent);
}

.layer-interaction-badge.is-not-clickable {
  color: var(--muted);
  opacity: 0.72;
}

.layer-row.is-zoom-disabled .layer-toggle {
  opacity: 0.58;
}

.layer-row.is-zoom-disabled .layer-drag-handle {
  opacity: 0.65;
}

.layer-zoom-hint {
  display: grid;
  gap: 1px;
  justify-items: center;
  font-size: 10px;
  line-height: 1.05;
  color: var(--muted);
  text-align: center;
}

.layer-action-slot,
.layer-legend-slot {
  display: inline-grid;
  place-items: center;
  min-width: 0;
}

.layer-action-placeholder {
  width: 16px;
  height: 16px;
  visibility: hidden;
}

.layer-click-hint {
  padding-left: 26px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.layer-note {
  padding: 4px 0 0 26px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.legend-chevron {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 4px;
  transition: transform 150ms ease;
}

.legend-chevron--placeholder {
  cursor: default;
  visibility: hidden;
}

.layer-row.is-expanded .legend-chevron {
  transform: rotate(90deg);
}

.layer-legend {
  display: none;
  padding: 6px 0 2px 26px;
}

.layer-row.is-expanded .layer-legend {
  display: block;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-ramp {
  height: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
}

.legend-ramp-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
}

.legend-group {
  margin-bottom: 4px;
}

.legend-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 6px 0 2px;
}

.status {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.panel__footer {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

@media (max-width: 720px) {
  /* Collapse the chrome toward the screen edges on small devices so map space
     remains usable. */
  .panel {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - 24px);
  }

}
