/*
MIT License

Copyright (c) 2026 Param Pathak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/
/* Original compact bookshelf and immersive reading design. */
:root{--bg:#17191d;--panel:#22252a;--line:#35383f;--accent:#c8d8c6}button,a,input,select{touch-action:manipulation}button{min-height:44px}.library-main{max-width:1500px;padding:24px clamp(16px,4vw,56px)}.hero{display:flex;gap:20px;justify-content:space-between;padding:0 0 24px;align-items:center}.hero h1{font:500 1.7rem system-ui;margin:8px 0}.hero h1 br{display:none}.hero>.library-intro .muted{font-size:.85rem}.upload-card{padding:12px 16px;gap:8px;width:min(400px,100%);border-style:solid;background:var(--panel)}.upload-card p{display:none}.upload-card label{font-size:.9rem}.eyebrow{margin:0;font-size:.65rem}.book-grid{grid-template-columns:repeat(auto-fill,minmax(145px,1fr));gap:26px 20px}.book-card{border:0;background:transparent;border-radius:0}.book-cover{aspect-ratio:2/3;height:auto!important;border-radius:8px;padding:0;background:#252b32;box-shadow:0 6px 16px #0004}.book-cover img{width:100%;height:100%;object-fit:contain}.book-card-content{padding:10px 0!important}.book-card-content h3{font:500 .9rem/1.4 system-ui;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0 0 3px}.book-card-content p{font-size:.75rem;margin:2px 0;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.book-card-content .read-link{font-size:.75rem;margin-top:6px}.book-card-content>.quiet-link{display:none}.book-card-content>button{font-size:.75rem;padding:4px 8px;min-height:32px}.book-progress{height:3px;width:100%;accent-color:var(--accent);display:block;margin:7px 0}.card-menu summary{min-width:36px;min-height:40px;font-size:1.3rem;padding:3px 10px}.section-heading{margin-bottom:16px}.action-row{gap:12px;font-size:.8rem}.cover-fallback{font:italic .9rem Georgia;max-width:85%}.reader-topbar{height:52px;padding:0 16px;gap:10px}.reader-topbar strong{flex:1;max-width:none;min-width:0}.reader-actions a{display:none}.reader-actions button{font-size:.8rem;padding:6px 9px}.reader-main{background:var(--bg)}.reader-footer{height:auto;min-height:92px;display:grid;grid-template-columns:auto 1fr auto;padding:8px 16px calc(8px + env(safe-area-inset-bottom));gap:8px}.reader-dock{grid-column:1/-1;display:flex;justify-content:center;gap:8px;order:2}.reader-dock button{font-size:.75rem;min-height:36px;padding:4px 12px;background:transparent}.reading-status span{max-width:50vw;font-size:.8rem}.reader-panel{top:52px;bottom:98px;max-width:100vw;border-radius:12px}.reader-page[data-focus=true]>.reader-topbar,.reader-page[data-focus=true]>.reader-footer{display:none}.reveal-chrome{position:fixed;right:16px;bottom:calc(16px + env(safe-area-inset-bottom));z-index:6;border-radius:50%;opacity:.8}.reveal-chrome[hidden]{display:none}.settings-panel label{margin:16px 0}.shell-page[data-reading=true]>.topbar{display:none}.shell-page>.topbar{padding-top:calc(8px + env(safe-area-inset-top));min-height:52px}.player-panel{padding-bottom:calc(10px + env(safe-area-inset-bottom))}.player-heading{gap:12px}.player-heading>div{min-width:0;flex:1}.player-heading strong,.player-heading p{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mini-toggle{white-space:nowrap}.player-panel[data-mini=true] .transport,.player-panel[data-mini=true] .player-options,.player-panel[data-mini=true]>small{display:none}.player-panel[data-mini=true]{max-height:145px}.player-panel[data-mini=true] #playingChapter{font-size:.75rem;margin:0}.player-panel[data-mini=true] #playerStatus{font-size:.7rem;margin:0}.player-panel[data-mini=true] .player-heading{margin-bottom:4px}.player-options input[type=range]{width:90px}dialog{padding:20px;max-height:85dvh}.topbar nav{gap:14px}.reader-topbar>a{white-space:nowrap}
@media(max-width:600px){.library-page>.topbar{height:56px}.library-main{padding:16px}.hero{align-items:stretch;flex-direction:column;gap:14px;padding-bottom:18px}.hero h1{font-size:1.4rem}.hero .muted{display:none}.upload-card{width:100%;grid-template-columns:1fr auto;align-items:center}.upload-card label{grid-column:1/-1}.upload-card input{min-width:0;width:100%;font-size:.75rem}.upload-card button{font-size:.75rem;padding:8px}.book-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 14px}.section-heading{gap:12px}.action-row select{padding:8px}.reader-topbar{padding:4px 8px}.reader-topbar strong{font-size:.75rem}.reader-actions{gap:2px}.reader-actions button{font-size:.7rem;padding:4px 6px}.reader-actions #contentsToggle,.reader-actions #settingsToggle{display:none}.reader-footer{padding-left:8px;padding-right:8px}.reader-dock{gap:4px}.reader-dock button{flex:1;padding:4px;font-size:.75rem}.reader-panel{top:52px;bottom:98px;width:min(380px,100vw)}.shell-page nav{gap:10px}.shell-page nav a{font-size:.75rem}.shell-page .brand{font-size:.85rem}.transport{gap:4px}.player-panel{padding-left:10px;padding-right:10px}.transport button{font-size:.8rem}.player-options{display:grid;grid-template-columns:1fr 1fr}.player-options label{display:flex;flex-direction:column;align-items:stretch;min-width:0}.player-options select{width:100%;min-width:0}.mini-toggle{padding:4px 8px;font-size:.75rem}}
@media(min-width:430px) and (max-width:600px){.book-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:14px 10px}.book-card-content h3{font-size:.8rem}}
/* Honor native hidden state even when component layout rules use flex/grid. */
[hidden]{display:none!important}
#networkState{padding:10px 16px;font-size:.8rem;background:#403323;color:#f6deae;flex:none}

