:root {
  color-scheme: light;
  --ink: #172724;
  --muted: #66736f;
  --paper: #f7f4ec;
  --panel: #fffdf7;
  --line: #ded6c7;
  --teal: #0b7a75;
  --teal-deep: #064d4b;
  --gold: #b88a2b;
  --gold-soft: #e8cf94;
  --shadow: 0 18px 42px rgba(23, 39, 36, 0.16);
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.viewer-open { overflow: hidden; }

button,
a { font: inherit; }

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

.map-pane {
  min-width: 0;
  position: relative;
  background: #dfe8df;
}

#map {
  height: 100%;
  width: 100%;
}

.map-badge {
  position: absolute;
  left: 22px;
  top: 22px;
  z-index: 500;
  padding: 11px 13px;
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid rgba(184, 138, 43, 0.36);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}

.badge-kicker,
.eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.map-badge strong {
  color: var(--teal-deep);
  font-size: 1.05rem;
}

.map-legend {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 500;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid rgba(222, 214, 199, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 750;
}

.map-tools {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 520;
  display: grid;
  gap: 8px;
  max-width: min(340px, calc(100% - 36px));
}

.mode-actions,
.layer-actions,
.panel-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-actions,
.layer-actions {
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid rgba(222, 214, 199, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.mode-actions button,
.panel-actions button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-deep);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  min-height: 38px;
  padding: 7px 10px;
}

.mode-actions button.is-active,
.panel-actions button.is-active {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #fff;
}

.layer-actions {
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 750;
}

.layer-actions label {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-height: 32px;
  white-space: nowrap;
}

.layer-actions input { accent-color: var(--teal); }

.map-legend span {
  align-items: center;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.map-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 4px;
  width: 34px;
}

.legend-recorded { background: #d18a00; }

.legend-camp { background: var(--teal-deep); }

.legend-planned {
  background: repeating-linear-gradient(90deg, var(--teal), var(--teal) 6px, transparent 6px, transparent 12px);
  border: 1px solid rgba(11, 122, 117, 0.24);
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.brand-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 14px;
}

h1,
h2,
p { margin: 0; }

h1 {
  color: var(--teal-deep);
  font-size: 1.85rem;
  line-height: 1.05;
}

h2 {
  color: var(--teal-deep);
  font-size: 1.05rem;
  line-height: 1.2;
}

.mark {
  align-items: center;
  aspect-ratio: 1;
  background: var(--teal);
  border: 2px solid var(--gold-soft);
  border-radius: 50%;
  color: #fffdf7;
  display: grid;
  flex: 0 0 44px;
  font-size: 1.3rem;
  font-weight: 800;
  place-items: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 22px 14px;
}

.panel-actions {
  padding: 0 22px 14px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbf8ef;
}

.stat strong {
  display: block;
  color: var(--teal-deep);
  font-size: 1.22rem;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  margin-top: 4px;
  white-space: nowrap;
}

.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 22px 16px;
  scrollbar-color: var(--gold-soft) transparent;
}

.day-button {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 82px;
  min-height: 58px;
  padding: 8px;
  text-align: left;
}

.day-button strong,
.day-button span { display: block; }

.day-button strong {
  color: var(--teal-deep);
  font-size: 0.82rem;
}

.day-button span {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 5px;
}

.day-button.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.day-button.is-active strong,
.day-button.is-active span { color: #fff; }

.focus-card {
  border-block: 1px solid var(--line);
  display: grid;
  grid-template-columns: 128px 1fr;
  min-height: 132px;
  background: #f8f3e8;
}

.focus-card img {
  cursor: pointer;
  height: 100%;
  min-height: 132px;
  object-fit: cover;
  width: 128px;
}

.focus-copy {
  min-width: 0;
  padding: 14px;
}

#focusDay,
#focusMeta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

#focusTitle {
  margin: 4px 0 8px;
  overflow-wrap: anywhere;
}

.focus-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.focus-actions a,
.focus-actions button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-deep);
  cursor: pointer;
  display: inline-flex;
  min-height: 44px;
  padding: 7px 10px;
  text-decoration: none;
}

