:root {
  --atlas-paper: #f4f5ee;
  --atlas-paper-raised: #fbfcf7;
  --atlas-ink: #18312d;
  --atlas-ink-soft: #52625b;
  --atlas-line: #ccd5c8;
  --atlas-moss: #517455;
  --atlas-lichen: #a4b28b;
  --atlas-water: #6f98a0;
  --atlas-ochre: #bd8b4b;
  --atlas-plum: #806571;
  --atlas-shadow: rgba(24, 49, 45, .13);
  --atlas-panel-width: 374px;
}

* { box-sizing: border-box; }

html,
body,
.atlas-shell,
#canopy-map { width: 100%; height: 100%; margin: 0; }

.atlas-body {
  overflow: hidden;
  color: var(--atlas-ink);
  background: var(--atlas-paper);
  font-family: "Alegreya Sans", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--atlas-ochre) 62%, white);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#canopy-map {
  position: fixed;
  inset: 0;
  background: #dfe7df;
}

.atlas-masthead {
  position: fixed;
  z-index: 6;
  top: 18px;
  left: 18px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  width: var(--atlas-panel-width);
  min-height: 58px;
  overflow: hidden;
  background: color-mix(in srgb, var(--atlas-paper-raised) 95%, transparent);
  border: 1px solid var(--atlas-line);
  border-radius: 13px 13px 0 0;
  box-shadow: 0 10px 30px var(--atlas-shadow);
  backdrop-filter: blur(12px);
}

.atlas-menu-button {
  display: grid;
  place-content: center;
  gap: 6px;
  width: 42px;
  height: 58px;
  padding: 0;
  color: var(--atlas-ink);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--atlas-line);
}

.atlas-menu-button span:not(.sr-only) {
  display: block;
  width: 15px;
  height: 1px;
  background: currentColor;
  transition: transform .2s ease;
}

.atlas-shell.panel-collapsed .atlas-menu-button span:first-child { transform: translateY(3.5px) rotate(45deg); }
.atlas-shell.panel-collapsed .atlas-menu-button span:nth-child(2) { transform: translateY(-3.5px) rotate(-45deg); }

.atlas-brand {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 0 11px;
  color: var(--atlas-ink);
  text-decoration: none;
}

.atlas-brand i {
  position: relative;
  width: 18px;
  height: 22px;
  flex: 0 0 auto;
  border: 1.5px solid var(--atlas-moss);
  border-radius: 95% 8% 95% 8%;
  transform: rotate(-35deg);
}

.atlas-brand i::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 8px;
  width: 1px;
  height: 18px;
  background: var(--atlas-moss);
  transform: rotate(35deg);
  transform-origin: top;
}

.atlas-brand span {
  overflow: hidden;
  font-family: "Alegreya", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.place-picker {
  position: relative;
  align-self: stretch;
  min-width: 132px;
  border-left: 1px solid var(--atlas-line);
}

.place-picker > span {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 13px;
  color: var(--atlas-ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  pointer-events: none;
}

.place-picker select {
  width: 100%;
  height: 100%;
  padding: 22px 30px 7px 12px;
  overflow: hidden;
  color: var(--atlas-ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 600;
  text-overflow: ellipsis;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--atlas-moss) 50%), linear-gradient(135deg, var(--atlas-moss) 50%, transparent 50%);
  background-position: calc(100% - 17px) 29px, calc(100% - 12px) 29px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.atlas-panel {
  position: fixed;
  z-index: 5;
  top: 76px;
  left: 18px;
  display: flex;
  flex-direction: column;
  width: var(--atlas-panel-width);
  max-height: calc(100vh - 94px);
  overflow: auto;
  background: color-mix(in srgb, var(--atlas-paper-raised) 95%, transparent);
  border: 1px solid var(--atlas-line);
  border-top: 0;
  border-radius: 0 0 13px 13px;
  box-shadow: 0 18px 42px var(--atlas-shadow);
  backdrop-filter: blur(12px);
  transform-origin: top left;
  transition: opacity .22s ease, transform .22s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--atlas-lichen) transparent;
}

.atlas-introduction,
.atlas-search,
.atlas-stats,
.atlas-section-heading,
.atlas-layers,
.atlas-panel-foot { flex-shrink: 0; }

.atlas-shell.panel-collapsed .atlas-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(.985);
}

