/* Explorer Atlas — dark lab theme (#060606 / zinc / sky-400 accent) by default,
   with an opt-in light theme. Every surface colour is a variable so the two
   themes stay in sync; the toggle stamps data-theme="light" on <html> and
   persists the choice (see script.js). Dark remains the default and the
   no-JS/no-preference fallback — it is the /tools house style. */

:root {
  color-scheme: dark;
  --bg: #060606;
  --surface: #101013;        /* popups, zoom control */
  --surface-2: #0c0c0e;      /* media wells behind images */
  --map-bg: #0a0a0b;         /* leaflet canvas + journal */
  --panel: rgba(24, 24, 27, 0.4);
  --panel-hi: rgba(24, 24, 27, 0.7);
  --border: rgba(63, 63, 70, 0.6);
  --border-soft: rgba(39, 39, 42, 0.7);
  --border-hi: #52525b;      /* hover/focus borders */
  --scroll: #27272a;
  --scroll-hi: #3f3f46;
  --fg: #f4f4f5;
  --fg-2: #d4d4d8;
  --fg-3: #a1a1aa;
  --fg-4: #71717a;
  --accent: #38bdf8;
  --on-accent: #060606;      /* text sitting on an accent fill */
  --code: #a5b4fc;
  --attrib-bg: rgba(6, 6, 6, 0.7);
  /* RGB triplets, not colours: the frosted-glass panels each use their own
     alpha, so theming the triplet keeps every existing opacity intact.
     Usage: rgba(var(--glass-rgb), 0.78). */
  --glass-rgb: 9, 9, 11;        /* near-black panel glass */
  --hairline-rgb: 255, 255, 255; /* barely-there highlight strokes */
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --map-bg: #e9e9ec;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-hi: rgba(255, 255, 255, 0.96);
  --border: rgba(161, 161, 170, 0.42);
  --border-soft: rgba(212, 212, 216, 0.9);
  --border-hi: #a1a1aa;
  --scroll: #d4d4d8;
  --scroll-hi: #a1a1aa;
  --fg: #18181b;
  --fg-2: #3f3f46;
  --fg-3: #52525b;
  --fg-4: #71717a;
  --accent: #0284c7;         /* sky-600: sky-400 fails contrast on white */
  --on-accent: #ffffff;
  --code: #4338ca;
  --attrib-bg: rgba(255, 255, 255, 0.78);
  --glass-rgb: 255, 255, 255;
  --hairline-rgb: 24, 24, 27;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
code { font-family: var(--mono); font-size: 0.86em; color: var(--code); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 33%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hi); }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ============ dashboard ============ */

.dash { max-width: 1280px; margin: 0 auto; padding: 1.6rem 1.4rem 3rem; }

.dash-head {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 1.2rem; border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 0.7rem; color: inherit; }
.brand:hover { text-decoration: none; }
.brand svg { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.brand strong { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.brand small { display: block; color: var(--fg-4); font-size: 0.74rem; }
#search {
  flex: 1; min-width: 200px; max-width: 26rem; height: 40px; margin-left: auto;
  padding: 0 0.9rem; border-radius: 0.55rem;
  border: 1px solid var(--border); background: rgba(var(--glass-rgb), 0.6);
  color: var(--fg-2); font: inherit; font-size: 0.88rem; outline: none;
}
#search:focus { border-color: var(--border-hi); color: var(--fg); }
.ext { font-size: 0.8rem; color: var(--fg-4); }

/* Share bars (shared ToolShare widget) — position only, never restyle internals. */
.dash-share { display: inline-flex; align-items: center; }
/* Per-journey share lives inside the journal drawer (the reading surface), so it
   never crowds the floating topbar — which on mobile would wrap and overlap the
   journal below it. */
.journey-share { margin-top: 0.9rem; pointer-events: auto; }

.stats { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1.3rem 0 0.4rem; }
.stat {
  display: flex; align-items: baseline; gap: 0.45rem; padding: 0.55rem 0.95rem;
  border: 1px solid var(--border); border-radius: 0.6rem; background: var(--panel);
}
.stat strong { font-size: 1.15rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.76rem; color: var(--fg-3); }

.group-title {
  display: flex; align-items: baseline; gap: 0.7rem; margin: 2rem 0 0;
  font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em;
  border-left: 3px solid var(--a); padding-left: 0.7rem;
}
.group-title span { font-size: 0.75rem; font-weight: 500; color: var(--fg-4); }

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 1rem; margin-top: 1rem;
}
.card {
  display: flex; flex-direction: column; overflow: hidden; color: inherit;
  border: 1px solid var(--border); border-radius: 0.8rem; background: var(--panel);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border-hi); background: var(--panel-hi); text-decoration: none; transform: translateY(-2px); }
