/* ───────── Tokens ───────── */
:root {
  --paper: #f6f2ea;
  --paper-2: #efe7da;
  --card: #fffdf8;
  --ink: #3b2a1a;
  --ink-2: #6e5a45;
  --line: #d9ccb6;
  --brown: #4a3421;
  --red: #b3200f;
  --red-ink: #fff;
  --amber: #e08a3c;
  --shadow: 0 6px 24px rgba(59, 42, 26, .16);
  --radius: 4px;
  --header: 62px;
  --panel-w: 390px;
  --tl-h: 92px;
  --sheet-h: 0px;
  --font-ui: "Cabin", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #1d1914;
  --paper-2: #26201a;
  --card: #2a231c;
  --ink: #f0e6d6;
  --ink-2: #b8a68e;
  --line: #45392c;
  --brown: #d9c3a3;
  --red: #d8432c;
  --amber: #f0a25c;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font-ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--red); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.muted { color: var(--ink-2); }
[hidden] { display: none !important; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 8px 14px; font-weight: 600; letter-spacing: .01em;
  text-decoration: none; white-space: nowrap; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn-red { background: var(--red); color: var(--red-ink); }
.btn-dark { background: var(--brown); color: var(--paper); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-lg { padding: 14px 30px; font-size: 15px; min-width: 180px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn .count { background: rgba(255,255,255,.22); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.lbl-short { display: none; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 50%; color: var(--brown); display: grid; place-items: center; }
.icon-btn:hover { background: var(--paper-2); }
.x { background: none; border: 0; font-size: 18px; color: var(--ink-2); width: 32px; height: 32px; border-radius: 50%; flex: none; }
.x:hover { background: var(--paper-2); color: var(--ink); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 12px; font-size: 11px; padding: 0 7px; line-height: 18px; color: var(--ink); }

/* ───────── Header ───────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--header); z-index: 30;
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right));
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--brown); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font: 700 21px var(--font-display); letter-spacing: -.01em; }
.brand-text small { font-size: 11px; color: var(--amber); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }

.search { position: relative; display: flex; width: min(340px, 28vw); flex: none; }
.search-btn { background: var(--red); color: #fff; border: 0; width: 34px; border-radius: var(--radius) 0 0 var(--radius); display: grid; place-items: center; }
.search input {
  flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; padding: 0 10px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px;
}
.search input:focus { outline: 2px solid var(--amber); outline-offset: -1px; }
.search-results {
  position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px 0; list-style: none; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
.search-results li { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.search-results li small { color: var(--ink-2); }
.search-results li.active, .search-results li:hover { background: var(--paper-2); }
.search-results .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--red); flex: none; width: 48px; }

.mainnav { display: flex; gap: 4px; min-width: 0; }
.mainnav a { color: var(--ink); text-decoration: none; font-weight: 500; font-size: 16px; padding: 6px 12px; border-radius: var(--radius); position: relative; white-space: nowrap; }
.mainnav a:hover { background: var(--paper-2); }
body[data-mode="maps"] .mainnav a[data-go="maps"]::after,
body[data-mode="history"] .mainnav a[data-go="history"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -2px; height: 2px; background: var(--red);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.lang { display: flex; align-items: center; gap: 2px; color: var(--brown); padding: 0 2px; }
.lang select { border: 0; background: transparent; color: var(--ink); font: 600 13px var(--font-ui); padding: 4px 2px; cursor: pointer; }
.lang select:focus-visible { outline: 2px solid var(--amber); border-radius: 3px; }

/* ───────── Stage + map ───────── */
.stage { position: fixed; inset: var(--header) 0 0 0; }
.map { position: absolute; inset: 0; background: var(--paper); }
body[data-mode="maps"]:not(.panel-closed) .map { right: var(--panel-w); }
.map-compare { z-index: 1; }
.maplibregl-ctrl-attrib { font-size: 10px; background: color-mix(in srgb, var(--paper) 80%, transparent) !important; color: var(--ink-2); }
.maplibregl-ctrl-attrib a { color: var(--ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
body[data-mode="maps"] .maplibregl-ctrl-bottom-right { bottom: var(--tl-h); }

.swipe { position: absolute; top: 0; bottom: 0; width: 0; z-index: 4; pointer-events: none; }
.swipe::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1.5px; width: 3px; background: var(--red); }
.swipe-handle {
  position: absolute; top: 40%; left: 0; transform: translate(-50%, -50%); pointer-events: auto; cursor: ew-resize;
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 20px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); user-select: none; touch-action: none; white-space: nowrap;
}

/* ───────── Hero: centred globe, era ticker, world starting points ───────── */
.hero {
  --gy: 60%; --gr: 260px;
  position: absolute; inset: 0; z-index: 20; pointer-events: none;
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  /* Clear circle where the globe sits, paper everywhere else */
  background: radial-gradient(circle at 50% var(--gy), transparent calc(var(--gr) * 1.02), color-mix(in srgb, var(--paper) 72%, transparent) calc(var(--gr) * 1.18), var(--paper) calc(var(--gr) * 1.55));
  transition: opacity .5s ease;
}
.hero > * { pointer-events: auto; }
body:not([data-mode="landing"]) .hero { opacity: 0; pointer-events: none; }
body:not([data-mode="landing"]) .hero > * { pointer-events: none; }
.hero-top { text-align: center; padding: 22px 24px 0; position: relative; }
.hero-top::before { content: ""; position: absolute; inset: -10px 8% -20px; z-index: -1; background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--paper) 88%, transparent) 40%, transparent 72%); pointer-events: none; }
.hero-kicker { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.hero h1 { font: 700 clamp(30px, 3.6vw, 54px)/1.05 var(--font-display); margin: 0 auto 10px; color: var(--brown); letter-spacing: -.02em; }
.hero-sub { font-size: 16.5px; color: var(--ink-2); max-width: 760px; margin: 0 auto 16px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-feats { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 14px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-2); }
.hero-feats li::before { content: "✦ "; color: var(--amber); }

.hero-bottom { grid-row: 3; display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 0 32px 26px; }
.hero-era { display: flex; align-items: flex-end; gap: 14px; max-width: 46%; }
.hero-spin { flex: none; width: 34px; height: 34px; margin-bottom: 10px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--brown); font-size: 11px; letter-spacing: -1px; }
.hero-year {
  display: block; font: 700 clamp(56px, 7vw, 104px)/.9 var(--font-display); letter-spacing: -.03em;
  color: transparent; -webkit-text-stroke: 1.6px var(--brown); transition: opacity .3s;
}
.hero-year.flip { opacity: 0; }
.hero-caption { margin: 6px 0 0; font-size: 15px; color: var(--ink); max-width: 380px; min-height: 2.9em; }
.hero-start { max-width: 470px; min-width: 0; text-align: right; }
.hero-start-label { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chip-city {
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 92%, transparent); color: var(--ink);
  border-radius: 18px; padding: 5px 11px; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: baseline; white-space: nowrap;
}
.chip-city small { color: var(--red); font-weight: 700; font-size: 11.5px; }
.chip-city:hover { border-color: var(--red); }
.hero-tour { margin-top: 12px; background: none; border: 0; padding: 0; color: var(--ink); font-size: 14px; line-height: 1.6; }
.hero-tour b { color: var(--red); }
.hero-tour:hover b { text-decoration: underline; }
.hero-tour-dot { display: inline-block; vertical-align: middle; margin-right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--amber); } 70%, 100% { box-shadow: 0 0 0 10px transparent; } }

