/* Silk Roads Atlas — shared styles.
   Look: an old paper map. Warm parchment land, quiet blue-gray seas, silk-red roads.
   Each chapter owns one color: 1 silk red, 2 saffron, 3 lapis. */
/* Fonts are self-hosted (SIL OFL, see assets/fonts/LICENSE.txt) so no visitor data reaches a third party. */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 500 800; font-display: swap; src: url("/assets/fonts/bricolage-grotesque.woff2") format("woff2") }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("/assets/fonts/source-serif-4.woff2") format("woff2") }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap; src: url("/assets/fonts/source-serif-4-italic.woff2") format("woff2") }

:root {
  --bg: #f3ead8; --paper: #fbf6ec; --surface: #fffcf6; --surface-2: #efe5d2; --ink: #2b2118; --muted: #6e604d; --line: #dccdb2;
  --sea: #cfdde0; --land: #efe3c8; --coast: #a8926c; --land-shade: rgb(90 70 40 / .25); --river: #7aa4b5; --desert: rgb(176 140 80 / .28);
  --silk: #b3261e; --silk-soft: #f6dfd9; --searoute: #1d6b87; --royal: #7a4fa0; --steppe: #8a6d1f;
  --c1: #b3261e; --c2: #b86a00; --c3: #2d5bb3; --c1-soft: #f6dfd9; --c2-soft: #f6e6cc; --c3-soft: #dde5f6;
  --ok: #1d7445; --ok-soft: #dff2e6; --bad: #b02a22; --bad-soft: #fbe4e1;
  --halo: #f7eedd; --shadow: 0 1px 2px rgb(60 40 20 / .08), 0 10px 30px rgb(60 40 20 / .12);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --ui: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 8px; --r: 14px; --r-lg: 22px;
  --top-h: 60px; --time-h: 60px; --panel-w: 390px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11151b; --paper: #171c24; --surface: #1a2029; --surface-2: #232b36; --ink: #ece4d6; --muted: #a99d89; --line: #2e3742;
  --sea: #0d1820; --land: #252b30; --coast: #4b5560; --land-shade: rgb(0 0 0 / .5); --river: #2f5a6c; --desert: rgb(200 170 110 / .16);
  --silk: #ff7a69; --silk-soft: #3a1d1a; --searoute: #5cc0de; --royal: #bb97e6; --steppe: #d9b65a;
  --c1: #ff7a69; --c2: #f2a541; --c3: #8ca6f4; --c1-soft: #3a1d1a; --c2-soft: #3a2a12; --c3-soft: #1c2747;
  --ok: #62cf8f; --ok-soft: #12301f; --bad: #f28b82; --bad-soft: #3a1a17;
  --halo: #1d232b; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #11151b; --paper: #171c24; --surface: #1a2029; --surface-2: #232b36; --ink: #ece4d6; --muted: #a99d89; --line: #2e3742;
  --sea: #0d1820; --land: #252b30; --coast: #4b5560; --land-shade: rgb(0 0 0 / .5); --river: #2f5a6c; --desert: rgb(200 170 110 / .16);
  --silk: #ff7a69; --silk-soft: #3a1d1a; --searoute: #5cc0de; --royal: #bb97e6; --steppe: #d9b65a;
  --c1: #ff7a69; --c2: #f2a541; --c3: #8ca6f4; --c1-soft: #3a1d1a; --c2-soft: #3a2a12; --c3-soft: #1c2747;
  --ok: #62cf8f; --ok-soft: #12301f; --bad: #f28b82; --bad-soft: #3a1a17;
  --halo: #1d232b; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
  color-scheme: dark; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box }
html, body { height: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--body); overflow: hidden;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr) var(--time-h); height: 100vh; height: 100dvh }
[hidden] { display: none !important }
button { font: inherit; color: inherit }
a { color: var(--c, var(--silk)); text-underline-offset: 3px }
:focus-visible { outline: 3px solid var(--c3); outline-offset: 2px; border-radius: 6px }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; letter-spacing: -.015em; margin: 0; text-wrap: balance }
p { margin: 0 }
ul, ol { margin: 0; padding-left: 1.2em }
.ic { width: 20px; height: 20px; flex: none }
.skip { position: absolute; left: var(--s4); top: -60px; z-index: 60; background: var(--ink); color: var(--bg); padding: var(--s2) var(--s4); border-radius: var(--r-sm); font: 600 15px var(--ui) }
.skip:focus { top: var(--s2) }
.eyebrow { font: 700 12px/1.2 var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--c, var(--muted)) }
.muted { color: var(--muted) }

