.trip-map {
  --map-paper: var(--bg, #faf7f0);
  --map-ink: var(--text, #302d29);
  --map-ochre: var(--accent, #956320);
  position: relative;
  isolation: isolate;
  background: var(--map-paper);
  color: var(--map-ink);
  margin: 0 auto 24px;
  max-width: 960px;
}
.trip-map[hidden] {
  display: none !important;
}
.trip-map-canvas {
  position: relative;
  height: 52vh;
  min-height: 300px;
  max-height: 520px;
  background: var(--panel);
  z-index: 0;
}
.trip-map-toolbar {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.trip-map-toolbar > * {
  pointer-events: auto;
}
.trip-map button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-height: 44px;
}
.trip-map-toolbar button,
.trip-map-collapse {
  padding: 8px 16px;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  background: var(--map-paper);
}
.trip-map-sheet {
  position: relative;
  z-index: 501;
  background: var(--map-paper);
  padding: 20px 24px 24px;
  margin-top: -12px;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--hairline);
}
.trip-map-sheet:before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--hairline);
  margin: -12px auto 16px;
}
.trip-map h2 {
  font-family: var(--heading-font);
  font-size: 26px;
  font-weight: 400;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
.trip-map-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hairline);
}
.trip-map-row img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 5px;
}
.trip-map-number {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--map-ochre);
  color: var(--bg, #fff);
  font-family: var(--heading-font);
}
.trip-map-row-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.trip-map-row-copy strong {
  font-family: var(--heading-font);
  font-size: 21px;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.trip-map-row small,
.trip-map-time,
.trip-map-meta,
.trip-map-city-approx {
  color: var(--meta);
}
.trip-map-chevron {
  color: var(--map-ochre);
  font-size: 24px;
}
.trip-map-status {
  font-size: 12px;
  color: var(--meta);
  padding: 12px 24px;
  margin: 0;
  position: relative;
  background: var(--map-paper);
}
.trip-map-status:empty {
  display: none;
}
.trip-map-legend {
  padding: 12px 24px;
  margin: 0;
  font-size: 12px;
  color: var(--meta);
  border-top: 1px solid var(--hairline);
}
.trip-map-gallery {
  display: flex;
  overflow: auto;
  gap: 8px;
  margin-bottom: 16px;
  scroll-snap-type: x mandatory;
}
.trip-map-gallery button {
  padding: 0;
  border: 0;
  background: transparent;
  flex: 0 0 100%;
  scroll-snap-align: start;
}
.trip-map-gallery img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.trip-map-jump {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--map-ochre);
  padding: 8px 0;
  color: var(--map-ochre) !important;
}
.trip-map-collapse {
  float: right;
}
.trip-map-pin {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  color: #302d29;
  font-family: var(--heading-font);
  font-size: 15px;
}
.trip-map-pin b {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  background: #956320;
  color: #fffaf2;
  border: 2px solid #fffaf2;
  border-radius: 50%;

  font: 700 15px sans-serif;
}
.trip-map-pin > span {
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 250, 242, 0.91);
}
.trip-map-marker.is-muted {
  opacity: 1;
}
.trip-map-arrow {
  display: block;
  font: 24px serif;
  color: var(--map-ochre);
}
.trip-map .leaflet-control-attribution {
  font-size: 10px !important;
}
.trip-map .leaflet-control-zoom {
  margin-top: 72px !important;
}
.map-photo-viewer {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
  max-width: min(96vw, 1000px);
  max-height: 94vh;
  padding: 20px;
}
.map-photo-viewer::backdrop {
  background: rgba(0, 0, 0, 0.8);
}
.map-photo-viewer img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
}
.map-photo-close {
  display: block;
  margin: 0 0 12px auto;
}
.map-photo-viewer p {
  overflow-wrap: anywhere;
}
.trip-map button:hover {
  filter: brightness(0.96);
}
.trip-map :focus-visible {
  outline: 2px solid var(--map-ochre);
  outline-offset: 3px;
}
@media (max-width: 600px) {
  .trip-map-sheet {
    padding: 20px 16px 24px;
  }
  .trip-map-toolbar {
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
  }
  .trip-map-gallery img {
    height: 210px;
  }
  .trip-map-row img {
    width: 64px;
    height: 54px;
  }
  .trip-map-row {
    gap: 8px;
  }
  .trip-map-canvas {
    height: 49vh;
  }
  .trip-map h2 {
    font-size: 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .trip-map * {
    scroll-behavior: auto !important;
  }
}
:root[data-mode="dark"] .trip-map .leaflet-control-attribution {
  background: var(--panel);
  color: var(--text);
}
:root[data-mode="dark"] .trip-map .leaflet-control-attribution a {
  color: var(--accent);
}
:root[data-mode="dark"] .trip-map .leaflet-control-zoom a {
  background: var(--panel);
  color: var(--text);
  border-color: var(--hairline);
}
/* Keep the provider credit inside the unobscured map at every viewport. */
.trip-map-sheet {
  margin-top: 0;
}
.trip-map .leaflet-control-attribution {
  padding: 3px 6px !important;
  background: rgba(255, 250, 242, 0.96);
  color: #302d29;
  line-height: 1.5;
}
@media (min-width: 1000px) {
  .trip-map {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
  }
  .trip-map-canvas {
    grid-column: 1;
    grid-row: 1;
    height: clamp(520px, 64vh, 680px);
    min-height: 0;
    max-height: none;
  }
  .trip-map-toolbar {
    right: auto;
    width: calc(66.666% - 32px);
  }
  .trip-map-sheet {
    grid-column: 2;
    grid-row: 1;
    height: clamp(520px, 64vh, 680px);
    max-height: clamp(520px, 64vh, 680px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    border-radius: 0;
    border-top: 0;
    border-left: 1px solid var(--hairline);
    padding: 24px 20px;
    box-sizing: border-box;
  }
  .trip-map-sheet:before {
    display: none;
  }
  .trip-map-legend {
    grid-column: 1;
    grid-row: 2;
    padding: 12px 16px;
  }
  .trip-map-status {
    grid-column: 2;
    grid-row: 2;
    border-top: 1px solid var(--hairline);
    padding: 12px 20px;
  }
  .trip-map-row img {
    width: 60px;
    height: 52px;
  }
  .trip-map-row {
    gap: 8px;
  }
  .trip-map-row-copy strong {
    font-size: 19px;
  }
  .trip-map-gallery img {
    height: 200px;
  }
}
/* Route strokes follow the journal accent immediately when its theme changes. */
.trip-map .leaflet-overlay-pane path {
  stroke: var(--map-ochre);
}

/* Open the city as a journal page beneath the persistent view dock. */
.trip-map-canvas {
  touch-action: none;
  overscroll-behavior: contain;
}
.trip-map.is-city {
  position: fixed;
  inset: 0 0 84px;
  width: 100%;
  max-width: none;
  margin: 0;
  z-index: 800;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(220px, 46%) minmax(0, 1fr) auto auto;
  overflow: hidden;
}
.trip-map.is-city .trip-map-toolbar {
  position: relative;
  inset: auto;
  width: auto;
  grid-row: 1;
  grid-column: 1;
  padding: 12px 16px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--map-paper);
}
.trip-map-city-title {
  font-family: var(--heading-font);
  font-size: 22px;
  font-weight: 400;
}
.trip-map.is-city .trip-map-canvas {
  grid-column: 1;
  grid-row: 2;
  height: 100%;
  min-height: 0;
  max-height: none;
}
.trip-map.is-city .trip-map-sheet {
  grid-column: 1;
  grid-row: 3;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  box-sizing: border-box;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-radius: 0;
  margin: 0;
  padding: 20px 16px;
}
.trip-map.is-city .trip-map-sheet:before {
  display: none;
}
.trip-map.is-city .trip-map-status {
  grid-column: 1;
  grid-row: 4;
}
.trip-map.is-city .trip-map-legend {
  grid-column: 1;
  grid-row: 5;
  padding: 8px 16px;
}
.trip-map-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: visible;
  gap: 12px;
  scroll-snap-type: none;
}
.trip-map-gallery button {
  min-width: 0;
  text-align: left;
}
.trip-map-gallery img {
  height: auto;
  aspect-ratio: 4 / 3;
}
.trip-map-photo span {
  display: block;
  font-size: 12px;
  padding: 6px 0;
  color: var(--meta);
  overflow-wrap: anywhere;
}
.trip-map-city-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 0 0 20px;
  margin-bottom: 20px;
}
.trip-map .trip-map-city-card img {
  grid-column: 1 / -1;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}