.habitat-ribbon {
  display: flex;
  height: 7px;
  flex: 0 0 auto;
  background: var(--atlas-line);
}

.habitat-ribbon span {
  flex: 1;
  opacity: .2;
  transition: flex .3s ease, opacity .3s ease;
}

.habitat-ribbon span.active { flex: 1.65; opacity: 1; }
.habitat-ribbon span:nth-child(5n+1) { background: var(--atlas-moss); }
.habitat-ribbon span:nth-child(5n+2) { background: var(--atlas-water); }
.habitat-ribbon span:nth-child(5n+3) { background: var(--atlas-ochre); }
.habitat-ribbon span:nth-child(5n+4) { background: var(--atlas-plum); }
.habitat-ribbon span:nth-child(5n+5) { background: var(--atlas-lichen); }

.atlas-introduction { padding: 21px 22px 17px; }

.atlas-eyebrow,
.atlas-section-heading span,
.atlas-record-label,
.atlas-detail-kicker {
  margin: 0;
  color: var(--atlas-moss);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.atlas-introduction h1 {
  margin: 5px 0 0;
  font-family: "Alegreya", Georgia, serif;
  font-size: 39px;
  font-weight: 500;
  line-height: .95;
  letter-spacing: -.035em;
}

.atlas-local-name {
  margin: 5px 0 -2px;
  color: var(--atlas-moss);
  font-family: "Alegreya", Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  text-align: left;
}

.atlas-lede {
  max-width: 305px;
  margin: 11px 0 0;
  color: var(--atlas-ink-soft);
  font-family: "Alegreya", Georgia, serif;
  font-size: 16px;
  line-height: 1.35;
}

.atlas-search {
  display: grid;
  grid-template-columns: 33px 1fr auto;
  align-items: center;
  margin: 0 18px;
  overflow: hidden;
  background: var(--atlas-paper);
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.atlas-search:focus-within {
  border-color: var(--atlas-moss);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--atlas-lichen) 28%, transparent);
}

.atlas-search-mark {
  position: relative;
  width: 13px;
  height: 13px;
  margin-left: 13px;
  border: 1.5px solid var(--atlas-moss);
  border-radius: 50%;
}

.atlas-search-mark::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.5px;
  background: var(--atlas-moss);
  transform: rotate(45deg);
}

.atlas-search input {
  min-width: 0;
  height: 42px;
  padding: 0 9px;
  color: var(--atlas-ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.atlas-search input::placeholder { color: color-mix(in srgb, var(--atlas-ink-soft) 72%, white); }

.atlas-search button {
  align-self: stretch;
  min-width: 50px;
  padding: 0 12px;
  color: var(--atlas-paper-raised);
  background: var(--atlas-ink);
  border: 0;
  font-weight: 600;
  transition: background .2s ease;
}

.atlas-search button:hover { background: var(--atlas-moss); }

.atlas-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 16px 18px 0;
  border-top: 1px solid var(--atlas-line);
  border-bottom: 1px solid var(--atlas-line);
}

.atlas-stats div { min-width: 0; padding: 11px 4px 11px 0; }
.atlas-stats div + div { padding-left: 15px; border-left: 1px solid var(--atlas-line); }

.atlas-stats b {
  display: block;
  overflow: hidden;
  font-family: "IBM Plex Mono", monospace;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.1;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.atlas-stats span {
  display: block;
  margin-top: 3px;
  color: var(--atlas-ink-soft);
  font-size: 10px;
  line-height: 1.15;
}

.atlas-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 17px 18px 8px;
}

.atlas-section-heading p {
  margin: 3px 0 0;
  color: var(--atlas-ink-soft);
  font-size: 11px;
}

.atlas-section-heading button,
.atlas-panel-foot button {
  padding: 2px 0;
  color: var(--atlas-moss);
  background: transparent;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--atlas-moss) 40%, transparent);
  font-size: 10px;
  font-weight: 600;
}