/* ---------- Buttons ---------- */
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 999px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink); transition: background .15s, border-color .15s }
.icon-btn:hover { background: var(--surface-2) }
.icon-btn.sm { width: 34px; height: 34px }
.icon-btn.sm .ic { width: 18px; height: 18px }
.btn { display: inline-flex; align-items: center; gap: var(--s2); font: 650 15px/1 var(--ui); padding: 11px 16px; border-radius: 999px; border: 1px solid var(--c, var(--silk)); background: var(--c, var(--silk)); color: var(--paper); cursor: pointer; text-decoration: none; transition: filter .15s, transform .1s }
.btn:hover { filter: brightness(1.08) }
.btn:active { transform: translateY(1px) }
.btn .ic { width: 18px; height: 18px }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line) }
.btn.ghost:hover { background: var(--surface-2); filter: none }
.btn[disabled] { opacity: .4; pointer-events: none }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 650 14px/1 var(--ui); padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); white-space: nowrap; transition: background .15s, border-color .15s }
.chip:hover { background: var(--surface-2) }
.chip[aria-expanded="true"], .chip.on { border-color: var(--ink); background: var(--surface-2) }
.chip .ic { width: 17px; height: 17px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow) }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: var(--s3); padding: 0 max(12px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: var(--paper); position: relative; z-index: 20 }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--ink); text-decoration: none; font: 750 19px/1 var(--display); letter-spacing: -.02em; flex: none }
.brand svg { width: 32px; height: 32px }
.brand em { font-style: normal; color: var(--silk) }
.tabs { display: flex; gap: 2px; margin: 0 auto; background: var(--surface-2); padding: 3px; border-radius: 999px; min-width: 0 }
.tab { display: flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; cursor: pointer; font: 650 14px/1 var(--ui); color: var(--muted); white-space: nowrap; transition: background .15s, color .15s }
.tab:hover { color: var(--ink) }
.tab-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 999px; font-size: 13px }
.tab[data-ch="1"] { --c: var(--c1) } .tab[data-ch="2"] { --c: var(--c2) } .tab[data-ch="3"] { --c: var(--c3) } .tab[data-ch="all"] { --c: var(--ink) }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12) }
.tab[aria-selected="true"] .tab-n { background: var(--c); color: var(--paper) }
.tab[data-ch="all"][aria-selected="true"] .tab-n { background: transparent; color: var(--ink) }
.tab-t { display: none }
.tab[aria-selected="true"] .tab-t { display: inline }
.top-actions { display: flex; gap: 2px; flex: none }

/* ---------- Stage ---------- */
.stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); min-height: 0 }
.map-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--sea) }
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none }
#map.dragging { cursor: grabbing }
#map:focus-visible { outline-offset: -4px }

/* Map layers. Strokes stay the same width at any zoom; text and markers are scaled by --u (map units per screen pixel). */
.sea { fill: var(--sea) }
.land { fill: var(--land); stroke: var(--coast); stroke-width: .8px; vector-effect: non-scaling-stroke; stroke-linejoin: round }
.land-shadow { fill: var(--land-shade); transform: translate(0, 2px) }
.lakes { fill: var(--sea); stroke: var(--river); stroke-width: .6px; vector-effect: non-scaling-stroke }
.rivers { fill: none; stroke: var(--river); stroke-width: 1.1px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round }
.emp { fill: var(--ec); fill-opacity: .17; stroke: var(--ec); stroke-opacity: .55; stroke-width: 1.4px; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; transition: fill-opacity .3s }
.emp.hot { fill-opacity: .3 }
.emp-label { font: italic 600 calc(var(--u) * 13px) var(--body); fill: var(--ec); letter-spacing: .06em; text-anchor: middle; paint-order: stroke; stroke: var(--halo); stroke-width: calc(var(--u) * 3px); stroke-linejoin: round; cursor: pointer; opacity: .95 }
.emp-label:hover { text-decoration: underline }
.lbl { text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--halo); stroke-width: calc(var(--u) * 2.5px); stroke-linejoin: round }
.lbl.k-sea { font: italic 400 calc(var(--u) * 13px) var(--body); fill: var(--searoute); stroke: none; opacity: .75; letter-spacing: .08em }
.lbl.k-desert { font: italic 400 calc(var(--u) * 12px) var(--body); fill: var(--muted); letter-spacing: .05em }
.lbl.k-mount { font: 600 calc(var(--u) * 10.5px) var(--ui); fill: var(--muted); letter-spacing: .14em; text-transform: uppercase }
.lbl.k-land { font: 700 calc(var(--u) * 14px) var(--ui); fill: var(--muted); letter-spacing: .3em; opacity: .55 }
.lbl.s1.k-sea { font-size: calc(var(--u) * 15px) }
.lbl.k-land.s2, .lbl.k-land.s3 { font-size: calc(var(--u) * 11px) }

