:root {
  --green: #164b3b;
  --green-2: #0f382d;
  --cream: #f6efdf;
  --paper: #fffaf0;
  --gold: #e6b964;
  --clay: #9b5c35;
  --ink: #303b32;
  --font-scale: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #102c25; color: var(--ink); font-family: Arial, "Helvetica Neue", sans-serif; }
button, a, select { font: inherit; }
button { cursor: pointer; }
body { min-height: 100vh; background: radial-gradient(circle at 50% 0, #285b4d 0, #112f27 48%, #091d18 100%); overflow-x: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.start-gate { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 22px; background: linear-gradient(rgba(12,42,34,.58), rgba(5,25,20,.9)), url('../images/cover-art.png') center/cover; }
.start-gate.hidden { opacity: 0; pointer-events: none; transition: .55s ease; }
.gate-card { width: min(520px, 94vw); padding: 34px; text-align: center; border: 1px solid rgba(255,255,255,.35); border-radius: 26px; background: rgba(255,250,240,.94); box-shadow: 0 24px 80px rgba(0,0,0,.34); backdrop-filter: blur(8px); }
.gate-logo { width: 116px; height: auto; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .76rem; font-weight: 800; color: var(--clay); }
.gate-card h1 { font: 700 clamp(2.5rem, 8vw, 4.8rem)/.95 Georgia, serif; color: var(--green); margin: .35em 0 .25em; }
.gate-card p { line-height: 1.55; }
.primary { border: 0; border-radius: 999px; background: var(--green); color: white; padding: 14px 34px; font-weight: 800; box-shadow: 0 10px 25px rgba(22,75,59,.25); }
.gate-card small { display: block; margin-top: 14px; color: #6d6b61; }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px clamp(12px, 3vw, 34px); background: rgba(9,37,30,.96); border-bottom: 1px solid rgba(255,255,255,.13); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.brand img { width: 52px; height: 38px; object-fit: contain; filter: brightness(0) invert(1); }
.brand span { display: grid; }
.brand b { font-family: Georgia, serif; font-size: 1.05rem; }
.brand small { opacity: .72; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.toolbar { display: flex; gap: 7px; }
.toolbar button, .quick-actions a, .quick-actions button, .reader-controls button { border: 1px solid rgba(255,255,255,.2); border-radius: 10px; background: rgba(255,255,255,.08); color: white; padding: 10px 13px; text-decoration: none; }
.toolbar button:hover, .toolbar button.active, .quick-actions a:hover, .quick-actions button:hover, .reader-controls button:hover, .reader-controls button.active { background: var(--gold); color: #15372e; border-color: var(--gold); }

.reader-shell { width: min(1240px, 100%); margin: auto; padding: clamp(12px, 2.2vw, 28px); }
.book-stage { width: min(1180px, 100%); aspect-ratio: 296 / 210; height: auto; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; perspective: 2200px; filter: drop-shadow(0 24px 36px rgba(0,0,0,.34)); }
.book-stage.single { grid-template-columns: minmax(0, 680px); justify-content: center; }
.sheet { position: relative; min-width: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(206,147,66,.65) transparent; container-type: inline-size; background: var(--paper); transform-style: preserve-3d; transition: transform .42s ease, opacity .28s ease; }
.sheet::-webkit-scrollbar { width: 5px; }
.sheet::-webkit-scrollbar-thumb { background: rgba(206,147,66,.65); border-radius: 9px; }
.sheet.left { border-radius: 14px 3px 3px 14px; box-shadow: inset -16px 0 24px rgba(62,49,30,.08); transform-origin: right center; }
.sheet.right { border-radius: 3px 14px 14px 3px; box-shadow: inset 16px 0 24px rgba(62,49,30,.08); transform-origin: left center; }
.book-stage.turn-next .right { transform: rotateY(-18deg); opacity: .45; }
.book-stage.turn-prev .left { transform: rotateY(18deg); opacity: .45; }

.page-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.page-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,250,239,.95) 0%, rgba(255,250,239,.83) 41%, rgba(255,250,239,.18) 67%, rgba(17,50,40,.34) 100%); }
.page-content { position: relative; z-index: 2; min-height: 100%; display: flex; flex-direction: column; padding: 7.8cqw 7cqw 6cqw; font-size: calc(clamp(13px, 2.75cqw, 20px) * var(--font-scale)); }
.folio { position: absolute; right: 4.2cqw; top: 3.7cqw; border: 1px solid var(--clay); border-radius: 50%; width: 7cqw; height: 7cqw; min-width: 34px; min-height: 34px; display: grid; place-items: center; color: var(--clay); font-size: .9em; font-weight: 800; background: rgba(255,250,240,.86); }
.page-kicker { margin: 0 0 1em; max-width: 78%; text-transform: uppercase; letter-spacing: .16em; font-weight: 800; color: var(--clay); font-size: .67em; }
.page-title { font: 700 calc(clamp(26px, 6.35cqw, 51px) * var(--font-scale))/1.04 Georgia, "Times New Roman", serif; color: var(--green); margin: 0 0 .5em; max-width: 94%; }
.page-body { font: 400 1em/1.5 Georgia, "Times New Roman", serif; max-width: 93%; margin: 0; color: #40483d; }
.page-bullets { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55em; margin: 1em 0 0; max-width: 96%; }
.page-bullets li { background: rgba(255,250,240,.91); border: 1px solid rgba(96,83,56,.2); border-top: .24em solid var(--gold); border-radius: .52em; padding: .58em .7em; font-size: .88em; line-height: 1.28; }
.page-quote { margin: auto 0 0; max-width: 91%; align-self: flex-start; background: var(--green); color: white; border-radius: .7em; padding: .75em 1em; font: 700 .92em/1.38 Georgia, serif; box-shadow: 0 12px 28px rgba(0,0,0,.18); }
.page-sources { margin-top: .65em; align-self: flex-start; background: rgba(255,250,240,.92); border-radius: 999px; padding: .38em .65em; color: #5b5f54; font-size: .62em; }
.page-sources button { border: 0; background: transparent; color: var(--green); font-weight: 800; padding: 0; }
.cover-page .page-overlay, .back-page .page-overlay { background: linear-gradient(180deg, rgba(255,250,239,.94) 0%, rgba(255,250,239,.76) 27%, rgba(255,250,239,.05) 62%, rgba(8,35,28,.75) 100%); }
.cover-page .page-content, .back-page .page-content { text-align: center; align-items: center; }
.cover-page .page-title { font-size: calc(clamp(42px, 10.5cqw, 82px) * var(--font-scale)); max-width: 100%; margin-top: 9cqw; }
.cover-page .page-body { max-width: 100%; font-size: calc(1.28em * var(--font-scale)); font-style: italic; }
.cover-page .page-quote, .back-page .page-quote { align-self: center; margin-top: auto; background: transparent; text-shadow: 0 2px 8px #000; color: white; }
.back-page .page-title { margin-top: 8cqw; }
.back-page .qr-back { width: min(210px, 38%); margin: 1em auto; background: #fff; padding: .55em; border-radius: .8em; box-shadow: 0 12px 30px rgba(0,0,0,.25); }

.reader-controls { width: min(1040px, 100%); margin: 20px auto 0; padding: 14px 16px 18px; border: 1px solid rgba(255,255,255,.2); border-radius: 18px; background: rgba(8,50,61,.72); color: white; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.pager { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.pager > strong { text-align: center; color: var(--gold); font-size: 1.05rem; }
.pager-actions { display: flex; gap: 10px; }
.nav-btn { min-height: 44px; font-weight: 700; }
.nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.progress-wrap { display: block; padding: 9px 0 12px; border-bottom: 1px solid rgba(255,255,255,.18); }
input[type=range] { accent-color: var(--gold); width: 100%; }
.media-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.18); }
.media-btn { min-height: 44px; font-weight: 800; }
.media-btn.narration { background: var(--gold); border-color: var(--gold); color: #17382f; }
.listen-panel { padding-top: 12px; }
.listen-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.listen-heading h2 { margin: 0; font-size: 1rem; }
.listen-heading > span { font-size: .8rem; opacity: .78; }
.listen-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.listen-field { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; background: rgba(255,255,255,.07); }
.listen-field span { font-size: .76rem; opacity: .78; }
.listen-field strong, .listen-field select { color: white; font-weight: 700; }
.listen-field select { width: 100%; border: 0; outline: 0; background: transparent; }
.listen-field select option { color: #18362e; }
.listen-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.listen-buttons button { padding: 9px 13px; }
.listen-buttons .primary-small { background: var(--gold); border-color: var(--gold); color: #18362e; font-weight: 800; }
.listen-buttons button:disabled { opacity: .4; cursor: not-allowed; }
.listen-status { margin: 10px 0 6px; font-size: .84rem; font-weight: 700; }
.listen-panel small { opacity: .72; line-height: 1.45; }
.quick-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }

.modal { width: min(760px,92vw); max-height: 82vh; border: 0; border-radius: 20px; background: var(--paper); padding: 28px; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.modal::backdrop { background: rgba(3,19,15,.72); backdrop-filter: blur(4px); }
.modal h2 { font-family: Georgia, serif; color: var(--green); font-size: 2rem; margin-top: 0; }
.close { position: sticky; float: right; top: 0; border: 0; border-radius: 50%; width: 38px; height: 38px; background: #ece1cc; font-size: 1.4rem; }
.source-item { padding: 14px 0; border-bottom: 1px solid #ded3bd; }
.source-item a { color: var(--green); font-weight: 700; }
.toc-list { display: grid; gap: 6px; }
.toc-list button { border: 0; text-align: left; background: #f3ead9; border-radius: 9px; padding: 10px 12px; color: #203e34; }
.toc-list button:hover { background: #e3d1ae; }

@media (max-width: 820px) {
  .brand span { display: none; }
  .toolbar span { display: none; }
  .topbar { gap: 8px; }
  .toolbar { gap: 4px; }
  .toolbar button { padding: 8px; }
  .reader-shell { padding: 10px; }
  .book-stage { grid-template-columns: 1fr; width: min(100%, 540px); height: max(620px, calc(100svh - 145px)); aspect-ratio: auto; }
  .sheet.left { display: none; }
  .sheet.right { border-radius: 12px; }
  .page-content { padding: 26px 25px 18px; font-size: calc(clamp(14px, 4.1vw, 18px) * var(--font-scale)); }
  .folio { right: 18px; top: 18px; width: 38px; height: 38px; }
  .page-title { font-size: calc(clamp(28px, 8vw, 43px) * var(--font-scale)); }
  .page-body { max-width: 100%; }
  .page-bullets { max-width: 100%; grid-template-columns: 1fr; }
  .page-quote { max-width: 100%; }
  .pager { grid-template-columns: auto 1fr; }
  .pager > strong { grid-column: 1 / -1; grid-row: 1; }
  .pager > #prevBtn { grid-column: 1; grid-row: 2; }
  .pager-actions { grid-column: 2; grid-row: 2; justify-content: flex-end; }
  .listen-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .media-actions { grid-template-columns: 1fr; }
  .reader-controls { padding: 12px; }
  .nav-btn { padding-inline: 10px !important; }
}

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