
:root {
  --night: #12100e;
  --night-2: #1c1814;
  --panel: #241e18;
  --cream: #f4efe4;
  --cream-dim: #d9d0c2;
  --paper: #f6f1e7;
  --paper-2: #ebe3d4;
  --ink: #1c1713;
  --ink-soft: #5a4e43;
  --gold: #c6a36a;
  --gold-2: #e6d3ab;
  --rust: #b55233;
  --moss: #2f6a52;
  --line: rgba(198, 163, 106, 0.38);
  --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --text: "Source Serif 4", Palatino, "Palatino Linotype", serif;
  --sans: "Figtree", "Segoe UI", sans-serif;
  --nav: 72px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

html[lang^="zh"] {
  --serif: "Noto Serif SC", "Songti SC", serif;
  --text: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
html[data-script="hant"] {
  --serif: "Noto Serif TC", "PMingLiU", serif;
  --text: "Noto Serif TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
html[data-script="ja"] {
  --serif: "Noto Serif JP", serif;
  --text: "Noto Serif JP", serif;
  --sans: "Noto Sans JP", sans-serif;
}
html[data-script="ko"] {
  --serif: "Noto Serif KR", serif;
  --text: "Noto Serif KR", serif;
  --sans: "Noto Sans KR", sans-serif;
}
html[data-script="arabic"] {
  --serif: "Noto Naskh Arabic", serif;
  --text: "Noto Naskh Arabic", serif;
  --sans: "Noto Sans Arabic", sans-serif;
}
html[data-script="hebrew"] {
  --serif: "Noto Serif Hebrew", serif;
  --text: "Noto Serif Hebrew", serif;
  --sans: "Noto Sans Hebrew", sans-serif;
}
html[data-script="deva"] {
  --serif: "Noto Serif Devanagari", serif;
  --text: "Noto Serif Devanagari", serif;
  --sans: "Noto Sans Devanagari", sans-serif;
}
html[data-script="beng"] {
  --serif: "Noto Serif Bengali", serif;
  --text: "Noto Serif Bengali", serif;
  --sans: "Noto Sans Bengali", sans-serif;
}
html[data-script="taml"] {
  --serif: "Noto Serif Tamil", serif;
  --text: "Noto Serif Tamil", serif;
  --sans: "Noto Sans Tamil", sans-serif;
}
html[data-script="thai"] {
  --serif: "Noto Serif Thai", serif;
  --text: "Noto Serif Thai", serif;
  --sans: "Noto Sans Thai", sans-serif;
}
html[data-script="cyrl"],
html[data-script="grek"],
html[data-script="vi"] {
  --serif: "Noto Serif", "Source Serif 4", serif;
  --text: "Noto Serif", "Source Serif 4", serif;
  --sans: "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body:has(#dock:not([hidden])) { scroll-padding-top: 140px; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(198, 163, 106, 0.08), transparent 50%),
    var(--night);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--rust); color: #fff8f3; }

.skip {
  position: absolute;
  left: 16px;
  top: -40px;
  background: var(--gold);
  color: var(--night);
  padding: 8px 12px;
  z-index: 80;
}
.skip:focus { top: 12px; }

#progress {
  position: fixed;
  left: 0; top: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--rust), var(--gold));
  z-index: 70;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: var(--nav);
  padding: 0 28px;
  background: rgba(18, 16, 14, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(244, 239, 228, 0.08);
}
.logo {
  font-family: var(--serif);
  letter-spacing: 0.16em;
  text-decoration: none;
  font-size: 0.95rem;
}
html[lang^="zh"] .logo { letter-spacing: 0.12em; }
.nav-links { display: flex; gap: 18px; margin-inline-start: 8px; }
.nav-links a {
  text-decoration: none;
  color: var(--cream-dim);
  font-size: 0.92rem;
}
.nav-links a:hover { color: var(--cream); }
.nav-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.lang-btn {
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.langs { display: flex; border: 1px solid var(--line); }
.langs button, .menu-btn, .btn, .chip, .icon-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
}
.langs button {
  padding: 6px 10px;
  color: var(--cream-dim);
}
.langs button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--night);
}
.menu-btn { display: none; padding: 8px 10px; border: 1px solid var(--line); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 12px 18px;
  border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.solid { background: var(--gold); color: var(--night); border-color: var(--gold); font-weight: 600; }
.btn.ghost { color: var(--cream); }
.btn.small { padding: 8px 12px; font-size: 0.92rem; }

.hero {
  position: relative;
  isolation: isolate;
  min-height: calc(100svh - var(--nav));
  overflow: hidden;
  border-bottom: 1px solid rgba(244, 239, 228, 0.08);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 6, 4, 0.08) 0%, rgba(8, 6, 4, 0.18) 42%, rgba(8, 6, 4, 0.55) 100%),
    linear-gradient(100deg, rgba(8, 6, 4, 0.88) 0%, rgba(8, 6, 4, 0.62) 32%, rgba(8, 6, 4, 0.22) 56%, rgba(8, 6, 4, 0.08) 100%);
}
.hero-copy {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  min-height: calc(100svh - var(--nav));
  max-width: 760px;
  padding: clamp(36px, 6vw, 84px) clamp(24px, 5vw, 72px) clamp(72px, 8vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 22px;
}
.eyebrow, .kicker {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-2);
}
html[lang^="zh"] .eyebrow,
html[lang^="zh"] .kicker {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.92rem;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(3.1rem, 6.4vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin: 0;
}
html[lang^="zh"] .hero h1 {
  letter-spacing: -0.02em;
  line-height: 1.08;
  font-weight: 600;
}
.lede, .dek {
  font-family: var(--text);
  font-size: 1.22rem;
  line-height: 1.55;
  color: var(--cream-dim);
  margin: 0;
  max-width: 38rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 8px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(244, 239, 228, 0.12);
}
.hero-stats div { min-width: 0; }
.hero-stats dt {
  font-family: var(--serif);
  font-size: 1.55rem;
  color: var(--gold-2);
}
.hero-stats dd { margin: 4px 0 0; color: var(--cream-dim); font-size: 0.92rem; }
.hero-photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  background: #000;
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 42%;
}
.hero-photo figcaption {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(420px, 42vw);
  margin: 0;
  padding: 36px 22px 16px;
  text-align: right;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #f6f1e8;
  font-size: 0.78rem;
  line-height: 1.45;
}
.cap {
  margin: 0;
  padding: 28px 16px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
  color: #f6f1e8;
  font-size: 0.78rem;
  line-height: 1.45;
}
.cap a, .credit a { color: var(--gold-2); }
.hero .btn.ghost {
  background: rgba(18, 16, 14, 0.35);
  border-color: rgba(244, 239, 228, 0.55);
}