.route { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; transition: opacity .3s }
.route.kind-land { stroke: var(--silk); stroke-width: 2.6px }
.route.kind-royal { stroke: var(--royal); stroke-width: 2.6px }
.route.kind-sea { stroke: var(--searoute); stroke-width: 2px; stroke-dasharray: 7 6 }
.route.kind-steppe { stroke: var(--steppe); stroke-width: 2.2px; stroke-dasharray: 1 6 }
.route-flow { fill: none; stroke: var(--paper); stroke-width: 1.2px; stroke-dasharray: 2 16; vector-effect: non-scaling-stroke; pointer-events: none; opacity: .9; animation: flow 3s linear infinite }
@keyframes flow { to { stroke-dashoffset: -36 } }
.route-hit { fill: none; stroke: transparent; stroke-width: 16px; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: stroke }
.route-g.hot .route { stroke-width: 4.5px }
.route-g.dim { opacity: .18 }
.faith { fill: none; stroke: var(--fc); stroke-width: 2.4px; stroke-dasharray: 10 5; vector-effect: non-scaling-stroke; stroke-linecap: round; opacity: .9 }
.faith-g { cursor: pointer }
.faith-hit { fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; pointer-events: stroke }
.faith-g.hot .faith { stroke-width: 4px; opacity: 1 }
.goods-flow { fill: none; stroke: var(--c2); stroke-width: 1.8px; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; opacity: 0; transition: opacity .25s; pointer-events: none }
.good-g.hot .goods-flow, .good-g:hover .goods-flow { opacity: 1 }
.good-tag { cursor: pointer }
.good-tag rect { fill: var(--c2-soft); stroke: var(--c2); stroke-width: 1px; vector-effect: non-scaling-stroke }
.good-tag text { font: 700 11px var(--ui); fill: var(--ink); text-anchor: middle; dominant-baseline: central }
.good-g.hot .good-tag rect { fill: var(--c2); } .good-g.hot .good-tag text { fill: var(--paper) }
.mk-s { transform: scale(var(--u)) }

.pl { cursor: pointer; outline: none }
.pl .dot { fill: var(--paper); stroke: var(--ink); stroke-width: 1.8px }
.pl.t-port .dot { stroke: var(--searoute) }
.pl.t-site .dot { fill: var(--ink) }
.pl .seen { fill: var(--silk); opacity: 0 }
.pl.is-seen .seen { opacity: 1 }
.pl .ring { fill: none; stroke: var(--silk); stroke-width: 2.4px; opacity: 0 }
.pl.sel .ring { opacity: 1; animation: pulse 1.8s ease-out infinite; transform-origin: center; transform-box: fill-box }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1 } 100% { transform: scale(1.9); opacity: 0 } }
.pl text { font: 650 13px var(--ui); fill: var(--ink); paint-order: stroke; stroke: var(--halo); stroke-width: 3.5px; stroke-linejoin: round }
.pl.r1 text { font-size: 14px; font-weight: 750 }
.pl.t-region text { font: italic 600 13px var(--body); fill: var(--muted); letter-spacing: .03em }
.pl.t-region .dot { display: none }
.pl.t-region .hit { fill: transparent }
.pl:hover text, .pl:focus-visible text, .pl.sel text { fill: var(--silk) }
.pl:focus-visible .dot { stroke: var(--c3); stroke-width: 3px }
.pl .hit { fill: transparent }
.pl.hide-lbl text { display: none }
.pl.hide-lbl:hover text, .pl.hide-lbl:focus-visible text { display: inline }
.pl.flash .ring { opacity: 1; animation: pulse 1s ease-out 2 }
/* Level of detail: rank 2 and 3 places, and small labels, appear as you zoom in. */
#map[data-lod="1"] .r2, #map[data-lod="1"] .r3, #map[data-lod="2"] .r3 { display: none }
#map[data-lod="1"] .lbl.s3, #map[data-lod="1"] .lbl.k-mount { display: none }
#map[data-lod="3"] .lbl.k-land.s1 { opacity: .3 }
.pl.r3 text, .pl.r2 text { font-size: 12px }
.tour-line { fill: none; stroke: var(--ink); stroke-width: 3px; stroke-dasharray: 1 7; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .75 }
.tour-stop { fill: var(--ink) }
.tour-stop-n { font: 800 10px var(--ui); fill: var(--paper); text-anchor: middle; dominant-baseline: central }
.off { display: none }

