:root {
  --bg: #18181d;
  --panel: rgba(42, 42, 49, 0.96);
  --panel-deep: rgba(31, 31, 38, 0.96);
  --ink: #f2f2f4;
  --muted: #b8b8c0;
  --line: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.08);
  --accent: #d7d7dd;
  --accent-strong: #f1f1f3;
  --warning: #d8c66f;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.45);
  --side-width: clamp(19rem, 25vw, 25rem);
  --page-gap: 1rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

button {
  font: inherit;
}

.envdash {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-width);
  gap: var(--page-gap);
  width: 100vw;
  height: 100vh;
  padding: var(--page-gap);
  overflow: hidden;
  background: linear-gradient(180deg, #1c1c22 0%, #131318 100%);
}

#envdash-leaflet {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  z-index: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #202029;
  box-shadow: var(--shadow);
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #202029;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.leaflet-container *,
.leaflet-container *::before,
.leaflet-container *::after {
  box-sizing: content-box;
}

.leaflet-tile-container img,
.leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-control-zoom {
  display: none;
}

.leaflet-control-attribution {
  color: rgba(255, 255, 255, 0.5);
  background: rgba(25, 25, 34, 0.62);
  font-size: 0.68rem;
}

.leaflet-control-scale-line {
  color: rgba(245, 245, 250, 0.8);
  background: rgba(28, 28, 38, 0.6);
  border-color: rgba(245, 245, 250, 0.55);
}

.leaflet-zoom-anim .leaflet-tile-pane {
  pointer-events: none;
  opacity: 1;
}

.leaflet-tile.leaflet-tile-loaded {
  opacity: 1;
}

.leaflet-tile {
  opacity: 1;
  transition: none !important;
}

.envdash-back {
  position: absolute;
  top: calc(var(--page-gap) + 1.1rem);
  left: calc(var(--page-gap) + 1.1rem);
  min-height: 2.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.95rem 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(40, 40, 43, 0.92), rgba(30, 30, 34, 0.96));
  color: rgba(245, 245, 247, 0.94);
  text-decoration: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  z-index: 10;
  backdrop-filter: blur(12px) saturate(110%);
  -webkit-backdrop-filter: blur(12px) saturate(110%);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.envdash-back:hover,
.envdash-back:focus-visible {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, rgba(48, 48, 52, 0.96), rgba(36, 36, 40, 0.98));
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.back-icon {
  position: relative;
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
  line-height: 1;
}

.back-icon::before {
  content: "←";
  font-family: system-ui, sans-serif;
  font-weight: 700;
}

.envdash-overlay-canvas {
  position: absolute;
  pointer-events: none;
  mix-blend-mode: screen;
  transform-origin: 0 0;
  will-change: transform;
}

.envdash-zoom {
  position: absolute;
  right: calc(var(--side-width) + var(--page-gap) + 3.5rem);
  bottom: calc(var(--page-gap) + 3.2rem);
  top: auto;
  display: grid;
  align-items: center;
  gap: 0.5rem;
  transform: none;
  z-index: 10;
}

.envdash-zoom button {
  width: 2.15rem;
  height: 2.15rem;
  border: 0;
  border-radius: 50%;
  background: rgba(27, 27, 35, 0.72);
  color: #eef2f8;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
}

.envdash-zoom button:hover,
.envdash-zoom button:focus-visible {
  background: rgba(27, 27, 35, 0.95);
  color: #f7f8fb;
  border: 1px solid rgba(215, 215, 221, 0.4);
  box-shadow: 0 0 16px rgba(215, 215, 221, 0.2);
}

.envdash-side-panel {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(40, 40, 43, 0.96), rgba(32, 32, 34, 0.99));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(22px) saturate(110%);
  -webkit-backdrop-filter: blur(22px) saturate(110%);
  z-index: 12;
  overflow: auto;
}

.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.1rem 0.2rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-eyebrow {
  display: block;
  margin-bottom: 0.24rem;
  color: rgba(255, 255, 255, 0.48);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.side-panel-head h1 {
  margin: 0;
  color: #f3f3f3;
  font-size: 1.16rem;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.settings-card {
  margin-top: 0.7rem;
  padding: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(40, 40, 43, 0.76), rgba(32, 32, 34, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 3px 10px rgba(0, 0, 0, 0.24);
}

.settings-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.68rem;
}

.settings-card-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.04);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-card-note {
  color: rgba(255, 255, 255, 0.45);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.settings-field label,
.layer-control label {
  display: block;
  margin-bottom: 0.35rem;
  color: rgba(255, 255, 255, 0.62);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
}

.settings-wide {
  margin-top: 0.65rem;
}

.info-tile,
.period-tile,
.depth-panel {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.info-tile {
  display: flex;
  min-height: 3.25rem;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.62rem 0.7rem;
  text-decoration: none;
}

.info-tile strong,
.period-tile strong,
.depth-summary strong {
  color: #f0f0f0;
  font-size: 0.84rem;
  line-height: 1.12;
}

.info-tile span,
.period-tile span,
.depth-summary span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.66rem;
  line-height: 1.2;
}

.period-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  min-height: 2.75rem;
  padding: 0.62rem 0.7rem;
}

.period-tile strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  text-align: right;
}