/* ───────── Floating cards ───────── */
.region-card, .tour-card { position: absolute; z-index: 6; background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius); }
.region-card { top: 16px; left: 66px; width: 360px; max-height: calc(100% - var(--tl-h) - 40px); overflow: auto; padding: 16px 18px 14px 50px; }
body[data-mode="landing"] .region-card { display: none; }
.region-back { position: absolute; left: 10px; top: 16px; background: none; border: 0; color: var(--ink); padding: 4px; border-radius: 50%; }
.region-back:hover { background: var(--paper-2); }
.region-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.region-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.region-head p { margin: 2px 0 0; font-size: 13px; }
.region-swatch { width: 48px; height: 32px; flex: none; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.region-body { font-size: 14px; color: var(--ink-2); margin-top: 10px; }
.region-body img { float: right; width: 92px; margin: 2px 0 6px 10px; border-radius: 3px; }
.region-body p { margin: 0 0 6px; }
.region-actions { margin-top: 10px; clear: both; display: flex; gap: 8px; }
.skeleton { display: block; height: 12px; border-radius: 3px; background: linear-gradient(90deg, var(--paper-2), var(--line), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 6px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.map-tools {
  position: absolute; left: 16px; top: 46%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.map-tools button { width: 36px; height: 36px; border: 0; background: none; font-size: 20px; display: grid; place-items: center; color: var(--ink); }
.map-tools button:hover { background: var(--paper-2); }
.map-tools button.on { color: var(--red); }
.map-tools hr { margin: 0; border: 0; border-top: 1px solid var(--line); }
body[data-mode="landing"] :is(.map-tools, .timeline, .snapshot-pill, .overlay-bar, .compare-bar, .tour-card) { opacity: 0; pointer-events: none; }

.compare-bar {
  position: absolute; z-index: 6; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius); font-size: 14px; white-space: nowrap;
}
body[data-mode="maps"]:not(.panel-closed) .compare-bar { left: calc((100% - var(--panel-w)) / 2); }
.compare-bar > button:not(.btn) { border: 1px solid var(--line); background: var(--paper); width: 30px; height: 30px; border-radius: var(--radius); }
.compare-bar input { width: 92px; height: 30px; text-align: center; font: 700 15px var(--font-ui); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); }

/* Overlay control */
.overlay-bar {
  position: absolute; z-index: 6; top: 16px; right: 16px; width: 330px;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 8px; background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius); border-left: 4px solid var(--amber);
}
body[data-mode="maps"]:not(.panel-closed) .overlay-bar { right: calc(var(--panel-w) + 16px); }
.overlay-bar img { width: 44px; height: 44px; object-fit: cover; border-radius: 2px; flex: none; background: var(--paper-2); }
.ov-info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ov-info small { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--red); font-weight: 700; }
.ov-info b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-range { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); }
.ov-range input { flex: 1; min-width: 0; accent-color: var(--red); }