.section { padding: clamp(48px, 8vw, 96px) 0; }
.wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.wrap-narrow { width: min(760px, calc(100% - 40px)); margin: 0 auto; }

.paper {
  background: var(--paper);
  color: var(--ink);
}
.paper .kicker { color: var(--rust); }
.paper .lede, .paper .dek { color: var(--ink-soft); }

.split {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 48px;
  align-items: start;
}
.prose { font-family: var(--text); font-size: 1.16rem; line-height: 1.75; }
html[lang^="zh"] .prose { font-size: 1.12rem; line-height: 1.95; }
.prose p { margin: 0 0 1.05em; }
.prose em { font-style: italic; }
.drop::first-letter {
  font-family: var(--serif);
  float: left;
  font-size: 3.4rem;
  line-height: 0.8;
  padding: 8px 10px 0 0;
  color: var(--rust);
}
html[lang^="zh"] .drop::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; }

.path-card, .claim, .note-card, .src-card, .quiz-card, .gloss-card {
  background: #fffdf8;
  border: 1px solid rgba(28, 23, 19, 0.08);
}
.paths { display: grid; gap: 12px; }
.path-card { padding: 16px 16px 18px; }
.path-card h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.35rem; font-weight: 560; }
.path-card p { margin: 0 0 12px; color: var(--ink-soft); }

.atlas-head, .archive-head, .band-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
}
.atlas-head h2, .archive-head h2, .band-head h2, .paper h2, .night-title {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
}
html[lang^="zh"] h2 { letter-spacing: 0; line-height: 1.25; }
.atlas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.tile {
  position: relative;
  min-height: 180px;
  border: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  color: white;
  background: #000;
}
.tile img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; transition: transform 0.5s ease; }
.tile:hover img { transform: scale(1.04); }
.tile span {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 1;
  font-family: var(--serif);
  font-size: 1.35rem;
  text-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.62));
}
.tile small {
  position: absolute;
  z-index: 1;
  left: 12px; top: 12px;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--gold-2);
}

