/* ————— The Valley Canon ————— */

@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/ebgaramond-italic.woff2') format('woff2');
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --book-font: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --gold: #c9a961;
  --gold-dim: #8f7a4b;
  --room: #17120e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--room);
  font-family: var(--ui-font);
  color: #d8cdbd;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

#stage {
  position: fixed; inset: 0;
}
.stage-canvas { display: block; width: 100%; height: 100%; outline: none; }
#stage::after {
  /* gentle vignette over the room */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 55%, rgba(0,0,0,0.5) 100%);
}

/* ————— chrome over the scene ————— */
.brand {
  position: fixed; top: 26px; left: 34px; z-index: 5;
  user-select: none; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease 0.35s;
}
.ready .brand { opacity: 1; }
.brand h1 {
  font-family: var(--book-font);
  font-size: 21px; font-weight: 600; letter-spacing: 0.14em;
  color: #e4d6ba;
}
.brand p {
  margin-top: 5px; font-size: 10.5px; letter-spacing: 0.24em;
  text-transform: uppercase; color: #93856f;
}
.hint {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 5; font-size: 11.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: #7c6f5c; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity 1.4s ease 0.9s;
  text-align: center; line-height: 1.9;
}
.ready .hint { opacity: 1; }
.hint kbd {
  font-family: inherit; border: 1px solid #4a4033; border-radius: 4px;
  padding: 1px 5px; font-size: 10px; color: #93856f;
}
.about-btn {
  position: fixed; top: 26px; right: 34px; z-index: 5;
  background: none; border: 1px solid #4a4033; color: #93856f;
  border-radius: 20px; padding: 7px 14px; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  opacity: 0; transition: opacity 1.2s ease 0.5s, color .25s, border-color .25s;
}
.ready .about-btn { opacity: 1; }
.about-btn:hover { color: #d8c9a8; border-color: #8f7a4b; }

/* ————— loading ————— */
.loading {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--room);
  transition: opacity 0.9s ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading .mark {
  font-family: var(--book-font); font-size: 30px; font-weight: 600;
  letter-spacing: 0.16em; color: #e4d6ba;
}
.loading .sub {
  margin-top: 10px; font-size: 10.5px; letter-spacing: 0.3em;
  text-transform: uppercase; color: #93856f;
}
.loading .bar {
  margin-top: 34px; width: 200px; height: 2px; background: #2e261d;
  border-radius: 2px; overflow: hidden;
}
.loading .bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #8f7a4b, #d8bd7f);
  transition: width 0.35s ease;
}
.loading .books-count {
  margin-top: 14px; font-size: 11px; color: #6b5f4e; letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

/* ————— hover tooltip card ————— */
.tip {
  position: fixed; z-index: 6; width: 300px;
  pointer-events: none; opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(.2,.8,.25,1);
  background: linear-gradient(160deg, rgba(37,30,22,0.94), rgba(24,19,14,0.96));
  border: 1px solid rgba(201,169,97,0.28);
  border-radius: 10px; padding: 16px 18px 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
}
.tip.on { opacity: 1; transform: translateY(0) scale(1); }
.tip .t-title {
  font-family: var(--book-font); font-size: 19px; font-weight: 600;
  color: #ecdfc2; line-height: 1.2;
}
.tip .t-meta {
  margin-top: 3px; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold);
}
.tip .t-tag {
  margin-top: 9px; font-family: var(--book-font); font-style: italic;
  font-size: 14.5px; color: #c3b598; line-height: 1.45;
}
.tip .t-blurb {
  margin-top: 7px; font-size: 12px; color: #9d907b; line-height: 1.55;
}
.tip .t-stats {
  margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(201,169,97,0.16);
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #7c6f5c;
  display: flex; justify-content: space-between;
}
.tip .t-resume { color: var(--gold); }
.tip .t-open {
  margin-top: 8px; font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: #93856f;
}