/* Map controls */
.zoom { position: absolute; right: var(--s3); top: var(--s3); display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; box-shadow: var(--shadow) }
.zoom .icon-btn { width: 38px; height: 38px }
.dock { position: absolute; left: var(--s3); bottom: var(--s3); display: flex; gap: var(--s2); max-width: calc(100% - 24px); overflow-x: auto; padding: 4px; scrollbar-width: none }
.dock::-webkit-scrollbar { display: none }
.layers { position: absolute; left: var(--s3); bottom: 64px; width: 270px; padding: var(--s4); display: grid; gap: var(--s2); z-index: 5 }
.tog { display: flex; align-items: center; gap: var(--s3); font: 600 15px/1.2 var(--ui); cursor: pointer; padding: 4px 0 }
.tog input { width: 18px; height: 18px; accent-color: var(--silk); margin: 0 }
.sw { width: 22px; height: 6px; border-radius: 3px; flex: none }
.sw-routes { background: var(--silk) } .sw-empires { background: color-mix(in srgb, #6a44b8 40%, transparent); height: 12px; border: 1px dashed #6a44b8 }
.sw-faiths { background: repeating-linear-gradient(90deg, #2d5bb3 0 6px, transparent 6px 9px) } .sw-goods { background: var(--c2) } .sw-labels { background: var(--muted); height: 2px }
.legend { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s2); font: 500 13px/1.3 var(--ui); color: var(--muted) }
.legend-row { display: flex; align-items: center; gap: var(--s2) }
.legend-row svg { width: 26px; height: 10px; flex: none }
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--paper); font: 600 13px/1.3 var(--ui); padding: 6px 10px; border-radius: 8px; max-width: 240px; transform: translate(12px, 12px) }

.tour-bar { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); padding: var(--s4) var(--s4) var(--s3); display: grid; gap: var(--s3); z-index: 6 }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2) }
.tour-text { font-size: 17px; line-height: 1.5 }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s2) }
.tour-step { font: 600 13px var(--ui); color: var(--muted) }
.toast { position: absolute; left: 50%; top: var(--s3); transform: translateX(-50%); background: var(--ink); color: var(--paper); font: 600 14px/1.35 var(--ui); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); z-index: 7; max-width: calc(100% - 120px); text-align: center; animation: toast 2.6s ease forwards; pointer-events: none }
.toast b { color: var(--c2) }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -6px) } 10%, 80% { opacity: 1; transform: translate(-50%, 0) } 100% { opacity: 0 } }