.timeline-wrap { overflow: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.timeline { display: flex; gap: 12px; width: max-content; padding-bottom: 8px; }
.t-card {
  width: 250px;
  scroll-snap-align: start;
  background: var(--panel);
  border: 1px solid rgba(244, 239, 228, 0.08);
  padding: 16px;
  text-decoration: none;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.t-card:hover { border-color: var(--line); }
.t-card strong { font-family: var(--serif); font-size: 1.25rem; color: var(--gold-2); font-weight: 520; }
.t-card span { color: var(--cream-dim); font-family: var(--text); line-height: 1.45; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.chip {
  border: 1px solid rgba(28, 23, 19, 0.16);
  padding: 7px 12px;
  color: var(--ink);
  background: transparent;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.search {
  width: min(320px, 100%);
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(28, 23, 19, 0.25);
  padding: 8px 0;
  outline: none;
}
.result-line { color: var(--ink-soft); margin: 0 0 18px; }

main [id], .chapter { scroll-margin-top: 132px; }
.plate { position: relative; background: #0d0b09; color: var(--cream); }
.plate .kicker { color: var(--gold-2); }
.plate .dek { color: var(--cream-dim); }
.plate-wide .plate-copy { pointer-events: none; }
.plate-wide .plate-copy a { pointer-events: auto; }
.capline { margin: 8px 0 0; max-width: 68ch; font-size: 0.82rem; line-height: 1.45; color: var(--cream-dim); }
.note-media .zoom { height: 100%; }
.gloss-card p, .src-card li, .path-card p { font-family: var(--text); line-height: 1.55; }
.plate img { width: 100%; }
.plate-wide { min-height: 68vh; }
.plate-wide img { height: min(78vh, 820px); object-fit: cover; }
.plate-portrait { display: grid; place-items: center; padding: 24px 16px 0; }
.plate-portrait img { width: auto; max-width: min(920px, 100%); max-height: min(86vh, 980px); object-fit: contain; }
.plate-frame {
  display: grid;
  grid-template-columns: minmax(240px, 520px) 1fr;
  gap: 28px;
  align-items: end;
  padding: clamp(24px, 4vw, 48px);
}
.plate-frame img { width: 100%; height: auto; }
.plate-panorama img { height: auto; object-fit: contain; background: #0d0b09; }
.plate-copy {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: clamp(20px, 4vw, 48px);
  background: linear-gradient(to top, rgba(8, 6, 4, 0.92) 0%, rgba(8, 6, 4, 0.72) 46%, rgba(8, 6, 4, 0.15) 100%);
}
.plate-frame .plate-copy, .plate-portrait .plate-copy, .plate-panorama .plate-copy {
  position: relative;
  background: none;
  padding: 8px 0 0;
}
.plate-portrait .plate-copy, .plate-panorama .plate-copy { padding: 20px clamp(20px, 4vw, 48px) 28px; }
.plate h2 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2.1rem, 4.6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin: 8px 0;
}
html[lang^="zh"] .plate h2 { letter-spacing: 0; line-height: 1.2; }
.chapter-body { padding: clamp(28px, 5vw, 64px) 0 72px; }
.chapter-grid {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 68ch) minmax(240px, 1fr);
  gap: 42px;
}
.quote {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 2.5vw, 2.15rem);
  line-height: 1.25;
  font-weight: 520;
  color: var(--ink);
}
.quote footer { margin-top: 12px; font-family: var(--sans); font-size: 0.92rem; color: var(--ink-soft); }
.claims { display: grid; gap: 12px; align-content: start; }
.claim { padding: 14px 14px 8px; }
.claim h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--sans);
}
html[lang^="zh"] .claim h3 { letter-spacing: 0.04em; text-transform: none; font-size: 0.95rem; }
.claim.known h3 { color: var(--moss); }
.claim.open h3 { color: #8a6232; }
.claim.reject h3 { color: var(--rust); }
.claim ul { margin: 0; padding-left: 1.1em; }
.claim li { margin: 0 0 8px; font-family: var(--text); line-height: 1.45; }
.further { color: var(--ink-soft); font-size: 0.98rem; }
.inline-fig { margin: 28px 0; }
.inline-fig img { width: 100%; height: auto; max-height: 82vh; object-fit: contain; background: #14110e; }
.inline-fig figcaption, .note-card figcaption, .credit {
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--ink-soft);
  padding-top: 8px;
}
.zoom {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  width: 100%;
}

.notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.note-card { overflow: hidden; }
.note-media { background: #14110e; }
.note-media.land { aspect-ratio: 3/2; }
.note-media.tall { aspect-ratio: 3/4; }
.note-media.pan { aspect-ratio: 2.35/1; }
.note-media img { width: 100%; height: 100%; }
.note-media img.cover { object-fit: cover; }
.note-media img.contain { object-fit: contain; }
.note-body { padding: 16px 18px 18px; }
.note-body h3 { font-family: var(--serif); font-size: 1.7rem; margin: 6px 0 8px; font-weight: 560; line-height: 1.15; }
.note-card figcaption { padding: 0 18px 16px; }

.quiz-wrap { width: min(820px, calc(100% - 40px)); margin: 0 auto; }
.quiz-card { padding: clamp(20px, 3vw, 36px); color: var(--ink); }
.quiz-card h3 { font-family: var(--serif); font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 8px 0 18px; font-weight: 560; line-height: 1.25; }
.choice {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0 0 10px;
  padding: 12px 14px;
  border: 1px solid rgba(28, 23, 19, 0.16);
  background: #fff;
  cursor: pointer;
}
.choice:hover { border-color: var(--ink); }
.choice.correct { border-color: var(--moss); background: #eef6f1; }
.choice.wrong { border-color: var(--rust); background: #fbf1ec; }
.explain { font-family: var(--text); font-size: 1.08rem; line-height: 1.6; }
.score-block { font-family: var(--text); font-size: 1.2rem; line-height: 1.6; }

.glossary, .sources { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gloss-card, .src-card { padding: 14px 16px; }
.gloss-card h3, .src-card h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.25rem; }
.src-card li { margin: 0 0 6px; }

#colophon {
  padding: 48px 0 80px;
  color: var(--cream-dim);
  border-top: 1px solid rgba(244, 239, 228, 0.08);
}
.credit-list { columns: 2; gap: 28px; padding: 0; margin: 18px 0 0; list-style: none; }
.credit-list li { break-inside: avoid; margin: 0 0 12px; font-size: 0.88rem; }
.credit-list a { color: var(--gold-2); }

#dock {
  position: fixed;
  z-index: 45;
  left: 50%;
  top: calc(var(--nav) + 8px);
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(18, 16, 14, 0.94);
  color: var(--cream);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#dock[hidden] { display: none; }
#dock p { margin: 0; }
#dock .row { display: flex; gap: 8px; }

#toc {
  width: min(480px, calc(100% - 24px));
  border: 0;
  padding: 18px;
  background: var(--paper);
  color: var(--ink);
}
#toc::backdrop, #lightbox::backdrop { background: rgba(0,0,0,0.62); }
#toc a, #toc button.linkish {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(28, 23, 19, 0.08);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
#lightbox {
  width: min(1100px, calc(100% - 24px));
  border: 0;
  padding: 12px;
  background: #0e0c0a;
  color: var(--cream);
}
#lightbox img { max-height: 78vh; margin: 0 auto; object-fit: contain; }
#lightbox figcaption { padding: 10px 4px 4px; font-size: 0.9rem; }
.icon-btn {
  position: absolute;
  right: 8px; top: 8px;
  width: 36px; height: 36px;
  color: white;
  font-size: 1.4rem;
}

.noscript { padding: 48px 20px; }

html[data-script="hant"] .eyebrow,
html[data-script="ja"] .eyebrow,
html[data-script="ko"] .eyebrow,
html[data-script="thai"] .eyebrow,
html[data-script="arabic"] .eyebrow,
html[data-script="hebrew"] .eyebrow,
html[data-script="deva"] .eyebrow,
html[data-script="beng"] .eyebrow,
html[data-script="taml"] .eyebrow,
html[data-script="hant"] .kicker,
html[data-script="ja"] .kicker,
html[data-script="ko"] .kicker,
html[data-script="thai"] .kicker,
html[data-script="arabic"] .kicker,
html[data-script="hebrew"] .kicker,
html[data-script="deva"] .kicker,
html[data-script="beng"] .kicker,
html[data-script="taml"] .kicker {
  letter-spacing: 0.04em;
  text-transform: none;
}
html[data-script="ja"] .hero h1,
html[data-script="ko"] .hero h1,
html[data-script="thai"] .hero h1,
html[data-script="arabic"] .hero h1,
html[data-script="hebrew"] .hero h1,
html[data-script="deva"] .hero h1,
html[data-script="beng"] .hero h1,
html[data-script="taml"] .hero h1,
html[data-script="hant"] .hero h1 {
  letter-spacing: 0;
  line-height: 1.12;
}
html[data-script="ja"] .drop::first-letter,
html[data-script="ko"] .drop::first-letter,
html[data-script="thai"] .drop::first-letter,
html[data-script="arabic"] .drop::first-letter,
html[data-script="hebrew"] .drop::first-letter,
html[data-script="deva"] .drop::first-letter,
html[data-script="beng"] .drop::first-letter,
html[data-script="taml"] .drop::first-letter,
html[data-script="hant"] .drop::first-letter {
  float: none;
  font-size: inherit;
  padding: 0;
  color: inherit;
}
html[dir="rtl"] .hero::before {
  background:
    linear-gradient(180deg, rgba(8, 6, 4, 0.08) 0%, rgba(8, 6, 4, 0.18) 42%, rgba(8, 6, 4, 0.55) 100%),
    linear-gradient(260deg, rgba(8, 6, 4, 0.88) 0%, rgba(8, 6, 4, 0.62) 32%, rgba(8, 6, 4, 0.22) 56%, rgba(8, 6, 4, 0.08) 100%);
}
html[dir="rtl"] .hero-copy { margin-inline-start: auto; }
html[dir="rtl"] .hero-photo figcaption { right: auto; left: 0; text-align: start; }
#langbox {
  width: min(720px, calc(100% - 24px));
  border: 0;
  padding: 18px 18px 22px;
  background: var(--paper);
  color: var(--ink);
}
#langbox::backdrop { background: rgba(0, 0, 0, 0.62); }
#langbox h2 { font-family: var(--serif); margin: 0; font-size: 1.8rem; }
.lang-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#langbox .icon-btn { position: static; color: var(--ink); width: auto; height: auto; font-size: 1.6rem; }
.lang-note { margin: 10px 0; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.5; }
#langbox input {
  width: 100%;
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid rgba(28, 23, 19, 0.16);
  background: #fffdf8;
  color: var(--ink);
}
.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: min(52vh, 480px);
  overflow: auto;
}
.lang-grid button {
  text-align: start;
  padding: 10px 12px;
  border: 1px solid rgba(28, 23, 19, 0.12);
  background: transparent;
  cursor: pointer;
}
.lang-grid button[aria-pressed="true"] { background: var(--night); color: var(--cream); }