.focus-actions a {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #fff;
}

.gallery-head {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 18px 22px 12px;
}

#galleryCount {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.gallery {
  align-content: start;
  display: grid;
  flex: 1 1 auto;
  gap: 12px;
  grid-auto-rows: max-content;
  grid-template-columns: 1fr;
  min-height: 0;
  overscroll-behavior: contain;
  overflow-y: auto;
  padding: 0 22px 22px;
}

.tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.tile img {
  background: #e8e2d5;
  display: block;
  flex: 0 0 178px;
  height: 178px;
  object-fit: cover;
  width: 100%;
}

.tile-copy {
  display: block;
  min-width: 0;
  padding: 8px;
}

.tile-copy strong {
  color: var(--teal-deep);
  display: block;
  font-size: 0.78rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-copy span {
  color: var(--muted);
  display: block;
  font-size: 0.68rem;
  margin-top: 4px;
}

.media-marker {
  align-items: center;
  background: var(--teal);
  border: 2px solid #fffdf7;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  color: #fff;
  display: grid;
  font-size: 11px;
  font-weight: 800;
  height: 24px;
  place-items: center;
  width: 24px;
}

.media-marker.video { background: var(--gold); }

.waypoint-marker {
  align-items: center;
  background: #fffdf7;
  border: 2px solid var(--teal-deep);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  color: var(--teal-deep);
  display: grid;
  font-size: 12px;
  font-weight: 900;
  height: 28px;
  place-items: center;
  width: 28px;
}

.waypoint-marker.camp {
  background: var(--teal-deep);
  border-color: #fffdf7;
  color: #fff;
}

.waypoint-marker.summit {
  background: var(--gold);
  border-color: #fffdf7;
  color: #172724;
}

.waypoint-marker.gate {
  background: #fffdf7;
  border-color: var(--gold);
  color: var(--teal-deep);
}

.day-anchor {
  background: #fffdf7;
  border: 2px solid var(--teal-deep);
  border-radius: 8px;
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
  white-space: nowrap;
}

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

.popup { min-width: 190px; }

.popup img {
  border-radius: 6px;
  display: block;
  max-height: 150px;
  object-fit: cover;
  width: 100%;
}

.popup strong {
  color: var(--teal-deep);
  display: block;
  margin-top: 8px;
}

.popup span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-top: 4px;
}

.waypoint-popup p {
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 7px;
}

.load-error {
  color: #9d2f2f;
  padding: 16px;
}

.viewer {
  display: none;
  inset: 0;
  position: fixed;
  z-index: 2000;
}

.viewer[aria-hidden="false"] {
  display: block;
}

.viewer-backdrop {
  background: rgba(12, 18, 17, 0.82);
  inset: 0;
  position: absolute;
}

.viewer-dialog {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  inset: 22px;
  overflow: hidden;
  position: absolute;
}

.viewer-close {
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-deep);
  cursor: pointer;
  min-height: 44px;
  padding: 9px 13px;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
}

.viewer-media {
  align-items: center;
  background: #111816;
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
  position: relative;
}

.viewer-media img {
  display: block;
  height: 100%;
  max-height: calc(100dvh - 160px);
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.viewer-nav {
  align-items: center;
  background: rgba(255, 253, 247, 0.76);
  border: 1px solid rgba(222, 214, 199, 0.62);
  border-radius: 999px;
  color: var(--teal-deep);
  cursor: pointer;
  display: grid;
  font-size: 2.1rem;
  font-weight: 500;
  height: 52px;
  line-height: 1;
  opacity: 0;
  place-items: center;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 160ms ease, background-color 160ms ease;
  width: 52px;
  z-index: 2;
}

.viewer-media:hover .viewer-nav:not(:disabled),
.viewer.controls-visible .viewer-nav:not(:disabled),
.viewer-nav:focus-visible {
  opacity: 0.82;
  pointer-events: auto;
}

.viewer-nav:hover,
.viewer-nav:focus-visible {
  background: rgba(255, 253, 247, 0.92);
}

.viewer-nav:disabled {
  cursor: default;
  opacity: 0;
}

.viewer-nav-prev { left: 16px; }

.viewer-nav-next { right: 16px; }
}