.trip-map .leaflet-control-zoom a {
  background: var(--map-paper);
  color: var(--map-ink);
  border-color: var(--hairline);
}
.trip-map.is-city .leaflet-control-zoom {
  margin-top: 16px !important;
}
@media (min-width: 1000px) {
  .trip-map.is-city {
    inset: 24px max(24px, calc((100vw - 1440px) / 2)) 96px;
    width: auto;
    grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    border: 1px solid var(--hairline);
    border-radius: 16px;
  }
  .trip-map.is-city .trip-map-toolbar {
    grid-column: 1 / -1;
  }
  .trip-map.is-city .trip-map-canvas {
    grid-column: 1;
    grid-row: 2;
  }
  .trip-map.is-city .trip-map-sheet {
    grid-column: 2;
    grid-row: 2;
    padding: 24px;
  }
  .trip-map.is-city .trip-map-legend {
    grid-column: 1;
    grid-row: 3;
  }
  .trip-map.is-city .trip-map-status {
    grid-column: 2;
    grid-row: 3;
  }
}
/* A city number stays on its true center; only its text occupies collision-free space. */
.trip-map-city-pin {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
}
.trip-map-city-pin b {
  position: relative;
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  z-index: 2;
}
.trip-map-city-pin > span {
  position: absolute;
  display: block;
  box-sizing: border-box;
  z-index: 3;
  white-space: normal;
  width: max-content;
  line-height: 22px;
}
.trip-map-label-leader {
  position: absolute;
  height: 1px;
  left: 16px;
  top: 16px;
  background: var(--map-ochre);
  opacity: 0.7;
  transform-origin: left center;
  pointer-events: none;
  z-index: 1;
}