/* ————— about panel ————— */
.about {
  position: fixed; inset: 0; z-index: 30; display: flex;
  align-items: center; justify-content: center;
  background: rgba(10,8,6,0.72);
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.about.on { opacity: 1; pointer-events: auto; }
.about-card {
  width: min(620px, 92vw); max-height: 84vh; overflow: auto;
  background: linear-gradient(165deg, #262019, #191410);
  border: 1px solid rgba(201,169,97,0.25); border-radius: 14px;
  padding: 34px 38px 28px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  transform: translateY(14px); transition: transform 0.35s cubic-bezier(.2,.8,.25,1);
}
.about.on .about-card { transform: translateY(0); }
.about-card h2 {
  font-family: var(--book-font); font-weight: 600; font-size: 24px;
  color: #ecdfc2; letter-spacing: 0.04em;
}
.about-card > p {
  margin-top: 12px; font-size: 13px; line-height: 1.65; color: #a3957e;
}
.about-card .vol-list { margin-top: 20px; }
.about-card .vol {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-top: 1px solid rgba(201,169,97,0.12);
  font-size: 12.5px;
}
.about-card .vol b {
  font-family: var(--book-font); font-size: 14.5px; font-weight: 600; color: #d9cba8;
}
.about-card .vol span { color: #8d8069; }
.about-card .vol a { color: var(--gold); text-decoration: none; white-space: nowrap; }
.about-card .vol a:hover { text-decoration: underline; }
.about-card .close-about {
  margin-top: 22px; background: none; border: 1px solid #4a4033;
  color: #b3a68c; border-radius: 8px; padding: 8px 20px; font-size: 12px;
  letter-spacing: 0.1em;
}
.about-card .close-about:hover { border-color: var(--gold-dim); color: #e0d2b2; }

/* ————— fallback 2D shelf ————— */
.flat-shelf {
  position: fixed; inset: 0; overflow: auto;
  display: flex; align-items: center; justify-content: safe center;
  gap: 6px; padding: 60px 40px;
  perspective: 900px;
}
.flat-book {
  flex: 0 0 auto; border: none; padding: 0; background: none;
  transition: transform 0.3s cubic-bezier(.2,.8,.25,1);
  transform-origin: bottom center;
}
.flat-book:hover, .flat-book:focus-visible { transform: translateY(-14px) rotateX(4deg); }
.flat-book img { display: block; border-radius: 2px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }

/* ═════════════════ READER ═════════════════ */

.reader {
  position: fixed; inset: 0; z-index: 20;
  opacity: 0; pointer-events: none;
  transition: opacity 0.45s ease;
}
.reader.visible { opacity: 1; pointer-events: auto; }
.reader-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(100% 80% at 50% 45%, rgba(16,13,10,0.82), rgba(10,8,6,0.94));
  backdrop-filter: blur(7px);
}
.reader-shell {
  position: absolute; inset: 0; display: flex; flex-direction: column;
}

/* themes */
.reader { --paper: #f5efe2; --paper-deep: #e9e0cc; --ink: #2e2a23; --ink-soft: #6d6353;
  --rule: rgba(80,66,44,0.25); --accent: #8a6d3b; --edge: #d9cfb8; }
.reader[data-theme="sepia"] { --paper: #efe2c8; --paper-deep: #e2d2b2; --ink: #4a3b28; --ink-soft: #82704f;
  --rule: rgba(100,80,50,0.3); --accent: #96703a; --edge: #d4c3a0; }
.reader[data-theme="ink"] { --paper: #201e1b; --paper-deep: #191713; --ink: #cfc6b4; --ink-soft: #857b68;
  --rule: rgba(200,180,140,0.18); --accent: #c9a961; --edge: #2e2b26; }

.reader-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px 10px; z-index: 4;
}
.reader-title {
  font-family: var(--book-font); font-size: 15px; color: #cfc0a2;
  letter-spacing: 0.04em; display: flex; gap: 8px; align-items: baseline;
  opacity: 0.9; min-width: 0;
}
.rt-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-sep, .rt-author { color: #8d8069; font-size: 13px; white-space: nowrap; }
.reader-actions { display: flex; gap: 8px; }
.rbtn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(216,189,127,0.07); color: #c4b696;
  border: 1px solid rgba(201,169,97,0.22); border-radius: 8px;
  padding: 7px 12px; font-size: 12.5px; letter-spacing: 0.03em;
  transition: background .2s, color .2s, border-color .2s;
}
.rbtn:hover { background: rgba(216,189,127,0.14); color: #ecdfc2; border-color: rgba(201,169,97,0.45); }
.rbtn .aa { font-family: var(--book-font); font-size: 14px; font-weight: 600; }

.book-zone {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}

/* paper + pages */
.bookview { position: relative; }
.paper {
  position: relative;
  background: var(--paper);
  border-radius: 4px 10px 10px 4px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 30px 80px rgba(0,0,0,0.65),
    0 6px 18px rgba(0,0,0,0.5);
  perspective: 2400px;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.reader[data-spread="2"] .paper { border-radius: 6px 10px 10px 6px; }
.paper.ch-fade { opacity: 0; transform: translateX(calc(var(--chdir, 1) * -26px)); }
.paper.ch-fade-in { animation: chIn 0.26s cubic-bezier(.2,.7,.2,1); }
@keyframes chIn {
  from { opacity: 0; transform: translateX(calc(var(--chdir, 1) * 26px)); }
  to { opacity: 1; transform: none; }
}
.reader.page-in .paper { animation: paperIn 0.55s cubic-bezier(.2,.7,.2,1); }
@keyframes paperIn {
  from { opacity: 0; transform: scale(0.965) translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* stacked page edges */
.page-edges {
  position: absolute; top: 4px; bottom: 4px; width: 14px; z-index: -1;
  background:
    repeating-linear-gradient(90deg, var(--edge) 0 1.5px, var(--paper-deep) 1.5px 3px);
  border-radius: 3px;
}
.pe-left { left: -9px; transform: skewY(-0.4deg); }
.pe-right { right: -9px; transform: skewY(0.4deg); }
.reader[data-spread="1"] .pe-left { display: none; }

.spread-window, .overlay-window {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
}
.overlay-window { z-index: 2; background: var(--paper); }
.overlay-window.half-right { left: 50%; }
.overlay-window.half-left { right: 50%; }

.stream {
  column-fill: auto;
  padding-top: 52px;
  padding-bottom: 56px;
  font-family: var(--book-font);
  color: var(--ink);
  line-height: 1.62;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  will-change: transform;
}
.overlay-window .stream { transform-origin: left top; }

/* interior page padding is carried by the blocks so columns snap cleanly */
.chapter > * {
  padding-left: 42px; padding-right: 42px;
}
.chapter > :first-child { margin-top: 0; }

.ch-opener {
  padding-top: 74px; padding-bottom: 26px;
  text-align: center;
  break-after: avoid;
}
.ch-group {
  font-family: var(--ui-font); font-size: 10px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 14px;
  opacity: 0.85;
}
.ch-eyebrow {
  font-family: var(--ui-font); font-size: 10.5px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 16px;
}
.ch-title {
  font-family: var(--book-font); font-weight: 500;
  font-size: 1.72em; line-height: 1.22; color: var(--ink);
  text-wrap: balance;
}
.ch-orn { margin-top: 18px; color: var(--accent); font-size: 15px; opacity: 0.85; }

.stream p {
  margin: 0; text-indent: 1.45em;
  orphans: 2; widows: 2;
}
.stream p.first { text-indent: 0; }
.stream p.first .dropcap {
  float: left;
  font-size: 3.05em; line-height: 0.83;
  padding: 0.045em 0.09em 0 0;
  font-weight: 500;
  color: var(--accent);
}
.stream .subhead {
  font-weight: 600; font-size: 0.86em; letter-spacing: 0.18em;
  text-transform: uppercase; text-align: center;
  margin: 1.6em 0 0.9em; color: var(--ink);
  break-after: avoid;
}
.stream .verse {
  margin: 1.05em 0 1.05em;
  padding-left: calc(42px + 2.2em);
  text-indent: -1.1em;
  text-align: left; font-style: italic; line-height: 1.55;
  color: var(--ink);
}
.stream .table {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.56em; line-height: 1.5; text-align: left;
  margin: 1em 0; overflow-x: auto; color: var(--ink-soft);
  white-space: pre;
}
.stream .footnote {
  font-size: 0.82em; line-height: 1.5; color: var(--ink-soft);
  text-indent: 0; margin-top: 0.55em; text-align: left;
}
.stream .fnref {
  font-size: 0.68em; color: var(--accent);
}
.stream em { font-style: italic; }
.finis {
  text-align: center; margin-top: 3.2em; padding-bottom: 60px;
  color: var(--accent); font-size: 1.25em; line-height: 2;
}
.finis span {
  font-family: var(--ui-font); font-size: 9.5px; letter-spacing: 0.34em; color: var(--ink-soft);
}

/* gutter & folios */
.gutter-shade {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 90px;
  transform: translateX(-50%); pointer-events: none; z-index: 3;
  background: linear-gradient(90deg,
    transparent 0%, rgba(60,45,25,0.05) 32%, rgba(50,38,22,0.17) 49%,
    rgba(50,38,22,0.17) 51%, rgba(60,45,25,0.05) 68%, transparent 100%);
}
.reader[data-theme="ink"] .gutter-shade {
  background: linear-gradient(90deg,
    transparent 0%, rgba(0,0,0,0.14) 32%, rgba(0,0,0,0.42) 50%,
    rgba(0,0,0,0.14) 68%, transparent 100%);
}
.reader[data-spread="1"] .gutter-shade { display: none; }
.folio, .running {
  position: absolute; z-index: 3; pointer-events: none;
  font-family: var(--book-font); color: var(--ink-soft);
  font-variant-numeric: oldstyle-nums;
}
.folio { bottom: 22px; font-size: 13px; letter-spacing: 0.06em; }
.fo-left { left: 42px; }
.fo-right { right: 42px; }
.running {
  top: 24px; font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase;
  max-width: 38%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  opacity: 0.75;
}
.rh-left { left: 42px; }
.rh-right { right: 42px; text-align: right; }

/* leaf */
.leaf {
  position: absolute; top: 0; z-index: 4;
  transform-style: preserve-3d;
  transform-origin: left center;
  pointer-events: none;
}
.leaf-face {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.lf-front { border-radius: 0 10px 10px 0; }
.lf-back { transform: rotateY(180deg); border-radius: 10px 0 0 10px; }
.leaf-window { position: absolute; inset: 0; overflow: hidden; }
.lf-back .leaf-window .stream { }
.leaf-shade {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
}
.lf-front .leaf-shade { background: linear-gradient(90deg, rgba(45,32,15,0.28), transparent 55%); }
.lf-back .leaf-shade { background: linear-gradient(-90deg, rgba(45,32,15,0.28), transparent 55%); }
.leaf.anim-fwd .lf-front .leaf-shade { animation: shadeIn 0.54s ease both; }
.leaf.anim-fwd .lf-back .leaf-shade { animation: shadeOut 0.54s ease both; }
.leaf.anim-bwd .lf-back .leaf-shade { animation: shadeIn 0.54s ease both; }
.leaf.anim-bwd .lf-front .leaf-shade { animation: shadeOut 0.54s ease both; }
@keyframes shadeIn { 0% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 0.1; } }
@keyframes shadeOut { 0% { opacity: 0.6; } 55% { opacity: 0.85; } 100% { opacity: 0; } }
/* soft cast shadow sweeping the base spread */
.paper.flipping .spread-window::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 40%, rgba(40,28,12,0.16) 60%, transparent 85%);
  animation: castSweep 0.55s ease both;
  pointer-events: none;
}
@keyframes castSweep {
  from { transform: translateX(20%); opacity: 0.9; }
  to { transform: translateX(-55%); opacity: 0; }
}

/* leaf back-face content mirror fix: back face is rotated by parent, content pre-mirrored */

/* edge nav zones */
.edge-nav {
  position: absolute; top: 8%; bottom: 8%; width: 15%;
  min-width: 54px;
  background: none; border: none; z-index: 5;
  opacity: 0; transition: opacity 0.25s ease;
  color: #b8a87f;
}
.edge-nav::before {
  content: ''; position: absolute; top: 50%; width: 34px; height: 34px;
  border-radius: 50%; transform: translateY(-50%);
  background: rgba(30,24,16,0.55) center/13px no-repeat;
  border: 1px solid rgba(201,169,97,0.3);
}
.en-left { left: -68px; }
.en-right { right: -68px; }
.en-left::before {
  left: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3E%3Cpath d='M10.5 3.5 6 8l4.5 4.5' stroke='%23d5c193' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.en-right::before {
  right: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3E%3Cpath d='M5.5 3.5 10 8l-4.5 4.5' stroke='%23d5c193' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.bookview:hover .edge-nav, .edge-nav:focus-visible { opacity: 0.9; }
.edge-nav:hover { opacity: 1; }

/* typesetting shimmer */
.typesetting[hidden], .toc-panel[hidden], .settings-pop[hidden], .leaf[hidden], .overlay-window[hidden] { display: none; }
.typesetting {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--ui-font); font-size: 11.5px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--ink-soft);
  background: var(--paper); border-radius: inherit;
}
.typesetting span {
  width: 26px; height: 2px; overflow: hidden; border-radius: 2px;
  background: linear-gradient(90deg, var(--rule), var(--accent), var(--rule));
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ————— TOC panel ————— */
.toc-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(360px, 88vw);
  z-index: 8; display: flex; flex-direction: column;
  background: linear-gradient(175deg, rgba(33,27,20,0.97), rgba(22,18,13,0.97));
  border-right: 1px solid rgba(201,169,97,0.2);
  box-shadow: 30px 0 80px rgba(0,0,0,0.45);
  animation: tocIn 0.32s cubic-bezier(.2,.8,.25,1);
}
@keyframes tocIn { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toc-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 24px 20px 16px 26px;
  border-bottom: 1px solid rgba(201,169,97,0.14);
}
.toc-book .tb-t { font-family: var(--book-font); font-weight: 600; font-size: 20px; color: #ecdfc2; }
.toc-book .tb-a { margin-top: 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #93856f; }
.toc-close { padding: 5px 10px; }
.toc-list { flex: 1; overflow-y: auto; padding: 10px 0 12px; scrollbar-width: thin; }
.toc-group {
  padding: 14px 26px 6px; font-size: 9.5px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold-dim);
}
.toc-item {
  display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 12px;
  background: none; border: none; text-align: left;
  padding: 8px 26px; color: #b7aa8e;
  transition: background 0.15s, color 0.15s;
}
.toc-item:hover { background: rgba(216,189,127,0.06); color: #e6d9ba; }
.toc-item.current { color: var(--gold); background: rgba(216,189,127,0.08); }
.toc-item.current .ti-t::before { content: '❧ '; font-size: 11px; }
.toc-item .ti-t { font-family: var(--book-font); font-size: 14.5px; line-height: 1.35; }
.toc-item .ti-w { font-size: 10px; color: #6f6553; white-space: nowrap; font-variant-numeric: tabular-nums; }
.toc-colophon {
  padding: 14px 26px 20px; border-top: 1px solid rgba(201,169,97,0.14);
  font-size: 11px; line-height: 1.65; color: #8d8069;
}
.toc-colophon a { color: var(--gold); text-decoration: none; }
.toc-colophon a:hover { text-decoration: underline; }

/* ————— settings ————— */
.settings-pop {
  position: absolute; top: 4px; right: 26px; z-index: 9;
  background: linear-gradient(170deg, rgba(37,30,22,0.98), rgba(24,19,14,0.98));
  border: 1px solid rgba(201,169,97,0.25); border-radius: 12px;
  padding: 16px; width: 240px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  animation: tocIn 0.25s cubic-bezier(.2,.8,.25,1);
}
.sp-row { display: flex; align-items: center; gap: 10px; }
.sp-size { justify-content: space-between; }
.sp-size .rbtn { font-family: var(--book-font); font-weight: 600; }
.sp-size .rbtn span { font-size: 10px; margin-left: 1px; }
.sz-val { font-size: 12px; color: #b7aa8e; font-variant-numeric: tabular-nums; }
.sp-themes { margin-top: 12px; }
.theme-b {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 1px solid rgba(201,169,97,0.18); border-radius: 9px;
  padding: 9px 4px 7px; color: #a3957e; font-size: 10.5px; letter-spacing: 0.06em;
}
.theme-b i { display: block; width: 26px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.4); }
.theme-b[data-t="paper"] i { background: #f5efe2; }
.theme-b[data-t="sepia"] i { background: #efe2c8; }
.theme-b[data-t="ink"] i { background: #23211d; }
.theme-b.on { border-color: var(--gold); color: #ecdfc2; }

/* ————— footer ————— */
.reader-bottom {
  padding: 10px 26px 16px; z-index: 4;
}
.progress-line {
  position: relative; height: 3px; border-radius: 3px;
  background: rgba(216,189,127,0.12); cursor: pointer;
  transition: transform .15s ease;
}
.progress-line:hover { transform: scaleY(1.9); }
.pl-fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px;
  background: linear-gradient(90deg, #8f7a4b, #d8bd7f);
  transition: width 0.3s ease;
}
.pl-ticks i {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(10,8,6,0.7);
}
.pos-label {
  margin-top: 9px; display: flex; gap: 18px; justify-content: center;
  font-size: 11px; letter-spacing: 0.08em; color: #8d8069;
  font-variant-numeric: tabular-nums;
}
.pos-ch {
  max-width: 40%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: #b0a184;
}

/* ————— screen size adaptations ————— */
@media (max-width: 900px) {
  .brand { top: 18px; left: 20px; }
  .brand h1 { font-size: 17px; }
  .about-btn { top: auto; bottom: 16px; right: 16px; }
  .reader-top { padding: 12px 14px 8px; }
  .reader-title .rt-author, .reader-title .rt-sep { display: none; }
  .rbtn-back span { display: none; }
  .en-left { left: 2px; }
  .en-right { right: 2px; }
  .edge-nav::before { display: none; }
  .chapter > * { padding-left: 26px; padding-right: 26px; }
  .stream .verse { padding-left: calc(26px + 1em); }
  .fo-left { left: 26px; } .fo-right { right: 26px; }
  .rh-left { left: 26px; } .rh-right { right: 26px; }
  .reader-bottom { padding: 8px 16px 12px; }
  .pos-label { font-size: 10px; gap: 10px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .paper.ch-fade, .paper.ch-fade-in { animation: none; transition: none; }
  .reader, .tip { transition-duration: 0.01s; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
