/* Palette: field-notebook paper and veld colours. Each section carries its own accent (see body[data-section]). */
:root, [data-theme="light"] {
  --bg: #f1ebdd; --bg2: #faf6ec; --bg3: #e7dfcc; --fg: #2a251d; --muted: #6e6352; --line: #d3c7ae;
  --sky: #e4ded0; --ok: #4f7a3a; --warn: #a77a1f; --err: #a23b2a; --on-accent: #fffaf0;
  --geology: #a8552b; --ecology: #4f7a3a; --archaeology: #8e3a2c; --history: #5d5a72;
  --accent: var(--geology); --accent2: #b4782e;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --shadow: 0 1px 2px rgb(60 45 20 / 12%), 0 6px 18px rgb(60 45 20 / 10%);
}
[data-theme="dark"] {
  --bg: #1c1a15; --bg2: #24211b; --bg3: #2f2b23; --fg: #ece5d4; --muted: #a89d87; --line: #3d382d;
  --sky: #15130f; --ok: #7fa865; --warn: #c9a04a; --err: #d0705e; --on-accent: #1c1a15;
  --geology: #dc8a55; --ecology: #93b86f; --archaeology: #d4806c; --history: #a9a5c8;
  --accent2: #d6a253;
  --shadow: 0 1px 2px #0006, 0 8px 24px #0005;
}
body[data-section="geology"] { --accent: var(--geology); }
body[data-section="ecology"] { --accent: var(--ecology); }
body[data-section="archaeology"] { --accent: var(--archaeology); }
body[data-section="history"] { --accent: var(--history); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); }
body { display: grid; grid-template: "top top" auto "sub sub" auto "main panel" 1fr / 1fr minmax(330px, 27vw); overflow: hidden; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; }
button, select, input { font: inherit; color: var(--fg); background: var(--bg2); border: 1px solid var(--line); border-radius: 3px; padding: 5px 10px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.icon { padding: 3px 9px; font-size: 16px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.small { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

/* Header: name, the four sections, search and tools. */
#topbar { grid-area: top; display: flex; align-items: stretch; gap: 22px; padding: 0 16px; min-height: 58px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; justify-content: center; line-height: 1.15; text-decoration: none; color: var(--fg); padding-right: 6px; }
.brand strong { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .01em; }
.brand .small { font-size: 11.5px; }
#sections { display: flex; align-items: stretch; gap: 2px; }
#sections a { display: flex; align-items: center; padding: 0 14px; font-family: var(--serif); font-size: 16.5px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
#sections a:hover { color: var(--fg); }
#sections a[data-section="geology"].active { color: var(--geology); border-color: var(--geology); }
#sections a[data-section="ecology"].active { color: var(--ecology); border-color: var(--ecology); }
#sections a[data-section="archaeology"].active { color: var(--archaeology); border-color: var(--archaeology); }
#sections a[data-section="history"].active { color: var(--history); border-color: var(--history); }
.search { position: relative; flex: 1; max-width: 380px; align-self: center; }
.search input { width: 100%; background: var(--bg); }
#search-results { position: absolute; z-index: 30; top: 36px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; max-height: 60vh; overflow: auto; box-shadow: var(--shadow); }
#search-results li { padding: 4px 6px; }
.actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.actions select { width: auto; max-width: 130px; }

/* Pages within the active section. */
#subnav { grid-area: sub; display: flex; align-items: center; gap: 4px; padding: 6px 16px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; }
#subnav .subnav-title { margin-right: 14px; font-size: 12px; color: var(--muted); font-style: italic; }
#subnav a { padding: 4px 11px; border-radius: 3px; color: var(--fg); text-decoration: none; font-size: 13px; border: 1px solid transparent; }
#subnav a:hover { border-color: var(--line); background: var(--bg2); }
#subnav a.active { background: var(--accent); color: var(--on-accent); }

#viewport { grid-area: main; position: relative; overflow: hidden; }
#viewport canvas { display: block; }
.label-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.map-label { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: #000a; color: #fff; white-space: nowrap; pointer-events: none; }
.map-label.kind-town { font-weight: 600; }
.map-label.measure { background: #ff3b6bcc; }
.map-label.river-label { background: transparent; color: #9fd4ff; font-style: italic; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.map-label.fault-label { background: transparent; color: #ffb3b3; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.map-tooltip { position: absolute; z-index: 5; pointer-events: none; max-width: 280px; padding: 6px 9px; border-radius: 6px; background: rgba(20,16,12,0.92); color: #fff; font-size: 12.5px; line-height: 1.35; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.map-tooltip strong, .map-tooltip span, .map-tooltip em { display: block; }
.map-tooltip span { color: #e6dccb; }
.map-tooltip em { color: #b9ad98; font-size: 11px; margin-top: 2px; }
.map-label.peak-label { background: transparent; font-size: 11px; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.zoom-far .map-label:not(.kind-town):not(.measure) { visibility: hidden; }
.zoom-mid .river-label, .zoom-mid .peak-label, .zoom-mid .kind-spring { visibility: hidden; }
.map-label.strat-label { background: #0008; transform: translateX(50%); }
.map-label.col-head { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.toolbar { position: absolute; z-index: 5; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; background: color-mix(in srgb, var(--bg2) 94%, transparent); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); }
.toolbar .toggle, .toolbar .range { display: inline-flex; align-items: center; gap: 4px; }
.toolbar input[type=range] { padding: 0; }
#time-slider { flex: 1; min-width: 160px; accent-color: var(--accent); }
.time-label { font-weight: 600; min-width: 220px; }
.legend { position: absolute; z-index: 5; bottom: 34px; left: 10px; max-width: 290px; max-height: 50%; overflow: auto; padding: 8px 10px; background: color-mix(in srgb, var(--bg2) 94%, transparent); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; box-shadow: var(--shadow); }
.legend:empty { display: none; }
.legend i, .unit-list i, table.log i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: middle; }
.legend i.dash { background: repeating-linear-gradient(90deg, #111 0 6px, transparent 6px 10px); border: 1px solid #888; }
.scope-banner { position: absolute; bottom: 6px; right: 10px; z-index: 5; background: color-mix(in srgb, var(--bg2) 85%, transparent); padding: 2px 8px; border-radius: 3px; }
.compare-caption { position: absolute; z-index: 5; top: 60px; left: 0; right: 0; display: flex; justify-content: space-around; pointer-events: none; font-weight: 700; text-shadow: 0 1px 3px #000; }
.compare-caption::after { content: ""; position: absolute; left: 50%; top: -10px; height: 100vh; border-left: 2px dashed var(--accent); }

#panel { grid-area: panel; overflow: auto; padding: 16px 18px 40px; background: var(--bg2); border-left: 1px solid var(--line); }
#panel h2 { margin: 0 0 8px; font-size: 22px; color: var(--fg); border-bottom: 2px solid var(--accent); padding-bottom: 4px; }
#panel h3 { margin: 18px 0 6px; font-size: 16.5px; color: var(--accent); }
#panel h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#panel p { max-width: 68ch; }
dl.facts { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 8px 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.tag { display: inline-block; padding: 1px 7px; margin: 0 4px 2px 0; border-radius: 3px; background: var(--bg3); font-size: 11px; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; color: #fff; background: #667; vertical-align: middle; }
.v-crossref-verified, .v-primary-source-in-workspace { background: var(--ok); }
.v-secondary-citation { background: var(--warn); }
.v-web-accessed { background: #6a5acd; }
.v-dataset-accessed { background: #2f7f9e; }
.time-hud { position: absolute; z-index: 6; left: 12px; top: 92px; max-width: 460px; padding: 8px 10px; border-radius: 6px; background: #000b; color: #fff; font-size: 13px; line-height: 1.4; pointer-events: none; border-left: 4px solid #3fa9ff; }
.time-hud.flood { border-left-color: #ff7a3d; }
.time-hud .small { opacity: 0.75; font-size: 11px; margin-top: 4px; }
.map-label.flow-label { background: #3a2f00cc; color: #ffe066; }
.map-label.north-label { background: transparent; font-weight: 700; font-size: 14px; text-shadow: 0 0 3px #000; }
.legend i.dot { border-radius: 50%; }
.grain-chart, .time-ruler { margin: 4px 0 8px; }
.grain-chart svg, .time-ruler svg { width: 100%; height: auto; font-family: inherit; }
.gc-class { font-size: 8px; fill: currentColor; opacity: 0.8; text-anchor: middle; }
.gc-name { font-size: 9px; fill: currentColor; text-anchor: end; }
.gc-v { font-size: 9px; fill: currentColor; text-anchor: end; }
.gc-head { opacity: 0.7; }
.gc-tick { font-size: 8px; fill: currentColor; opacity: 0.8; text-anchor: middle; }
.gc-axis { stroke: currentColor; opacity: 0.6; }
.gc-hl .gc-name { font-weight: 700; fill: var(--accent); }
.tr-dep { fill: #d08a52; }
.tr-intr { fill: #e0442c; }
.tr-break { stroke: currentColor; stroke-dasharray: 2 2; }
.tr-stop { fill: currentColor; opacity: 0.5; }
.tr-cur { fill: var(--accent); }
.tr-tecto { stroke: #000a; stroke-width: 0.5; opacity: 0.75; }
.tr-tecto.k-fault, .tr-tecto.k-rift { fill: #ff5a36; }
.tr-tecto.k-uplift { fill: #ffa040; }
.tr-tecto.k-subsidence { fill: #5aa9ff; }
.tr-tecto.k-deformation { fill: #ffd166; }
.tr-tecto-cur { opacity: 1; stroke: #fff; stroke-width: 0.8; }
.tecto-event { margin: 6px 0; padding: 4px 8px; border-left: 4px solid #ff5a36; background: #ffffff08; }
.tecto-event.k-uplift { border-color: #ffa040; }
.tecto-event.k-subsidence { border-color: #5aa9ff; }
.tecto-event.k-deformation { border-color: #ffd166; }
.map-label.tecto-label { background: #4a1408cc; color: #ffd2c4; }
.sed-unit { margin: 6px 0; padding: 4px 0; border-bottom: 1px solid #ffffff14; }
.sed-unit .swatch { display: inline-block; width: 10px; height: 10px; margin-right: 4px; border-radius: 2px; }
.phyd { border-collapse: collapse; font-size: 12px; margin: 4px 0; }
.phyd th, .phyd td { text-align: left; padding: 2px 8px 2px 0; border-bottom: 1px solid #ffffff1a; font-weight: normal; }
.phyd th { opacity: 0.8; }
.geocode { border-left: 4px solid #9aa0a6; padding: 4px 8px; margin: 6px 0; background: #ffffff0d; }
.geocode.conf-high { border-color: #4ade80; }
.geocode.conf-medium { border-color: #e8e15a; }
.lvl-error { background: var(--err); } .lvl-warn { background: var(--warn); } .lvl-review { background: #557; }
.cites { display: inline; }
button.cite { padding: 0 5px; margin: 0 2px; font-size: 11px; border-radius: 4px; background: transparent; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.inference { margin: 8px 0; padding: 6px 9px; border-left: 3px solid var(--accent2); background: color-mix(in srgb, var(--accent2) 10%, transparent); font-size: 12.5px; }
.note { border-left: 3px solid var(--muted); padding-left: 8px; }
figure.media { margin: 10px 0; cursor: zoom-in; }
figure.media img { width: 100%; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
figure.media figcaption { font-size: 12px; color: var(--muted); }
blockquote { margin: 8px 0; padding: 6px 10px; background: var(--bg3); border-radius: 6px; font-size: 12.5px; }
blockquote footer { margin-top: 4px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.filters input { grid-column: 1 / -1; }
.gaz-list { list-style: none; padding: 0; }
.gaz-list li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.hist-maps { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 8px 0; }
.hist-card { display: flex; gap: 8px; align-items: center; text-align: left; padding: 4px; background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; color: inherit; }
.hist-card img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: #fff; }
.hist-card.active { border-color: var(--accent); outline: 1px solid var(--accent); }
.hist-people ul { padding-left: 16px; font-size: 12.5px; }
.jour-list { display: grid; gap: 4px; margin: 8px 0; }
.jour-card { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px 8px; background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; color: inherit; }
.jour-card.active { border-color: var(--accent); outline: 1px solid var(--accent); }
.jour-card i, .jour-swatch { flex: none; display: inline-block; width: 22px; height: 5px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(20,14,8,0.7); vertical-align: middle; margin-right: 6px; }
.jour-card i.dashed, .jour-swatch.dashed { -webkit-mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 10px); mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 10px); }
.jour-stops { padding-left: 20px; font-size: 13px; }
.jour-stops li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.jour-stops li.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.jour-stops details summary { cursor: pointer; color: var(--muted, inherit); }
.jour-notmapped ul { padding-left: 16px; font-size: 12.5px; }
.jour-links { margin: 4px 0 0; padding-left: 16px; font-size: 12.5px; }
.town-history .site-farms { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.town-history .basis-documented { background: #2e7d4f; color: #fff; }
.town-history .basis-map-evidence { background: #b7791f; color: #fff; }
.town-history .basis-unknown { background: #6b6b6b; color: #fff; }
.town-events { margin: 6px 0; padding-left: 0; list-style: none; font-size: 13px; }
.town-events li { margin: 0 0 5px; padding-left: 74px; text-indent: -74px; }
.town-events .yr { display: inline-block; width: 70px; text-indent: 0; font-weight: 600; color: var(--accent2); }
.jour-stops .arch-gallery { margin-top: 6px; }
.map-label.journey-label { background: #2a1d12e0; color: #fff3dc; font-size: 11.5px; border: 1px solid #ffffff40; }
.map-label.journey-label.pick { pointer-events: auto; cursor: pointer; }
.map-label.journey-label.pick:hover { border-color: #ffd166; }
.map-label.journey-label.active { background: #ffd166; color: #2a1d12; border-color: #2a1d12; font-weight: 700; }
.jour-story { padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.jour-story h3 { margin: 6px 0 2px; font-size: 14.5px; }
.jour-nav { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0; }
.gaz-list li.hit { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.gaz-list li.active { border-left: 3px solid var(--accent); padding-left: 6px; }
.unit-list { list-style: none; padding: 0; columns: 2; font-size: 12.5px; }
table.log { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.log td, table.log th { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
ol.refs li { margin-bottom: 8px; }
ol.refs li.focus { outline: 2px solid var(--accent); border-radius: 4px; }
details { margin: 6px 0; }
summary { cursor: pointer; font-weight: 600; }
.error { color: var(--err); }

.story { position: absolute; z-index: 8; left: 12px; bottom: 34px; width: min(460px, 70%); max-height: 70%; overflow: auto; padding: 12px 16px; background: var(--bg2); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 4px; box-shadow: var(--shadow); }
.story header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.story header strong { flex: 1; color: var(--fg); font-family: var(--serif); font-size: 16px; }
.story footer { display: flex; justify-content: space-between; margin-top: 10px; }
.step-text { font-size: 15px; }
.options { display: grid; gap: 6px; }
.option.correct { background: var(--ok); color: #fff; }
.option.wrong { background: var(--err); color: #fff; }
.objectives { font-size: 12.5px; color: var(--muted); }

dialog { max-width: min(720px, 92vw); color: var(--fg); background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 14px 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(30 25 15 / 55%); }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
dialog form { display: flex; gap: 6px; margin: 8px 0; }
dialog form input { flex: 1; }
.media-dialog { max-width: 95vw; }
.media-dialog img { max-width: 90vw; max-height: 80vh; background: #fff; }
.qa { border-top: 1px solid var(--line); padding-top: 6px; }
.qa .q { font-weight: 600; }

/* Archaeology view */
body.wide-panel { grid-template-columns: 1fr minmax(390px, 34vw); }
.map-label.kind-archaeological-site { background: #b0306ecc; }
.map-label.kind-heritage { background: #6b3fb0cc; font-size: 11px; }
.zoom-mid .kind-heritage { visibility: hidden; }
ul.reg-list { columns: 2; column-gap: 14px; padding-left: 16px; font-size: 12.5px; }
ul.reg-list li { break-inside: avoid; margin-bottom: 3px; }
.arch-timeline { width: 100%; height: auto; margin: 4px 0; }
.arch-timeline .arch-band-label { font-size: 10px; fill: var(--fg); }
.arch-timeline .arch-tick { font-size: 9px; fill: var(--muted); }
.arch-timeline .arch-grid { stroke: var(--line); stroke-dasharray: 2 3; }
.arch-timeline .arch-date { cursor: pointer; }
.arch-timeline .arch-date:hover circle, .arch-timeline .arch-date:focus circle { stroke: var(--accent); stroke-width: 2.5; }
.period-tag i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.site-cards { display: grid; gap: 8px; }
.site-card { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg3); cursor: pointer; }
.site-card:hover, .site-card:focus { border-color: var(--accent); outline: none; }
.site-card img, .site-card .no-thumb { width: 84px; height: 64px; object-fit: cover; border-radius: 5px; }
.site-card .no-thumb { display: grid; place-items: center; font-size: 28px; color: var(--muted); background: var(--bg2); }
mark.farm-name { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--fg); padding: 0 5px; border-radius: 4px; font-weight: 600; font-size: 12.5px; }
.farm-banner { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 10px; padding: 8px 10px; border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 0 6px 6px 0; }
.farm-banner strong { font-size: 17px; }
.arch-geo { border-left: 3px solid var(--accent2); padding-left: 9px; margin: 10px 0; }
.arch-geo h4 { margin-top: 0 !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--fg) !important; font-size: 13.5px !important; }
.unit-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 10px; background: var(--bg3); text-decoration: none; color: var(--fg); font-size: 11.5px; }
.unit-chip i { display: inline-block; width: 12px; height: 9px; border-radius: 2px; }
.arch-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.arch-gallery figure.media { margin: 0; }
.arch-gallery figure.media img { height: 120px; object-fit: cover; }
figure.media .credit { display: block; font-style: italic; }
table.arch-dates { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.arch-dates td { border-top: 1px solid var(--line); padding: 4px 4px; vertical-align: top; }
table.arch-dates td:first-child { width: 42%; color: var(--muted); }

/* Presentation mode: chrome hidden, larger type for projection. */
body.presentation { grid-template: "main panel" 1fr / 1fr minmax(380px, 30vw); font-size: 17px; }
body.presentation #topbar, body.presentation #subnav { display: none; }
body.presentation .step-text { font-size: 22px; }
body.presentation #panel h2 { font-size: 26px; }

@media (max-width: 1100px) {
  #topbar { flex-wrap: wrap; gap: 8px 16px; padding: 6px 12px 0; }
  .search { order: 3; max-width: none; flex-basis: 100%; margin-bottom: 6px; }
  .brand .small { display: none; }
}
/* Phones and narrow tablets: header tools fold into a menu, the panel becomes a bottom sheet (map / split / text). */
#btn-menu, #sheet-bar, .map-fab { display: none; }
@media (max-width: 900px) {
  html, body { height: 100dvh; }
  body, body.wide-panel { grid-template: "top" auto "sub" auto "main" minmax(0, 1fr) "bar" auto "panel" 40dvh / minmax(0, 1fr); }
  body[data-sheet="map"] { grid-template-rows: auto auto minmax(0, 1fr) auto 0; }
  body[data-sheet="text"] { grid-template-rows: auto auto 0 auto minmax(0, 1fr); }
  body[data-sheet="map"] #panel { display: none; }
  #topbar button, #topbar select, .toolbar button, .toolbar select, #sheet-bar button { min-height: 34px; }
  input, select { font-size: 16px; }

  #topbar { flex-wrap: wrap; align-items: center; gap: 0 8px; padding: 4px 10px 0; min-height: 0; }
  .brand { order: 1; flex: 1; padding: 2px 0; }
  .brand strong { font-size: 18px; }
  #btn-menu { display: inline-block; order: 2; }
  #sections { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  #sections a { padding: 6px 9px; font-size: 15px; }
  .search, .actions { display: none; order: 4; flex-basis: 100%; }
  body.menu-open .search { display: block; max-width: none; margin: 6px 0; }
  body.menu-open .actions { display: flex; flex-wrap: wrap; margin: 0 0 8px; }
  .actions #btn-present { display: none; }
  #search-results { max-height: 50dvh; }

  #subnav { padding: 4px 10px; scrollbar-width: none; }
  #subnav .subnav-title { display: none; }

  /* Map tools: one row that scrolls sideways; the layer menu opens as a fixed sheet so the row does not clip it. */
  .toolbar { z-index: 7; top: 6px; left: 6px; right: 6px; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 4px 6px; white-space: nowrap; scrollbar-width: none; }
  .toolbar > * { flex: none; }
  .toolbar .sep { display: none; }
  .toolbar > #time-slider { width: 150px; min-width: 0; }
  .time-label { min-width: 0; }
  .toolbar .layer-menu-body { position: fixed; top: 22dvh; left: 8px; right: 8px; width: auto; max-height: 60dvh; white-space: normal; grid-template-columns: 1fr; }
  .time-hud { top: 54px; left: 6px; right: 6px; max-width: none; font-size: 12px; }
  .map-label { font-size: 10.5px; padding: 1px 4px; }
  .zoom-mid .map-label:not(.kind-town):not(.measure):not(.journey-label) { visibility: hidden; }
  .scope-banner { display: none; }

  .map-fab { position: absolute; z-index: 6; left: 8px; bottom: 8px; box-shadow: var(--shadow); }
  #legend:not(:empty) + .map-fab { display: block; }
  .legend { display: none; bottom: 50px; left: 8px; max-width: calc(100% - 16px); max-height: 60%; }
  body.legend-open .legend:not(:empty) { display: block; }
  body.legend-open .map-fab { background: var(--accent); color: var(--on-accent); }

  .story { left: 6px; right: 6px; bottom: 6px; width: auto; max-height: calc(100% - 60px); }

  #sheet-bar { grid-area: bar; display: flex; align-items: center; gap: 4px; padding: 3px 8px; background: var(--bg2); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgb(60 45 20 / 14%); }
  #sheet-title { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 4px 2px; font-family: var(--serif); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #sheet-bar button[data-sheet]:disabled { opacity: .35; cursor: default; }
  #panel { border-left: 0; padding: 10px 14px 32px; }
  #panel h2 { font-size: 19px; }
  .site-card { grid-template-columns: 64px 1fr; }
  .site-card img, .site-card .no-thumb { width: 64px; height: 52px; }
}

/* ---- Data classes, ecology, layer stack, cinematic tour ---- */
.tag.dc-geology { background: #c4704f; color: #fff; } .tag.dc-palaeontology { background: #8e7cc3; color: #fff; }
.tag.dc-economic-geology { background: #6b6b4f; color: #fff; } .tag.dc-hydrology { background: #2f7fc4; color: #fff; }
.tag.dc-climate { background: #b8874a; color: #fff; } .tag.dc-archaeology { background: #c2457f; color: #fff; }
.tag.dc-ecology { background: #c98a00; color: #fff; } .tag.dc-vegetation { background: #2f8f4f; color: #fff; }
.tag.dc-conservation { background: #3e9f5e; color: #fff; } .tag.dc-geospatial { background: #6b7280; color: #fff; }
.tag.dc-history { background: #9c8a55; color: #fff; }
.tag.secondary { opacity: 0.6; }
.tag.note-class { background: var(--bg3); border: 1px solid var(--line, #445); font-size: 10.5px; }
.class-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.seg { display: inline-flex; gap: 0; margin: 4px 0 10px; border-radius: 8px; overflow: hidden; border: 1px solid var(--bg3); }
.seg button { border: 0; border-radius: 0; padding: 4px 10px; background: transparent; color: inherit; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--on-accent); }
nav.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 12px; }
nav.tabs .tab { padding: 4px 10px; border-radius: 3px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; font-size: 12.5px; }
nav.tabs .tab.active { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.evidence { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: .03em; vertical-align: 1px; }
.ev-field { background: #1f6f43; color: #e9fff1; } .ev-records { background: #7a5a00; color: #fff4d0; }
.ev-model { background: #4b3f8f; color: #ece8ff; } .ev-historical { background: #6f5a3a; color: #fff1dc; }
ul.class-list { list-style: none; padding: 0; } ul.class-list li { margin: 0 0 8px; } ul.class-list i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
svg.chart { width: 100%; max-width: 420px; height: auto; } svg.chart .svg-label, svg.chart .svg-value { fill: currentColor; font-size: 11px; }
svg.chart .bar-leopard { fill: #e0a526; } svg.chart .err { stroke: currentColor; stroke-width: 1.3; }
table.species-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.species-table th, table.species-table td { border-bottom: 1px solid var(--bg3); padding: 4px 4px; vertical-align: top; text-align: left; }
table.species-table td.num { text-align: right; white-space: nowrap; } table.species-table tr.current { background: rgba(255, 196, 0, 0.12); }
.sel-bar { display: inline-block; width: 46px; height: 7px; margin-right: 4px; border-radius: 4px; background: linear-gradient(90deg, #ffc400 var(--w), rgba(127,127,127,.25) var(--w)); vertical-align: 1px; }
.veg-class { display: flex; gap: 8px; align-items: flex-start; } .veg-class > i { flex: 0 0 14px; height: 14px; border-radius: 3px; margin-top: 4px; }
ul.indicator-list { padding-left: 16px; font-size: 12.5px; }
.layer-stack ol { margin: 4px 0; padding-left: 18px; font-size: 12px; } .layer-stack li { display: flex; justify-content: space-between; gap: 8px; }
.map-label.eco-label { background: rgba(120, 70, 0, 0.82); color: #fff3d0; border: 1px solid #ffb703; font-weight: 600; }
.cinema-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.cinema-overlay .bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .6s ease; }
.cinema-overlay .bar.top { top: 0; } .cinema-overlay .bar.bottom { bottom: 0; display: flex; align-items: center; justify-content: center; }
.cinema-overlay.on .bar { height: 11%; } .cinema-overlay.on .bar.bottom { height: 19%; }
.cinema-caption { max-width: 820px; padding: 0 24px; color: #f2eadb; text-align: center; opacity: 0; transform: translateY(8px); transition: opacity .8s ease, transform .8s ease; font-family: Georgia, 'Times New Roman', serif; }
.cinema-caption.show { opacity: 1; transform: none; } .cinema-caption h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: .04em; color: #ffd27a; }
.cinema-caption p { margin: 2px 0; font-size: 15px; line-height: 1.4; } .cinema-caption .small, .cinema-caption .small a { font-size: 11px; color: #bfb5a3; pointer-events: auto; }
.cinema-exit { position: absolute; top: 12px; right: 14px; pointer-events: auto; background: rgba(0,0,0,.55); color: #fff; border: 1px solid #666; border-radius: 6px; padding: 4px 10px; cursor: pointer; opacity: 0; transition: opacity .6s; }
.cinema-overlay.on .cinema-exit { opacity: 1; }
body.cinema #legend, body.cinema #toolbar { opacity: 0; pointer-events: none; transition: opacity .6s; }
body.cinema .label-layer .map-label:not(.kind-town):not(.eco-label):not(.river-label) { display: none; }
.layer-menu { position: relative; }
.layer-menu > summary { cursor: pointer; list-style: none; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg3); }
.layer-menu > summary::after { content: ' \25BE'; }
.layer-menu[open] > summary { background: var(--accent); color: var(--on-accent); }
.layer-menu-body { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: min(640px, 80vw); max-height: 70vh; overflow: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; background: var(--bg2, #141c2b); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
.layer-menu-body > p { grid-column: 1 / -1; margin: 0; }
.class-group { margin: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; gap: 3px; }
.class-group legend { display: flex; align-items: center; gap: 6px; padding: 0 4px; font-weight: 600; font-size: 12.5px; }
.class-group legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px; vertical-align: 0; }
.class-group .solo { font-size: 11px; font-weight: 400; }
.class-group.disabled { opacity: .55; } .class-group .toggle { font-size: 12px; } .class-group p { margin: 0; }