.trip-map-city-approx {
  font-size: 12px;
  line-height: 1.6;
  margin: -8px 0 16px;
}

/* Counts stay on the authorized center; labels leave the basemap visible. */
.trip-map-count-pin { position: relative; width: 44px; height: 44px; }
.trip-map-count-pin > b { position: relative; z-index: 2; min-width: 44px; height: 44px; box-sizing: border-box; background: var(--map-ochre); color: var(--map-paper); border-color: var(--map-paper); }
.trip-map-count-pin > span { position: absolute; z-index: 3; top: 48px; left: 50%; transform: translateX(-50%); max-width: 146px; overflow: hidden; text-overflow: ellipsis; background: var(--map-paper); color: var(--map-ink); font-size: 13px; line-height: 18px; }
.trip-map-marker.is-selected { z-index: 900 !important; }
.trip-map-marker.is-selected .trip-map-count-pin > b { outline: 3px solid var(--map-ochre); outline-offset: 3px; }
.trip-map-back-places,
.trip-map-show-more {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 16px;
}
.trip-map-panel-toggle {
  margin-left: auto;
  font-size: 12px !important;
  padding: 8px 12px !important;
}
.trip-map-sheet:before {
  display: none;
}
.trip-map-photo small {
  display: block;
  padding-top: 6px;
  color: var(--meta);
}
.trip-map.is-city.is-panel-expanded {
  grid-template-rows: auto minmax(100px, 25%) minmax(0, 1fr) auto auto;
}
@media (min-width: 1000px) {
  .trip-map.is-city.is-panel-expanded {
    grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
}
/* Only the city workspace owns vertical page gestures. */
.trip-map:not(.is-city) .trip-map-canvas {
  touch-action: pan-y;
  overscroll-behavior: auto;
}

.trip-map-map-toggle { display: none; }
.trip-map-place-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.trip-map-place-heading h3 { font: 400 20px/1.3 var(--heading-font); margin: 0; overflow-wrap: anywhere; }
.trip-map-place-heading .trip-map-back-places { flex: 0 0 44px; width: 44px; padding: 0; margin: 0; }
.trip-map-city-approx { margin: 0 0 10px; line-height: 1.4; }
@media (max-width: 999px) {
  .trip-map-canvas { height: clamp(280px, calc(100svh - 280px), 900px); height: clamp(280px, calc(100dvh - 280px), 900px); min-height: 0; max-height: none; }
  .trip-map.is-city { inset: 0; height: 100svh; height: 100dvh; grid-template-rows: auto clamp(140px, 25dvh, 180px) minmax(0, 1fr); }
  .trip-map.is-city .trip-map-toolbar { padding: 8px 12px; gap: 4px 8px; }
  .trip-map.is-city .trip-map-city-title { font-size: 20px; flex: 1; }
  .trip-map.is-city .trip-map-toolbar > button { padding: 6px 10px; }
  .trip-map.is-city .trip-map-panel-toggle { display: none; }
  .trip-map.is-city .trip-map-map-toggle { display: block; font-size: 12px; }
  .trip-map.is-city .trip-map-sheet { padding: 12px 16px; }
  .trip-map.is-city .trip-map-status, .trip-map.is-city .trip-map-legend { padding: 8px 0; }
  .trip-map.is-city.is-place .trip-map-legend { display: none; }
  .trip-map.is-city .trip-map-gallery { grid-template-columns: minmax(0, 1fr); }
}
/* Overview controls sit in page flow so they cannot cover city counts. */
.trip-map:not(.is-city) .trip-map-toolbar {
  position: relative;
  inset: auto;
  width: auto;
  padding: 8px 16px;
}
@media (min-width: 1000px) {
  .trip-map:not(.is-city) .trip-map-toolbar { grid-column: 1; grid-row: 2; }
  .trip-map:not(.is-city) .trip-map-legend { grid-row: 3; }
}
/* The overview is a map; city/place photos open only after selecting a marker. */
.trip-map:not(.is-city) .trip-map-sheet { display: none; }
.trip-map:not(.is-city) .trip-map-canvas { touch-action: none; overscroll-behavior: contain; border-radius: 16px; }
.trip-map:not(.is-city) .trip-map-status { padding: 0 16px; }
.trip-map:not(.is-city) .trip-map-legend { padding: 0 16px 8px; }
@media (min-width: 1000px) {
  .trip-map:not(.is-city) { display: block; max-width: 1200px; }
  .trip-map:not(.is-city) .trip-map-canvas { height: clamp(420px, calc(100dvh - 240px), 900px); }
}

/* The map owns the viewport from overview through the selected place. */
.trip-map.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  display: block;
  overflow: hidden;
  z-index: 1000;
  border: 0;
  border-radius: 0;
}
.trip-map.is-fullscreen .trip-map-canvas {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
  border-radius: 0;
  touch-action: none;
}
.trip-map.is-fullscreen .trip-map-toolbar {
  position: absolute;
  inset: calc(12px + env(safe-area-inset-top, 0px)) 12px auto;
  width: auto;
  padding: 0;
  background: transparent;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.trip-map.is-fullscreen .trip-map-city-title {
  flex: 0 1 auto;
  max-width: min(240px, 40vw);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--map-paper);
  padding: 8px 12px;
  border-radius: 24px;
  font-size: 18px;
}
.trip-map.is-fullscreen .trip-map-sheet { display: none; }
.trip-map.is-fullscreen.is-place .trip-map-sheet {
  display: block;
  position: absolute;
  inset: auto 0 0;
  height: 70%;
  max-height: none;
  padding: 16px;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--hairline);
}
.trip-map.is-fullscreen.is-place .trip-map-canvas { bottom: 70%; height: 30%; }
.trip-map.is-fullscreen .trip-map-status { display: none; }
.trip-map.is-fullscreen > .trip-map-legend { position: absolute; left: 12px; bottom: 24px; z-index: 500; max-width: calc(100% - 100px); padding: 4px 8px; background: var(--map-paper); border: 0; border-radius: 8px; font-size: 11px; }
.trip-map.is-fullscreen .trip-map-sheet .trip-map-legend { display: block; padding: 8px 0; }
.trip-map.is-fullscreen.is-place .trip-map-toolbar { flex-wrap: nowrap; gap: 4px; }
.trip-map.is-fullscreen.is-place .trip-map-city-title { flex: 0 1 auto; max-width: min(240px, 40vw); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 8px; }
.trip-map.is-fullscreen.is-place .trip-map-toolbar > button { flex: 0 0 auto; font-size: 12px; padding: 8px; }
.trip-map.is-fullscreen .trip-map-sheet .trip-map-status { display: block; }
.trip-map.is-fullscreen .trip-map-place-heading .trip-map-back-places { width: auto; padding: 8px; flex-basis: auto; font-size: 12px; }
.trip-map.is-fullscreen .leaflet-control-zoom { margin: 0 12px 28px 0 !important; }
@media (min-width: 1000px) {
  .trip-map.is-fullscreen.is-place .trip-map-sheet { inset: 0 0 0 auto; width: 400px; height: 100%; border-radius: 0; }
  .trip-map.is-fullscreen.is-place .trip-map-canvas { inset: 0 400px 0 0; height: 100%; }
  .trip-map.is-fullscreen.is-place .trip-map-toolbar { right: 412px; }
  .trip-map.is-fullscreen .trip-map-gallery { grid-template-columns: minmax(0, 1fr); }
}
body:has(.trip-map.is-fullscreen:not([hidden])) .trip-masthead,
body:has(.trip-map.is-fullscreen:not([hidden])) .trip-view-nav { display: none; }
body:has(.trip-map.is-fullscreen:not([hidden])) > header.shell,
body:has(.trip-map.is-fullscreen:not([hidden])) .share-bar,
body:has(.trip-map.is-fullscreen:not([hidden])) .share-invite { display: none; }