@media (max-width: 980px) {
  .hero, .split, .chapter-grid, .notes-grid, .atlas-grid, .glossary, .sources { grid-template-columns: 1fr; }
  .atlas-grid { grid-template-columns: 1fr 1fr; }
  .nav-links, .nav-tools .btn.solid { display: none; }
  .menu-btn { display: inline-flex; }
  .plate-frame { grid-template-columns: 1fr; }
  .credit-list { columns: 1; }
  .hero::before {
    background: linear-gradient(180deg, rgba(8, 6, 4, 0.18) 0%, rgba(8, 6, 4, 0.28) 22%, rgba(8, 6, 4, 0.78) 58%, rgba(8, 6, 4, 0.9) 100%);
  }
  .hero-copy { max-width: none; padding: 36px 20px 96px; }
  .hero-photo figcaption { width: 100%; text-align: start; padding: 28px 16px 14px; }
  .hero-photo img { object-position: center 38%; }
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .nav { padding: 0 14px; gap: 8px; }
  .atlas-grid { grid-template-columns: 1fr; }
  .wrap, .chapter-grid, .quiz-wrap { width: calc(100% - 28px); }
  .lang-grid { grid-template-columns: 1fr; }
  #dock { width: calc(100% - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile img, .btn { transition: none; }
}