.snapshot-pill {
  position: absolute; z-index: 5; bottom: calc(var(--tl-h) + 6px); right: 16px;
  background: color-mix(in srgb, var(--card) 90%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 3px 11px; font-size: 12px; color: var(--ink);
  display: flex; align-items: center; gap: 6px; max-width: calc(100% - 32px); white-space: nowrap; overflow: hidden;
}
body[data-mode="maps"]:not(.panel-closed) .snapshot-pill { right: calc(var(--panel-w) + 16px); }
.loading-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); animation: blink .8s infinite alternate; flex: none; }
@keyframes blink { to { opacity: .2; } }

.busy {
  position: absolute; z-index: 8; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: var(--brown); color: var(--paper); padding: 10px 18px; border-radius: 22px; font-size: 14px; box-shadow: var(--shadow);
}
body[data-mode="maps"]:not(.panel-closed) .busy { left: calc((100% - var(--panel-w)) / 2); }

/* ───────── Timeline ───────── */
.timeline {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: var(--sheet-h); height: var(--tl-h);
  display: flex; align-items: center; gap: 4px; padding: 0 28px 0 70px; padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(0deg, var(--paper) 30%, color-mix(in srgb, var(--paper) 70%, transparent) 70%, transparent);
  transition: opacity .3s, bottom .3s;
}
body[data-mode="maps"]:not(.panel-closed) .timeline { right: var(--panel-w); }
.tl-play { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 2px solid var(--red); background: var(--card); color: var(--red); display: grid; place-items: center; box-shadow: var(--shadow); }
.tl-play .i-pause, body.playing .tl-play .i-play { display: none; }
body.playing .tl-play .i-pause { display: block; }
.tl-track { position: relative; flex: 1; height: 100%; margin: 0 18px; cursor: pointer; touch-action: none; }
.tl-ticks { position: absolute; left: 0; right: 0; top: 50%; height: 30px; }
.tl-ticks i { position: absolute; bottom: 14px; width: 1px; height: 6px; background: var(--ink-2); opacity: .6; }
.tl-ticks i.major { height: 16px; opacity: 1; background: var(--ink); }
.tl-ticks i.era { height: 22px; width: 2px; background: var(--red); opacity: .5; }
.tl-ticks span { position: absolute; top: 18px; transform: translateX(-50%); font-size: 13px; color: var(--ink); white-space: nowrap; user-select: none; }
.tl-snaps { position: absolute; left: 0; right: 0; top: calc(50% + 10px); height: 4px; }
.tl-snaps b { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--amber); transform: translateX(-50%); }
.tl-thumb { position: absolute; top: 0; height: 100%; transform: translateX(-50%); outline: none; }
.tl-knob {
  position: absolute; left: 50%; top: calc(50% - 17px); width: 26px; height: 26px; transform: translateX(-50%);
  border-radius: 50%; background: var(--red); border: 7px solid var(--card); box-shadow: 0 0 0 2px var(--red), var(--shadow); cursor: grab;
}
.tl-thumb:focus-visible .tl-knob { box-shadow: 0 0 0 2px var(--red), 0 0 0 6px color-mix(in srgb, var(--red) 30%, transparent); }
.tl-bubble {
  position: absolute; left: 50%; bottom: calc(50% + 16px); transform: translateX(-50%);
  width: 104px; height: 32px; border: 0; border-radius: var(--radius); background: var(--red); color: #fff; text-align: center;
  font: 700 16px var(--font-ui); box-shadow: var(--shadow); padding: 0 4px;
}
.tl-bubble:focus { outline: 2px solid var(--amber); }
.tl-nudge { position: absolute; bottom: calc(50% + 21px); border: 0; background: none; color: var(--red); font-size: 13px; padding: 2px 4px; opacity: 0; transition: opacity .15s; }
.tl-thumb:hover .tl-nudge, .tl-thumb:focus-within .tl-nudge { opacity: 1; }
.tl-nudge.left { right: calc(50% + 54px); }
.tl-nudge.right { left: calc(50% + 54px); }