.atlas-layers { padding: 0 10px; }

.atlas-layer {
  display: grid;
  grid-template-columns: 29px 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  color: var(--atlas-ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--atlas-line) 72%, transparent);
  border-radius: 7px;
  transition: background .18s ease;
}

.atlas-layer:hover { background: color-mix(in srgb, var(--atlas-lichen) 14%, transparent); }

.atlas-layer-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--layer-color, var(--atlas-moss));
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: .42;
  transition: color .2s ease, opacity .2s ease, transform .2s ease;
}

.atlas-layer-swatch::after {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  transform: scale(.45);
  transition: transform .2s ease;
}

.atlas-layer.active .atlas-layer-swatch { opacity: 1; transform: rotate(-8deg); }
.atlas-layer.active .atlas-layer-swatch::after { transform: scale(1); }

.atlas-layer-copy { min-width: 0; }

.atlas-layer-copy b {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-layer-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--atlas-ink-soft);
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-layer-count {
  color: var(--atlas-ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  white-space: nowrap;
}

.atlas-panel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 16px;
}

.atlas-status {
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: var(--atlas-ink-soft);
  font-size: 10px;
}

.atlas-status i {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: var(--atlas-moss);
  border-radius: 50%;
}

.atlas-status.loading i { animation: atlas-pulse 1.1s ease-in-out infinite; }
.atlas-status.error i { background: var(--atlas-ochre); }

.atlas-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-detail {
  position: fixed;
  z-index: 8;
  top: 18px;
  right: 18px;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 27px;
  overflow: auto;
  color: var(--atlas-paper-raised);
  background: var(--atlas-ink);
  border: 1px solid color-mix(in srgb, var(--atlas-lichen) 42%, transparent);
  border-radius: 13px;
  box-shadow: 0 22px 54px rgba(16, 36, 31, .26);
  transform: translateX(calc(100% + 30px));
  transition: transform .3s cubic-bezier(.2, .75, .25, 1);
}

.atlas-detail.open { transform: none; }

.atlas-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--atlas-paper-raised) 32%, transparent);
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  transition: background .2s ease;
}

.atlas-detail-close:hover { background: color-mix(in srgb, var(--atlas-paper-raised) 10%, transparent); }

.atlas-detail-kicker { color: var(--atlas-lichen); }

.atlas-detail h2 {
  margin: 23px 38px 3px 0;
  font-family: "Alegreya", Georgia, serif;
  font-size: 34px;
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.025em;
}

.atlas-detail h2[dir="rtl"] { margin-right: 0; margin-left: 38px; text-align: right; }

.atlas-scientific {
  margin: 5px 0 0;
  color: var(--atlas-lichen);
  font-family: "Alegreya", Georgia, serif;
  font-size: 15px;
  font-style: italic;
}

.atlas-detail-summary {
  margin: 13px 0 0;
  color: color-mix(in srgb, var(--atlas-paper-raised) 78%, transparent);
  line-height: 1.45;
}

.atlas-records {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 22px 0;
  border-top: 1px solid color-mix(in srgb, var(--atlas-paper-raised) 20%, transparent);
}

.atlas-record {
  min-width: 0;
  padding: 11px 10px 11px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--atlas-paper-raised) 20%, transparent);
}

.atlas-record:nth-child(even) { padding-left: 12px; border-left: 1px solid color-mix(in srgb, var(--atlas-paper-raised) 20%, transparent); }
.atlas-record-label { color: var(--atlas-lichen); font-size: 8px; }

.atlas-record b {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 500;
}

.atlas-benefit,
.atlas-coverage {
  margin: 20px 0;
  padding: 15px;
  color: var(--atlas-ink);
  background: var(--atlas-paper);
  border-radius: 8px;
}

.atlas-benefit h3,
.atlas-coverage h3 { margin: 0; font-family: "Alegreya", Georgia, serif; font-size: 18px; font-weight: 600; }
.atlas-benefit > p,
.atlas-coverage > p { margin: 5px 0 12px; color: var(--atlas-ink-soft); font-size: 11px; line-height: 1.4; }

.atlas-benefit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.atlas-benefit-grid b { display: block; font-family: "IBM Plex Mono", monospace; font-size: 15px; }
.atlas-benefit-grid span { color: var(--atlas-ink-soft); font-size: 9px; }

.atlas-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 4px;
  color: var(--atlas-paper-raised);
  font-weight: 600;
  text-decoration-color: var(--atlas-lichen);
  text-underline-offset: 4px;
}

.atlas-source-list { margin: 14px 0 0; padding: 0; list-style: none; }
.atlas-source-list li { padding: 8px 0; border-top: 1px solid var(--atlas-line); }
.atlas-source-list a { color: var(--atlas-moss); font-weight: 600; }

.atlas-scale-note {
  position: fixed;
  z-index: 3;
  right: 18px;
  bottom: 12px;
  max-width: calc(100vw - 36px);
  padding: 5px 8px;
  color: var(--atlas-ink-soft);
  background: color-mix(in srgb, var(--atlas-paper) 86%, transparent);
  border-radius: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  letter-spacing: .02em;
}

.maplibregl-ctrl-bottom-right { right: 12px; bottom: 34px; }
.maplibregl-ctrl-group { overflow: hidden; border: 1px solid var(--atlas-line); border-radius: 8px; box-shadow: 0 5px 18px var(--atlas-shadow); }
.maplibregl-ctrl-group button { width: 34px; height: 34px; background-color: var(--atlas-paper-raised); }
.maplibregl-ctrl-attrib { font-size: 9px; }

.maplibregl-popup-content {
  min-width: 150px;
  padding: 10px 12px;
  color: var(--atlas-ink);
  background: var(--atlas-paper-raised);
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  box-shadow: 0 8px 22px var(--atlas-shadow);
  font-size: 11px;
}

.maplibregl-popup-content b { display: block; font-family: "Alegreya", Georgia, serif; font-size: 15px; line-height: 1; }
.maplibregl-popup-content i { display: block; margin-top: 3px; color: var(--atlas-ink-soft); font-family: "Alegreya", Georgia, serif; }
.maplibregl-popup-tip { border-top-color: var(--atlas-paper-raised) !important; }

@keyframes atlas-pulse {
  0%, 100% { opacity: .35; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 680px) {
  :root { --atlas-panel-width: calc(100vw - 20px); }

  .atlas-masthead { top: 10px; left: 10px; min-height: 54px; border-radius: 12px; }
  .atlas-menu-button { height: 54px; }
  .atlas-brand span { font-size: 16px; }
  .place-picker { min-width: 125px; }
  .place-picker > span { top: 7px; }
  .place-picker select { padding-top: 19px; background-position: calc(100% - 17px) 26px, calc(100% - 12px) 26px; }

  .atlas-panel {
    top: auto;
    bottom: 10px;
    left: 10px;
    max-height: min(70vh, 610px);
    border-top: 1px solid var(--atlas-line);
    border-radius: 12px;
    transform-origin: bottom center;
  }

  .atlas-shell.panel-collapsed .atlas-panel { transform: translateY(10px) scale(.985); }
  .atlas-introduction { padding: 17px 18px 13px; }
  .atlas-introduction h1 { font-size: 33px; }
  .atlas-lede { font-size: 14px; }
  .atlas-stats { margin-top: 13px; }
  .atlas-section-heading { padding-top: 13px; }
  .atlas-layer { min-height: 46px; }

  .atlas-detail {
    top: auto;
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-height: 74vh;
    border-radius: 14px;
    transform: translateY(calc(100% + 20px));
  }

  .atlas-detail.open { transform: none; }
  .atlas-scale-note { display: none; }
  .maplibregl-ctrl-bottom-right { bottom: 10px; }
}

@media (max-width: 390px) {
  .atlas-brand i { display: none; }
  .atlas-brand { padding: 0 8px; }
  .place-picker { min-width: 119px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
