.historic-grid{display:grid;grid-template-columns:1.3rem repeat(8,minmax(0,1fr));grid-template-rows:repeat(8,minmax(0,1fr)) 1.3rem;aspect-ratio:1;max-width:440px;margin:auto}.historic-grid span{display:grid;place-items:center;min-width:0}.ch-cell{font-size:clamp(1rem,4vw,2.15rem);line-height:1;background:#ffedc6;color:#252031}.ch-cell.dark-square{background:#a991c2}.ch-cell.red{color:#872c3d}.ch-cell.green{color:#145444}.ch-cell.gold{color:#72500b}.ch-cell.black{color:#251932}.ch-coordinate{font-size:.8rem;font-weight:700}
.library-reader {background:radial-gradient(ellipse at 50% 0%,#432966,var(--night) 65%);color:var(--cream);min-height:calc(100vh - 65px);padding:clamp(1.35rem,4vw,3rem) 4vw 0}
.reader-heading {text-align:center}
.reader-heading h1 {font-size:clamp(2.35rem,5vw,4.65rem)}
.reader-heading p {margin:.75rem auto;color:#eddbfb;font-size:.95rem}
.reader {max-width:1050px;margin:auto}
.book-spread {display:grid;grid-template-columns:1fr 1fr;min-height:clamp(320px,34vw,460px);border:1px solid #885c52;border-radius:12px 19px 19px 12px;background:#ffefce;color:var(--ink);box-shadow:0 6px #d6b785,0 10px #a96657,0 24px 40px #120a24a6;overflow:hidden;touch-action:pan-y}
.illustrated-leaf,.text-leaf {display:grid;align-content:center;justify-items:start;min-width:0;padding:clamp(1.35rem,4vw,3.5rem)}
.illustrated-leaf {background:linear-gradient(90deg,#f8e6bd,#fff3da 89%,#d8b784)}
.text-leaf {background:linear-gradient(90deg,#ead0a4,#fff8e9 9%,#fff5df)}
.illustrated-leaf img {width:100%;height:auto;display:block;border-radius:.65rem;box-shadow:0 3px 8px #663b2429}
.illustrated-leaf figure {width:100%;margin:0}
.historic-grid {max-width:330px}
.text-leaf h2 {font-size:clamp(1.75rem,3vw,3.05rem)}
.text-leaf p {max-width:43ch;font-size:clamp(1.05rem,1.5vw,1.28rem);margin:1rem 0 0;line-height:1.63}
.audio-controls,.page-controls {display:flex;gap:.65rem;align-items:center;justify-content:center;flex-wrap:wrap}
.audio-controls {margin:1.25rem auto .3rem}
.audio-controls[hidden],.illustrated-leaf [hidden] {display:none}
.reader-button {background:#fffaeb;border:1px solid #c9acd9;border-radius:.6rem;color:var(--ink);min-height:44px;padding:.56rem .95rem;font-weight:700}
.reader-button:not(:disabled):hover {background:#ffdf86}
.reader-button:disabled {opacity:.55;cursor:default}
.audio-status {margin:.4rem auto .85rem;max-width:55ch;text-align:center;color:#f5e3ff;font-size:.9rem}
.audio-status:empty {display:none}
.page-controls {justify-content:space-between;margin:1.6rem auto .5rem}
#page-number {font-size:.9rem;text-align:center}
.reading-note {text-align:center;color:#ead6f9;font-size:.88rem;margin:1.3rem auto 0}
.reader-footer {justify-content:center;padding:1rem 0 1.5rem}
@media (max-width:640px) {
  .book-spread {grid-template-columns:1fr;min-height:0}
  .illustrated-leaf {background:#f8e6bd;padding:.9rem;justify-items:center}
  .illustrated-leaf img {max-width:450px}
  .text-leaf {background:#fff5df;padding:1.25rem}
  .reader-button {padding-inline:.7rem}
  .ch-cell {font-size:clamp(1rem,6vw,2rem)}
}
@media (prefers-reduced-motion:no-preference) {
  .book-spread.turn-next {animation:turn-next .34s ease-out}
  .book-spread.turn-back {animation:turn-back .34s ease-out}
  @keyframes turn-next {from {transform:perspective(1500px) rotateY(-5deg);opacity:.7} to {transform:none;opacity:1}}
  @keyframes turn-back {from {transform:perspective(1500px) rotateY(5deg);opacity:.7} to {transform:none;opacity:1}}
}
.book-spread.text-only {grid-template-columns:1fr}
.text-only .illustrated-leaf {display:none}
.text-only .text-leaf {justify-items:center}
.text-only .text-leaf p {max-width:66ch}
.illustrated-leaf figure {margin-top:1.25rem}
.text-leaf p {font-size:clamp(1rem,1.36vw,1.16rem)}

.reader-chapters {display:flex;justify-content:center;flex-wrap:wrap;gap:.6rem;margin:1.25rem auto}
.reader-chapters [aria-pressed="true"] {background:#ffda72;border-color:#b68127}
.book-spread.scan-open {display:block;background:#fff6e0}
.scan-open .illustrated-leaf,.scan-leaf[hidden],.text-leaf[hidden] {display:none}
.scan-leaf {text-align:center;padding:clamp(.5rem,2vw,1.2rem)}
.scan-leaf a {display:block;width:min(100%,40rem);margin:auto;cursor:zoom-in}
.scan-leaf img {display:block;width:100%;height:auto}
#scan-zoom {display:block;margin:.6rem auto;color:var(--muted);font-size:.9rem}
.story-art {display:grid;gap:1rem;width:100%;justify-items:center}
.story-art img {width:auto;max-width:100%;max-height:32rem;object-fit:contain}
.book-spread.art-only {grid-template-columns:1fr}
.art-only .illustrated-leaf {justify-items:center}
.art-only .story-art img {max-height:72vh}
#reader-note a {text-decoration:underline}

.story-art .story-opening-art {width:100%;height:auto;max-height:none}