/* ───────── Maps panel ───────── */
.panel {
  position: absolute; z-index: 7; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .3s ease, height .3s ease;
}
body[data-mode="maps"]:not(.panel-closed) .panel { transform: none; }
.sheet-grip { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 0 18px; min-height: 46px; background: var(--brown); color: var(--paper); }
.panel-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; }
.panel-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.panel-collapse { background: none; border: 0; color: var(--paper); padding: 6px; border-radius: 50%; flex: none; }
.panel-collapse:hover { background: rgba(255,255,255,.12); }
.panel-reopen { position: absolute; z-index: 7; top: 16px; right: 16px; background: var(--card); border: 0; padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 600; }
.panel-filters { padding: 8px 14px 6px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.tabs { display: flex; gap: 2px; }
.tab { background: none; border: 0; padding: 4px 10px; font-size: 15px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--red); }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-select { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 3px; }
.mini-select select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px 4px; max-width: 160px; }
.panel-sub { font-size: 12px; margin: 6px 18px 2px; min-height: 17px; }
.cards { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; overscroll-behavior: contain; }
.card {
  display: grid; grid-template-columns: 1fr 92px; gap: 12px; padding: 12px 14px 12px 18px; border-bottom: 1px dashed var(--line); cursor: pointer; transition: background .12s;
}
.card:hover, .card:focus-visible { background: var(--paper-2); outline: none; }
.card h3 { margin: 0; font-size: 15px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.card-actions { margin-left: auto; display: flex; gap: 6px; }
.badge { font-size: 10px; letter-spacing: .04em; font-weight: 700; padding: 3px 6px; border-radius: 3px; background: var(--brown); color: var(--paper); white-space: nowrap; }
.pin { font-size: 13px; }
.fav { background: none; border: 0; font-size: 19px; line-height: 1; padding: 2px 4px; color: var(--ink-2); }
.fav.on { color: var(--red); }
.has-note { font-size: 12px; color: var(--amber); }
.thumb { width: 92px; height: 92px; object-fit: cover; border-radius: 2px; background: var(--paper-2); box-shadow: 0 1px 3px rgba(0,0,0,.25); filter: sepia(.12); }
.empty { padding: 30px 22px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; font-family: var(--font-display); }
.group { padding: 12px 18px 6px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--line); background: var(--paper-2); }
.group b { display: block; color: var(--ink); font-size: 14px; }
.group.loading { display: flex; align-items: center; gap: 8px; background: none; border-bottom: 1px dashed var(--line); }
.card.skel { cursor: default; }
.panel-foot { display: flex; gap: 8px; justify-content: center; padding: 8px; border-top: 1px solid var(--line); }
.panel-foot:not(:has(button:not([hidden]))) { display: none; }