.card-media { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.card:hover .card-media img { transform: scale(1.04); }
.cover-fallback {
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 30% 20%, color-mix(in srgb, var(--a) 22%, transparent), transparent 60%),
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(var(--hairline-rgb), 0.025) 14px 15px), var(--surface-2);
}
.card-body { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.9rem 1rem 1rem; flex: 1; }
.card-body h3 { margin: 0; font-size: 0.98rem; font-weight: 700; line-height: 1.35; }
.card-body p {
  margin: 0; color: var(--fg-3); font-size: 0.8rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; gap: 0.8rem; margin-top: auto; padding-top: 0.55rem;
  font-size: 0.72rem; color: var(--fg-4); font-family: var(--mono);
}
.card-meta span:first-child { color: var(--a); }

.empty { text-align: center; color: var(--fg-4); padding: 3rem 0; }
.dash-foot {
  margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border-soft);
  font-size: 0.75rem; color: var(--fg-4);
}

/* ============ journey view ============ */

.journey { position: fixed; inset: 0; overflow: hidden; --journal-w: 420px; }

#map-pane { position: absolute; inset: 0; }
#leaflet-map { width: 100%; height: 100%; background: var(--map-bg); }
#map-offline {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 1rem;
  align-items: center; justify-content: center; text-align: center;
  color: var(--fg-3); font-size: 0.9rem; padding: 2rem;
}

