/* Shared floating tools: inherit each page's existing palette. */
:root{--page-tools-right:max(20px,env(safe-area-inset-right));--page-tools-bottom:calc(24px + env(safe-area-inset-bottom));--page-tools-size:46px;--page-tools-gap:8px}
#site-page-tools{position:fixed;right:var(--page-tools-right);bottom:var(--page-tools-bottom);z-index:90;display:flex;flex-direction:column;gap:var(--page-tools-gap)}
html:has(.music-launcher) #site-page-tools{gap:calc(var(--page-tools-size) + 2 * var(--page-tools-gap))}
#site-page-tools button{appearance:none;display:grid;place-items:center;width:var(--page-tools-size);height:var(--page-tools-size);padding:0;border:1px solid var(--line,#d5d8cf);border-radius:50%;background:var(--paper,#f7f6f1);color:var(--ink,#1b221e);box-shadow:0 3px 16px #00000012;cursor:pointer;transition:transform .18s,box-shadow .18s}
#site-page-tools button:hover{transform:translateY(-2px);box-shadow:0 5px 20px #0002}#site-page-tools button:focus-visible,#site-page-qr button:focus-visible{outline:2px solid var(--accent,#365d83);outline-offset:4px}
#site-page-tools svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
html.page-tools-ready #floating-top{display:none!important}
#site-page-qr{box-sizing:border-box;position:fixed;inset:0;margin:auto;padding:32px;width:min(400px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;border:1px solid var(--line,#d5d8cf);border-radius:16px;background:var(--paper,#f7f6f1);color:var(--ink,#1b221e);box-shadow:0 24px 90px #0004;text-align:center;font:inherit}
#site-page-qr::backdrop{background:#0007;backdrop-filter:blur(6px)}#site-page-qr h2{font:600 24px/1.4 inherit;font-family:inherit;font-size:24px;line-height:1.4;margin:14px 0 8px}#site-page-qr p{font-size:14px;line-height:1.7;margin:8px 0;color:var(--muted,#61685e)}
#site-page-qr .page-qr-close{position:absolute;right:8px;top:8px;width:40px;height:40px;border:0;background:transparent;color:inherit;font-size:26px;cursor:pointer}#site-page-qr img{display:block;width:240px;max-width:100%;height:auto;margin:20px auto 12px;border-radius:4px;background:white}#site-page-qr .page-qr-url{display:block;overflow-wrap:anywhere;font-size:12px;line-height:1.6;color:var(--muted,#61685e)}
@media(max-width:600px){:root{--page-tools-right:max(12px,env(safe-area-inset-right));--page-tools-bottom:calc(18px + env(safe-area-inset-bottom));--page-tools-size:44px}#site-page-qr{padding:28px 22px}}
@media(prefers-reduced-motion:reduce){#site-page-tools button{transition:none}}
@media print{#site-page-tools,#site-page-qr{display:none!important}}

#site-page-qr img[hidden]{display:none}

/* A single mobile tool rail replaces the three-button tower beside the text. */
#site-page-tools [hidden]{display:none!important}
#site-page-tools .page-tool-reader,#site-reading-tools{display:none}
@media(max-width:760px){
 html.page-tools-ready body:not(.music-standalone){padding-bottom:calc(64px + env(safe-area-inset-bottom))}
 html.page-tools-ready #site-page-tools{left:0;right:0;bottom:0;min-height:58px;padding:6px max(16px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));box-sizing:border-box;flex-direction:row;align-items:center;justify-content:space-between;gap:12px;background:var(--paper,#f7f6f1);border-top:1px solid var(--line,#d5d8cf)}
 html.page-tools-ready #site-page-tools>.page-tool-qr,html.page-tools-ready .music-launcher{display:none!important}
 #site-page-tools .page-tool-reader{display:flex;align-items:center;gap:8px;width:auto;min-height:44px;padding:0 12px;border-radius:6px;box-shadow:none;font:inherit;font-size:14px}
 #site-page-tools .page-tool-top{width:44px;height:44px;box-shadow:none}
 #site-page-tools #site-reading-tools:not([hidden]){display:grid;position:absolute;left:16px;bottom:calc(100% + 8px);width:min(320px,calc(100vw - 32px));padding:8px;border:1px solid var(--line,#d5d8cf);border-radius:10px;box-sizing:border-box;background:var(--paper,#f7f6f1);box-shadow:0 8px 30px #0002}
 #site-page-tools .reading-tool-action{display:block;text-align:start;border:0;border-radius:4px;box-shadow:none;width:100%;height:auto;min-height:48px;padding:12px;font:inherit;font-size:15px;line-height:1.5}
 #site-page-tools button:hover{transform:none}
 html.page-tools-ready body:not(.music-standalone) .music-panel{left:auto;right:12px;bottom:calc(74px + env(safe-area-inset-bottom));width:min(420px,calc(100vw - 24px));max-height:calc(100dvh - 100px - env(safe-area-inset-bottom))}
 /* Existing full-width chapter/app navigation occupies its own rail. */
 html.page-tools-ready .book-chapter-page #site-page-tools{bottom:calc(66px + env(safe-area-inset-bottom));padding-bottom:6px}
 html.page-tools-ready .mobile-reading #site-page-tools{bottom:calc(74px + env(safe-area-inset-bottom));padding-bottom:6px}
 html.page-tools-ready .book-chapter-page .music-panel{bottom:calc(140px + env(safe-area-inset-bottom));max-height:calc(100dvh - 170px - env(safe-area-inset-bottom))}
 html.page-tools-ready .mobile-reading .music-panel{bottom:calc(148px + env(safe-area-inset-bottom));max-height:calc(100dvh - 178px - env(safe-area-inset-bottom))}
 html.page-tools-ready .mobile-reading #main{padding-right:20px}
}