/* ───────── Tour card ───────── */
.tour-card { left: 66px; bottom: calc(var(--sheet-h) + var(--tl-h) + 14px); width: 380px; padding: 14px 18px; border-top: 4px solid var(--amber); }
.tour-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tour-name { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.tour-card h3 { margin: 4px 0 0; font: 700 21px/1.2 var(--font-display); color: var(--brown); }
.tour-year { margin: 2px 0 8px; color: var(--ink-2); font-size: 13px; }
.tour-card p { margin: 0 0 8px; font-size: 14.5px; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.dots { display: flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--red); }

/* ───────── Dialogs ───────── */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--card); box-shadow: var(--shadow); border-radius: 6px; }
dialog::backdrop { background: rgba(30, 20, 10, .55); backdrop-filter: blur(2px); }
.sheet { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; padding: 24px 26px; }
.sheet > .x { position: absolute; top: 12px; right: 12px; }
.sheet h2 { margin: 0 0 6px; font: 700 24px var(--font-display); color: var(--brown); padding-right: 30px; }
.sheet h3 { margin: 18px 0 6px; font-size: 15px; }
.sheet .sources { padding-left: 18px; margin: 0; }
.sheet .sources li { margin-bottom: 6px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0 0; }
.keys dd { margin: 0; color: var(--ink-2); }
kbd { font: 600 12px var(--font-ui); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: var(--paper); }
.tour-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.tour-list button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper); padding: 12px 14px; border-radius: var(--radius); display: grid; gap: 2px; }
.tour-list button:hover { border-color: var(--red); }
.tour-list b { font: 700 17px var(--font-display); color: var(--brown); }
.tour-list span { font-size: 13px; color: var(--ink-2); }

.viewer {
  width: min(1280px, calc(100vw - 32px)); height: min(860px, calc(100dvh - 32px)); max-width: none; max-height: none;
  display: none; grid-template-columns: 1fr 340px; grid-template-rows: minmax(0, 1fr); overflow: hidden;
}
.viewer[open] { display: grid; }
.viewer-stage { position: relative; background: #2a231c; min-height: 0; }
.osd { position: absolute; inset: 0; width: 100%; height: 100%; } /* OSD forces position:relative inline */
.viewer-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #d9c3a3; font-family: var(--font-display); font-size: 18px; pointer-events: none; text-align: center; padding: 20px; }
.viewer-side { position: relative; padding: 22px 22px 18px; overflow: auto; border-left: 1px solid var(--line); }
.viewer-side > p.muted { margin: 0 36px 0 0; font-size: 13px; }
.viewer-close { position: absolute; top: 10px; right: 10px; }
.viewer-side h2 { font: 700 21px/1.25 var(--font-display); margin: 4px 0 8px; color: var(--brown); padding-right: 20px; }
.v-by { font-size: 14px; margin: 0 0 8px; }
.v-pinned { font-size: 13px; color: var(--red); margin: 0 0 10px; }
.v-desc { font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; }
.v-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.v-tags span { font-size: 11.5px; border: 1px solid var(--line); border-radius: 12px; padding: 1px 8px; text-transform: capitalize; }
.v-actions { display: grid; gap: 8px; }
.v-actions .btn { white-space: normal; text-align: center; }
.v-notes { display: grid; gap: 6px; margin-top: 18px; font-size: 13px; font-weight: 600; }
.v-notes textarea { font: 14px var(--font-ui); padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); resize: vertical; }

.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 110px; transform: translateX(-50%); max-width: calc(100vw - 32px); text-align: center;
  background: var(--brown); color: var(--paper); padding: 9px 16px; border-radius: 20px; font-size: 14px; box-shadow: var(--shadow);
}
.maplibregl-popup.hover-tip .maplibregl-popup-content { background: var(--card); color: var(--ink); padding: 4px 9px; border-radius: 3px; font: 600 13px var(--font-ui); box-shadow: var(--shadow); }
.maplibregl-popup.hover-tip .maplibregl-popup-tip { display: none; }

/* ───────── Timeline label density (classes set from the track width) ───────── */
.tl-mid .tl-ticks span.opt { display: none; }
.tl-narrow .tl-ticks span:not(.key), .tl-narrow .tl-ticks span.deep { display: none; }

/* ───────── Tablet (768–1099px) ───────── */
@media (max-width: 1099px) {
  :root { --panel-w: 340px; }
  .topbar { gap: 12px; padding: 0 14px; }
  .brand-text small { display: none; }
  .search { width: min(260px, 26vw); }
  .mainnav a { padding: 6px 8px; font-size: 15px; }
  .nav-about { display: none; }
  .topbar-actions .lbl { display: none; }
  .topbar-actions .lbl-short { display: inline; }
  .hero-bottom { padding: 0 20px 20px; }
  .hero-start { max-width: 360px; }
  .region-card { width: 320px; }
  .tour-card { width: 340px; }
  .overlay-bar { width: 290px; }
  .timeline { padding-left: 64px; padding-right: 16px; }
}