.trip-map.is-fullscreen .trip-map-place-heading {
  position: sticky;
  top: 0;
  background: var(--map-paper);
  z-index: 2;
  padding: 4px 0 8px;
}

.trip-map.is-fullscreen .trip-map-exit { margin-left: auto; }

/* Journey visits remain available through city and photo focus. */
.trip-map.is-fullscreen .trip-map-journey {
  position: absolute;
  z-index: 600;
  top: calc(72px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overscroll-behavior: contain;
  padding: 4px;
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  background: var(--map-paper);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  scrollbar-width: none;
}
.trip-map-journey-city {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--map-ink);
  white-space: nowrap;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.trip-map-journey-city[data-connected="true"]:before { content: "›"; margin-right: 10px; color: var(--meta); }
.trip-map-journey-city[aria-pressed="true"] { color: var(--map-ochre); background: color-mix(in srgb, var(--map-ochre) 12%, var(--map-paper)); box-shadow: inset 0 -2px var(--map-ochre); }
.trip-map-marker.is-background .trip-map-pin > b { background: var(--map-paper); color: var(--map-ochre); border-color: var(--map-ochre); }
.trip-map-count-pin > b { padding: 0 3px; font-size: 12px; }
@media (min-width: 1000px) {
  .trip-map.is-fullscreen.is-place .trip-map-journey { right: 412px; }
}

.trip-map.is-fullscreen .trip-map-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0;
  min-height: 48px;
  background: var(--map-paper);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-city-title { grid-column: 2; max-width: 100%; }
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-exit { grid-column: 1; grid-row: 1; margin-left: 0; }
.trip-map.is-fullscreen:not(.is-city) .trip-map-toolbar > button:not(.trip-map-exit) { grid-column: 1; grid-row: 1; }
/* In photo mode the journey sits in the sheet, freeing the short map for its pin. */
.trip-map.is-fullscreen .trip-map-sheet > .trip-map-journey {
  position: sticky;
  top: -16px;
  inset-inline: auto;
  margin: -4px 0 12px;
  padding: 4px 0 8px;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: none;
  background: var(--map-paper);
}
.trip-map.is-fullscreen .trip-map-sheet > .trip-map-journey + .trip-map-place-heading { top: 41px; }

/* Quiet map chrome inherits both journal palettes; route order carries the emphasis. */
.trip-map.is-fullscreen .trip-map-toolbar > button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 8px 12px;
  min-height: 48px;
  font-size: 13px;
}
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-city-title {
  background: transparent;
  border-radius: 0;
  text-align: center;
  padding: 8px 4px;
  font: 500 20px/1.4 var(--heading-font);
}
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-exit {
  border-left: 1px solid var(--hairline);
  border-radius: 0 16px 16px 0;
}
.trip-map.is-fullscreen.is-place .trip-map-sheet {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 32px rgb(0 0 0 / 0.12);
}
.trip-map.is-fullscreen .trip-map-place-heading { gap: 12px; padding-bottom: 12px; }
.trip-map.is-fullscreen .trip-map-place-heading h3 { font-size: 22px; line-height: 1.4; flex: 1; }
.trip-map.is-fullscreen .trip-map-place-heading .trip-map-back-places {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  min-height: 44px;
}
.trip-map.is-fullscreen .trip-map-city-approx { font-size: 12px; line-height: 1.7; margin-bottom: 12px; }
.trip-map.is-fullscreen .trip-map-gallery { gap: 24px; margin-top: 16px; }
.trip-map.is-fullscreen .trip-map-photo img { border-radius: 12px; }
.trip-map.is-fullscreen .trip-map-photo span { font-size: 14px; line-height: 1.65; padding-top: 4px; }
.trip-map.is-fullscreen .trip-map-photo small { font-size: 12px; padding-top: 10px; }
.trip-map.is-fullscreen .trip-map-pin { color: var(--map-ink); }
.trip-map.is-fullscreen .trip-map-pin > span { background: var(--map-paper); color: var(--map-ink); border: 1px solid var(--hairline); border-radius: 8px; padding: 3px 8px; }
.trip-map.is-fullscreen > .trip-map-legend { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1000px) {
  .trip-map.is-fullscreen .trip-map-toolbar { max-width: 460px; }
  .trip-map.is-fullscreen.is-place .trip-map-sheet { border-radius: 24px 0 0 24px; padding: 20px 24px; }
  .trip-map.is-fullscreen .trip-map-sheet > .trip-map-journey { top: -20px; }
  .trip-map.is-fullscreen .trip-map-sheet > .trip-map-journey + .trip-map-place-heading { top: 37px; }
}

