/* R166: full-height reading viewport, compact controls and honest load/error states. */
.ihi-book-reader [hidden]{display:none!important}
.ihi-book-reader{height:auto;min-height:100dvh;overflow:visible;grid-template-rows:auto auto auto minmax(0,1fr) auto}
.book-topbar{min-height:68px;padding-block:8px}
.book-toolbar{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr);grid-template-areas:"nav options" "interaction search";align-items:center;gap:7px 14px;padding:8px clamp(12px,2.2vw,32px)}
.book-nav{grid-area:nav;justify-content:start}
.book-options{grid-area:options;justify-content:end;min-width:0}
.book-interaction-controls{grid-area:interaction;justify-content:start;flex-wrap:nowrap}
.book-search{grid-area:search;min-width:0;grid-column:auto}
.book-top-actions a,.book-top-actions button{font-size:12px}
.book-toolbar input,.book-toolbar select,.book-toolbar button{min-height:36px}
.book-toolbar select{max-width:180px}
.book-status{font-size:12px;min-height:27px;padding:4px 16px}
.book-stage{height:max(555px,calc(100dvh - 218px));min-height:555px;overflow:auto;overscroll-behavior:contain;padding:12px 10px 18px;justify-items:safe center}
.book-spread{justify-self:safe center}
.book-sheet{box-shadow:inset 0 0 22px #50421a0b,0 1px 4px #203d2620}
.book-footer{padding:8px 16px;min-height:29px}
.book-error{align-self:center;justify-self:center;max-width:min(560px,calc(100% - 36px));margin:28px auto 65px;padding:clamp(22px,3vw,36px);border:1px solid #d4dfd7;border-radius:18px;background:#fff;box-shadow:0 15px 40px rgba(0,40,23,.09);text-align:center}
.book-error-icon{display:grid;place-items:center;width:46px;height:46px;margin:auto auto 10px;border-radius:50%;background:#fff4e5;color:#8b5a16;font-size:25px;font-weight:800}
.book-error h2{margin:0;font-size:clamp(19px,2vw,25px)}
.book-error p{color:#50675a;max-width:460px;margin:12px auto 20px;line-height:1.6}
.book-error-actions{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap}
.book-error-actions button,.book-error-actions a{border:1px solid #bfcec4;border-radius:9px;padding:10px 16px;font-weight:750;cursor:pointer;font-size:13px;text-decoration:none}
.book-error-actions button{color:white;background:var(--green)}
.book-error-actions a{color:var(--green);background:#fff}
.book-error small{display:block;color:#85958b;margin-top:20px}
.ihi-book-reader[data-state="error"]{grid-template-rows:auto auto auto minmax(340px,1fr) auto}
.ihi-book-reader[data-state="error"] .book-error{grid-row:4}
.ihi-book-reader[data-state="loading"] .book-spread{opacity:.3}
.ihi-book-reader[data-state="ready"] .book-spread{opacity:1}
.book-toolbar button:disabled,.book-top-actions button:disabled{opacity:.45;cursor:not-allowed}
.ihi-book-reader:is(:fullscreen,.is-fullscreen){height:100dvh;min-height:0;overflow:hidden;grid-template-rows:auto auto auto minmax(0,1fr) auto}
.ihi-book-reader:is(:fullscreen,.is-fullscreen) .book-stage{height:auto;min-height:0}
.ihi-book-reader:is(:fullscreen,.is-fullscreen) .book-error{grid-row:4;margin:15px auto}
@media(max-width:900px){
 .book-toolbar{grid-template-columns:1fr 1fr;grid-template-areas:"nav options" "interaction interaction" "search search"}
 .book-nav{justify-content:start}
 .book-interaction-controls{justify-content:center;flex-wrap:wrap}
 .book-search{grid-column:auto}
}
@media(max-width:820px){
 .ihi-book-reader{min-height:100dvh;height:auto}
 .book-toolbar{grid-template-columns:minmax(0,1fr);grid-template-areas:"nav" "options" "interaction" "search";padding:8px 10px;gap:7px}
 .book-topbar{min-height:60px}
 .book-nav{justify-content:center}
 .book-options{justify-content:stretch}
 .book-interaction-controls{justify-content:stretch}
 .book-stage{height:max(470px,calc(100dvh - 340px));min-height:470px;padding:9px 2px 14px}
 .book-error{grid-row:4}
 .ihi-book-reader:is(:fullscreen,.is-fullscreen) .book-stage{height:auto;min-height:0}
}
@media(max-width:440px){
 .book-interaction-controls button{font-size:11px;min-height:40px}
 .book-top-actions button,.book-top-actions a{min-height:36px}
 .book-options select{max-width:none}
 .book-stage{grid-template-columns:32px minmax(0,1fr) 32px}
 .book-error{margin:24px auto 40px}
}
@media(prefers-reduced-motion:reduce){.ihi-book-reader [data-book-sheet]{animation:none!important}}
.ihi-book-reader[data-state="error"] .book-footer{display:none}
.ihi-book-reader[data-state="error"]{grid-template-rows:auto auto auto minmax(350px,1fr)}