/* ───────── Phone (<768px): bottom sheet layout ───────── */
@media (max-width: 767px) {
  :root { --header: 98px; --tl-h: 80px; --panel-w: 100vw; }
  body[data-mode="maps"][data-sheet="peek"] { --sheet-h: 104px; }
  body[data-mode="maps"][data-sheet="half"] { --sheet-h: 46dvh; }
  body[data-mode="maps"][data-sheet="full"] { --sheet-h: calc(100dvh - var(--header) - 12px); }

  .topbar { flex-wrap: wrap; height: var(--header); gap: 8px 4px; padding: 8px 12px; align-content: center; }
  .brand-text { display: none; }
  .search { order: 3; width: 100%; }
  .brand img { width: 30px; height: 30px; }
  .mainnav { gap: 0; }
  .mainnav a { font-size: 14px; padding: 6px 5px; }
  .topbar-actions { gap: 0; margin-left: auto; }
  .topbar-actions .icon-btn { padding: 4px; }
  .topbar-actions .icon-btn[data-action="share"] { display: none; } /* the URL is the share link */
  .topbar-actions .btn { padding: 6px 8px; font-size: 13px; }
  .lang svg { display: none; }
  .lang select { padding: 4px 0; }

  body[data-mode="maps"] .map, body[data-mode="maps"]:not(.panel-closed) .map { right: 0; }
  .panel, body[data-mode="maps"]:not(.panel-closed) .panel {
    top: auto; left: 0; right: 0; width: auto; height: var(--sheet-h); border-left: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.14); padding-bottom: env(safe-area-inset-bottom);
  }
  .panel { transform: translateY(110%); }
  body[data-mode="maps"] .panel { transform: none; }
  .sheet-grip { display: block; position: absolute; top: 0; left: 0; right: 0; height: 22px; background: none; border: 0; z-index: 2; touch-action: none; }
  .sheet-grip span { display: block; width: 44px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--paper) 70%, transparent); margin: 7px auto 0; }
  .panel-head { border-radius: 14px 14px 0 0; padding-top: 14px; min-height: 52px; }
  .panel-collapse svg { transform: rotate(90deg); }
  body[data-sheet="peek"] .panel-collapse svg { transform: rotate(-90deg); }
  body[data-sheet="peek"] :is(.panel-filters, .panel-sub, .cards, .panel-foot) { visibility: hidden; }
  .panel-reopen { display: none !important; }

  body[data-mode="maps"] .timeline, body[data-mode="maps"]:not(.panel-closed) .timeline { right: 0; }
  .timeline { padding: 0 12px 0 14px; }
  .tl-track { margin: 0 14px 0 10px; }
  .tl-nudge { display: none; }
  .tl-bubble { width: 96px; font-size: 15px; }

  .map-tools { left: auto; right: 10px; top: 10px; transform: none; }
  .map-tools button { width: 38px; height: 38px; }
  .map-tools .t-desk { display: none; }

  .region-card { top: 10px; left: 10px; right: 60px; width: auto; max-height: 42dvh; padding: 12px 14px 12px 44px; }
  .region-back { top: 12px; left: 6px; }
  .region-body img { width: 70px; }
  .tour-card { left: 10px; right: 10px; width: auto; bottom: calc(var(--sheet-h) + var(--tl-h) + 6px); padding: 12px 14px; max-height: 40dvh; overflow: auto; }
  .tour-card h3 { font-size: 18px; }
  .tour-card p { font-size: 14px; }

  .overlay-bar, body[data-mode="maps"]:not(.panel-closed) .overlay-bar { top: 10px; left: 10px; right: 60px; width: auto; }
  .compare-bar, body[data-mode="maps"]:not(.panel-closed) .compare-bar { top: 10px; left: 10px; right: 60px; transform: none; flex-wrap: wrap; justify-content: center; white-space: normal; }
  .snapshot-pill, body[data-mode="maps"]:not(.panel-closed) .snapshot-pill { left: 10px; right: auto; bottom: calc(var(--sheet-h) + var(--tl-h) + 4px); font-size: 11px; }
  body[data-mode="maps"]:not([data-sheet="peek"]) .snapshot-pill { display: none; }
  .busy, body[data-mode="maps"]:not(.panel-closed) .busy { left: 50%; top: 30%; width: max-content; max-width: calc(100vw - 40px); text-align: center; }
  body[data-mode="maps"] .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h) + var(--tl-h)); }

  .hero { grid-template-rows: auto minmax(150px, 1fr) auto; }
  .hero-top { padding: 16px 16px 0; }
  .hero-kicker { font-size: 10.5px; margin-bottom: 4px; }
  .hero-sub { font-size: 14.5px; margin-bottom: 12px; }
  .hero-cta { gap: 8px; }
  .hero-feats { display: none; }
  .hero-bottom { flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 10px; padding: 0 0 14px; }
  .hero-era { max-width: none; padding: 0 16px; }
  .hero-year { font-size: 52px; }
  .hero-caption { font-size: 13.5px; min-height: 0; }
  .hero-start { max-width: none; text-align: left; }
  .hero-start-label { padding: 0 16px; margin-bottom: 6px; }
  .hero-chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; }
  .hero-chips::-webkit-scrollbar { display: none; }
  .hero-tour { padding: 0 16px; text-align: left; }
  .btn-lg { min-width: 0; flex: 1 1 140px; padding: 13px 16px; }

  .card { grid-template-columns: 1fr 76px; padding: 12px 14px; }
  .thumb { width: 76px; height: 76px; }

  .viewer { width: 100vw; height: 100dvh; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: 52% 48%; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--line); padding: 16px; }
  .sheet { padding: 20px 18px; }
  .toast { bottom: calc(var(--sheet-h) + var(--tl-h) + 12px); }
}

