:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #5e6b62;
  --line: #d8ded9;
  --paper: #f7f7f2;
  --panel: #ffffff;
  --forest: #1f6f4a;
  --forest-dark: #12452e;
  --lake: #2f6f91;
  --ridge: #7f6844;
  --sun: #d99036;
  --shadow: 0 18px 55px rgba(23, 33, 27, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
}

.leaflet-interactive,
.leaflet-marker-icon {
  cursor: pointer;
  pointer-events: auto;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-bottom,
.leaflet-top {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-popup {
  position: absolute;
  text-align: center;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #fff;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.18);
}

.leaflet-popup-content-wrapper {
  padding: 1px;
  text-align: left;
}

.leaflet-popup-content {
  margin: 13px 18px;
}

.leaflet-popup-tip-container {
  overflow: hidden;
  position: absolute;
  left: 50%;
  margin-left: -20px;
  width: 40px;
  height: 20px;
}

.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  padding: 1px;
  margin: -10px auto 0;
  transform: rotate(45deg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.map-panel {
  height: 100vh;
  min-height: 100vh;
  position: sticky;
  top: 0;
  z-index: 0;
  overflow: hidden;
}

#map {
  height: 100vh;
  width: 100%;
  background: #dfe9e1;
}

.sidebar {
  position: relative;
  z-index: 2;
  max-height: 100vh;
  min-height: 100vh;
  overflow-y: auto;
  padding: 28px;
  background: var(--paper);
  border-left: 1px solid var(--line);
}

.masthead {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ridge);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2.45rem, 6vw, 4.2rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.lede {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.tools {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  margin: 22px 0;
}

.search-field,
.select-field,
.mobile-summit-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.mobile-summit-control {
  display: none;
  margin: 18px 0;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  padding: 0 12px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--panel);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--forest-dark) 50%),
    linear-gradient(135deg, var(--forest-dark) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  line-height: 1.2;
  padding-right: 38px;
}

select::-ms-expand {
  display: none;
}

input:focus,
select:focus {
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(47, 111, 145, 0.14);
}

.selected-peak {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.selected-heading h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.1;
}

.facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 18px 0 0;
}

.facts div {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 14px;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-weight: 700;
}

.notes {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--forest-dark);
  background: #f9fbf9;
  font-weight: 800;
  text-decoration: none;
}

.button.primary {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

.trailhead-section {
  margin-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.trailhead-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trailhead-card button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  text-align: left;
  font: inherit;
}

.trailhead-card button:hover,
.trailhead-card button:focus-visible {
  border-color: var(--lake);
  background: #f2f7f9;
  outline: none;
}

.trailhead-card.active button {
  border-color: var(--sun);
  box-shadow: 0 0 0 3px rgba(217, 144, 54, 0.18);
}

.trailhead-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--lake);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.trailhead-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 850;
  line-height: 1.25;
}

.trailhead-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.25;
}

.peak-list {
  display: grid;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.peak-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.peak-card button {
  width: 100%;
  min-height: 82px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  text-align: left;
  font: inherit;
}

.rank {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #eef3ef;
  color: var(--forest-dark);
  font-weight: 900;
}

.peak-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.peak-name {
  font-weight: 900;
  line-height: 1.25;
}

.peak-elevation {
  color: var(--ridge);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.peak-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.peak-card.active {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(31, 111, 74, 0.14);
}

.peak-card button:hover,
.peak-card button:focus-visible {
  background: #f2f6f1;
  outline: none;
}

.pin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  background: var(--forest);
  color: #fff;
  box-shadow: 0 8px 20px rgba(18, 69, 46, 0.38);
}

.pin span {
  transform: rotate(45deg);
  font-size: 0.72rem;
  font-weight: 900;
}

.pin.selected {
  background: var(--sun);
  color: #22180d;
}

.pin.related {
  background: #efbe74;
  color: #22180d;
}

.trailhead-pin {
  width: 30px;
  height: 30px;
  background: var(--lake);
  color: #fff;
}

.trailhead-pin.selected {
  background: var(--sun);
  color: #22180d;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.popup {
  min-width: 220px;
}

.popup h3 {
  margin: 0 0 8px;
}

.popup p {
  margin: 5px 0;
}

.popup a {
  color: var(--forest-dark);
  font-weight: 800;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .map-panel {
    height: 54vh;
    min-height: 54vh;
    position: relative;
  }

  #map {
    height: 54vh;
  }

  .sidebar {
    max-height: none;
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 22px;
  }

  .tools {
    display: none;
  }

  .mobile-summit-control {
    display: grid;
  }

  .mobile-summit-control select {
    min-height: 48px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 750;
  }
}

@media (max-width: 520px) {
  .actions,
  .peak-title {
    grid-template-columns: 1fr;
  }

  .peak-title {
    display: grid;
    gap: 2px;
  }

  .facts div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  h1 {
    font-size: 3rem;
  }
}
