:root {
  color-scheme: light;
  --paper: #f8f7f2;
  --paper-edge: #d8d7d1;
  --ink: #000000;
  --muted: #555555;
  --accent: #000000;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #f8f7f2;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { height: 100%; }
body { min-width: 300px; min-height: 100%; margin: 0; overflow: hidden; background: #f8f7f2; }
button, input { font: inherit; }
button { -webkit-appearance: none; appearance: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.book-header { position: fixed; z-index: 20; top: 0; left: 0; width: 100%; height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(1rem, 4vw, 3rem); }
.book-title { color: var(--ink); font-size: .88rem; font-variant: small-caps; letter-spacing: .14em; text-decoration: none; }
.text-button { padding: .55rem 0; border: 0; border-bottom: 1px solid var(--ink); color: var(--ink); background: transparent; font-size: .72rem; cursor: pointer; }

.reader { position: fixed; inset: 62px 0 86px; display: grid; grid-template-columns: minmax(48px, 1fr) minmax(260px, min(72vh * .709, 520px)) minmax(48px, 1fr); align-items: center; touch-action: pan-y; perspective: 1300px; }
.page { position: relative; grid-column: 2; width: 100%; aspect-ratio: 105 / 148; max-height: calc(100dvh - 174px); overflow: hidden; color: var(--ink); background: var(--paper); border: 1px solid var(--paper-edge); box-shadow: 0 2px 2px rgba(0,0,0,.1), 9px 10px 0 -5px #eeeeea, 11px 12px 0 -5px #cecdc7, 0 28px 60px rgba(0,0,0,.16); transform-origin: left center; }
.page::before { content: ""; position: absolute; z-index: 0; inset: 0; pointer-events: none; opacity: .17; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 150 150' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.5' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E"); mix-blend-mode: multiply; }
.page::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; pointer-events: none; background: linear-gradient(90deg, rgba(71,56,38,.14), transparent); }
.page-running-head { position: absolute; z-index: 1; top: 4.2%; left: 9%; right: 9%; display: flex; justify-content: space-between; padding-bottom: .45rem; border-bottom: 1px solid rgba(37,35,31,.25); color: var(--muted); font-size: clamp(.43rem, 1.1vh, .58rem); font-style: italic; letter-spacing: .04em; }
.page-copy { position: absolute; z-index: 1; inset: 11% 10% 10%; overflow: hidden; }
.chapter-label { margin: 0 0 .6rem; color: var(--muted); font-size: clamp(.46rem, 1.15vh, .62rem); font-variant: small-caps; letter-spacing: .12em; text-transform: uppercase; }
.page-copy h1 { margin: 0 0 clamp(.8rem, 2.5vh, 1.4rem); font-size: clamp(1.25rem, 3.2vh, 2.1rem); font-weight: 500; line-height: 1.02; text-wrap: balance; }
.page-text { font-size: clamp(.76rem, 1.75vh, 1rem); line-height: 1.48; hyphens: auto; text-align: justify; }
.page-text p { margin: 0 0 .8em; }
.page-text p:first-child::first-letter { float: left; margin: .03em .08em -.05em 0; font-size: 3.15em; line-height: .8; }
.page-footer { position: absolute; z-index: 1; left: 9%; right: 9%; bottom: 3.6%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: var(--muted); font-size: clamp(.43rem, 1.1vh, .58rem); }
.page-footer span:first-child { grid-column: 1; font-style: italic; }.page-footer span:last-child { grid-column: 2; }
.page.turn-next { animation: turn-next .38s ease; }.page.turn-previous { animation: turn-previous .38s ease; }

.page-edge { align-self: stretch; min-width: 48px; padding: 0; border: 0; color: rgba(37,35,31,.48); background: transparent; cursor: pointer; }
.page-edge span { display: inline-grid; place-items: center; width: 44px; height: 44px; font-size: 2rem; transition: transform .2s, color .2s; }
.page-edge:hover span { color: var(--ink); transform: scale(1.15); }
.page-edge:disabled { visibility: hidden; }
.page-edge-left { grid-column: 1; grid-row: 1; text-align: right; }.page-edge-right { grid-column: 3; grid-row: 1; text-align: left; }

.audio-bar { position: fixed; z-index: 30; left: 0; bottom: 0; width: 100%; min-height: 74px; display: grid; grid-template-columns: minmax(150px, 1fr) auto auto auto minmax(200px, 2fr) auto; align-items: center; gap: clamp(.45rem, 1.8vw, 1.25rem); padding: .7rem clamp(1rem, 4vw, 3rem) max(.7rem, env(safe-area-inset-bottom)); border-top: 1px solid #ccccca; background: rgba(248,247,242,.96); backdrop-filter: blur(12px); }
.audio-bar button { width: 38px; height: 38px; padding: 0; border: 0; color: var(--ink); background: transparent; cursor: pointer; }
.audio-bar .play { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: #f8f3e7; background: var(--ink); }
.audio-bar .play::before { content: ""; width: 0; height: 0; margin-left: 3px; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 10px solid currentColor; }
.audio-bar .play.is-playing::before { width: 11px; height: 13px; margin-left: 0; border: 0; background: linear-gradient(90deg,currentColor 0 3px,transparent 3px 8px,currentColor 8px 11px); }
.track-title { min-width: 0; }.track-title small { display: block; color: var(--muted); font-size: .48rem; letter-spacing: .12em; }.track-title strong { display: block; overflow: hidden; margin-top: .2rem; font-size: .8rem; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.timeline { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; color: var(--muted); font: .56rem ui-monospace, monospace; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.continuous { display: flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .62rem; white-space: nowrap; }

.contents { position: fixed; z-index: 50; top: 0; right: 0; width: min(390px, 92vw); height: 100dvh; display: grid; grid-template-rows: auto 1fr; color: var(--ink); background: var(--paper); border-left: 1px solid #b9ae97; box-shadow: -18px 0 55px rgba(45,35,25,.24); transform: translateX(105%); transition: transform .35s ease; }
.contents.is-open { transform: translateX(0); }
.contents > header { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 1.2rem; border-bottom: 1px solid #c5baa3; }
.contents > header strong { font-weight: 400; font-variant: small-caps; letter-spacing: .1em; }.contents > header button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; }
.contents-list { overflow-y: auto; padding: 0 1.2rem 2rem; overscroll-behavior: contain; }.contents-list h2 { position: sticky; top: 0; z-index: 2; margin: 0; padding: 1.4rem 0 .6rem; color: var(--accent); background: var(--paper); font-size: .75rem; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; }
.contents-list button { width: 100%; min-height: 50px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .6rem; padding: .65rem 0; border: 0; border-bottom: 1px solid #d4cab5; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }.contents-list button:hover { color: var(--accent); }.contents-list button span { font-size: .83rem; }.contents-list button small { color: var(--muted); font: .5rem ui-monospace, monospace; }

@keyframes turn-next { 0% { transform: rotateY(0); filter: brightness(1); } 48% { transform: rotateY(-8deg) translateX(-7px); filter: brightness(.9); } 100% { transform: rotateY(0); filter: brightness(1); } }
@keyframes turn-previous { 0% { transform: rotateY(0); } 48% { transform: rotateY(8deg) translateX(7px); } 100% { transform: rotateY(0); } }

@media (max-width: 680px) {
  .book-header { height: 50px; padding-top: env(safe-area-inset-top); }.book-title { font-size: .7rem; }.text-button { font-size: .66rem; }
  .reader { inset: 50px 0 116px; grid-template-columns: 1fr; padding: 0 8px; }
  .page { grid-column: 1; width: auto; height: min(calc(100dvh - 180px), calc((100vw - 26px) * 1.4095)); max-width: calc(100vw - 26px); max-height: none; justify-self: center; }
  .page-edge { position: absolute; z-index: 5; top: 0; width: 18%; min-width: 52px; height: 100%; opacity: 0; }.page-edge-left { left: 0; }.page-edge-right { right: 0; }
  .page-copy { inset: 10.5% 8.5% 10%; }.page-running-head { left: 8%; right: 8%; }.page-text { font-size: clamp(.74rem, 3.35vw, .94rem); line-height: 1.45; }.page-copy h1 { font-size: clamp(1.2rem, 6vw, 1.7rem); }
  .audio-bar { min-height: 108px; grid-template-columns: 1fr auto auto auto; gap: .25rem .45rem; padding: .55rem .8rem max(.55rem,env(safe-area-inset-bottom)); }.track-title { grid-column: 1; grid-row: 2; }.audio-bar #audio-previous { grid-column: 2; grid-row: 2; }.audio-bar .play { grid-column: 3; grid-row: 2; }.audio-bar #audio-next { grid-column: 4; grid-row: 2; }.timeline { grid-column: 1 / -1; grid-row: 1; }.continuous { display: none; }
}
@media (max-height: 620px) and (orientation: landscape) { .book-header { display: none; }.reader { inset: 8px 0 78px; }.page { max-height: calc(100dvh - 94px); }.page-copy { top: 10%; }.audio-bar { min-height: 70px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }
