:root {
  color-scheme: light;
  --paper: #f9f2e2;
  --ink: #283b30;
  --copper: #a45031;
  --serif: "PT Serif", Georgia, serif;
  --sans: "Inter", "Segoe UI", sans-serif;
  --grain: url("assets/grain.png");
  --endpaper: url("assets/endpaper.webp");
  --page-decoration: url("assets/sprig.webp");
  font: 500 100%/1.45 var(--sans);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  --focus-ring: var(--focus-on-forest);
  margin: 0; min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; isolation: isolate; color: #f5eddb;
  background-color: var(--forest);
}
.reader-backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
div.reader-backdrop { background: var(--endpaper) center bottom / cover no-repeat; }
img.reader-backdrop { inline-size: 100%; block-size: 100%; object-fit: cover; opacity: .2; }
#reader-root { display: contents; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
h1,h2,p { margin: 0; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.18em; height: 1.18em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.utility { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 17px; min-height: 40px; border-radius: 30px; background: transparent; font-size: .875rem; }
.utility:hover { color: var(--focus-on-forest); }
.reader-tools { display: flex; flex: none; align-items: center; gap: clamp(12px,2vw,28px); }
.shelf-link { display: inline-flex; align-items: center; min-height: 44px; color: #f2e8ce; font-size: .86rem; text-underline-offset: .28em; text-decoration-color: #d8bc8680; white-space: nowrap; }
.shelf-link:hover { text-decoration-color: currentColor; }
.reading-room {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; padding: clamp(12px,2.2dvh,28px) 0 16px; overflow: clip;
}
/* При раскрытии настроек верхняя строка плеера остаётся под курсором. */
.reading-room:has(.desktop-playback) { justify-content: flex-start; }
.reader {
  --arrow-gutter: clamp(26px,3.6vw,56px);
  inline-size: min(100%,1520px);
}
.opening-status {
  display: none; position: absolute; inset-inline: 0; inset-block-start: min(38svh,20rem);
  place-items: center; gap: 10px; pointer-events: none;
  color: #f5eddb; font-size: .9375rem; text-shadow: 0 1px 6px #101e19;
}
.opening-status .icon { inline-size: 23px; block-size: 23px; color: var(--gold); }
[data-reader-opening] .reader { visibility: hidden; }
[data-reader-opening] .opening-status { display: grid; }
.book-tools {
  --player-width: 46rem;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-inline: var(--arrow-gutter); margin-block-end: 8px;
}
.book-title { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e6ddc9; font-size: .875rem; }
.reader-heading { display: none; }
.book-tools .utility { flex: none; min-block-size: 44px; }
.book-tools-with-narration {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,var(--player-width)) minmax(0,1fr);
  grid-template-areas: "title narration contents"; reading-flow: grid-rows;
}
.book-tools-with-narration .book-title { grid-area: title; }
.book-tools-with-narration .utility { grid-area: contents; justify-self: end; }
.narration-player {
  --narration-gold: #efd09a;
  --narration-muted: #bed0c2;
  grid-area: narration; min-inline-size: 0; inline-size: min(100%,var(--player-width)); margin-inline: auto;
  padding: .5rem .75rem; border: 1px solid #496457; border-radius: .875rem;
  color: #f6eee0; background: #18352d;
}
.desktop-playback { display: grid; gap: .375rem; color-scheme: dark; }
.narration-transport { display: flex; align-items: center; gap: .5rem; }
.narration-actions { display: flex; gap: 3px; }
.desktop-playback .narration-action { min-block-size: 2.25rem; }
.narration-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-block-size: 44px; padding: 5px 8px; border-radius: 8px;
  background: transparent; font-size: .8125rem; line-height: 1.15; touch-action: manipulation;
}
.narration-action .icon { inline-size: 19px; block-size: 19px; color: var(--narration-gold); }
.narration-action:not(:disabled):hover { background: #29473c; }
.narration-action:focus-visible { outline-offset: 2px; }
.narration-action:disabled { opacity: .62; }
.narration-action.narration-play {
  inline-size: 125px; flex: none; background: var(--narration-gold); color: #142d25; font-weight: 650;
}
.narration-play .icon { color: inherit; }
.narration-action.narration-play:not(:disabled):hover { background: #f9e0b4; }
.desktop-playback .sound-toggle { flex: none; gap: .375rem; padding-inline: .625rem; border: 1px solid #577367; }
.desktop-playback .sound-toggle::after {
  content: ""; inline-size: .375rem; block-size: .375rem; margin: -.2rem .125rem 0;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.desktop-playback .sound-toggle[aria-expanded="true"] { background: #365348; border-color: #a3b7a4; }
.desktop-playback .sound-toggle[aria-expanded="true"]::after { margin-block: .2rem 0; transform: rotate(225deg); }
.narration-voices {
  min-inline-size: 0; margin: 0; padding: 0; border: 0;
}
.voice-options {
  display: flex;
  border: 1px solid #466257; border-radius: 9px; background: #112b24;
}
.desktop-playback .narration-voices legend { float: inline-start; padding: 0; margin-inline-end: .5rem; line-height: 2rem; }
.narration-voices label { position: relative; cursor: pointer; }
.narration-voices label input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.narration-voices label span {
  display: grid; place-items: center; min-block-size: 2rem; padding: 4px 10px;
  border-radius: 8px; color: var(--narration-muted); font-size: .75rem; line-height: 1.2;
}
.narration-voices label:hover span { color: #fff3db; }
.narration-voices label:has(input:disabled) { cursor: default; }
.narration-voices input:disabled + span { opacity: .6; }
.narration-voices label input:checked + span {
  color: #f3f7ef; background: #365348; outline: 1px solid #a3b7a4; outline-offset: -2px;
}
.narration-voices label input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: -3px; }
.sound-timeline {
  flex: 1; min-inline-size: 0; display: grid; align-items: center;
  grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "track time"; column-gap: .625rem;
}
.narration-player input[type="range"] {
  min-inline-size: 0; inline-size: 100%; block-size: 2rem; margin: 0; accent-color: var(--narration-gold); cursor: pointer;
}
.sound-timeline input { grid-area: track; }
.narration-player input:disabled { cursor: default; }
.narration-time, .sound-percent { font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.narration-time { grid-area: time; }
.sound-percent { min-inline-size: 5ch; text-align: end; }
.sound-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.desktop-playback .sound-options {
  padding-block-start: .375rem; border-block-start: 1px solid #39564a; color: var(--narration-muted); font-size: .8125rem;
}
.sound-volume {
  display: grid; align-items: center; grid-template-columns: auto auto minmax(3.5rem,6rem) auto; column-gap: .25rem;
}
.sound-options .narration-mute { min-block-size: 2rem; inline-size: 2rem; padding: 0; }
.sound-speed, .device-volume { display: flex; align-items: center; gap: .5rem; }
.sound-speed select {
  min-block-size: 2rem; padding: .25rem .4rem; border: 1px solid #577367; border-radius: .5rem;
  font: inherit; font-variant-numeric: tabular-nums; color: #f6eee0; background: #112b24; cursor: pointer;
}
.narration-status:not(.sr-only) {
  margin-block-start: .375rem; padding-inline: 4px; color: #f6e1ba; font-size: .75rem;
}
.book-layout {
  position: relative; display: grid; align-items: center;
  grid-template-columns: var(--arrow-gutter) minmax(0,1fr) var(--arrow-gutter);
}
@media (pointer: coarse) {
  .reader { --arrow-gutter: clamp(44px,3.6vw,56px); }
}
.page-arrow {
  display: grid; place-items: center; inline-size: 100%; block-size: 48px; padding: 0;
  border-radius: 6px; color: var(--gold); background: transparent; touch-action: manipulation;
}
.page-arrow .icon { width: clamp(22px,2.5vw,32px); height: clamp(22px,2.5vw,32px); stroke-width: 1.9; }
.page-arrow:not(:disabled):is(:hover,:active) { color: #fff4d7; }
.page-arrow:focus-visible { outline-offset: -3px; }
.page-arrow:disabled { opacity: .35; }
.book-cover {
  position: relative; isolation: isolate; padding: 5px 8px 9px;
  border: 1px solid #9f7850; border-bottom-color: #493020; border-radius: 11px 12px 12px 11px;
  background: var(--grain), linear-gradient(90deg,#775136,#8c6645 47%,#593c28 49.7%,#62462e 50.2%,#916848 54%,#63452e);
  box-shadow: 0 3px 0 #523824,0 6px 1px #332b21,0 18px 26px -8px #0009,0 36px 52px -20px #000a;
  touch-action: pan-y pinch-zoom;
}
.page-edges {
  position: relative; padding: 0 3px 6px; border-radius: 5px 6px 6px 5px;
  background: repeating-linear-gradient(to bottom,#efe3c9 0 1px,#ab976e 1px 2px,#e4d4af 2px 3px);
  box-shadow: -2px 0 0 #c5b28b,2px 0 0 #b8a783,0 1px 0 #513b27;
}
.page-edges::after {
  content: ""; position: absolute; left: 47%; right: 47%; bottom: -1px; height: 8px; pointer-events: none;
  background: linear-gradient(90deg,transparent,#42362290 44%,#33291b 50%,#4f412c85 57%,transparent);
}
.spread { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); position: relative; isolation: isolate; }
.leaf { position: relative; min-width: 0; }
.leaf[data-offstage] { display: none; }
.copy-page {
  grid-area: 1 / 1; display: flex; flex-direction: column; justify-content: safe center; align-items: flex-start;
  padding: clamp(32px,3vw,49px) clamp(38px,4.6vw,74px) 53px;
  min-height: clamp(480px,min(52vw,72dvh),690px); border-radius: 4px 2px 2px 4px; color: var(--ink);
  background: var(--grain),linear-gradient(90deg,#e5d8b9 0%,#f9f1df 2.2%,#faf3e4 17%,#fbf5e9 72%,#f5ecda 91%,#ecdfc7 96.5%,#c8ba9b 99.4%,#9e8c6e);
}
.copy-page::before { content: ""; position: absolute; inset: 10px auto 10px 9px; width: 1px; background: #b6a47c32; }
.page-flow { position: relative; width: 100%; }
.chapter-label { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; overflow-wrap: anywhere; color: #825d35; }
.chapter-label i { display: block; flex: none; height: 1px; width: 25px; background: #b39157; }
h1 {
  margin-inline-start: -.025em;
  font: 600 clamp(2.25rem,1.25rem + 3.1vw,4.5rem)/1.04 var(--display);
  letter-spacing: -.03em; overflow-wrap: anywhere; text-wrap: balance;
}
.title-first,.title-second { display: block; }
.title-second { color: var(--copper); }
.ornament { display: flex; align-items: center; gap: 6px; margin: 19px 0 18px; color: #a68a52; }
.ornament i { width: 27px; height: 1px; background: currentColor; opacity: .78; }
.ornament i:last-child { width: 13px; }
.ornament svg { width: 10px; height: 10px; }
.prose {
  max-inline-size: 64ch;
  font: 400 clamp(1.125rem,1rem + .375vw,1.3125rem)/1.6 var(--serif);
  color: #3b3c31; overflow-wrap: break-word;
}
.prose p { text-wrap: pretty; }
.prose p + p { margin-block-start: .75em; }
.page-decoration {
  flex: none; inline-size: clamp(77px,7.25vw,108px); max-inline-size: 100%; aspect-ratio: 3/1;
  margin: 21px 0 0 1px; opacity: .82; pointer-events: none;
  background: var(--page-decoration) left center / contain no-repeat;
}
.folio { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; font: 600 1.05rem/1 var(--display); color: #927b52; }
.folio::before,.folio::after { content: ""; width: 12px; height: 1px; background: #b9a784; }
.art-page {
  grid-area: 1 / 2; display: grid; padding: 11px 11px 11px 9px; border-radius: 2px 4px 4px 2px;
  background: var(--grain),linear-gradient(90deg,#a18e70,#e0d2b7 2%,#f8eed9 8%,#f4e8cb 97%,#e4d3ab);
}
.painting { position: relative; overflow: hidden; isolation: isolate; border-radius: 2px; background: #193f3b; cursor: grab; }
.picture-loading {
  display: none; position: absolute; inset: 0; place-items: center; padding: 12px;
  color: #f5eddb; font-size: .875rem; text-align: center; pointer-events: none;
}
.spread > .art-page[data-picture-loading] .picture-loading { display: grid; }
.spread > .art-page[data-picture-loading] .painting > .plate-image:first-child { opacity: 0; }
.curl-print :is(.scene-action, .scene-motion) { display: none; }
.film-control {
  position: absolute; z-index: 3; bottom: 12px; left: 12px; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 1px solid #f8edcd7a; border-radius: 50%;
  color: #fff4d7; background: #172c26ce; cursor: pointer; touch-action: manipulation;
}
.film-control .icon { width: 18px; height: 18px; }
.painting[data-replay-above] .film-control { top: 12px; bottom: auto; }
.painting[data-replay-opposite] .film-control { left: auto; right: 12px; }
.painting[data-replay-centered] .film-control { left: 50%; right: auto; translate: -50% 0; }
.film-control:hover { background: #132621; }
.film-control[hidden] { display: none; }
.painting::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 2px 0 8px #1e281c3b,inset 0 0 0 1px #3a3d263d; background: linear-gradient(90deg,#201e1633,transparent 7%); }
.ribbon {
  position: absolute; z-index: 2; left: calc(50% - 57px); top: -4px; width: 24px; height: 47px; pointer-events: none;
  background: repeating-linear-gradient(90deg,transparent 0 1px,#5b311c14 1px 2px),linear-gradient(90deg,#995232,#b56540 24%,#b06840 75%,#8e492c);
  clip-path: polygon(0 0,100% 0,100% 100%,50% 82%,0 100%);
}
.ribbon::before { content: ""; position: absolute; inset: 0 3px; border-inline: 1px dashed #e9bd8775; }
.ribbon svg { display: block; margin: 13px auto; width: 10px; height: 10px; color: #f2cc95; }
.edge { position: absolute; z-index: 7; inset-block: 0; width: clamp(34px,3.4vw,54px); padding: 0; background: transparent; cursor: grab; touch-action: pinch-zoom; -webkit-user-select: none; user-select: none; }
.edge-left { left: 0; }
.edge-right { right: 0; }
.edge[data-disabled] { pointer-events: none; }
.spread.is-turning { grid-template-rows: minmax(0,1fr); }
.spread.is-turning > .copy-page { min-block-size: 0; overflow: clip; }
.spread.is-turning, .spread.is-turning * { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.spread.is-turning .ribbon { visibility: hidden; }

/* Only the moving sheet is duplicated. The real pages stay accessible at rest. */
.curl-stage { position: absolute; z-index: 5; inset: 0; pointer-events: none; }
.curl-sheet,.curl-slice,.curl-print,.curl-shading { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.curl-slice { transform-origin: 0 0; pointer-events: none; backface-visibility: hidden; }
.curl-print > .leaf { width: 100%; height: 100%; min-height: 0; }
.curl-print.reverse { transform: scaleX(-1); }
.curl-shadow { position: absolute; display: block; pointer-events: none; }
.curl-mobile-print { position: absolute; inset: 0; display: grid; grid-template: var(--art-height) minmax(0,1fr) / minmax(0,1fr); }
.curl-paper-back { position: absolute; inset: 0; background: var(--paper) var(--grain); }
.curl-paper-back .curl-mobile-print { opacity: .095; }

.pagination { margin-block-start: clamp(14px,2dvh,23px); }
.stops { display: flex; flex-wrap: wrap; justify-content: center; }
.stop { height: 24px; width: 24px; display: grid; place-items: center; padding: 0; background: transparent; border-radius: 5px; }
.stop::after { content: ""; width: 5px; height: 5px; border-radius: 4px; background: #bdc4a477; }
.stop[aria-current="page"]::after { width: 20px; background: #c9d8c8; }
.stop:hover::after { background: #d9e3d7; }

dialog { width: min(440px,calc(100% - 32px)); max-height: 90svh; padding: 26px 28px 22px; border: 1px solid #bba477; border-radius: 10px; background: var(--paper) var(--grain); color: var(--ink); box-shadow: 0 20px 90px #0016109c,inset 0 0 0 5px #e9ddc46b; overflow-y: auto; }
dialog { --focus-ring: var(--focus-on-paper); }
dialog::backdrop { background: #071e18b8; backdrop-filter: blur(4px); }
.contents-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.contents-head p { color: #85613e; font-size: .875rem; overflow-wrap: anywhere; }
.contents-head h2 {
  margin-top: 3px; font: 600 2rem/1.12 var(--display); letter-spacing: -.03em;
  overflow-wrap: anywhere; hyphens: auto;
}
.close-dialog { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border: 1px solid #cdbd9e; border-radius: 50%; background: transparent; }
.close-dialog:hover { background: #e7dcc7; }
.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list li + li { border-top: 1px solid #b8a98d58; }
.chapter-link { display: flex; align-items: center; width: 100%; gap: 13px; padding: 8px; text-align: left; background: transparent; border-radius: 4px; }
.chapter-link:hover,.chapter-link[aria-current="page"] { background: #e3eadc; }
.thumb,.thumb img { display: block; width: 53px; height: 53px; flex: none; object-fit: cover; border-radius: 3px; }
.chapter-link small { display: block; font: 500 .75rem/1.45 var(--sans); color: #805f3d; text-transform: uppercase; letter-spacing: .09em; overflow-wrap: anywhere; }
.chapter-link strong { display: block; font: 600 1.375rem/1.18 var(--display); overflow-wrap: anywhere; }
.chapter-link > svg { opacity: 0; margin-inline-start: auto; color: var(--ink); flex: none; width: 13px; height: 13px; }
.chapter-link[aria-current="page"] > svg { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .opening-status { animation: reader-fade .18s ease .12s backwards; }
  .opening-status .icon { animation: opening-star 1s ease-in-out infinite alternate; }
  .book-revealed .reader { animation: reader-fade .38s ease-out; }
  .spread > .art-page .painting > .plate-image:first-child { transition: opacity .24s ease-out; }
  @keyframes reader-fade { from { opacity: 0; } }
  @keyframes opening-star { from { opacity: .45; } }
}
@media (min-width: 701px) and (max-height: 540px) {
  .reading-room { padding-block: 8px 12px; }
  .book-layout > .page-arrow { align-self: start; margin-block-start: 20dvh; }
  .copy-page { min-height: 52dvh; padding-block: 20px 26px; }
  .chapter-label { margin-bottom: 8px; }
  h1 { font-size: clamp(2.25rem,1.25rem + 2.5vw,3.25rem); }
  .ornament { margin-block: 10px; }
  .page-decoration { inline-size: 74px; margin-block-start: 10px; }
}
@media (max-width:1050px) and (min-width:701px) {
  .copy-page { padding-inline: clamp(30px,4vw,45px); }
  .ribbon { left: calc(50% - 41px); }
}
@media (max-width:700px) {
  .utility { min-height: 36px; padding: 6px 11px; font-size: .8125rem; gap: 6px; }
}
@media (max-width: 700px), (max-width: 1024px) and (orientation: portrait) {
  div.reader-backdrop { background-position: var(--endpaper-mobile-position, 25% bottom); }
  .reading-room { justify-content: flex-start; padding-block: 10px 14px; }
  .reader { inline-size: calc(100% - 2 * clamp(5px,1.45vw,10px)); }
  .book-cover { padding: 3px 4px 5px; border-radius: 7px; }
  .page-edges { padding: 0 2px 4px; } .page-edges::after { display: none; }
  .spread { grid-template-columns: minmax(0,1fr); }
  .spread.is-turning { grid-template-rows: auto minmax(0,1fr); }
  .art-page { grid-area: 1 / 1; padding: 8px 8px 0; background: var(--paper) var(--grain); border-radius: 3px 3px 0 0; }
  .painting {
    aspect-ratio: 1; inline-size: 100%;
    /* На невысоких экранах оставляем место для текста под иллюстрацией. */
    max-block-size: clamp(48svh,calc(100svh - 31rem),66svh);
  }
  .plate-image { object-position: var(--scene-art-position, center 46%); }
  .film-control { left: auto; right: 42px; bottom: 8px; }
  .painting[data-replay-opposite] .film-control { left: 42px; right: auto; }
  .copy-page { grid-area: 2 / 1; justify-content: flex-start; min-height: 0; padding: 20px clamp(22px,6vw,64px) 40px; background: var(--paper) var(--grain); border-radius: 0 0 3px 3px; }
  .copy-page::before { display: none; } .chapter-label { gap: 8px; margin-bottom: 8px; }
  .chapter-label i { width: 19px; }
  h1 { font-size: clamp(2rem,1.5rem + 2.8vw,3.25rem); }
  .title-first,.title-second { display: inline; }
  .ornament { margin: 12px 0; gap: 4px; } .ornament i { width: 19px; } .ornament svg { width: 8px; height: 8px; }
  .page-decoration { inline-size: clamp(76px,20vw,96px); margin-block-start: 12px; }
  .folio { bottom: 8px; font-size: .86rem; }
  .ribbon { left: auto; right: 21px; top: -2px; width: 18px; height: 32px; }
  .ribbon svg { margin-top: 8px; width: 8px; height: 8px; }
  .edge { width: 9%; min-width: 24px; } .curl-stage { overflow: clip; }
}
body[data-book="post"] {
  --forest: #204047; --ink: #244142; --copper: #9e412c; --gold: #f2cd89;
  --endpaper: url("assets/reader/post-endpaper.webp");
  --endpaper-mobile-position: 15% bottom;
  --page-decoration: url("assets/reader/post-ornament.webp");
}
body[data-book="spark"] {
  --forest: #252a4d; --ink: #303755; --copper: #78518a; --gold: #f6c87b;
  --endpaper: url("assets/reader/spark-endpaper.webp");
  --endpaper-mobile-position: right bottom;
  --page-decoration: url("assets/reader/spark-ornament.webp");
}
body[data-book="mitten"] {
  --forest: #49353a; --ink: #493635; --copper: #903f4e; --gold: #f3cb9e;
  --endpaper: url("assets/reader/mitten-endpaper.webp");
  --endpaper-mobile-position: 10% bottom;
  --page-decoration: url("assets/reader/mitten-ornament.webp");
}
body[data-book="tram"] {
  --forest: #253b3c; --ink: #283c3b; --copper: #9b3e2e; --gold: #efc380;
  --endpaper: url("assets/reader/tram-endpaper.webp");
  --endpaper-mobile-position: 82% bottom;
  --page-decoration: url("assets/reader/tram-ornament.webp");
}
body[data-book="bell"] {
  --forest: #173844; --ink: #273e42; --copper: #934927; --gold: #f2ca89;
  --endpaper: url("assets/reader/bell-endpaper.webp");
  --page-decoration: url("assets/reader/bell-ornament.webp");
}
body[data-book="boot-garden"] {
  --forest: #423a2b; --ink: #2e392a; --copper: #943e29; --gold: #f4cc84;
  --endpaper: linear-gradient(#34271b80, #39281d18), url("assets/reader/boot-garden-endpaper.webp");
  --endpaper-mobile-position: 20% bottom;
  --page-decoration: url("assets/reader/boot-garden-ornament.webp");
}
body:not([data-book="fox"]) h1 { hyphens: auto; }
body:not([data-book="fox"]) .chapter-label { color: var(--copper); }
body:not([data-book="fox"]) .brand-description { color: #e6ddc9; }
body[data-book="spark"] .ribbon { background: linear-gradient(90deg,#674766,#9a6a91 50%,#644066); }
body[data-book="mitten"] .ribbon { background: linear-gradient(90deg,#893f49,#bd6c77 50%,#803943); }
body[data-book="bell"] .ribbon { background: linear-gradient(90deg,#772b36,#b65047 50%,#6e2831); }
body[data-book="boot-garden"] .ribbon { background: linear-gradient(90deg,#2e486e,#557ba7 50%,#374f77); }
body[data-book="boot-garden"] .page-decoration { background-size: 155% auto; background-position: 48% 55%; }
body[data-book="wind-suitcase"] {
  --forest: #37304e; --ink: #343148; --copper: #9b3840; --gold: #f3ce92;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/wind-suitcase-endpaper.webp");
  --endpaper-mobile-position: 22% bottom;
  --page-decoration: url("assets/reader/wind-suitcase-ornament.webp");
}
body[data-book="wind-suitcase"] .ribbon { background: linear-gradient(90deg,#a24247d0,#a24247 50%,#a24247d0); }
body[data-book="caterpillar-lift"] {
  --forest: #30483b; --ink: #274234; --copper: #665021; --gold: #ead399;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/caterpillar-lift-endpaper.webp");
  --endpaper-mobile-position: 18% bottom;
  --page-decoration: url("assets/reader/caterpillar-lift-ornament.webp");
}
body[data-book="caterpillar-lift"] .ribbon { background: linear-gradient(90deg,#a27439d0,#a27439 50%,#a27439d0); }
body[data-book="rustle-conductor"] {
  --forest: #43392f; --ink: #3c382e; --copper: #944331; --gold: #f4d597;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/rustle-conductor-endpaper.webp");
  --endpaper-mobile-position: 23% bottom;
  --page-decoration: url("assets/reader/rustle-conductor-ornament.webp");
}
body[data-book="rustle-conductor"] .ribbon { background: linear-gradient(90deg,#4d66a3d0,#4d66a3 50%,#4d66a3d0); }
body[data-book="scent-map"] {
  --forest: #443249; --ink: #493647; --copper: #86534c; --gold: #f2ce8c;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/scent-map-endpaper.webp");
  --endpaper-mobile-position: 14% bottom;
  --page-decoration: url("assets/reader/scent-map-ornament.webp");
}
body[data-book="scent-map"] .ribbon { background: linear-gradient(90deg,#855a8bd0,#855a8b 50%,#855a8bd0); }
body[data-book="paper-sea-dragon"] {
  --forest: #254555; --ink: #254053; --copper: #a23d37; --gold: #ffdfab;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/paper-sea-dragon-endpaper.webp");
  --endpaper-mobile-position: 75% bottom;
  --page-decoration: url("assets/reader/paper-sea-dragon-ornament.webp");
}
body[data-book="paper-sea-dragon"] .ribbon { background: linear-gradient(90deg,#bc514cd0,#bc514c 50%,#bc514cd0); }
body[data-book="blue-paint"] {
  --forest: #333f5d; --ink: #2e405e; --copper: #903e41; --gold: #f8d69f;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/blue-paint-endpaper.webp");
  --endpaper-mobile-position: 62% bottom;
  --page-decoration: url("assets/reader/blue-paint-ornament.webp");
}
body[data-book="blue-paint"] .ribbon { background: linear-gradient(90deg,#466caed0,#466cae 50%,#466caed0); }
body[data-book="whale-echo"] {
  --forest: #183e42; --ink: #244645; --copper: #985344; --gold: #f2d0a2;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/whale-echo-endpaper.webp");
  --endpaper-mobile-position: 70% bottom;
  --page-decoration: url("assets/reader/whale-echo-ornament.webp");
}
body[data-book="whale-echo"] .ribbon { background: linear-gradient(90deg,#c07660d0,#c07660 50%,#c07660d0); }
body[data-book="button-workshop"] {
  --forest: #483849; --ink: #4b3b47; --copper: #983d46; --gold: #f2d1a0;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/button-workshop-endpaper.webp");
  --endpaper-mobile-position: 32% bottom;
  --page-decoration: url("assets/reader/button-workshop-ornament.webp");
}
body[data-book="button-workshop"] .ribbon { background: linear-gradient(90deg,#9d543cd0,#9d543c 50%,#9d543cd0); }
body[data-book="clock-minute"] {
  --forest: #453541; --ink: #493841; --copper: #8c4c34; --gold: #f2ce9d;
  --endpaper: linear-gradient(#211e2c76, #29262224), url("assets/reader/clock-minute-endpaper.webp");
  --endpaper-mobile-position: 25% bottom;
  --page-decoration: url("assets/reader/clock-minute-ornament.webp");
}
body[data-book="clock-minute"] .ribbon { background: linear-gradient(90deg,#a2644ad0,#a2644a 50%,#a2644ad0); }
body[data-book="tram"] h1 { font-family: var(--sans); font-weight: 500; line-height: 1.04; }
body[data-book="tram"] .title-second { font-style: normal; }
@media (min-width:701px) and (orientation: landscape), (min-width:1025px) {
  body:not([data-book="fox"]) h1 { font-size: clamp(2.75rem,4.5vw,4.5rem); }
  body[data-book="tram"] h1 { font-size: clamp(2.05rem,3.05vw,3.3rem); }
}
@media (max-width:700px) {
  .reader-tools { gap: 10px; }
  .shelf-link { font-size: .8125rem; }
}
@media (max-width: 700px), (max-width: 1024px) and (orientation: portrait) {
  body[data-book="tram"] h1 { font-size: clamp(2rem,7.4vw,2.8rem); }
}
@media (max-width:370px) {
  .reader-tools { gap: 7px; }
  .utility { padding-inline: 8px; }
}

@media (max-width: 70rem), (pointer: coarse) {
  body[data-book] > .library-header, #reader-root > .site-header { display: none; }
  .reading-room { justify-content: start; padding-block: env(safe-area-inset-top, 0px) 1rem; }
  .reader { padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); }
  .reader-heading {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-block-size: 3.25rem; padding-inline: clamp(.625rem, 2vw, 2rem);
  }
  .reader-heading .shelf-link {
    flex: none; gap: .3rem; color: #f4e5c9; text-decoration: none; font-size: .875rem;
  }
  .reader-heading .book-title { font: 600 clamp(1rem, 2vw, 1.375rem)/1.2 var(--display); }
  .book-layout { grid-template-columns: minmax(0, 1fr); }
  .book-layout > .page-arrow, .pagination { display: none; }
  .book-tools {
    position: fixed; z-index: 8; inset: auto 0 0; min-block-size: var(--bottom-bar-space);
    display: flex; justify-content: center; align-items: center; gap: clamp(.375rem, 2vw, 1.25rem);
    margin: 0; padding: .375rem max(.375rem, env(safe-area-inset-right, 0px))
      calc(.375rem + env(safe-area-inset-bottom, 0px)) max(.375rem, env(safe-area-inset-left, 0px));
    background: var(--header-background); border-block-start: 1px solid #587262; box-shadow: 0 -3px 16px #10271d26;
  }
  .book-tools > .book-title { display: none; }
  .page-controls, .compact-playback { display: flex; align-items: center; gap: clamp(.125rem, .6vw, .5rem); }
  .page-controls .page-arrow {
    inline-size: 44px; block-size: 44px; color: var(--header-ink); border-radius: .65rem;
  }
  .page-controls .page-arrow .icon { inline-size: 21px; block-size: 21px; }
  .page-controls .utility {
    flex-direction: column-reverse; gap: .1rem; min-inline-size: 3.5rem; padding: .2rem .4rem;
    font: 600 .75rem/1.2 var(--sans); font-variant-numeric: tabular-nums; color: #f6edda; border-radius: .65rem;
  }
  .page-controls .utility .icon { inline-size: 21px; block-size: 21px; color: var(--header-accent); }
  .book-tools .narration-player {
    display: block; inline-size: auto; padding: 0; margin: 0; border: 0; background: transparent;
  }
  .compact-playback > .narration-play { inline-size: clamp(6.3rem, 27vw, 8rem); border-radius: 2rem; padding-inline: .375rem; }
  .compact-playback > .sound-toggle {
    flex-direction: column; gap: .1rem; min-inline-size: 44px; padding: .125rem .375rem; font-size: .75rem;
  }
  .compact-playback > .sound-toggle .icon { inline-size: 21px; block-size: 21px; }
  .narration-status:not(.sr-only) {
    position: absolute; inset-inline: 0; inset-block-end: calc(100% + .375rem); inline-size: fit-content;
    max-inline-size: 95%; margin-inline: auto; padding: .35rem .75rem; border-radius: .5rem;
    background: var(--header-background); text-align: center; pointer-events: none;
  }
  :root:has(.reader-sheet[open]) { overflow: hidden; }
  .reader-sheet {
    position: fixed; inset: auto 0 0; margin: 0 auto; inline-size: min(100%, 32rem); max-inline-size: 100%;
    max-block-size: 82dvh; padding: 1.25rem max(1rem, env(safe-area-inset-right, 0px))
      calc(1.25rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    border-radius: 1.25rem 1.25rem 0 0; box-shadow: 0 -10px 40px #071e184d; overscroll-behavior: contain;
  }
  .reader-sheet .close-dialog { inline-size: 44px; block-size: 44px; }
  .reader-sheet .contents-head { align-items: center; }
  .contents-shelf {
    display: inline-flex; align-items: center; gap: .35rem; min-block-size: 44px;
    margin-block-start: .75rem; color: var(--ink); font-size: .875rem; text-underline-offset: .25em;
  }
  .reader-sheet .sound-timeline { grid-template-areas: "label time" "track track"; }
  .reader-sheet .sound-timeline label { grid-area: label; }
  .reader-sheet .sound-options { display: grid; grid-template-columns: minmax(0,1fr); gap: 1rem; margin-block-start: .5rem; }
  .reader-sheet :is(.sound-timeline, .sound-volume, .sound-speed) label, .reader-sheet legend { font: 600 .875rem/1.4 var(--sans); }
  .reader-sheet .narration-time, .reader-sheet .sound-percent { font-size: .8125rem; }
  .reader-sheet .sound-volume { grid-template-columns: auto minmax(0,1fr) auto; }
  .reader-sheet .sound-volume label { grid-column: 1 / -1; }
  .reader-sheet input[type="range"] { block-size: 44px; accent-color: #315844; }
  .reader-sheet .narration-mute { min-block-size: 44px; inline-size: 44px; }
  .reader-sheet .sound-speed { justify-content: space-between; }
  .reader-sheet .sound-speed select { min-block-size: 44px; padding-inline: .75rem; color: var(--ink); background: var(--paper); border-color: #a69c83; }
  .reader-sheet .voice-options { gap: .5rem; border: 0; background: none; }
  .reader-sheet legend { margin-block-end: .5rem; padding: 0; }
  .reader-sheet .narration-voices label { flex: 1; }
  .reader-sheet .narration-voices label span {
    min-block-size: 44px; border: 1px solid #a69c83; color: var(--ink); font-size: .875rem; background: transparent;
  }
  .reader-sheet .narration-voices input:checked + span { color: #fff6de; background: #315444; border-color: #315444; outline: none; font-weight: 650; }
  .reader-sheet .narration-voices input:focus-visible + span { outline: 2px solid #ac682c; outline-offset: 2px; }
  .reader-sheet .narration-actions { flex-wrap: wrap; justify-content: start; gap: .5rem; margin-block-start: 1.125rem; }
  .reader-sheet .narration-action { color: var(--ink); }
  .reader-sheet .narration-action .icon { color: inherit; }
  .reader-sheet .narration-action:not(.narration-play):hover { background: #e5e8d7; }
  .reader-sheet .narration-play { inline-size: auto; padding-inline: .9rem; }
  .sheet-status { margin-block-start: .5rem; font-size: .8125rem; }
  @media (min-width: 38rem) {
    .reader-sheet { inset-block-end: max(1rem, env(safe-area-inset-bottom, 0px)); border-radius: 1.25rem; padding: 1.5rem; }
    .reader-heading, .book-layout { margin-inline: .75rem; }
    .page-controls, .compact-playback { gap: .625rem; }
    .book-tools:has(.narration-player) {
      justify-content: space-between; padding-inline: max(6vw, env(safe-area-inset-left, 0px)) max(6vw, env(safe-area-inset-right, 0px));
    }
  }
  .book-tools:not(:has(.narration-player)) .page-controls { inline-size: min(100%, 24rem); justify-content: space-between; }
  @media (max-width: 23rem) {
    .compact-playback > .narration-play { flex-direction: column; gap: .1rem; font-size: .75rem; inline-size: 5.5rem; border-radius: .75rem; }
  }
}