.topbar {
  position: absolute; top: 0.9rem; left: 0.9rem; right: calc(var(--journal-w, 420px) + 1.8rem);
  display: flex; align-items: center; gap: 0.55rem; z-index: 940; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar-title {
  min-width: 0; padding: 0.42rem 0.85rem; border-radius: 0.6rem;
  border: 1px solid var(--border); background: rgba(var(--glass-rgb), 0.78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar-title strong { display: block; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title small { display: block; color: var(--fg-4); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.8rem; border-radius: 0.6rem; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--border); background: rgba(var(--glass-rgb), 0.78); color: var(--fg-2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--a, var(--accent)); color: var(--fg); text-decoration: none; }
.btn.back { font-size: 1rem; padding: 0.4rem 0.7rem; }

/* Theme toggle: square, so the glyph swap (moon <-> sun) doesn't reflow the bar. */
.theme-btn { width: 34px; padding: 0.4rem 0; justify-content: center; flex: none; }
.theme-ico { font-size: 0.95rem; line-height: 1; }
/* In the dashboard header the toggle sits between the search field and the
   external link; margin-left:auto lives on #search, so nothing else is needed. */
.dash-head .theme-btn { height: 40px; }
.toggle input { accent-color: var(--a, var(--accent)); margin: 0 0.1rem 0 0; }

/* --- glassmorphic journal drawer --- */
.journal {
  position: absolute; top: 0.9rem; right: 0.9rem; bottom: 0.9rem; width: var(--journal-w);
  z-index: 950; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--border); border-radius: 1rem;
  background: rgba(var(--glass-rgb), 0.72);
  backdrop-filter: blur(16px) saturate(1.15); -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.8);
  padding: 1.2rem 1.2rem 1rem;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.journal.closed { transform: translateX(calc(100% + 1.2rem)); opacity: 0; pointer-events: none; }

.journal-head h2 { margin: 0 0 0.3rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }
.journal-head p { margin: 0; color: var(--fg-3); font-size: 0.82rem; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.95rem 0; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.24rem 0.6rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--border); background: rgba(var(--glass-rgb), 0.5); color: var(--fg-4);
  transition: all 0.15s;
}
.chip i { width: 0.55rem; height: 0.55rem; border-radius: 999px; background: var(--c); opacity: 0.35; }
.chip b { color: var(--fg-4); font-weight: 600; }
.chip.active { color: var(--fg-2); border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.chip.active i { opacity: 1; box-shadow: 0 0 8px -1px var(--c); }

.stops { list-style: none; margin: 0 0 1.2rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.stop-item {
  display: flex; gap: 0.65rem; align-items: flex-start; cursor: pointer;
  padding: 0.5rem 0.6rem; border-radius: 0.6rem; border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.stop-item:hover { background: rgba(var(--hairline-rgb), 0.04); }
.stop-item.active { background: rgba(var(--hairline-rgb), 0.05); border-color: color-mix(in srgb, var(--c) 50%, transparent); }
.pin-num {
  flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600; color: var(--on-accent);
  background: var(--c); box-shadow: 0 0 10px -2px var(--c);
}
.stop-body { min-width: 0; flex: 1; }
.stop-item strong { display: block; font-size: 0.84rem; line-height: 1.35; }
.stop-item small { display: block; color: var(--fg-4); font-size: 0.68rem; }
.stop-item p { margin: 0.2rem 0 0; color: var(--fg-3); font-size: 0.74rem; line-height: 1.45; }
.stop-img {
  display: block; width: 100%; height: auto; max-height: 140px; object-fit: cover;
  margin: 0.4rem 0 0.1rem; border-radius: 0.45rem; border: 1px solid var(--border);
}
.stop-tip { color: var(--fg-4); font-style: italic; }
.stop-img { cursor: zoom-in; transition: filter 0.15s; }
.stop-media:hover .stop-img { filter: brightness(1.12); }
/* Journal photo: a button so a multi-image stop is browsable straight from the
   journal (opens the full gallery lightbox), with a 1/N badge signalling extras. */
.stop-media {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  background: none; cursor: zoom-in; margin: 0.4rem 0 0.1rem;
}
.stop-media .stop-img { margin: 0; }
.stop-media:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0.5rem; }
.stop-photocount {
  position: absolute; right: 0.4rem; bottom: 0.5rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.12rem 0.45rem; border-radius: 999px;
  background: rgba(0, 0, 0, 0.74); color: #fff;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em;
  pointer-events: none;
}
.stop-media.has-gallery .stop-img { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.stop-links { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.stop-link {
  display: inline-block; margin-top: 0.35rem; color: var(--c); font-size: 0.72rem;
  font-weight: 600; text-decoration: none; word-break: break-word;
}
.stop-link:hover { text-decoration: underline; }
.stop-link.dir { color: var(--fg-4); }
.stop-link.dir:hover { color: var(--fg-3); }

/* journal article (rendered markdown) */
.article { border-top: 1px solid var(--border-soft); padding-top: 1rem; font-size: 0.86rem; color: var(--fg-2); }
.article h2, .article h3, .article h4 { color: var(--fg); letter-spacing: -0.01em; line-height: 1.3; margin: 1.4em 0 0.5em; }
.article h2 { font-size: 1.08rem; }
.article h3 { font-size: 0.95rem; }
.article h4 { font-size: 0.88rem; }
.article p { margin: 0.55em 0; }
.article ul, .article ol { margin: 0.55em 0; padding-left: 1.25em; }
.article li { margin: 0.25em 0; }
.article blockquote {
  margin: 0.8em 0; padding: 0.5em 0.9em; border-left: 3px solid var(--a, var(--accent));
  background: rgba(var(--hairline-rgb), 0.03); border-radius: 0 0.5rem 0.5rem 0; color: var(--fg-3);
}
.article hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1.2em 0; }
.article pre {
  background: var(--map-bg); border: 1px solid var(--border-soft); border-radius: 0.55rem;
  padding: 0.8em; overflow-x: auto; font-size: 0.78rem; line-height: 1.5;
}
.article pre code { color: #cbd5e1; }
.tbl-wrap { overflow-x: auto; margin: 0.8em 0; border: 1px solid var(--border-soft); border-radius: 0.55rem; }
.article table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.article th {
  text-align: left; padding: 0.5em 0.7em; color: var(--fg-3); font-weight: 600;
  background: rgba(var(--glass-rgb), 0.6); border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
.article td { padding: 0.45em 0.7em; border-bottom: 1px solid rgba(39, 39, 42, 0.5); vertical-align: top; }
.article tr:last-child td { border-bottom: none; }

/* inline fly-to mentions */
.geo {
  color: var(--a, var(--accent)); font-weight: 600;
  border-bottom: 1px dashed color-mix(in srgb, var(--a, var(--accent)) 55%, transparent);
  transition: background 0.15s;
}
.geo:hover { background: color-mix(in srgb, var(--a, var(--accent)) 14%, transparent); border-radius: 0.2rem; }

.journal-foot { margin-top: 1.4rem; padding-top: 0.8rem; border-top: 1px solid var(--border-soft); font-size: 0.68rem; color: var(--fg-4); }
.journal-foot code { color: var(--fg-4); }

/* --- original artifact overlay --- */
.original-overlay { position: absolute; inset: 0; z-index: 990; display: flex; flex-direction: column; background: rgba(var(--glass-rgb), 0.92); }
.original-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-soft); font-size: 0.85rem;
}
.original-overlay iframe { flex: 1; border: 0; width: 100%; background: #fff; }

/* --- Leaflet dark chrome + custom pins --- */
.leaflet-container { font: inherit; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--fg-2) !important; border-color: var(--scroll) !important; }
.leaflet-control-zoom a:hover { background: #1b1b20 !important; }
.leaflet-control-attribution { background: var(--attrib-bg) !important; color: var(--border-hi) !important; font-size: 0.62rem !important; }
.leaflet-control-attribution a { color: var(--fg-4) !important; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--fg-2); border: 1px solid var(--border); border-radius: 0.7rem; font-size: 0.8rem; }
.leaflet-popup-content { margin: 0.7rem 0.9rem; line-height: 1.5; }
.leaflet-popup-content a { color: #38bdf8; }
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }
.leaflet-popup-close-button { color: var(--fg-4) !important; z-index: 5; }

/* --- rich popup card (.atlas-pop) --- */
.atlas-pop .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; }
.atlas-pop .leaflet-popup-content {
  margin: 0; width: auto; line-height: 1.5; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--scroll-hi) transparent;
}
.atlas-pop .leaflet-popup-content::-webkit-scrollbar { width: 7px; }
.atlas-pop .leaflet-popup-content::-webkit-scrollbar-thumb { background: var(--scroll-hi); border-radius: 999px; border: 2px solid var(--surface); }
.pop-media {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  cursor: zoom-in; background: var(--surface-2);
}
.pop-media img { display: block; width: 100%; height: 150px; object-fit: cover; }
/* "1/4" badge on the hero when a stop has a gallery. */
.pop-count {
  position: absolute; right: 0.4rem; bottom: 0.4rem;
  padding: 0.1rem 0.4rem; border-radius: 999px;
  background: rgba(0, 0, 0, 0.66); color: #fff;
  font-family: var(--mono); font-size: 0.62rem; font-weight: 600;
}
/* Thumbnail strip — only rendered when a stop has >1 photo. Horizontal scroll
   keeps the popup a fixed height no matter how many shots a stop carries. */
.pop-thumbs {
  display: flex; gap: 0.25rem; padding: 0.25rem;
  overflow-x: auto; scrollbar-width: none; background: var(--surface-2);
}
.pop-thumbs::-webkit-scrollbar { display: none; }
.pop-thumb {
  flex: none; width: 46px; height: 34px; padding: 0; border-radius: 0.25rem;
  overflow: hidden; opacity: 0.55; cursor: zoom-in;
  border: 1px solid transparent; transition: opacity 0.15s, border-color 0.15s;
}
.pop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pop-thumb:hover, .pop-thumb.is-on { opacity: 1; border-color: var(--accent); }
.pop-media .pop-zoom {
  position: absolute; right: 0.5rem; bottom: 0.5rem; width: 1.6rem; height: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.4rem; background: rgba(var(--glass-rgb), 0.65); color: var(--fg-2);
  font-size: 0.85rem; opacity: 0.85; transition: opacity 0.15s, background 0.15s;
}
.pop-media:hover .pop-zoom { opacity: 1; background: rgba(var(--glass-rgb), 0.85); }
.pop-inner { padding: 0.7rem 0.85rem 0.8rem; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.pop-cat {
  display: inline-flex; align-items: center; padding: 0.14rem 0.5rem; border-radius: 999px;
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: color-mix(in srgb, var(--c) 80%, #fff);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.pop-n { color: var(--fg-4); font-family: var(--mono); font-size: 0.66rem; }
.pop-name { display: block; color: var(--fg); font-size: 0.95rem; font-weight: 700; line-height: 1.3; }
.pop-meta { margin-top: 0.2rem; color: var(--fg-4); font-size: 0.7rem; font-family: var(--mono); }
.pop-note { margin: 0.45rem 0 0; color: var(--fg-3); font-size: 0.78rem; }
.pop-tip {
  margin: 0.5rem 0 0; padding: 0.4rem 0.6rem; border-left: 2px solid var(--accent);
  border-radius: 0 0.4rem 0.4rem 0; background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--fg-3); font-size: 0.74rem; font-style: italic;
}
.pop-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.65rem; }
.pop-btn {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.3rem 0.6rem; border-radius: 0.45rem; font-size: 0.72rem; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none !important; transition: background 0.15s, border-color 0.15s;
}
.pop-btn:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.pop-btn.ghost { border-color: var(--border); background: transparent; color: var(--fg-3) !important; }
.pop-btn.ghost:hover { border-color: var(--border-hi); color: var(--fg-2) !important; }
.pop-navs { display: flex; gap: 0.25rem; margin-left: auto; }
.pop-btn.nav { padding: 0.3rem 0.55rem; font-size: 0.8rem; line-height: 1; border-color: var(--border); background: transparent; color: var(--fg-3) !important; }
.pop-btn.nav:hover:not(:disabled) { border-color: var(--border-hi); color: var(--fg) !important; }
.pop-btn.nav:disabled { opacity: 0.35; cursor: default; }

/* marker hover tooltip */
.atlas-tt {
  background: rgba(var(--glass-rgb), 0.88) !important; color: var(--fg-2) !important;
  border: 1px solid var(--border) !important; border-radius: 0.45rem !important;
  font-size: 0.72rem !important; font-weight: 600; padding: 0.22rem 0.55rem !important;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.7) !important;
}
.atlas-tt::before { display: none; }

/* --- photo lightbox --- */
.lightbox {
  position: absolute; inset: 0; z-index: 996; cursor: zoom-out;
  display: flex; align-items: center; justify-content: center;
  background: rgba(var(--glass-rgb), 0.92);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lightbox figure { margin: 0; max-width: min(92vw, 1100px); max-height: 90vh; text-align: center; }
.lightbox img {
  max-width: 100%; max-height: 82vh; border-radius: 0.7rem;
  border: 1px solid var(--border); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
}
.lightbox figcaption { margin-top: 0.7rem; color: var(--fg-2); font-size: 0.85rem; font-weight: 600; }
/* Lightbox gallery arrows — shown only when the open stop has >1 photo. */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 2.6rem; height: 2.6rem; display: flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--border);
  background: rgba(var(--glass-rgb), 0.8); color: var(--fg-2);
  font-size: 1.3rem; line-height: 1; z-index: 2;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.lb-nav:hover { border-color: var(--accent); color: var(--fg); }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
@media (max-width: 560px) { .lb-prev { left: 0.4rem; } .lb-next { right: 0.4rem; } }

.lb-close {
  position: absolute; top: 1rem; right: 1rem; width: 2.3rem; height: 2.3rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--border);
  background: rgba(var(--glass-rgb), 0.8); color: var(--fg-2); font-size: 0.95rem;
}
.lb-close:hover { border-color: var(--border-hi); color: var(--fg); }

.atlas-pin-wrap { background: none; border: none; }
.atlas-pin {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 88%, #000);
  color: var(--on-accent); font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  border: 2px solid rgba(var(--glass-rgb), 0.85);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 60%, transparent), 0 4px 10px -2px rgba(0, 0, 0, 0.7);
}
.atlas-pin-wrap.pulse .atlas-pin { animation: pinpulse 1.6s ease-out infinite; }
@keyframes pinpulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 65%, transparent), 0 4px 10px -2px rgba(0, 0, 0, 0.7); }
  70% { box-shadow: 0 0 0 14px transparent, 0 4px 10px -2px rgba(0, 0, 0, 0.7); }
  100% { box-shadow: 0 0 0 0 transparent, 0 4px 10px -2px rgba(0, 0, 0, 0.7); }
}

/* ============ responsive ============ */

/* ── phone popups ──────────────────────────────────────────────────────────
   Leaflet writes the popup width INLINE from the bindPopup minWidth/maxWidth
   (300/340 here), so on a ~360px phone the card spanned nearly the whole
   viewport, and maxHeight:380 + a 150px photo left almost no map visible.
   Overriding the inline width needs !important; the rest just tightens the
   card so the map stays the subject. Kept in CSS rather than responsive
   bindPopup options so it also survives a rotate/resize without a re-bind. */
@media (max-width: 560px) {
  .leaflet-popup { max-width: 90vw !important; }
  .leaflet-popup-content-wrapper { max-width: 90vw; border-radius: 0.6rem; }
  .atlas-pop .leaflet-popup-content,
  .leaflet-popup-content {
    /* An explicit width, NOT `auto`: auto beats Leaflet's inline width but then
       shrink-wraps the text, collapsing the card to ~125px on a 390px phone —
       worse than the bug being fixed. min() keeps one consistent card that
       never exceeds the screen. Capping the HEIGHT is what actually keeps the
       map visible; 46vh leaves over half the map in view. */
    width: min(86vw, 300px) !important;
    max-height: min(62vh, 380px) !important;
    overflow-y: auto;
  }
  .pop-media img { height: 116px; }
  .pop-actions { flex-wrap: wrap; }
}

@media (max-width: 880px) {
  .journey { --journal-w: min(100vw - 1.8rem, 400px); }
  .topbar { right: 0.9rem; flex-wrap: wrap; z-index: 960; }
  .topbar-title { order: -1; width: 100%; }
  .journal { top: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
