/* Viewport shell only. Original chapter typography/artwork/templates remain unchanged. */
html.chapter-shell-root,html:has(body.chapter-shell){height:100%;overflow:hidden;overscroll-behavior:none;scroll-behavior:auto}
body.chapter-shell{position:fixed!important;inset:0!important;width:100%!important;height:100svh;height:100dvh;margin:0;overflow:hidden!important;overscroll-behavior:none;--screen-header:calc(100px + env(safe-area-inset-top));--screen-controls:calc(58px + env(safe-area-inset-bottom))}
.chapter-shell>header{position:absolute;inset:0 0 auto;height:var(--screen-header);z-index:70}
.chapter-shell #main{position:absolute;inset:var(--screen-header) 0 var(--screen-controls);width:100%;margin:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scroll-behavior:auto;isolation:isolate;scroll-padding-bottom:24px;scrollbar-gutter:stable}
.chapter-shell #main>footer{position:relative;margin:0}
#screen-controls{position:absolute;inset:auto 0 0;height:var(--screen-controls);padding:7px max(4%,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(4%,env(safe-area-inset-left));display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--black);color:var(--paper);border-top:3px solid var(--red);z-index:45;font:900 11px/1.3 monospace}
#screen-controls button{min-height:40px;padding:7px 14px;background:var(--paper);color:var(--black);border:2px solid var(--paper);font:900 12px sans-serif;clip-path:polygon(4% 0,100% 0,96% 100%,0 100%)}
#screen-label{white-space:nowrap}
.chapter-shell #chapter-hud{bottom:calc(var(--screen-controls) + 12px)}
.chapter-shell.file-active #main,.chapter-shell.archive-open #main{overflow-y:hidden}
html.intro-pending .chapter-shell #screen-controls{visibility:hidden;pointer-events:none}
.chapter-shell.impact-routing #screen-controls{pointer-events:none}
@media(max-width:600px){body.chapter-shell{--screen-header:calc(80px + env(safe-area-inset-top));--screen-controls:calc(58px + env(safe-area-inset-bottom))}#screen-controls{gap:6px;padding-left:10px;padding-right:10px}#screen-controls button{padding:7px 10px;font-size:11px}#screen-label{font-size:9px}}
.chapter-shell #main:focus-visible{outline:2px solid var(--red);outline-offset:-2px}