/* Stable journal return; selection uses the same ink across route and map. */
.trip-map.is-fullscreen .trip-map-toolbar {
  grid-template-columns: auto minmax(0, 1fr);
  width: max-content;
  max-width: calc(100% - 24px);
}
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-exit {
  grid-column: 1;
  grid-row: 1;
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-left: 0;
  border-radius: 16px;
  white-space: nowrap;
}
.trip-map.is-fullscreen .trip-map-toolbar > .trip-map-city-title {
  grid-column: 2;
  padding: 8px 16px 8px 8px;
}
.trip-map-journey-city[aria-pressed="true"] {
  color: var(--map-paper);
  background: var(--map-ochre);
  box-shadow: none;
}
.trip-map-journey-city[aria-pressed="true"]:before { color: inherit; }
.trip-map-count-pin > b {
  background: var(--map-paper);
  color: var(--map-ochre);
  border-color: var(--map-ochre);
  font-size: 14px;
}
.trip-map-marker.is-selected .trip-map-count-pin > b {
  background: var(--map-ochre);
  color: var(--map-paper);
  border-color: var(--map-ochre);
  outline: none;
}
.trip-map .trip-map-back-places,
.map-photo-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.trip-map.is-fullscreen .trip-map-place-heading .trip-map-back-places { flex: 0 0 44px; border: 0; border-radius: 50%; }
.map-photo-close { display: flex; margin-left: auto; }
.trip-map-place-heading h3 { min-width: 0; }
.trip-map-exit svg,
.trip-map-back-places svg,
.map-photo-close svg { flex-shrink: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .trip-map .trip-map-back-places:hover,
  .map-photo-close:hover { background: var(--hairline); }
  .trip-map-exit:hover { background: var(--panel); }
}
.trip-map-journey-city:active,
.trip-map-back-places:active,
.map-photo-close:active { opacity: .75; }