/* ---------- Panel ---------- */
.panel { background: var(--paper); border-left: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; z-index: 8 }
.grab { display: none }
.panel-scroll { overflow-y: auto; padding: var(--s5) var(--s5) var(--s6); display: grid; gap: var(--s5); align-content: start; overscroll-behavior: contain }
.p-head { display: grid; gap: var(--s2) }
.p-head h2 { font-size: 28px }
.p-sub { font: 500 15px/1.35 var(--ui); color: var(--muted) }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 4px; font: 650 14px/1 var(--ui); color: var(--muted); background: none; border: 0; padding: 6px 8px 6px 0; cursor: pointer }
.back:hover { color: var(--ink) }
.back .ic { width: 16px; height: 16px }
.tags { display: flex; flex-wrap: wrap; gap: 6px }
.tag { font: 700 12px/1 var(--ui); padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 0; letter-spacing: .02em }
button.tag { cursor: pointer } button.tag:hover { filter: brightness(.96) }
.tag.ch1 { background: var(--c1-soft); color: var(--c1) } .tag.ch2 { background: var(--c2-soft); color: var(--c2) } .tag.ch3 { background: var(--c3-soft); color: var(--c3) }
.tag.extra { background: transparent; border: 1px dashed var(--muted) }
.summary { font-size: 18px; line-height: 1.6 }
.sec { display: grid; gap: var(--s2) }
.sec h3 { font: 700 13px/1.2 var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted) }
.deeper { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.deeper summary { cursor: pointer; list-style: none; padding: var(--s3) var(--s4); font: 700 15px var(--ui); display: flex; justify-content: space-between; align-items: center }
.deeper summary::-webkit-details-marker { display: none }
.deeper summary::after { content: "+"; font-size: 20px; color: var(--muted) }
.deeper[open] summary::after { content: "–" }
.deeper summary:hover { background: var(--surface-2); border-radius: var(--r) }
.deeper ul { padding: 0 var(--s4) var(--s4) 2.2em; display: grid; gap: var(--s2) }
.links { display: grid; gap: 2px; list-style: none; padding: 0 }
.link { width: 100%; text-align: left; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: baseline; background: none; border: 0; padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-sm); cursor: pointer; font: 500 15px/1.35 var(--ui) }
.link:hover { background: var(--surface-2) }
.link .yr { font-weight: 750; color: var(--c, var(--muted)); min-width: 64px; font-variant-numeric: tabular-nums }
.link .nm { font-weight: 650 }
.link small { display: block; color: var(--muted); font-weight: 500; font-size: 13px }
.ch-card { --c: var(--c1); display: grid; gap: var(--s3) }
.ch-card h2 { font-size: 30px }
.ch-card .blurb { font-size: 17.5px }
.big { list-style: none; padding: 0; display: grid; gap: var(--s2) }
.big li { position: relative; padding-left: 26px; font-size: 16.5px; line-height: 1.45 }
.big li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 10px; height: 10px; border-radius: 50%; background: var(--c) }
.row-btns { display: flex; flex-wrap: wrap; gap: var(--s2) }
.prog { display: grid; gap: 6px; font: 600 14px var(--ui) }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 4px; transition: width .4s }
.place-list { columns: 2; column-gap: var(--s4); list-style: none; padding: 0 }
.place-list li { break-inside: avoid }
.place-list .link { grid-template-columns: 12px minmax(0, 1fr); margin: 0; padding: 5px 6px; font-size: 14.5px }
.pdot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ink); align-self: center }
.is-seen .pdot { background: var(--silk); border-color: var(--silk) }
.good-mini { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--c2-soft); color: var(--ink); font: 700 12px var(--ui) }

/* ---------- Time bar ---------- */
.timebar { display: flex; align-items: center; gap: var(--s3); padding: 0 max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom, 0) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--paper); z-index: 20 }
.time-track { position: relative; flex: 1; min-width: 0; height: 40px; display: flex; align-items: center }
.time-ticks { position: absolute; left: 0; right: 0; top: 50%; height: 8px; transform: translateY(-50%); border-radius: 4px; background: var(--surface-2); overflow: hidden; pointer-events: none }
.time-ticks .band { position: absolute; top: 0; bottom: 0; opacity: .45 }
.time-ticks .ev { position: absolute; top: 1px; bottom: 1px; width: 2px; background: var(--ink); opacity: .35 }
#time { position: relative; z-index: 1; width: 100%; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; height: 40px; cursor: pointer }
#time::-webkit-slider-runnable-track { height: 8px; background: transparent }
#time::-moz-range-track { height: 8px; background: transparent }
#time::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -7px; border-radius: 50%; background: var(--silk); border: 3px solid var(--paper); box-shadow: 0 1px 4px rgb(0 0 0 / .35) }
#time::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--silk); border: 3px solid var(--paper); box-shadow: 0 1px 4px rgb(0 0 0 / .35) }
#time:focus-visible { outline: none } #time:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--c3) }
.year { font: 800 18px/1 var(--display); min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -.01em }