.viewer-copy {
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
}

#viewerMeta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

#viewerTitle {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.viewer-actions a {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-deep);
  display: inline-flex;
  justify-content: center;
  min-height: 46px;
  padding: 10px 14px;
  text-decoration: none;
}

.viewer-actions a:first-child {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #fff;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 48dvh 52dvh;
    height: 100dvh;
    min-height: 0;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .brand-row { padding-top: 16px; }
  h1 { font-size: 1.45rem; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .shell {
    grid-template-columns: minmax(0, 1fr) minmax(500px, 32vw);
  }

  .gallery {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile img {
    flex-basis: 132px;
    height: 132px;
  }

  .focus-card {
    grid-template-columns: 150px 1fr;
    min-height: 146px;
  }

  .focus-card img {
    min-height: 146px;
    width: 150px;
  }
}

@media (min-width: 1500px) {
  .shell {
    grid-template-columns: minmax(0, 1fr) 580px;
  }

  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tile img {
    flex-basis: 120px;
    height: 120px;
  }
}

body.mode-map-full .shell {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  min-height: 0;
}

body.mode-map-full .map-pane {
  height: 100dvh;
  min-height: 0;
}

body.mode-map-full .panel {
  display: none;
}

body.mode-photos-full .shell {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  min-height: 0;
}

body.mode-photos-full .map-pane {
  display: none;
}

body.mode-photos-full .panel {
  border-left: 0;
  height: 100dvh;
}

body.mode-photos-full .gallery {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 980px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 36vw);
    grid-template-rows: 1fr;
    height: 100dvh;
    min-height: 0;
  }

  .map-pane {
    height: 100dvh;
    min-height: 0;
  }

  .panel {
    border-left: 1px solid var(--line);
    border-top: 0;
    min-height: 0;
    overflow: hidden;
  }

  .map-badge {
    left: 10px;
    top: 10px;
    padding: 7px 9px;
  }

  .map-badge strong { font-size: 0.9rem; }
  .badge-kicker { font-size: 0.64rem; }
  .map-legend { display: none; }

  .map-tools {
    bottom: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    right: 10px;
    top: auto;
  }

  .mode-actions,
  .layer-actions {
    box-shadow: 0 10px 28px rgba(23, 39, 36, 0.14);
    justify-content: center;
    padding: 6px;
  }

  .mode-actions button {
    flex: 1 1 76px;
    min-height: 40px;
    padding: 6px 8px;
  }

  .layer-actions label {
    flex: 1 1 80px;
    justify-content: center;
    min-height: 30px;
  }

  .brand-row {
    padding: 10px 12px 8px;
  }

  h1 { font-size: 1.12rem; }
  h2 { font-size: 0.92rem; }
  .eyebrow { font-size: 0.62rem; }
  .mark,
  .stats { display: none; }

  .panel-actions,
  .day-strip,
  .gallery-head,
  .gallery {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel-actions {
    padding-bottom: 8px;
  }

  .panel-actions button {
    flex: 1 1 110px;
    min-height: 40px;
  }

  .day-strip {
    padding-bottom: 8px;
  }

  .day-button {
    flex-basis: 72px;
    min-height: 46px;
    padding: 6px;
  }

  .day-button strong { font-size: 0.72rem; }
  .day-button span { font-size: 0.62rem; }

  .focus-card {
    grid-template-columns: 82px 1fr;
    min-height: 82px;
  }

  .focus-card img {
    min-height: 82px;
    width: 82px;
  }

  .focus-copy { padding: 8px; }
  #focusTitle { margin: 2px 0 4px; }
  #focusDay,
  #focusMeta { font-size: 0.66rem; }
  .focus-actions { display: none; }

  .gallery-head {
    padding-bottom: 8px;
    padding-top: 10px;
  }

  .gallery {
    flex: 1 1 auto;
    gap: 8px;
    grid-template-columns: 1fr;
    overflow-y: auto;
    padding-bottom: 12px;
  }

  .tile {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .tile img {
    flex-basis: auto;
    height: 76px;
    width: 76px;
  }

  .tile-copy {
    min-width: 0;
    padding: 8px;
  }

  body.mode-map-full .shell {
    grid-template-columns: 1fr;
  }

  body.mode-map-full .map-pane {
    height: 100dvh;
  }

  body.mode-photos-full .shell {
    grid-template-columns: 1fr;
  }

  body.mode-photos-full .panel {
    height: 100dvh;
  }

  body.mode-photos-full .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.mode-photos-full .tile {
    display: flex;
  }

  body.mode-photos-full .tile img {
    flex-basis: 118px;
    height: 118px;
    width: 100%;
  }
}

@media (max-width: 620px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  .shell {
    display: block;
    height: auto;
    min-height: 0;
  }

  .map-pane {
    height: 48dvh;
    min-height: 320px;
  }

  .panel {
    min-height: 0;
    overflow: visible;
  }

  .map-badge {
    left: 12px;
    top: 12px;
    padding: 8px 10px;
  }

  .map-legend {
    display: none;
  }

  .map-tools {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    max-width: none;
  }

  .mode-actions,
  .layer-actions {
    justify-content: center;
    padding: 7px;
  }

  .mode-actions button {
    flex: 1 1 88px;
    min-height: 44px;
  }

  .layer-actions label {
    flex: 1 1 88px;
    justify-content: center;
  }

  .brand-row,
  .stats,
  .day-strip,
  .gallery-head,
  .gallery {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel-actions { padding: 0 14px 12px; }
  .panel-actions button {
    flex: 1 1 130px;
    min-height: 46px;
  }

  .brand-row {
    padding-bottom: 8px;
    padding-top: 12px;
  }
  .mark { display: none; }
  .stats { display: none; }
  .stat { padding: 8px; }
  .stat strong { font-size: 0.98rem; }
  .stat span {
    font-size: 0.62rem;
    line-height: 1.1;
    white-space: normal;
  }
  .day-strip { padding-bottom: 12px; }
  .day-button {
    flex-basis: 84px;
    min-height: 56px;
    padding: 7px;
  }
  .focus-card {
    grid-template-columns: 90px 1fr;
    min-height: 100px;
  }
  .focus-card img {
    min-height: 100px;
    width: 90px;
  }
  .focus-copy { padding: 10px; }
  .focus-actions { margin-top: 8px; }
  .focus-actions a,
  .focus-actions button {
    flex: 1 1 140px;
    justify-content: center;
    min-height: 48px;
    padding: 10px 12px;
  }
  .gallery-head { padding-top: 12px; }
  .gallery {
    flex: none;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .tile img {
    flex-basis: 136px;
    height: 136px;
  }

  .viewer-media img {
    max-height: calc(100dvh - 154px);
  }

  .viewer-nav {
    height: 46px;
    width: 46px;
  }

  .viewer-nav-prev { left: 10px; }

  .viewer-nav-next { right: 10px; }

  .viewer-dialog {
    border-radius: 0;
    inset: 0;
  }

  .viewer-copy {
    padding: 12px 14px 14px;
  }

  .viewer-actions a {
    flex: 1 1 140px;
    min-height: 50px;
  }

  .viewer-close {
    min-height: 48px;
    min-width: 72px;
    right: 10px;
    top: 10px;
  }

  body.mode-map-full .map-pane {
    height: 100dvh;
    min-height: 100dvh;
  }

  body.mode-photos-full .gallery {
    grid-template-columns: 1fr;
  }
}