.depth-panel {
  padding: 0.62rem 0.7rem 0.58rem;
}

.depth-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.depth-summary strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
}

.depth-slider {
  width: 100%;
  margin: 0.55rem 0 0;
  accent-color: #9da0a6;
}

.depth-limits {
  display: flex;
  justify-content: space-between;
  margin-top: 0.32rem;
  color: rgba(255, 255, 255, 0.45);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  font-weight: 500;
}

.settings-card.compact {
  padding: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(40, 40, 43, 0.76), rgba(32, 32, 34, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 3px 10px rgba(0, 0, 0, 0.24);
}

.settings-card.compact h2 {
  margin: 0 0 0.65rem;
  color: #f0f0f0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layer-card {
  margin-top: 0.7rem;
}

.layer-control {
  display: flex;
  min-height: 3.45rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.62rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(40, 40, 43, 0.46), rgba(32, 32, 34, 0.36));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.layer-control + .layer-control {
  margin-top: 0.5rem;
}

.layer-control strong {
  display: block;
  color: #f0f0f0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.1;
}

.layer-color-picker {
  display: block;
  width: 2.2rem;
  height: 1.55rem;
  margin-top: 0.4rem;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: #000;
  cursor: pointer;
}

.layer-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.layer-color-picker::-webkit-color-swatch {
  border: 0;
  border-radius: 10px;
}

.layer-color-picker::-moz-color-swatch {
  border: 0;
  border-radius: 10px;
}

.layer-control.compact-row {
  align-items: center;
}

.layer-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 2.65rem;
  height: 1.48rem;
  border: 0;
  border-radius: 999px;
  background: rgba(200, 201, 204, 0.5);
  cursor: pointer;
  transition: background 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.layer-toggle::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.12rem;
  height: 1.12rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease;
}

.layer-toggle.on {
  background: rgba(78, 196, 180, 0.9);
  box-shadow: 0 0 0 3px rgba(78, 196, 180, 0.12);
}

.layer-toggle.on::after {
  transform: translateX(1.16rem);
}

.side-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--ink);
  font-size: 0.84rem;
}

.side-panel-row + .side-panel-row {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.side-panel-row strong {
  color: #f1f1f3;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  font-weight: 500;
}

.envdash-legend {
  position: absolute;
  left: calc((100vw - var(--side-width) - var(--page-gap) * 3) / 2 + var(--page-gap));
  bottom: 8.55rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: min(25rem, 52vw);
  padding: 0.48rem 0.7rem;
  border-radius: 0.55rem;
  background: linear-gradient(180deg, rgba(42, 42, 49, 0.92), rgba(31, 31, 38, 0.9));
  color: rgba(245, 245, 250, 0.9);
  z-index: 10;
  box-shadow: var(--shadow);
}

.legend-ramp {
  height: 1.35rem;
  flex: 1;
  min-width: 8rem;
  background: linear-gradient(90deg, #122a73, #1a73be, #eeeada, #dd6f32, #6f0c07);
}

.envdash-timeline {
  position: absolute;
  left: 7.25rem;
  right: calc(var(--side-width) + var(--page-gap) * 2 + 7.25rem);
  bottom: 3.95rem;
  height: 3.15rem;
  display: grid;
  grid-template-columns: 2.65rem minmax(8rem, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(42, 42, 49, 0.92), rgba(31, 31, 38, 0.9));
  box-shadow: var(--shadow);
  z-index: 10;
}

.envdash-play {
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 50%;
  color: var(--accent-strong);
  background: rgba(31, 31, 42, 0.96);
  cursor: pointer;
}

.envdash-play[aria-pressed="true"] {
  color: #17171c;
  background: #d7d7dd;
}

.envdash-timeline input {
  width: 100%;
  accent-color: #d7d7dd;
}

.envdash-timeline output {
  color: rgba(245, 245, 250, 0.9);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.envdash-status {
  display: none;
  position: absolute;
  left: calc((100vw - var(--side-width) - var(--page-gap) * 3) / 2 + var(--page-gap));
  bottom: 1.15rem;
  transform: translateX(-50%);
  padding: 0.55rem 0.78rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(42, 42, 49, 0.92), rgba(31, 31, 38, 0.9));
  color: rgba(245, 245, 250, 0.86);
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  z-index: 10;
  transition: opacity 260ms ease;
}

.envdash-status.is-faded {
  opacity: 0.62;
}

@media (max-width: 760px) {
  .envdash {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  #envdash-leaflet {
    grid-column: 1;
    grid-row: 1;
  }

  .envdash-side-panel {
    grid-column: 1;
    grid-row: 2;
    max-height: 15rem;
  }

  .envdash-status {
    display: none;
  }

  .envdash-zoom {
    right: 1rem;
    top: 42%;
    bottom: auto;
  }

  .envdash-legend {
    left: 1rem;
    right: 1rem;
    bottom: 22rem;
    transform: none;
    min-width: 0;
  }

  .envdash-timeline {
    left: 1rem;
    right: 1rem;
    bottom: 18rem;
    grid-template-columns: 2.35rem 1fr;
  }

  .envdash-timeline output {
    display: none;
  }
}