body.safari-lock { overflow: hidden; }
#safari-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 16, 14, 0.78);
}
#safari-gate[hidden] { display: none; }
.safari-panel {
  position: relative;
  isolation: isolate;
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: auto;
  color: var(--cream);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0 0 24px;
  background: #12100e;
}
.safari-photo {
  flex: 0 0 auto;
  height: min(30vh, 220px);
  margin: 0 0 18px;
  background-color: #12100e;
  background-size: cover;
  background-position: center 46%;
  box-shadow: inset 0 -56px 40px -24px #12100e;
}
.safari-kicker {
  margin: 0 28px 10px;
  color: var(--gold-2);
  font-size: 0.92rem;
}
.safari-panel h2 {
  margin: 0 28px 14px;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.15;
  color: var(--cream);
}
.safari-panel p {
  margin: 0 28px 12px;
  font-family: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--cream-dim);
}
#safari-note { color: var(--gold-2); }
#safari-open { margin: 8px 28px 0; align-self: flex-start; }
.safari-credit { margin: 12px 28px 0; font-size: 0.75rem; line-height: 1.4; color: var(--cream-dim); }
.safari-credit a { color: var(--gold-2); }
@media (max-width: 720px) {
  .safari-photo { height: 148px; margin-bottom: 14px; }
  .safari-kicker, .safari-panel h2, .safari-panel p, #safari-open, .safari-credit { margin-left: 18px; margin-right: 18px; }
  .safari-panel h2 { font-size: 1.45rem; margin-bottom: 8px; }
  .safari-panel p { font-size: 0.92rem; line-height: 1.45; margin-bottom: 8px; }
  .safari-panel { padding-bottom: 16px; }
}

