/* Persistent app navigation. Authentication/confirmation sheets keep their guards. */
:root{--app-bottom-height:calc(84px + env(safe-area-inset-bottom))}
.site-rail,.site-bottom{box-sizing:border-box;font-family:'Zen Kaku Gothic New',sans-serif;color:#596370;background:white}
.site-rail a,.site-bottom a{text-decoration:none;color:inherit;box-sizing:border-box;min-height:44px}
.site-rail{position:fixed;inset:0 auto 0 0;width:224px;padding:24px;display:flex;flex-direction:column;z-index:60;overflow:auto}
.site-brand{display:flex;align-items:center;height:56px;flex:none;font:400 24px/1.4 'Marcellus',serif;letter-spacing:.08em;color:#253449!important}
.site-rail .site-write{display:flex;justify-content:center;align-items:center;background:#253449;color:white;border-radius:8px;margin:32px 0 40px;font-size:14px;flex:none}
.site-rail nav{display:flex;flex-direction:column;gap:8px;height:auto}
.site-rail nav a{display:flex;align-items:center;gap:12px;height:48px;padding:0 16px;font-size:14px;border-radius:8px}
.site-rail nav a>span{display:block;width:auto;font-size:14px;line-height:1.5;min-width:0}
.site-rail img,.site-bottom img{width:22px;height:22px;object-fit:contain;flex:none}
.site-rail [aria-current=page]{background:#e9edf1;color:#253449;font-weight:600}
.site-rail .site-origin{display:flex;align-items:center;padding:8px;margin:12px 0;font-size:13px;text-decoration:underline;text-underline-offset:5px;border-radius:6px}
.site-rail .site-profile{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:auto;border-top:1px solid #e9edf1;padding-top:16px;font-size:14px;min-height:72px}
.site-profile>span:first-child{overflow-wrap:anywhere;min-width:0}.site-bottom{display:none}
.site-rail a:focus-visible,.site-bottom a:focus-visible{outline:3px solid #b97b53;outline-offset:2px}
@media(min-width:1100px){
 body.has-site-navigation{padding-left:224px}
 .has-site-navigation .demo-sidebar{display:none}.has-site-navigation .demo-main{margin-left:0}
 #modal::backdrop{left:224px}
 body.has-site-navigation dialog,body:not(.signed-out):has(>.shell) dialog:not(#modal){left:224px;right:0;max-width:calc(100vw - 264px)}
 body.has-site-navigation dialog::backdrop,body:not(.signed-out):has(>.shell) dialog:not(#modal)::backdrop{left:224px}
 .reader-underlay{left:224px}
}
@media(max-width:1099px){
 .site-rail{display:none}.has-site-navigation .demo-sidebar{display:none}.has-site-navigation .demo-main{margin-left:0}
 body.has-site-navigation{padding-bottom:calc(var(--app-bottom-height) + 20px)}
 .site-bottom{display:flex;position:fixed;inset:auto 0 0;height:var(--app-bottom-height);padding:8px 0 calc(20px + env(safe-area-inset-bottom));z-index:80;border-top:1px solid #e9edf1;gap:0;align-items:flex-start}
 .site-bottom a{display:flex;flex:1;min-width:0;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-size:12px;line-height:1.4;text-align:center;padding:4px 2px;height:56px}
 .site-bottom a span{width:auto;white-space:normal;font-size:12px}.site-bottom a[href$="#questions"]{background:#e9edf1;border-radius:12px}
 html body:not(.signed-out):not(.legal-pending):not(.profile-setup-page) .mobile-nav{display:flex!important}
 html body:has(dialog[open]) .sidebar{visibility:visible}
 body.writing-page #main{padding-bottom:calc(var(--app-bottom-height) + 24px)}
 body.writing-page .writer-toolbar #save-story{position:static!important;left:auto;right:auto;bottom:auto;width:auto!important;min-width:90px!important;max-width:45%!important;margin-left:auto;font-size:14px;padding:10px 12px}
 body.writing-page .writer-toolbar:after{display:none}
 body.writing-page .design-editor-title{font-size:16px}
 #modal::backdrop{bottom:var(--app-bottom-height)}
 body.has-site-navigation dialog,body:not(.signed-out):has(>.shell) dialog:not(#modal){bottom:var(--app-bottom-height);max-height:calc(100dvh - var(--app-bottom-height) - 16px)}
 body.has-site-navigation dialog::backdrop,body:not(.signed-out):has(>.shell) dialog:not(#modal)::backdrop{bottom:var(--app-bottom-height)}
 .reader-underlay{bottom:var(--app-bottom-height)}
 .writing-page #toast{bottom:calc(var(--app-bottom-height) + 12px)}
}
@media print{.site-rail,.site-bottom,.persistent-dialog-nav{display:none!important}body.has-site-navigation{padding:0!important}}
/* Replace legacy full-viewport/translated sheets: fixed navigation must stay in
   viewport coordinates, and scrollable content must end above the mobile bar. */
@media(min-width:1100px){
 html body:not(.signed-out) #modal[open]{position:fixed!important;inset:24px 24px 24px 248px!important;transform:none!important;margin:auto!important;width:720px!important;max-width:calc(100vw - 272px)!important;height:fit-content!important;max-height:calc(100dvh - 48px)!important;min-height:0!important}
 html body:not(.signed-out) #modal[open]:is(.reading-modal,.revision-modal,.invite-accept-modal),html body:not(.signed-out) #modal[open]:has(.unavailable-record){inset:0 0 0 224px!important;width:calc(100vw - 224px)!important;max-width:calc(100vw - 224px)!important;height:100dvh!important;max-height:100dvh!important;margin:0!important}
}
@media(max-width:1099px){
 html body:not(.signed-out) #modal[open]{position:fixed!important;inset:auto 0 var(--app-bottom-height)!important;transform:none!important;margin:0!important;width:100%!important;max-width:100%!important;min-height:0!important;height:auto!important;max-height:calc(100dvh - var(--app-bottom-height) - 16px)!important}
 html body:not(.signed-out) #modal[open]:is(.reading-modal,.revision-modal,.invite-accept-modal),html body:not(.signed-out) #modal[open]:has(.unavailable-record){top:0!important;height:calc(100dvh - var(--app-bottom-height))!important;max-height:calc(100dvh - var(--app-bottom-height))!important}
 body.has-site-navigation dialog,body:not(.signed-out):has(>.shell) dialog:not(#modal){bottom:var(--app-bottom-height)!important;max-height:calc(100dvh - var(--app-bottom-height) - 16px)!important;overflow:auto}
}

/* Match the application identity on book, origin and legal pages. */
.site-rail .site-brand{display:flex;align-items:center;gap:6px}
.site-brand .brand-image{display:block;position:relative;width:36px;height:40px;overflow:hidden;flex:none}
.site-brand .brand-image img{position:absolute;width:60px;height:63px;left:-12px;top:-11px;max-width:none;object-fit:fill}
.site-brand .brand-word{font:24px/1.5 Marcellus,serif;letter-spacing:.02em}
.site-bottom .site-plus{font:28px/24px 'Zen Kaku Gothic New',sans-serif;width:24px;height:24px;display:block}