/* A viewport-sized photo stage keeps controls and captions out of the image. */
.map-photo-viewer {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  margin: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
  gap: 12px;
  overflow: hidden;
  background: var(--bg);
}
.map-photo-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.map-viewer-toolbar { display: flex; align-items: center; gap: 12px; min-width: 0; }
.map-viewer-toolbar strong { font: 400 18px var(--heading-font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-viewer-count { margin-left: auto; color: var(--meta); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-photo-viewer .map-photo-close { flex: 0 0 44px; margin: 0; border: 0; border-radius: 50%; background: var(--panel); }
.map-viewer-stage { position: relative; display: grid; place-items: center; min-height: 0; min-width: 0; touch-action: pan-y pinch-zoom; }
.map-photo-viewer .map-viewer-stage img { width: 100%; height: 100%; max-height: 100%; min-height: 0; object-fit: contain; grid-area: 1 / 1; }
.map-viewer-status { position: absolute; bottom: 12px; color: var(--meta); background: var(--bg); padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.map-viewer-status:empty { display: none; }
.map-photo-viewer .map-viewer-caption { margin: 0 auto; width: 100%; max-width: 720px; max-height: min(20dvh, 140px); overflow: auto; overscroll-behavior: contain; white-space: pre-wrap; font-size: 14px; line-height: 1.7; color: var(--meta); }
.map-photo-viewer .map-viewer-previous,
.map-photo-viewer .map-viewer-next { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--hairline); border-radius: 50%; background: var(--bg); box-shadow: 0 2px 12px rgb(0 0 0 / .12); }
.map-viewer-previous { left: 0; }
.map-viewer-next { right: 0; }
.map-photo-viewer button[hidden], .map-photo-viewer p[hidden] { display: none; }
.map-photo-viewer button:disabled { opacity: .35; }
@media (min-width: 1000px) { .map-photo-viewer { padding-inline: 32px; gap: 16px; } }
.map-photo-viewer .map-viewer-retry { position: absolute; top: 50%; padding: 8px 20px; border-radius: 24px; background: var(--bg); }

/* Keep the improved projected route arrows while restoring the full canvas. */
.trip-map-direction { background: transparent; border: 0; pointer-events: none; }
.trip-map-arrow { display: block; width: 18px; height: 18px; line-height: 0; transform-origin: center; color: var(--map-ochre); }
.trip-map.is-fullscreen > .trip-map-status:not(:empty) {
  display: block; position: absolute; inset: auto auto 64px 12px; z-index: 500;
  max-width: min(440px, calc(100% - 84px)); margin: 0; padding: 8px 12px;
  border: 1px solid var(--hairline); border-radius: 8px;
  background: var(--map-paper); color: var(--meta); font-size: 12px;
  pointer-events: none;
}
.trip-map.is-fullscreen .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