/* Persistent player presentation: hiding controls never removes its media element. */
.player-panel{box-sizing:border-box;max-height:min(340px,42dvh);padding:8px 16px calc(8px + env(safe-area-inset-bottom));scrollbar-width:thin;overscroll-behavior:contain}.player-heading{display:grid;grid-template-columns:36px minmax(0,1fr) auto 44px;gap:8px;align-items:center}.player-cover{width:36px;height:48px;object-fit:contain;border-radius:4px;background:#292d33}.player-cover[hidden]{display:none}.player-heading:has(.player-cover[hidden]){grid-template-columns:minmax(0,1fr) auto 44px}.player-title{min-width:0;width:100%;text-align:left;background:transparent;border:0;padding:0;overflow:hidden}.player-title strong,.player-title p{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:100%}.player-title strong{font-size:.85rem}.player-title p{font-size:.75rem;margin:3px 0}.player-heading #miniPrevious,.player-heading #miniNext,.player-heading #miniPlay{display:none}.player-heading button{min-height:44px;flex-shrink:0}.player-settings summary{cursor:pointer;font-size:.8rem;padding:8px 0}.player-options{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}.player-options label{min-width:0;display:flex;flex-direction:column;align-items:stretch}.player-options select{width:100%;min-width:0}.player-panel #miniProgress{display:none}.player-panel[data-mini=true]{max-height:110px;overflow:hidden;padding-top:6px;padding-bottom:calc(6px + env(safe-area-inset-bottom))}.player-panel[data-mini=true] .player-heading{grid-template-columns:32px minmax(0,1fr) repeat(4,40px);gap:4px;margin:0}.player-panel[data-mini=true] .player-heading:has(.player-cover[hidden]){grid-template-columns:minmax(0,1fr) repeat(4,40px)}.player-panel[data-mini=true] .player-cover{width:32px;height:42px}.player-panel[data-mini=true] #miniPrevious,.player-panel[data-mini=true] #miniNext,.player-panel[data-mini=true] #miniPlay{display:block;min-width:0;padding:4px;font-size:.8rem}.player-panel[data-mini=true] #expandPlayer{padding:4px;min-width:0}.player-panel[data-mini=true] #closePlayer,.player-panel[data-mini=true] .player-settings{display:none}.player-panel[data-mini=true] #miniProgress{display:block;width:100%;height:3px;margin:4px 0 0;accent-color:var(--accent);border:0}.player-panel[data-mini=true] #playerStatus{font-size:.65rem;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;margin:3px 0 0}.transport #audioSeek{flex-basis:100%;width:100%;min-width:0}.transport{margin:6px 0;justify-content:center}.transport #audioTime{flex-basis:100%;text-align:center}.player-panel[data-mini=false] #playPause{min-width:64px}@media(max-width:600px){.player-panel{padding-left:8px;padding-right:8px;max-height:min(340px,44dvh);border-radius:12px 12px 0 0}.player-heading{gap:6px}.player-title strong{font-size:.78rem}.transport{gap:4px}.transport button{padding:7px;min-height:44px}.player-panel .player-options{grid-template-columns:repeat(2,minmax(0,1fr))}.player-panel .player-options input[type=range]{width:100%}.player-panel[data-mini=true] .player-heading{grid-template-columns:28px minmax(0,1fr) repeat(4,40px)}.player-panel[data-mini=true] .player-cover{width:28px;height:38px}}

.player-title #playingChapter{display:block;font-size:.75rem;margin:3px 0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
/* Screen-sized reading surfaces and five unobtrusive controls. */
.reader-topbar{height:44px;min-height:44px;border:0;padding:0 10px;flex:none}.reader-topbar strong{font-size:.8rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.reader-icon{width:44px;min-width:44px;height:44px;min-height:44px;padding:0!important;display:inline-grid;place-items:center;border:0;background:transparent;font-size:22px;line-height:1;color:inherit}.reader-icon[hidden]{display:none}.reader-footer{display:flex;flex-direction:column;min-height:0;height:auto;gap:2px;padding:2px 8px calc(3px + env(safe-area-inset-bottom));border:0}.reading-status{width:100%;display:flex;justify-content:center;gap:8px;align-items:center;min-height:18px}.reading-status #sectionTitle{display:none}.reading-status small{font-size:.65rem}.reader-dock{display:flex;justify-content:space-around;width:min(400px,100%);order:0;gap:0}.reader-dock .reader-icon{flex:none;font-size:21px}.reader-dock #dockSettings{font-size:17px}.reader-panel{top:44px;bottom:calc(68px + env(safe-area-inset-bottom));max-height:75dvh;overflow:auto}.return-narration{position:fixed;right:12px;bottom:calc(82px + env(safe-area-inset-bottom));border-radius:50%;background:var(--panel);box-shadow:0 2px 12px #0005;z-index:8}.reader-main{overflow:hidden}.reader-main iframe{display:block}.reader-page{overflow:hidden}.reader-page[data-focus=true] .return-narration{bottom:calc(16px + env(safe-area-inset-bottom))}
/* One persistent audio element; outside-reader presentation is only a floating pill. */
.shell-page .player-panel[data-mini=true]{position:fixed;bottom:calc(14px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:min(420px,calc(100% - 24px));border:1px solid var(--line);border-radius:30px;box-shadow:0 8px 24px #0006;padding:5px 10px;max-height:64px;z-index:12}.shell-page .player-panel[data-mini=true] .player-heading,.shell-page .player-panel[data-mini=true] .player-heading:has(.player-cover[hidden]){display:grid;grid-template-columns:28px minmax(0,1fr) 44px 44px;gap:4px}.shell-page .player-panel[data-mini=true] .player-cover{display:block;width:28px;height:38px}.shell-page .player-panel[data-mini=true] .player-cover[hidden]{visibility:hidden;display:block!important}.shell-page .player-panel[data-mini=true] #miniPrevious,.shell-page .player-panel[data-mini=true] #miniNext,.shell-page .player-panel[data-mini=true] #expandPlayer,.shell-page .player-panel[data-mini=true] #playingChapter,.shell-page .player-panel[data-mini=true] #miniProgress,.shell-page .player-panel[data-mini=true] #playerStatus{display:none!important}.shell-page .player-panel[data-mini=true] #miniPlay,.shell-page .player-panel[data-mini=true] #closePlayer{display:block;padding:0;min-height:44px;font-size:22px;border:0;background:transparent}.shell-page .player-panel[data-mini=true] .player-title strong{font-size:.8rem}.shell-page #workspace{min-height:0}.shell-page[data-reading=true] .player-panel[data-mini=true]{bottom:calc(74px + env(safe-area-inset-bottom));width:min(340px,calc(100% - 32px))}.shell-page .player-panel[data-mini=false]{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(560px,100%);max-height:min(340px,50dvh);overflow:auto;border-radius:18px 18px 0 0;z-index:12}.shell-page #miniPlay,.shell-page #playPause{font-size:22px}.player-title{cursor:pointer}.player-cover{cursor:pointer}@media(max-height:430px){.reader-topbar{height:36px;min-height:36px}.reader-footer{padding-top:0}.reader-dock .reader-icon{height:36px;min-height:36px}.reading-status{min-height:12px}.shell-page[data-reading=true] .player-panel[data-mini=true]{bottom:calc(58px + env(safe-area-inset-bottom))}}
/* The reader itself owns the headphones sheet entry point; no pill covers its text. */
.shell-page[data-reading=true] .player-panel[data-mini=true]{display:none}.book-title{color:inherit;text-decoration:none}

/* Headphones represent actual playback, never job or cache availability. */
#dockListen{color:#fff}#dockListen[data-playing=true]{color:#58a8ff}

/* Reader overlays never resize the text surface when controls are toggled. */
.reader-page[data-focus=true]>.reader-topbar,.reader-page[data-focus=true]>.reader-footer{display:flex;opacity:0;pointer-events:none;visibility:hidden}
.reader-topbar,.reader-footer{transition:opacity .18s ease;flex-shrink:0}
.reader-audio-slot{height:0;flex-shrink:0;position:relative}
.reader-page[data-audio-engaged=true] .reader-audio-slot{height:78px}
.reader-mini{position:absolute;left:50%;transform:translateX(-50%);bottom:5px;width:min(480px,calc(100% - 16px));box-sizing:border-box;display:grid;grid-template-columns:28px minmax(0,1fr) repeat(4,40px);align-items:center;gap:3px;padding:6px 8px;background:#292c32;color:#edf0ef;border:1px solid #41454d;border-radius:14px;box-shadow:0 4px 16px #0004;z-index:30}
.reader-mini>img{width:28px;height:40px;object-fit:contain;border-radius:3px}.reader-mini:has(>img[hidden]){grid-template-columns:minmax(0,1fr) repeat(4,40px)}
.reader-mini-title{min-width:0}.reader-mini-title strong,.reader-mini-title small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:1.4}.reader-mini-title strong{font-size:12px}.reader-mini-title small{color:#b6bdc7}
.reader-mini button{min-width:0;min-height:44px;padding:0;border:0;background:transparent;color:inherit;font-size:13px}.reader-mini #readerMiniPlay{font-size:20px}.reader-mini #readerMiniClose{font-size:22px}.reader-mini progress{grid-column:1/-1;height:3px;width:100%;accent-color:#58a8ff;border:0;margin:0}.reader-mini progress::-webkit-progress-bar{background:#454a53}.reader-mini progress::-webkit-progress-value{background:#58a8ff}
.contents-panel{z-index:20;max-height:none;overflow:hidden;box-sizing:border-box}.contents-book{display:flex;align-items:center;gap:12px;margin-bottom:12px}.contents-book img{width:44px;height:62px;object-fit:contain}.contents-book strong{font-size:16px}.contents-book p{font-size:13px;color:var(--muted);margin:5px 0}.contents-panel #contentsChapter{display:block;color:#58a8ff;margin-bottom:12px}.contents-panel .section-list button{border-bottom:1px solid var(--line);border-radius:0;padding:14px 8px;margin:0}.contents-panel .section-list button.active{color:#58a8ff}.contents-panel .section-list{overscroll-behavior:contain}.contents-panel .tab-row{flex-shrink:0}
@media(max-width:600px), (hover:none) and (pointer:coarse){.contents-panel{inset:0;width:100%;border-radius:0;padding:calc(8px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom));height:100dvh}.reader-mini{gap:1px;grid-template-columns:24px minmax(0,1fr) repeat(4,36px);padding:6px}.reader-mini:has(>img[hidden]){grid-template-columns:minmax(0,1fr) repeat(4,36px)}.reader-mini>img{width:24px;height:36px}}
.contents-panel{z-index:40;min-height:0}.contents-panel> :not(.section-list){flex-shrink:0}.contents-panel .section-list{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden}.contents-panel .section-list[data-virtualized=true]>button{height:56px;min-height:56px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.contents-panel .pagination{flex:none;margin:4px 0 0}.contents-panel .pagination button{min-height:36px;padding:4px 12px}
@media(max-height:550px){.contents-panel .contents-book,.contents-panel #contentsChapter{display:none}.contents-panel .panel-heading{margin-bottom:4px}.contents-panel .tab-row{margin-bottom:4px}.contents-panel .section-list{margin-top:4px}}
@media(prefers-reduced-motion:reduce){.reader-topbar,.reader-footer{transition:none}}
/* Reading controls overlay a stable text viewport; visibility never repaginates. */
.reader-topbar{position:absolute;inset:env(safe-area-inset-top) 0 auto;z-index:5;background:var(--bg)}
.reader-main{padding-top:calc(44px + env(safe-area-inset-top));padding-bottom:calc(20px + env(safe-area-inset-bottom));flex:1}
.reader-footer{position:absolute;inset:auto 0 0;z-index:6;background:var(--bg)}
.reader-audio-slot,.reader-page[data-audio-engaged=true] .reader-audio-slot{position:absolute;bottom:calc(66px + env(safe-area-inset-bottom));left:0;right:0;height:0;z-index:7}
.reader-page[data-focus=true] .reader-mini{opacity:0;visibility:hidden;pointer-events:none}
.reader-mini{transition:opacity .18s ease}.reader-mini-title{text-align:left!important}
.return-narration,.reader-page[data-focus=true] .return-narration{top:calc(50px + env(safe-area-inset-top));bottom:auto;right:12px;border-radius:24px;padding:6px 12px;font-size:12px;min-height:36px}
.shell-page .player-panel[data-mini=false]{inset:0;transform:none;width:100%;max-height:none;height:100dvh;border-radius:0;padding:calc(12px + env(safe-area-inset-top)) max(16px,calc((100vw - 760px)/2)) calc(14px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:10px;background:#17191d;overflow:auto}
.player-panel[data-mini=false] .player-heading{grid-template-columns:52px minmax(0,1fr) auto 44px;flex:none}
.player-panel[data-mini=false] .player-cover{width:52px;height:72px}
.player-panel[data-mini=false] .player-title strong,.player-panel[data-mini=false] .player-title #playingChapter{white-space:normal;line-height:1.4}
.spoken-passages{flex:1;min-height:140px;overflow:auto;overscroll-behavior:contain;font:19px/1.65 Georgia,serif;padding:0 8px}
.spoken-passages p{margin:18px 0}.current-passage{color:#c3deff;border-left:3px solid #58a8ff;padding-left:12px}.nearby-passage{color:#89929e;font-size:16px}
.player-panel[data-mini=true] .spoken-passages,.player-panel[data-mini=true] #sleepStatus{display:none}
.player-panel[data-mini=false] .transport{flex:none;display:grid;grid-template-columns:repeat(5,1fr);align-items:center;gap:6px;margin:0}
.player-panel[data-mini=false] #audioSeek{grid-column:1/-1;grid-row:1;accent-color:#58a8ff;min-height:36px}
.player-panel[data-mini=false] #audioTime{grid-column:1/-1;grid-row:2;font-size:13px;color:#acb7c5}
.player-panel[data-mini=false] #playPause{height:60px;border-radius:50%;background:#365d89}
.player-panel[data-mini=false] .player-settings{flex:none}.player-panel[data-mini=false] .player-options{grid-template-columns:repeat(3,minmax(0,1fr))}
.player-panel[data-mini=false] #sleepStatus,.player-panel[data-mini=false]>small{font-size:11px;margin:0}
.shell-page .player-panel[data-mini=true] .player-heading{grid-template-columns:28px minmax(0,1fr) repeat(4,36px)}
.shell-page .player-panel[data-mini=true] #miniPrevious,.shell-page .player-panel[data-mini=true] #miniNext,.shell-page .player-panel[data-mini=true] #playingChapter,.shell-page .player-panel[data-mini=true] #miniProgress{display:block!important}
.shell-page .player-panel[data-mini=true]{max-height:82px;border-radius:16px}.shell-page .player-panel[data-mini=true] #miniProgress{accent-color:#58a8ff}
@media(max-width:430px){.player-panel[data-mini=false] .player-options{grid-template-columns:repeat(2,minmax(0,1fr))}.spoken-passages{font-size:18px}.player-panel[data-mini=false] .transport button{padding:6px;font-size:13px}}

/* One viewport-contained action sheet, shared by the entire bookshelf. */
.book-card{position:relative}.book-card>.card-menu{position:absolute;right:4px;top:4px;min-width:44px;min-height:44px;padding:4px;font-size:24px;border-radius:50%;background:#11151bd9;z-index:1}.book-menu-selected .book-cover{outline:2px solid var(--accent);outline-offset:3px}
.book-menu-dialog{position:fixed;inset:0;margin:auto;width:min(380px,calc(100vw - 32px));max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain;padding:24px;border:1px solid var(--line);border-radius:16px;background:var(--panel);color:var(--ink);box-sizing:border-box}.book-menu-dialog::backdrop{background:#0009}.book-menu-dialog h2{padding-right:40px;overflow-wrap:anywhere;margin:0 0 8px}.book-menu-dialog p{margin:0 0 16px}.book-menu-close{position:absolute;right:8px;top:8px;min-width:44px;min-height:44px;font-size:24px;padding:0}.book-menu-actions{display:grid;gap:6px}.book-menu-actions a,.book-menu-actions button{display:flex;align-items:center;text-align:left;min-height:48px;padding:10px 14px;border-radius:8px}.book-menu-actions a:hover{background:var(--bg)}
@media(max-width:700px){.book-menu-dialog{inset:auto 0 0;margin:0 auto;width:100%;max-width:100%;max-height:calc(100dvh - 24px - env(safe-area-inset-top));border-radius:20px 20px 0 0;padding:24px max(20px,env(safe-area-inset-left)) calc(20px + env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-right))}}
.reader-topbar,.reader-footer,.reader-mini{transition:opacity .18s ease,visibility .18s ease}@media(prefers-reduced-motion:reduce){.reader-topbar,.reader-footer,.reader-mini{transition:none}}

.reader-mini{grid-template-columns:28px minmax(0,1fr) repeat(5,44px)}.reader-mini:has(>img[hidden]){grid-template-columns:minmax(0,1fr) repeat(5,44px)}@media(max-width:600px){.reader-mini{grid-template-columns:24px minmax(0,1fr) repeat(5,44px)}}
@media(max-height:550px){.book-menu-dialog{width:min(560px,calc(100vw - 32px));padding:16px}.book-menu-actions{grid-template-columns:repeat(2,minmax(0,1fr))}.book-menu-dialog p{margin-bottom:8px}}
.reader-page[data-theme=gray],.shell-page[data-reading=true][data-reader-theme=gray]{--bg:#292b30;--panel:#34373e;--ink:#e4e2de;--muted:#b9b9b8;--line:#50545d;--spoken:#414b59;color-scheme:dark}
.reader-page[data-theme=dark],.shell-page[data-reading=true][data-reader-theme=dark]{--bg:#11151b;--panel:#1a2028;--ink:#edf0ef;--muted:#a5adae;--spoken:#303c49;color-scheme:dark}
.reader-page[data-theme=lightgray],.shell-page[data-reading=true][data-reader-theme=lightgray]{--bg:#e5e5e1;--panel:#d7d8d5;--ink:#292b2d;--muted:#505657;--line:#a2a9ad;--accent:#42684b;--spoken:#becbd4;color-scheme:light}
.reader-page[data-theme=light],.shell-page[data-reading=true][data-reader-theme=light]{--bg:#fafaf7;--panel:#eeefea;--ink:#252c28;--muted:#505657;--line:#a2a9ad;--accent:#42684b;--spoken:#d4e0d5;color-scheme:light}
.theme-swatches{display:flex;gap:8px;margin-top:10px}.theme-swatches button{min-width:52px;min-height:44px;font:20px Georgia;border:1px solid #879098}.theme-swatches [data-reader-theme=gray]{background:#292b30;color:#e4e2de}.theme-swatches [data-reader-theme=dark]{background:#11151b;color:#edf0ef}.theme-swatches [data-reader-theme=lightgray]{background:#e5e5e1;color:#292b2d}
.shell-page[data-reading=true] .player-panel[data-mini=false]{background:var(--bg);color:var(--ink)}.shell-page[data-reading=true] .current-passage{background:var(--spoken);color:var(--ink);border-radius:8px;padding:12px;border-left-color:var(--accent)}.shell-page[data-reading=true] .nearby-passage,.shell-page[data-reading=true] .player-panel[data-mini=false] #audioTime{color:var(--muted)}
.reader-mini{background:var(--panel);color:var(--ink);border-color:var(--line)}.reader-mini-title small{color:var(--muted)}
.library-page[data-listening=true]{padding-bottom:calc(110px + env(safe-area-inset-bottom))}.current-passage mark{background:var(--spoken,#414b59);color:inherit;border-radius:3px;box-shadow:0 1px 0 currentColor}
.reader-page #dockListen[data-playing=false]{color:var(--ink)}
.reader-page[data-theme=lightgray],.reader-page[data-theme=light]{--audio-active:#235d94}.reader-page #dockListen[data-playing=true]{color:var(--audio-active,#58a8ff)}
.shell-page .player-panel[data-mini=false] #playPause{--play-bg:#365d89;--play-ink:#f3f5f6;background:var(--play-bg);color:var(--play-ink)}
