/* v1.0.15: responsive book; owner changes go to assets/custom.css */
body.book-view{--book-header-h:70px;--book-title-h:70px;--book-tools-h:65px;--book-rail-w:38px;--book-top:calc(var(--book-header-h) + var(--book-title-h) + var(--book-tools-h))}
body.book-view>header{position:sticky;top:0;z-index:1000;width:100%;box-shadow:0 1px 5px #0002}
body.book-view main{max-width:none;margin:0 auto;padding:0 8px;min-height:80vh}
body.book-view main>h1{position:sticky;top:var(--book-header-h);z-index:995;background:#f3f6f9;margin:0;padding:10px 10px;font-size:24px;border-bottom:1px solid #dce4ed}
.book-toolbar{position:sticky;top:calc(var(--book-header-h) + var(--book-title-h));z-index:994;display:flex;justify-content:flex-start;align-items:center;gap:12px;flex-wrap:wrap;background:#f3f6f9;padding:6px 8px;margin:0 0 4px;border-bottom:1px solid #dce4ed}
.book-toolbar form{margin:0}.book-toolbar label{display:flex;align-items:center;gap:8px;margin:0}.book-toolbar select{width:auto;max-width:170px;margin:0;padding:5px 8px}.book-toolbar .btn{margin:0;padding:7px 12px}
.book-shell{display:block;max-width:1650px;margin:0 auto;padding-right:calc(var(--book-rail-w) + 8px)}
.book-spreads{display:flex;flex-direction:column;gap:0;min-width:0;background:#202020}
.book-spread{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0;align-items:start}
.book-sheet{position:relative;min-width:0;line-height:0;scroll-margin-top:calc(var(--book-top) + 10px);background:#202020}
.book-sheet img{display:block;width:100%;height:auto;aspect-ratio:1600/2263;object-fit:fill}
.book-sheet.book-empty{aspect-ratio:1600/2263;background:#202020}
.book-hit{position:absolute;display:block;box-sizing:border-box;border:1px solid #e31717;outline:0;cursor:pointer}
.book-hit:hover,.book-hit:focus-visible{background:#ffdc5030;outline:2px solid #e00;z-index:2}
.book-mode-debug .book-hit{border-width:2px;background:#e3171714}
.book-side{position:fixed;right:6px;top:calc(var(--book-top) + 4px);bottom:6px;width:var(--book-rail-w);z-index:990;display:flex;flex-direction:column;align-items:stretch;background:#ebf0f4;border:1px solid #bdc8d0;border-radius:3px;overflow:hidden}
.book-side-head{font-size:9px;text-align:center;font-weight:700;padding:7px 0 5px}
.book-page-nav{min-height:0;flex:1;display:flex;flex-direction:column;gap:2px;overflow-y:auto;overscroll-behavior:contain;padding:2px 3px;scrollbar-width:thin}
.book-page-nav a{flex:0 0 28px;display:flex;align-items:center;justify-content:center;border:1px solid #9baebc;border-radius:1px;background:#fff;text-decoration:none;color:#345;font-size:11px;font-weight:600}
.book-page-nav a.active,.book-page-nav a:hover{border-color:#e32222;color:#b11;background:#fff3f3}
.book-rail-indicator{flex-shrink:0;text-align:center;background:white;border:2px solid #e22;border-radius:3px;margin:4px 2px;padding:4px 0;font-weight:800;color:#c00;font-size:12px}
@media(max-width:760px){body.book-view{--book-rail-w:33px}body.book-view>header{padding:8px 10px}body.book-view main{padding:0 3px}body.book-view main>h1{padding:6px;font-size:19px}.book-toolbar{gap:5px;padding:5px 4px}.book-toolbar label{font-size:12px}.book-toolbar select{max-width:90px;font-size:12px}.book-toolbar .btn{padding:5px 7px;font-size:12px}.book-shell{padding-right:calc(var(--book-rail-w) + 2px)}.book-spread{display:flex;flex-direction:column}.book-sheet{width:100%;flex:none}.book-sheet.book-empty{display:none}.book-page-nav a{flex-basis:26px;font-size:10px}.book-side{right:2px;bottom:3px}.book-side-head{font-size:8px}}

/* v1.0.16: desktop faithful legacy book layout. Mobile single-page stays intact. */
.book-toolbar>.book-heading{font-size:25px;font-weight:700;margin:0 auto 0 0;padding:0;line-height:1.3;background:transparent;border:0;position:static;white-space:nowrap}
body.book-view .book-toolbar{top:var(--book-header-h);margin:0;min-height:58px;z-index:995;padding:8px 14px;justify-content:flex-start;gap:16px;border-bottom:1px solid #cbd5df}
body.book-view .book-shell{max-width:none;width:100%;margin:0;padding-right:calc(var(--book-rail-w) + 3px)}
body.book-view main{padding:0}
.book-spreads{width:100%}
.book-spread{gap:0}
.book-sheet{scroll-margin-top:calc(var(--book-header-h) + var(--book-tools-h) + 8px)}
@media(min-width:761px){
 body.book-view{--book-rail-w:26px}
 .book-side{top:calc(var(--book-header-h) + var(--book-tools-h) + 2px);bottom:0;right:0;width:var(--book-rail-w);background:#f3f3f3;border:0;border-left:1px solid #bdc7cf;border-radius:0;overflow:visible}
 .book-side-head{display:none}
 .book-page-nav{display:flex;flex-direction:column;flex:1;min-height:0;gap:0;padding:2px 0;overflow:hidden;scrollbar-width:none;background:#e6e6e6}
 .book-page-nav a{position:relative;flex:1 1 0;min-height:1px;max-height:none;border:0;border-bottom:1px solid #8d8d8d;border-radius:0;background:#eee;color:transparent;font-size:0;overflow:visible;line-height:0}
 .book-page-nav a:nth-child(5n){border-bottom:2px solid #555}
 .book-page-nav a:nth-child(10n){border-bottom:2px solid #b82020}
 .book-page-nav a.active,.book-page-nav a:hover{background:#b82020;border-color:#b82020}
 .book-page-nav a.active::before{content:attr(data-page);position:absolute;z-index:3;right:calc(100% + 1px);top:50%;transform:translateY(-50%);height:25px;min-width:30px;box-sizing:border-box;display:flex;justify-content:center;align-items:center;padding:0 4px;border:2px solid #c92323;border-radius:3px;background:#fff;color:#b11;font:700 12px/1 Arial,sans-serif;box-shadow:0 1px 3px #0003}
 .book-rail-indicator{display:none}
}
@media(max-width:760px){
 .book-toolbar>.book-heading{font-size:19px;white-space:normal;flex-basis:100%;margin:0}
 body.book-view .book-toolbar{min-height:0;padding:5px 4px;gap:5px}
 body.book-view .book-shell{padding-right:calc(var(--book-rail-w) + 2px)}
 .book-spread{display:flex;flex-direction:column}
 .book-sheet.book-empty{display:none}
}

/* v1.0.17: compact fixed-toolbar pagination, independent of right-hand page rail */
body.book-view .book-toolbar-pages{display:flex;align-items:center;gap:3px;margin-left:8px;flex:0 1 auto;min-width:0;white-space:nowrap}
body.book-view .book-pager-btn{box-sizing:border-box;min-width:31px;height:34px;padding:0 6px;display:inline-flex;align-items:center;justify-content:center;border:1px solid #a9a9a9;border-radius:5px;background:#fff;color:#43206b;font-weight:600;font-size:14px;line-height:1;cursor:pointer}
body.book-view .book-pager-btn.active{background:#393939;border-color:#393939;color:#fff}
body.book-view .book-pager-btn:hover:not(:disabled){border-color:#333}
body.book-view .book-pager-btn:disabled{opacity:.35;cursor:default}
@media(max-width:1300px) and (min-width:761px){body.book-view .book-toolbar{gap:8px}.book-toolbar>.book-heading{font-size:21px}body.book-view .book-pager-btn{min-width:25px;padding:0 4px;font-size:12px}}
@media(max-width:760px){body.book-view .book-toolbar-pages{margin:3px 0 0;max-width:100%;width:100%;justify-content:center;gap:3px}body.book-view .book-pager-btn{min-width:35px;height:32px;font-size:13px}}

/* v1.0.17: right-hand page rail removed; full-width book and toolbar pager only */
body.book-view{--book-rail-w:0px}
body.book-view .book-shell{padding-right:0!important}
body.book-view .book-side{display:none!important}
@media(max-width:760px){body.book-view .book-shell{padding-right:0!important}}

/* v1.0.18 - normal book hotspots invisible; debug remains red */
body.book-view .book-hit{border:0!important;background:transparent!important;outline:0!important}
body.book-view .book-hit:hover,body.book-view .book-hit:focus-visible{background:#ffdc5028!important;outline:2px solid #aa3030!important}
body.book-view .book-mode-debug .book-hit{border:2px solid #e31717!important;background:#e3171714!important}
body.book-view .book-mode-debug .book-hit:hover,body.book-view .book-mode-debug .book-hit:focus-visible{background:#e317172e!important}
/* top pagination and direct page jump */
body.book-view .book-page-jump{display:flex;align-items:center;gap:4px;margin:0 0 0 6px;flex:0 0 auto}
body.book-view .book-page-jump input{width:78px;min-width:0;height:34px;padding:5px 6px;margin:0;max-width:none;font-size:13px}
body.book-view .book-page-jump button{height:34px;min-width:32px;margin:0;padding:0 7px;border-radius:5px}
body.book-view .book-toolbar form:first-of-type label{margin:0}
body.book-view .book-toolbar{position:sticky;top:var(--book-header-h);z-index:995}
@media(max-width:760px){body.book-view .book-page-jump{margin:3px 0}body.book-view .book-toolbar-pages{width:auto;flex:1 1 auto;justify-content:flex-start}body.book-view .book-page-jump input{width:65px}}

/* v1.0.32 compact book navigation – one row on small screens */
body.book-view .book-heading{display:none!important}
@media(max-width:760px){
body.book-view .book-toolbar{display:flex!important;flex-flow:row nowrap!important;align-items:center!important;gap:3px!important;padding:5px 3px!important;overflow:hidden!important}
body.book-view .book-toolbar form{flex:none!important;margin:0!important}
body.book-view .book-toolbar-pages{display:flex!important;width:auto!important;flex:1 1 auto!important;justify-content:center!important;min-width:0!important;gap:2px!important;margin:0!important}
body.book-view .book-pager-btn{min-width:20px!important;height:28px!important;padding:0 3px!important;font-size:11px!important}
body.book-view .book-toolbar select{max-width:64px!important;padding:2px!important;font-size:11px!important}
body.book-view .book-page-total{font-size:10px!important;white-space:nowrap!important}
body.book-view .book-page-jump{margin:0!important;gap:2px!important;flex:none!important}
body.book-view .book-page-jump input{width:40px!important;height:28px!important;font-size:11px!important;padding:1px 3px!important}
body.book-view .book-page-jump button{min-width:23px!important;height:28px!important;padding:0 4px!important}
}
