/* Books & Stories — specific styling; shared tokens/footer come from style.css */
.library-header{min-height:84px;background:#24245f;color:#fff;display:flex;justify-content:space-between;align-items:center;gap:1.5rem;padding:1rem clamp(1.25rem,6vw,6rem)}
.library-brand{font:600 1.2rem/1.3 var(--serif,Georgia,serif)}
.library-brand span{color:#f5cb79;font-size:1.6rem;margin-right:.35rem}
.library-header nav{display:flex;flex-wrap:wrap;gap:1.5rem;font-size:.9rem}
.library-header a:hover,.library-header a:focus-visible{color:#f5cb79}
.library-intro{text-align:center;padding:clamp(4rem,9vw,7rem) 1.5rem 3rem;background:linear-gradient(145deg,#f9f6ff 0%,#ece7f5 55%,#fbf5eb 100%)}
.library-intro .eyebrow{color:#8269a8}
.library-intro h1{color:#272044;font-size:clamp(3rem,7vw,5.4rem);margin:.8rem 0 1.5rem}
.library-intro h1 em{color:#8b69af}
.library-intro>p:last-child{max-width:580px;margin:0 auto;color:#655d75;font-size:1.07rem}
.library-choices{max-width:1190px;padding:2.5rem 1.5rem 1rem;margin:0 auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1.5rem}
.shelf-card{appearance:none;position:relative;isolation:isolate;overflow:hidden;border:1px solid rgba(84,65,108,.13);border-radius:24px;padding:clamp(2rem,5vw,4rem);min-height:410px;display:flex;flex-direction:column;align-items:flex-start;text-align:left;cursor:pointer;font:inherit;color:#fff;box-shadow:0 20px 45px rgba(47,36,77,.13);transition:transform .22s ease,box-shadow .22s ease}
.shelf-card:before{content:"";position:absolute;inset:0;z-index:-1;opacity:.65;background:radial-gradient(circle at 78% 24%,rgba(255,255,255,.17),transparent 38%),repeating-radial-gradient(circle at 85% 15%,transparent 0 47px,rgba(255,255,255,.11) 48px 49px,transparent 50px 90px)}
.shelf-fiction{background:linear-gradient(138deg,#2d315f 0%,#56518a 57%,#9279aa 100%)}
.shelf-nonfiction{background:linear-gradient(135deg,#47435e 0%,#78627b 60%,#aa8d8c 100%)}
.shelf-card:hover{transform:translateY(-5px);box-shadow:0 25px 50px rgba(47,36,77,.22)}
.shelf-card:focus-visible{outline:3px solid #a080d1;outline-offset:4px}
.shelf-ornament{font-size:2.5rem;color:#ffe4ab;margin-bottom:auto}
.shelf-label{font-size:.7rem;letter-spacing:.2em;text-transform:uppercase;font-weight:700;color:#ffedc9}
.shelf-title{display:block;font:600 clamp(2.9rem,5vw,4.3rem)/1.15 var(--serif,Georgia,serif);margin:.5rem 0 .8rem}
.shelf-description{max-width:340px;color:#f3eefa;line-height:1.7}
.shelf-link{display:inline-flex;gap:1.2rem;align-items:center;margin-top:1.8rem;font-weight:700;font-size:.85rem;border-bottom:1px solid rgba(255,255,255,.65);padding-bottom:.35rem}
.library-note{text-align:center;color:#807589;font:italic 1rem var(--serif,Georgia,serif);padding:1rem 1rem 4rem}
.library-dialog{border:0;padding:0;width:min(920px,calc(100% - 2rem));max-width:none;max-height:min(88vh,900px);max-height:min(88dvh,900px);border-radius:20px;color:#302b43;box-shadow:0 30px 110px rgba(12,9,36,.5);background:#fffdf9}
.library-dialog::backdrop{background:rgba(13,12,35,.75);backdrop-filter:blur(6px)}
.dialog-shell{min-height:min(480px,75vh);display:flex;flex-direction:column}
.dialog-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom:1px solid #e8e0ec;padding:1rem 1.5rem;background:#f5f0fa}
.dialog-step{margin:0;color:#8c779b;letter-spacing:.15em;font-size:.67rem;text-transform:uppercase;font-weight:700}
.dialog-back,.dialog-close{background:none;border:0;cursor:pointer;color:#47385f;font:600 .9rem var(--sans,Arial,sans-serif);padding:.5rem;border-radius:8px}
.dialog-close{font-size:1.8rem;line-height:1}
.dialog-back:hover,.dialog-close:hover,.dialog-back:focus-visible,.dialog-close:focus-visible{background:#e8ddf3}
.dialog-body{overflow-y:auto;padding:clamp(1.5rem,4vw,3rem);flex:1}
.dialog-body h2{font-size:clamp(2rem,4vw,3.1rem);margin:.35rem 0 1rem}
.dialog-description{color:#756b80;margin-bottom:2rem}
.dialog-content{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
.genre-option,.story-option{font:inherit;text-align:left;background:#f4eef9;color:#392f52;border:1px solid #e4d7ee;border-radius:14px;min-height:100px;padding:1.3rem;cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:.7rem;font-weight:700;transition:background .2s,transform .2s}
.genre-option:hover,.story-option:hover{background:#e9ddf4;transform:translateY(-2px)}
.genre-option:focus-visible,.story-option:focus-visible{outline:3px solid #8a65ba;outline-offset:2px}
.genre-option span:last-child,.story-option span:last-child{color:#9e83b1}
.empty-shelf,.reader-status{grid-column:1/-1;padding:2rem;text-align:center;border:1px dashed #d4c2e3;border-radius:14px;background:#faf7fc;color:#726581;line-height:1.7}
.dialog-content.is-reading{display:block}
.reader-text{white-space:pre-wrap;overflow-wrap:anywhere;font:1.08rem/1.95 Georgia,serif;color:#2e2a35;max-width:68ch;margin:auto}
.reader-text p{margin:0 0 1.3rem}
.reader-text h3{font-family:Georgia,serif}
@media(max-width:700px){.library-header{flex-direction:column;text-align:center}.library-choices{grid-template-columns:1fr}.shelf-card{min-height:340px}.dialog-content{grid-template-columns:1fr}.library-dialog{width:calc(100% - 1rem);max-height:94dvh}.dialog-header{padding:.7rem 1rem}.dialog-body{padding:1.35rem}}
@media(prefers-reduced-motion:reduce){.shelf-card,.genre-option,.story-option{transition:none}}

/* Illustrated title selection */
.dialog-content.has-titles {grid-template-columns:1fr;}
.story-option.book-tile {min-height:140px;display:grid;grid-template-columns:84px minmax(0,1fr) auto;gap:1.25rem;align-items:center;padding:1rem;text-align:left;}
.book-cover {width:84px;height:118px;object-fit:cover;border-radius:7px;background:#262036;box-shadow:0 5px 12px #2d24422f;}
.book-copy{display:grid;gap:.4rem;min-width:0;}
.book-name{font:600 clamp(1.15rem,3vw,1.5rem)/1.3 var(--serif,Georgia,serif);color:#342846;}
.book-meta{font-size:.83rem;color:#78698b;font-weight:500;}
.book-action{font-size:.82rem;color:#715491;font-weight:700;}
/* Scrollable illuminated manuscript window */
.library-dialog.reading-mode{width:min(1250px,calc(100% - 1rem));max-height:96dvh;}
.library-dialog.reading-mode .dialog-body{padding:clamp(.5rem,2vw,1.4rem);background:#eae4ed;}
.library-dialog.reading-mode .dialog-body>h2, .library-dialog.reading-mode .dialog-body>.eyebrow, .library-dialog.reading-mode .dialog-description{margin-left:clamp(.5rem,2vw,1.5rem);}
.reader-view{max-width:100%;overflow-x:auto;min-height:220px;}
.reader-view .docx-wrapper{padding:12px!important;background:transparent!important;}
.reader-view .docx{max-width:100%;box-shadow:0 12px 35px #231c3626;margin:0 auto 20px!important;}
.reader-view .docx img{max-width:100%;height:auto;}
.reader-loading{padding:2rem;text-align:center;color:#695879;}
@media(max-width:600px){.story-option.book-tile{grid-template-columns:65px minmax(0,1fr);}.book-cover{width:65px;height:92px;}.book-action{grid-column:2;}.reader-view .docx-wrapper{padding:0!important;}}

/* Reading Room 2.0: toolbar and expanded viewing mode */
.reading-toolbar[hidden]{display:none!important}
.reading-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.65rem 1rem;padding:.65rem 1.25rem;background:#fffbf2;border-bottom:1px solid #e4d7bc;color:#3d3350}
.reader-chapter-label{font-size:.75rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#655573}
#reader-chapters{flex:1;min-width:155px;max-width:480px;padding:.55rem .75rem;border:1px solid #c9b8d0;border-radius:9px;background:#fff;color:#302745;font:inherit;font-size:.85rem}
.reader-tools-end{display:flex;align-items:center;flex-wrap:wrap;gap:.35rem;margin-left:auto}
.reader-tool{border:1px solid #d3c6d9;border-radius:9px;background:#fff;color:#463359;cursor:pointer;padding:.43rem .7rem;font:600 .82rem/1.4 var(--sans,Arial,sans-serif)}
.reader-tool:hover:not(:disabled),.reader-tool:focus-visible{background:#eee4f5;outline-color:#8664ac}
.reader-tool:disabled{opacity:.45;cursor:not-allowed}
#reader-zoom-value{display:inline-block;min-width:3.7rem;text-align:center;font-size:.82rem;font-variant-numeric:tabular-nums}
.library-dialog.reader-expanded{width:100vw!important;height:100dvh!important;max-height:100dvh!important;border-radius:0!important}
.library-dialog.reader-expanded .dialog-shell{height:100%;min-height:0}
.library-dialog.reading-mode .dialog-shell{max-height:96dvh}
.library-dialog.reader-expanded .dialog-shell{max-height:none}
.library-dialog.reading-mode .dialog-header{flex-shrink:0}
.library-dialog.reading-mode .reading-toolbar{flex-shrink:0}
.library-dialog.reading-mode .dialog-body{min-height:0;overscroll-behavior:contain}
.reader-view .docx-wrapper{transform-origin:top center}
@media(max-width:650px){.reading-toolbar{padding:.55rem .7rem}.reader-chapter-label{display:none}#reader-chapters{max-width:none;width:100%;flex-basis:100%}.reader-tools-end{width:100%;justify-content:flex-end}}
@media(prefers-reduced-motion:reduce){.reader-tool{transition:none}}

/* Reading Room 2.2: true browser fullscreen and viewport-filling fallback */
.library-dialog:fullscreen,
.library-dialog.reader-expanded{
  position:fixed!important;
  inset:0!important;
  margin:0!important;
  padding:0!important;
  width:100vw!important;
  height:100vh!important;
  height:100dvh!important;
  max-width:none!important;
  max-height:none!important;
  border-radius:0!important;
  overflow:hidden!important;
  background:#fffdf9;
}
.library-dialog:fullscreen .dialog-shell,
.library-dialog.reader-expanded .dialog-shell{
  height:100%!important;
  max-height:none!important;
  min-height:0!important;
}
.library-dialog:fullscreen .dialog-body,
.library-dialog.reader-expanded .dialog-body{min-height:0;flex:1 1 auto;overflow-y:auto;}