/* Short landscape phones */
@media (max-height: 480px) and (max-width: 950px) {
  :root { --tl-h: 70px; }
  .hero-sub, .hero-feats, .hero-tour { display: none; }
  .region-card { max-height: 60dvh; }
}

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

/* ───────── Quiz card ───────── */
.quiz-card {
  position: absolute; z-index: 9; right: 16px; bottom: calc(var(--sheet-h) + var(--tl-h) + 14px); width: 400px; max-height: calc(100% - var(--tl-h) - 40px); overflow: auto;
  background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius); border-top: 4px solid var(--red); padding: 14px 18px 16px;
}
body[data-mode="maps"]:not(.panel-closed) .quiz-card { right: calc(var(--panel-w) + 16px); }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quiz-name { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.quiz-progress { height: 4px; background: var(--paper-2); border-radius: 2px; margin: 8px 0 12px; overflow: hidden; }
.quiz-progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s; }
.quiz-q { font: 600 18px/1.3 var(--font-display); color: var(--brown); margin: 0 0 4px; }
.quiz-meta { font-size: 12px; color: var(--ink-2); margin: 0 0 10px; }
.quiz-quote { font-size: 14px; background: var(--paper); border-left: 3px solid var(--amber); padding: 8px 10px; margin: 0 0 12px; border-radius: 0 3px 3px 0; }
.quiz-opts { display: grid; gap: 7px; }
.q-opt {
  text-align: left; border: 1px solid var(--line); background: var(--paper); padding: 9px 12px; border-radius: var(--radius); font-size: 14px; line-height: 1.35;
}
.q-opt:hover:not(:disabled) { border-color: var(--brown); }
.q-opt.right { border-color: #2f7d4a; background: color-mix(in srgb, #2f7d4a 14%, var(--paper)); }
.q-opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, var(--paper)); }
.q-opt:disabled { cursor: default; opacity: 1; }
.quiz-feedback { margin: 12px 0 0; font-size: 14px; }
.quiz-feedback b.ok { color: #2f7d4a; }
.quiz-feedback b.no { color: var(--red); }
.quiz-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.quiz-hint { font-size: 13px; color: var(--ink-2); margin: 0; display: flex; align-items: center; gap: 6px; }
.quiz-hint::before { content: "👆"; }
.quiz-score { text-align: center; padding: 6px 0; }
.quiz-score .big { font: 700 54px/1 var(--font-display); color: var(--brown); }
.quiz-score p { margin: 8px 0 0; }
body.quiz-clicking .maplibregl-canvas { cursor: crosshair !important; }
@media (max-width: 767px) {
  .quiz-card, body[data-mode="maps"]:not(.panel-closed) .quiz-card { left: 10px; right: 10px; width: auto; bottom: calc(var(--sheet-h) + var(--tl-h) + 6px); max-height: 52dvh; }
}
