/* KNIGO R5 reader. Pixels for controls; user typography variables apply to text only.
   Viewport-fixed scenery never depends on chapter height, font size or text width. */
html.reader-document {font-size:16px;scroll-behavior:auto;scroll-padding-top:24px}
body.reader-page{--r-font:"Times New Roman",Georgia,"Liberation Serif",serif;--r-size:22px;--r-leading:1.8;--r-text-width:960px;--r-page-width:96%;--r-gap:.75em;--r-indent:1.5em;--r-letters:0em;--r-bg:#f8f3e8;--r-panel:#fcf9f1;--r-ink:#28231c;--r-muted:#6f6250;--r-border:#d5c39f;--r-accent:#164333;--r-selected:#e6e6d3;--r-tool-bottom:0px;margin:0;isolation:isolate;font-family:"Times New Roman",Georgia,serif;background:var(--r-bg);color:var(--r-ink);font-size:16px;line-height:1.5}
.r-backdrop{position:fixed;inset:0;z-index:-1;background:#d4c4a8 url('../backgrounds/reader-room-hd.png') center top/cover no-repeat;pointer-events:none}
.reader-scene{margin:0;padding:0;min-height:100vh;background:none;overflow:visible;position:relative}
.reader-page .site-header{margin:0 auto;width:96%;max-width:2200px;height:92px;padding:0 18px;gap:14px;box-shadow:0 3px 12px #33231320}
.reader-page .brand>img{width:66px;height:66px}
.reader-page .brand strong{font-size:44px}
.reader-page .brand small{font-size:10px;letter-spacing:.02em}
.reader-page .desktop-nav{gap:18px;margin-left:18px}
.reader-page .desktop-nav>a{font-size:16px;padding:15px 0}
.reader-page .account-actions{gap:8px;margin-left:12px}
.reader-page .account-actions .button{font-size:14px;padding:10px 18px;min-height:42px}
.reader-page .mobile-menu{font-size:16px}
.r-breadcrumb{margin:0 auto;width:96%;max-width:2200px;padding:18px 14px;background:var(--r-panel);border:1px solid var(--r-border);border-top:0}
.r-breadcrumb .breadcrumbs{font-size:14px;color:var(--r-muted);gap:9px}
.r-breadcrumb .breadcrumbs a{color:var(--r-accent)}
.reader-main{margin:0;padding:0;min-width:0}
.r-layout-frame{width:var(--r-page-width);max-width:2200px;margin:16px auto 0;container-type:inline-size;container-name:readerframe;min-width:0}
.r-shell{display:grid;grid-template-columns:clamp(224px,20%,270px) minmax(0,1fr) 90px;gap:16px;align-items:start;min-width:0}
.r-shell>*{min-width:0}
.r-sidebar{position:sticky;top:12px;max-height:calc(100dvh - 24px);overflow:auto;overscroll-behavior:contain;background:var(--r-panel);border:1px solid var(--r-border);padding:22px 18px;border-radius:6px;scrollbar-width:thin;scrollbar-color:#b7a079 transparent}
.r-book{display:flex;align-items:flex-start;gap:14px;margin-bottom:24px}
.r-book>a{width:34%;flex-shrink:0}
.r-book img{width:100%;height:auto;filter:drop-shadow(1px 2px 2px #35261138)}
.r-book h2{font-size:22px;font-weight:400;line-height:1.2;margin:0 0 10px;overflow-wrap:break-word}
.r-book .text-link{font-size:16px;line-height:1.4;color:var(--r-accent)}
.r-book .text-button{font-size:15px;min-height:40px;color:var(--r-accent);margin-top:10px;gap:6px}
.r-book>div{min-width:0}
.r-toc-tabs{display:flex;align-items:stretch;gap:10px;border-bottom:1px solid var(--r-border);margin-bottom:14px}
.r-toc-tabs button{padding:10px 0;font-size:16px;min-height:44px;color:var(--r-muted);border-bottom:2px solid transparent;white-space:normal;min-width:0}
.r-toc-tabs button[aria-pressed=true]{border-color:var(--r-accent);color:var(--r-accent)}
.r-toc-search{width:100%;font-size:16px;min-height:44px;border:1px solid var(--r-border);background:var(--r-bg);color:var(--r-ink);margin:0 0 10px;padding:9px 12px}
[data-r-chapters] a{display:block;padding:12px 10px;min-height:46px;font-size:16px;line-height:1.4;border-bottom:1px solid var(--r-border);color:var(--r-ink);overflow-wrap:break-word}
[data-r-chapters] a[aria-current=page]{background:var(--r-selected);border-left:3px solid var(--r-accent);font-weight:600}
.r-about{display:flex;gap:9px;align-items:center;padding:12px 4px;min-height:44px;font-size:16px;color:var(--r-accent)}
.r-paper{background:var(--r-bg);border:1px solid var(--r-border);border-radius:6px;box-shadow:0 3px 12px #36271124;padding:44px clamp(22px,3.2cqw,60px) 0;min-width:0;min-height:640px;color:var(--r-ink)}
.r-paper.ornamented::before,.r-paper.ornamented::after{opacity:.6;width:28px;height:28px}
.r-reading-heading{text-align:center;margin:0 auto 36px;max-width:100%;font-family:"Times New Roman",Georgia,serif}
.r-reading-heading h1{font-size:clamp(32px,3.8cqw,50px);line-height:1.13;letter-spacing:-.035em;margin:16px 0 26px;overflow-wrap:break-word;color:var(--r-ink)}
.r-reading-heading h2{font-size:clamp(24px,2.5cqw,32px);line-height:1.25;margin:0;overflow-wrap:break-word;color:var(--r-ink)}
.r-byline{font-size:13px;letter-spacing:.14em;margin:0 0 14px;line-height:1.5;color:var(--r-muted)}
.r-divider{width:160px;height:34px;object-fit:contain;margin:auto;opacity:.9}
.r-text{font-family:var(--r-font);font-size:var(--r-size);line-height:var(--r-leading);letter-spacing:var(--r-letters);max-width:var(--r-text-width);width:100%;margin:0 auto;min-width:0;overflow-wrap:break-word;color:var(--r-ink);font-weight:400}
.r-text.is-prose{text-align:var(--r-alignment,left);hyphens:var(--r-hyphens,none)}
.r-text.is-prose p{font-size:inherit;line-height:inherit;margin:0 0 var(--r-gap);text-indent:var(--r-indent)}
.r-text.is-prose p:first-child{text-indent:0}
.r-text.is-verse{width:fit-content;max-width:min(100%,var(--r-text-width));text-align:left;hyphens:none;line-height:var(--r-leading)}
.r-text.is-verse .verse-line{display:block;padding-left:1.05em;text-indent:-1.05em;overflow-wrap:break-word}
.r-text.is-verse .verse-space{display:block;height:1em}
.r-provenance{margin:36px auto 24px;font-family:Arial,sans-serif;border-top:1px solid var(--r-border);padding-top:12px;color:var(--r-muted);max-width:var(--r-text-width);font-size:12px;line-height:1.6}
.r-provenance summary{cursor:pointer;min-height:32px}
.r-provenance p{margin:10px 0}
.r-chapter-footer{margin-top:20px;border-top:1px solid var(--r-border);padding:22px 0 24px;background:none}
.r-progress{display:flex;align-items:center;gap:12px;font:13px/1.4 Arial,sans-serif;color:var(--r-muted);flex-wrap:wrap;margin-bottom:18px}
.r-progress span{white-space:nowrap}
.r-progress input{flex:1;min-width:80px;padding:0;accent-color:var(--r-accent);height:32px}
.r-progress output{min-width:34px;text-align:right}
.r-chapter-nav{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.r-chapter-nav .button{min-height:44px;font:15px/1.3 "Times New Roman",Georgia,serif;padding:10px 14px;gap:7px;color:var(--r-accent);border-color:var(--r-border)}
.r-chapter-nav .button.primary{color:#fffaf0;background:var(--r-accent)}
.r-rail{align-self:stretch;min-width:0}
.r-tools{position:sticky;top:12px;display:grid;gap:6px;padding:8px;border:1px solid var(--r-border);border-radius:6px;background:var(--r-panel);max-height:calc(100dvh - 24px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
.r-tool{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;min-width:0;width:100%;min-height:56px;padding:6px 2px;border:1px solid var(--r-border);border-radius:4px;color:var(--r-muted);background:var(--r-bg);font:13px/1.2 "Times New Roman",Georgia,serif;overflow-wrap:break-word;white-space:normal}
.r-tool:hover,.r-tool[aria-pressed=true]{background:var(--r-selected);color:var(--r-accent);border-color:var(--r-accent)}
.r-tool [data-r-label]{display:block;max-width:100%;line-height:1.2;text-align:center}
.r-tool[data-r-action=bookmark][aria-pressed=true] .r-icon{fill:var(--r-accent)}
.r-icon{width:22px;height:22px;max-width:100%;display:inline-block;vertical-align:middle;flex-shrink:0}
.r-tool .r-icon{width:24px;height:24px}
.r-reader-actions{font-family:Arial,sans-serif}
/* Dialogs are outside the grid. Opening settings cannot compress the reading column. */
.r-dialog{width:min(780px,calc(100vw - 24px));max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);margin:auto;padding:0;background:var(--r-panel);border:1px solid var(--r-border);border-radius:8px;color:var(--r-ink);overflow:hidden;box-shadow:0 15px 65px #0004;font:16px/1.5 Arial,sans-serif}
.r-dialog::backdrop{background:#11170fb0}
.r-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:18px;border-bottom:1px solid var(--r-border);padding:16px 20px;margin:0}
.r-dialog-header h2{font:28px/1.15 "Times New Roman",Georgia,serif;letter-spacing:-.02em;margin:0;color:inherit;min-width:0}
.r-close{display:flex;align-items:center;justify-content:center;border:1px solid var(--r-border);border-radius:5px;width:44px;height:44px;flex-shrink:0;color:inherit}
.r-close:hover{background:var(--r-selected)}
.r-dialog-body{padding:22px;max-height:calc(100dvh - 116px);overflow:auto;overscroll-behavior:contain}
.r-settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:22px}
.r-control{min-width:0;margin:0 0 8px}
.r-control-title{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:7px}
.r-control>label{display:block;margin-bottom:9px}
.r-number-wrap{display:flex;gap:5px;align-items:center;font-size:13px;flex-shrink:0;color:var(--r-muted)}
.r-number-wrap input{width:74px;font:15px/1 Arial,sans-serif;min-height:40px;padding:7px 5px;border:1px solid var(--r-border);background:var(--r-bg);color:var(--r-ink);border-radius:4px}
.r-control-title label{font-size:14px;line-height:1.4}
.r-control select{width:100%;font:16px/1.4 Arial,sans-serif;min-height:44px;border:1px solid var(--r-border);background:var(--r-bg);color:var(--r-ink);padding:8px 10px;min-width:0}
.r-control input[type=range]{width:100%;height:32px;accent-color:var(--r-accent);padding:0;border:0;background:transparent}
.r-dialog .r-note{font:13px/1.65 Arial,sans-serif;color:var(--r-muted);margin:12px 0}
.r-checkbox{display:flex;align-items:center;gap:10px;font-size:14px;min-height:44px;color:var(--r-ink)}
.r-checkbox input{width:18px;height:18px;accent-color:var(--r-accent)}
.r-advanced{border-block:1px solid var(--r-border);padding:14px 0;margin-top:18px}
.r-advanced summary{font-size:15px;cursor:pointer;min-height:32px;padding:4px 0}
.r-advanced[open] .r-settings-grid{margin-top:18px}
.r-dialog-actions,.r-audio-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;margin-top:22px}
.r-dialog .button{font:15px/1.4 Arial,sans-serif;min-height:44px;padding:10px 14px;border-color:var(--r-border);color:var(--r-accent)}
.r-dialog .button.primary{background:var(--r-accent);color:#fff9eb}
.r-theme-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:20px}
.r-theme{display:flex;align-items:center;gap:10px;border:1px solid var(--r-border);border-radius:6px;background:var(--r-bg);color:var(--r-ink);min-height:62px;padding:12px;font:14px/1.35 Arial,sans-serif;min-width:0;text-align:left}
.r-theme[aria-pressed=true]{outline:2px solid var(--r-accent);outline-offset:1px;background:var(--r-selected)}
.r-swatch{width:27px;height:27px;border:1px solid #9999;border-radius:50%;flex-shrink:0}
.r-bookmark{display:flex;align-items:center;gap:10px;padding:12px 0;border-bottom:1px solid var(--r-border);font-size:15px}
.r-bookmark>a{color:var(--r-accent);flex:1;min-width:0;overflow-wrap:break-word}
.r-bookmark small{display:block;font-size:12px;line-height:1.5;color:var(--r-muted)}
.r-bookmark button{width:40px;height:40px;border:1px solid var(--r-border);border-radius:4px;flex-shrink:0}
.r-toc-empty{font-size:14px;color:var(--r-muted);padding:12px 0}
#r-share-link{width:100%;resize:vertical;min-height:94px;max-height:220px;font:15px/1.65 Arial,sans-serif;background:var(--r-bg);color:var(--r-ink);border:1px solid var(--r-border);padding:12px;overflow-wrap:anywhere}
.r-focus-exit{position:fixed;z-index:45;top:10px;right:12px;display:flex;align-items:center;gap:8px;max-width:calc(100vw - 24px);padding:9px 14px;min-height:44px;border:1px solid var(--r-border);border-radius:5px;background:var(--r-panel);color:var(--r-ink);font:14px/1.3 Arial,sans-serif;box-shadow:0 2px 12px #0003}
.r-focus-exit kbd{font:12px Arial,sans-serif;border:1px solid var(--r-border);border-radius:3px;padding:2px 4px;color:var(--r-muted)}
.r-focused .reader-scene>.site-header,.r-focused .mobile-menu,.r-focused .r-breadcrumb,.r-focused .r-sidebar,.r-focused .site-footer,.r-focused .motto{display:none!important}
.r-focused .r-backdrop{visibility:hidden}
.r-focused .r-layout-frame{width:96%;max-width:1700px;margin-top:66px}
.r-focused .r-shell{grid-template-columns:minmax(0,1fr) 90px}
.r-focused .r-tools{top:66px;max-height:calc(100dvh - 78px)}
.r-mini-player{position:fixed;z-index:40;bottom:18px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:10px;max-width:calc(100vw - 32px);padding:10px 14px;border:1px solid var(--r-border);border-radius:7px;background:var(--r-panel);color:var(--r-ink);box-shadow:0 3px 18px #0003;font:13px/1.4 Arial,sans-serif}
.r-mini-player>span{max-width:220px}
.r-mini-player button{min-height:40px;padding:8px 12px;color:var(--r-accent);border:1px solid var(--r-border);border-radius:4px;white-space:nowrap}
.r-speaking{background:var(--r-selected);outline:1px solid var(--r-border);outline-offset:3px;border-radius:2px}
.r-speech-status{font:14px/1.5 Arial,sans-serif;color:var(--r-accent);padding:12px;border-left:3px solid var(--r-accent);background:var(--r-selected)}
.reader-page .motto{padding:22px 0;background:var(--r-panel);width:96%;max-width:2200px;margin:16px auto 0}
.reader-page .motto>span{font-size:10px}
.reader-page .site-footer{margin:0;width:100%;font-size:14px;padding:16px 3% 12px}
.reader-page .site-footer .brand strong{font-size:30px}
.reader-page .site-footer .brand small{font-size:8px}
.reader-page .site-footer .brand img{width:48px;height:48px}
.reader-page .footer-bottom{font-size:12px;line-height:1.5}
/* Container width, not font metrics, determines whether a sidebar fits. */
@container readerframe (max-width:1080px){
 .r-shell{grid-template-columns:minmax(0,1fr) 88px;gap:12px}
 .r-sidebar{display:none}
 .r-paper{padding-inline:clamp(22px,4cqw,44px)}
}
@media(min-width:1920px){
 .reader-page .site-header{height:100px;padding-inline:26px}
 .reader-page .desktop-nav>a{font-size:18px}
 .r-shell{grid-template-columns:270px minmax(0,1fr) 96px;gap:20px}
 .r-tool{font-size:14px;min-height:60px}
 .r-reading-heading h1{font-size:50px}
 .r-reading-heading h2{font-size:32px}
}
@media(max-width:1180px){
 .reader-page .desktop-nav,.reader-page .account-actions{display:none}
 .reader-page .site-header{justify-content:space-between;height:80px}
 .reader-page .menu-toggle{display:flex;min-width:44px;min-height:44px;border:1px solid var(--line)}
 .reader-page .mobile-menu:not([hidden]){display:grid;position:absolute;top:79px;left:2%;width:96%;padding:12px 20px;grid-template-columns:1fr 1fr;gap:4px 18px;background:var(--paper);border:1px solid var(--gold);z-index:40}
 .reader-page .mobile-menu a{font-size:16px;min-height:44px;padding:12px 4px}
}
@media(max-width:760px){
 body.reader-page{--r-tool-bottom:120px;padding-bottom:calc(var(--r-tool-bottom) + env(safe-area-inset-bottom))}
 .reader-page .site-header{width:100%;height:76px;margin:0;padding-inline:12px}
 .reader-page .brand strong{font-size:36px}
 .reader-page .brand>img{width:54px;height:54px}
 .reader-page .brand small{font-size:8px}
 .r-backdrop{display:none}
 .r-breadcrumb{width:100%;padding:12px 16px;border-inline:0;background:var(--r-panel)}
 .r-breadcrumb .breadcrumbs{font-size:12px}
 .r-layout-frame,.r-focused .r-layout-frame{width:100%;max-width:none;margin:0}
 .r-shell,.r-focused .r-shell{display:block}
 .r-sidebar{display:none}
 .r-paper{border-radius:0;border-inline:0;padding:30px 20px 0;box-shadow:none;min-height:60vh}
 .r-reading-heading{margin-bottom:30px}
 .r-reading-heading h1{font-size:34px;margin-bottom:22px}
 .r-reading-heading h2{font-size:24px}
 .r-byline{font-size:12px;letter-spacing:.08em}
 .r-text{max-width:100%}
 .r-rail{position:fixed;z-index:30;bottom:0;left:0;right:0;padding:6px 8px calc(6px + env(safe-area-inset-bottom));background:var(--r-panel);border-top:1px solid var(--r-border);box-shadow:0 -2px 12px #0001}
 .r-tools,.r-focused .r-tools{position:static;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;max-height:none;padding:0;border:0;overflow:visible;border-radius:0;box-shadow:none}
 .r-tool{min-height:49px;font-size:12px;padding:5px 2px;gap:3px}
 .r-tool .r-icon{width:20px;height:20px}
 .r-chapter-nav{gap:6px}
 .r-chapter-nav .button{font-size:14px;padding:9px 11px}
 .r-chapter-nav .button .r-icon{width:18px;height:18px}
 .r-progress{font-size:12px;gap:8px}
 .r-dialog{width:calc(100vw - 16px);max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px)}
 .r-dialog-header{padding:12px 14px;gap:12px}
 .r-dialog-header h2{font-size:25px}
 .r-dialog-body{padding:18px 14px;max-height:calc(100dvh - 97px)}
 .r-settings-grid{grid-template-columns:1fr;gap:16px}
 .r-theme-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 .r-theme{min-height:59px;font-size:13px;padding:10px;gap:9px}
 .r-dialog-actions{justify-content:stretch}
 .r-dialog-actions .button{flex:1;font-size:14px}
 .r-audio-actions{display:grid;grid-template-columns:1fr 1fr}
 .r-audio-actions .button{font-size:14px;padding-inline:9px}
 .r-focused .r-paper{padding-top:76px}
 .r-focus-exit{top:8px;font-size:12px;padding:8px 10px}
 .r-focus-exit kbd{display:none}
 .r-mini-player{bottom:calc(var(--r-tool-bottom) + 8px + env(safe-area-inset-bottom));gap:6px;padding:8px;font-size:11px;max-width:calc(100vw - 16px)}
 .r-mini-player button{font-size:12px;padding:7px 8px}
 .r-mini-player>span{max-width:112px}
 .reader-page .motto{width:100%;margin:0;padding:22px 8px}
 .reader-page .motto>span{font-size:8px;letter-spacing:.1em}
 .reader-page .site-footer{padding:18px 4%}
 .reader-page .site-footer .brand strong{font-size:27px}
 .reader-page .footer-bottom{font-size:11px}
 .reader-page .toast{bottom:calc(var(--r-tool-bottom) + 18px + env(safe-area-inset-bottom));z-index:100;font-size:14px}
}
@media(max-width:760px) and (max-height:500px){
 body.reader-page{--r-tool-bottom:62px}
 .r-tools,.r-focused .r-tools{grid-template-columns:repeat(8,minmax(0,1fr))}
 .r-tool{font-size:10px;min-height:46px}
 .r-mini-player>span{max-width:none}
}
@media(prefers-reduced-motion:reduce){.reader-document{scroll-behavior:auto}.reader-page *{transition:none!important}}
@media print{
 html.reader-document,body.reader-page{font-size:12pt;background:#fff!important;color:#000!important;padding:0!important}
 .r-backdrop,.reader-page .site-header,.reader-page .mobile-menu,.reader-page .site-footer,.r-breadcrumb,.r-rail,.r-sidebar,.r-dialog,.r-focus-exit,.r-mini-player,.r-provenance,.r-chapter-footer,.reader-page .motto,.toast,.skip-link,.noscript-note{display:none!important}
 .reader-scene,.reader-main,.r-layout-frame,.r-shell{display:block!important;background:none!important;width:100%!important;max-width:none!important;margin:0!important;container-type:normal}
 .r-paper{min-height:0!important;border:0!important;padding:0!important;box-shadow:none!important;background:#fff!important;border-radius:0}
 .r-paper::before,.r-paper::after{display:none}
 .r-text{font-size:12pt!important;line-height:1.65!important;color:#000!important;max-width:none!important}
 .r-text.is-verse{max-width:100%!important;width:fit-content}
 .r-text p,.verse-line{orphans:3;widows:3}
 .r-reading-heading h1{font-size:26pt;color:#000}
 .r-reading-heading h2{font-size:18pt;color:#000}
 .r-speaking{background:none;outline:0}
}
@media(min-width:761px) and (max-height:760px){
 .r-tools,.r-sidebar{max-height:calc(100dvh - 180px)}
 .r-tool{min-height:50px;gap:3px;padding-block:5px}
 .r-tool .r-icon{width:21px;height:21px}
 .r-focused .r-tools{max-height:calc(100dvh - 78px)}
}
/* Foreground of a primary action must remain legible in both light and dark themes. */
.r-dialog .button.primary,.r-chapter-nav .button.primary{color:var(--r-on-accent,#fffaf0)}
.reader-page input::placeholder,.reader-page textarea::placeholder{color:var(--r-muted);opacity:1}
.r-quick-size{display:flex;align-items:center;gap:12px;margin:0 0 22px;padding-bottom:18px;border-bottom:1px solid var(--r-border)}
.r-quick-size>span{margin-right:auto;font-size:15px}
.r-quick-size button{border:1px solid var(--r-border);background:var(--r-bg);border-radius:4px;color:var(--r-ink);width:44px;height:44px;font:18px Arial,sans-serif}
.r-quick-size output{font:15px Arial,sans-serif;min-width:48px;text-align:center;color:var(--r-accent)}
body.reader-page[data-reader-theme=night]{color-scheme:dark}
/* Theme swaps must change foreground/background atomically, not through low-contrast fades. */
.reader-page .button,.reader-page .r-tool,.reader-page .r-theme{transition:none}