/* ---------- Dialogs ---------- */
.modal { border: 0; padding: 0; background: transparent; color: var(--ink); width: min(620px, calc(100vw - 24px)); max-height: min(86dvh, 820px) }
.modal::backdrop { background: rgb(20 14 8 / .45); backdrop-filter: blur(2px) }
.modal-in { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s6) var(--s5) var(--s5); max-height: min(86dvh, 820px); overflow-y: auto; display: grid; gap: var(--s4) }
.modal-x { position: absolute; right: var(--s3); top: var(--s3) }
#dlg-body { display: grid; gap: var(--s4) }
#dlg-body h2 { font-size: 28px; padding-right: 40px }
.search-in { display: flex; align-items: center; gap: var(--s2); border: 2px solid var(--line); border-radius: 999px; padding: 4px 14px; background: var(--surface) }
.search-in:focus-within { border-color: var(--ink) }
.search-in input { flex: 1; min-width: 0; border: 0; background: transparent; font: 500 17px var(--ui); padding: 8px 0; color: var(--ink); outline: none }
.results { list-style: none; padding: 0; display: grid; gap: 2px; min-height: 120px }
.kind { font: 700 11px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); min-width: 64px }
.tl-group { display: grid; gap: 2px }
.tl-group h3 { font: 750 16px var(--display); color: var(--c); margin: var(--s3) 0 var(--s1) }
.tour-cards { display: grid; gap: var(--s2); grid-template-columns: minmax(0, 1fr) }
.tour-card { text-align: left; display: grid; gap: 4px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r); background: var(--surface); cursor: pointer; font: 500 14px/1.4 var(--ui); color: var(--muted) }
.tour-card:hover { background: var(--surface-2) }
.tour-card b { font: 700 17px var(--display); color: var(--ink) }
.qz-q { font: 700 21px/1.3 var(--display) }
.qz-opts { display: grid; gap: var(--s2) }
.qz-opt { text-align: left; padding: 13px 16px; border-radius: var(--r); border: 2px solid var(--line); background: var(--surface); cursor: pointer; font: 600 16px/1.35 var(--ui) }
.qz-opt:hover { border-color: var(--ink) }
.qz-opt.right { border-color: var(--ok); background: var(--ok-soft) }
.qz-opt.wrong { border-color: var(--bad); background: var(--bad-soft) }
.qz-opt[disabled] { cursor: default }
.qz-why { font-size: 16px; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--surface-2) }
.qz-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font: 600 14px var(--ui); color: var(--muted) }
.qz-score { font: 800 56px/1 var(--display); color: var(--c) }
.ch-pick { display: flex; flex-wrap: wrap; gap: var(--s2) }
.about p + p { margin-top: var(--s3) }
.about h3 { font: 700 15px var(--ui); margin-top: var(--s2) }
.welcome-map { width: 100%; height: auto; border-radius: var(--r); background: var(--sea) }

body.lost { display: grid; place-items: center; overflow: auto; grid-template-rows: none }
.lost-in { text-align: center; display: grid; gap: var(--s4); padding: var(--s5); justify-items: center }

/* ---------- Mobile: the panel becomes a bottom sheet ---------- */
@media (min-width: 1100px) { .tab-t { display: inline } .tab .tab-t { max-width: 150px; overflow: hidden; text-overflow: ellipsis } .tab[aria-selected="true"] .tab-t { max-width: none } }
@media (max-width: 860px) {
  :root { --top-h: 56px; --time-h: 56px }
  .stage { grid-template-columns: minmax(0, 1fr) }
  .tab[aria-selected="true"] .tab-t { display: none }
  .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 58%; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / .18); transform: translateY(calc(100% - 74px)); transition: transform .3s ease }
  .panel.open { transform: none }
  .grab { display: block; width: 100%; height: 22px; flex: none; background: none; border: 0; cursor: pointer; position: relative; touch-action: none }
  .grab::before { content: ""; position: absolute; left: 50%; top: 9px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line) }
  .panel-scroll { padding: 0 var(--s4) var(--s5); gap: var(--s4) }
  .panel:not(.open) .panel-scroll { overflow: hidden }
  .p-head h2, .ch-card h2 { font-size: 24px }
  .dock { bottom: 86px }
  .layers { bottom: 136px }
  .tour-bar { bottom: 86px }
  .panel.touring { transform: translateY(100%) }
  .summary { font-size: 17px }
}
@media (max-width: 560px) {
  .brand span { display: none }
  .tabs { margin: 0 auto }
  .tab { padding: 6px 8px }
  .top-actions .icon-btn { width: 38px; height: 38px }
  .year { min-width: 70px; font-size: 16px }
  .chip span { font-size: 13px }
  .place-list { columns: 1 }
  .modal-in { padding: var(--s6) var(--s4) var(--s4) }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
}
