/* Bottom navigation replaces the primary sidebar; theme tokens remain shared. */
:root{--bottom-nav-height:64px;--bottom-nav-padding:5px;--bottom-nav-bottom:18px}
.app-shell{display:block;min-height:100svh}
.app-shell>.main-column{margin-left:0;width:100%;min-width:0}
.app-shell .main-content{max-width:2000px;min-height:calc(100svh - 90px);padding:24px 24px calc(var(--bottom-nav-height) + var(--bottom-nav-bottom) + 20px + env(safe-area-inset-bottom));margin-inline:auto}
.app-topbar{max-width:2000px;margin-inline:auto;padding:24px 24px 0;display:flex;align-items:center;min-height:58px}
.app-topbar .brand-label{margin:0;padding:0}
.app-shell .page-menu,.app-shell .mobile-close{display:none!important}
.bottom-nav-position{position:fixed;inset-inline:0;bottom:calc(var(--bottom-nav-bottom) + env(safe-area-inset-bottom));display:flex;justify-content:center;padding-inline:16px;pointer-events:none;z-index:30}
.bottom-nav-dock{display:flex;align-items:center;gap:10px;width:min(100%,420px);pointer-events:auto}
.bottom-nav-dock .bottom-nav{flex:1;min-width:0;width:auto}
.bottom-nav-sync{height:var(--bottom-nav-height);flex:0 0 var(--bottom-nav-height);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;border-radius:50%;border:1px solid var(--color-rule);background:linear-gradient(160deg,var(--color-sidebar),var(--color-paper));color:var(--color-accent);box-shadow:inset 0 1px 1px color-mix(in srgb,var(--color-ink) 12%,transparent),0 8px 30px var(--color-book-shadow);cursor:pointer;touch-action:manipulation;transition:transform 160ms ease,color 180ms ease}
.bottom-nav-sync:active{transform:scale(.96)}
.bottom-nav-sync:disabled{opacity:.65;cursor:wait}
.bottom-nav-sync .bottom-nav-label{color:inherit}
.bottom-nav{width:min(100%,340px);height:var(--bottom-nav-height);padding:var(--bottom-nav-padding);position:relative;isolation:isolate;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));border-radius:999px;pointer-events:auto;border:1px solid var(--color-rule);background:linear-gradient(160deg,var(--color-sidebar),var(--color-paper));color:var(--color-ink);box-shadow:inset 0 1px 1px color-mix(in srgb,var(--color-ink) 12%,transparent),0 8px 30px var(--color-book-shadow);}
.bottom-nav-selection{position:absolute;top:var(--bottom-nav-padding);bottom:var(--bottom-nav-padding);left:var(--bottom-nav-padding);width:var(--selection-width,0px);transform:translate3d(var(--selection-x,0px),0,0);border-radius:999px;background:var(--color-selected,var(--color-accent-soft));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--color-accent) 18%,transparent);z-index:-1;pointer-events:none;will-change:transform}
.bottom-nav{touch-action:pan-y}
.bottom-nav-selection::after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(180deg,color-mix(in srgb,var(--color-accent) 16%,transparent),transparent);opacity:0;transition:opacity 110ms ease;pointer-events:none}
.bottom-nav[data-pressed=true] .bottom-nav-selection::after{opacity:1}
.bottom-nav[data-scrubbing=true] .bottom-nav-button{color:var(--color-body)}
.bottom-nav[data-scrubbing=true] .bottom-nav-button .solid{opacity:0;transform:scale(.88)}
.bottom-nav[data-scrubbing=true] .bottom-nav-button .outline{opacity:1;transform:scale(1)}
.bottom-nav[data-scrubbing=true] .bottom-nav-button[data-preview=true]{color:var(--color-selected-ink,var(--color-accent))}
.bottom-nav[data-scrubbing=true] .bottom-nav-button[data-preview=true] .solid{opacity:1;transform:scale(1)}
.bottom-nav[data-scrubbing=true] .bottom-nav-button[data-preview=true] .outline{opacity:0;transform:scale(.88)}
.bottom-nav-button{border:0;background:none;padding:5px 0;min-width:0;border-radius:999px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;color:var(--color-body);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:color 180ms ease,transform 160ms cubic-bezier(.22,1,.36,1)}
.bottom-nav-button[aria-current=page]{color:var(--color-selected-ink,var(--color-accent))}
.bottom-nav-button:active{transform:scale(.96)}
.bottom-nav-icon{width:23px;height:23px;position:relative;display:block;pointer-events:none}
.bottom-nav-icon svg{position:absolute;inset:0;display:block;width:100%;height:100%;transition:opacity 190ms ease,transform 260ms cubic-bezier(.22,1,.36,1)}
.bottom-nav-icon .solid{opacity:0;transform:scale(.88)}
.bottom-nav-button[aria-current=page] .solid{opacity:1;transform:scale(1)}
.bottom-nav-button[aria-current=page] .outline{opacity:0;transform:scale(.88)}
.bottom-nav-label{font-family:var(--font-body);font-size:9px;line-height:1.15;white-space:nowrap;color:var(--color-muted);transition:color 220ms ease}
.bottom-nav-button[aria-current=page] .bottom-nav-label{color:inherit}
@media(hover:hover){}
.bottom-nav-button:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px}
.app-shell .account-sync-toolbar{width:100%;max-width:620px;margin:0 auto 20px;display:flex;align-items:center;justify-content:space-between;gap:16px;font-size:12px;color:var(--color-muted)}
.account-sync-toolbar [role=status]{display:flex;flex-wrap:wrap;column-gap:12px;row-gap:4px;min-width:0}
.account-sync-toolbar .button{flex-shrink:0;display:inline-flex;align-items:center;gap:8px}
.app-shell:has(.account-page) .content-page-heading,.app-shell:has(.misc-details) .content-page-heading{width:100%;max-width:620px;margin-inline:auto}
.app-shell .account-page,.app-shell .misc-details{width:100%;max-width:620px;margin-inline:auto}
.app-shell .policy-page{width:100%;max-width:760px;margin-inline:auto}
.app-shell .toast{bottom:calc(var(--bottom-nav-height) + var(--bottom-nav-bottom) + 16px + env(safe-area-inset-bottom))}
.library-view .book-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(min-width:700px){.library-view .book-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(min-width:960px){.library-view .book-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(min-width:768px){:root{--bottom-nav-height:74px;--bottom-nav-padding:6px;--bottom-nav-bottom:26px}.app-shell .main-content{padding-inline:40px;padding-top:26px}.app-topbar{padding:26px 40px 0;min-height:66px}.bottom-nav{width:420px}.bottom-nav-icon{width:26px;height:26px}.bottom-nav-label{font-size:10px}.bottom-nav-button{gap:5px}}
@media(min-width:768px){.bottom-nav-dock{width:506px;gap:12px}.bottom-nav-sync{gap:5px}.bottom-nav-sync svg{width:26px;height:26px}}
@media(max-width:359px){.bottom-nav-label{font-size:8px}.bottom-nav-icon{width:21px;height:21px}}

/* The reader keeps its controls on a clear row above the shared Sync position. */
.reader-sync-position{position:fixed;inset-inline:0;bottom:calc(var(--bottom-nav-bottom) + env(safe-area-inset-bottom));display:flex;justify-content:center;padding-inline:16px;pointer-events:none;z-index:30}
.reader-sync-dock{display:flex;justify-content:flex-end;width:min(100%,420px);pointer-events:none}
.reader-sync-dock .bottom-nav-sync{pointer-events:auto}
.reader-floating-sync .reader-controls,.reader-floating-sync .reader-bottom-left,.reader-floating-sync .reader-bottom-right{bottom:calc(var(--bottom-nav-bottom) + var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom))}
.reader.reader-floating-sync .reading-main{height:calc(100svh - var(--bottom-nav-bottom) - var(--bottom-nav-height) - 56px - env(safe-area-inset-bottom))}
.reader.reader-floating-sync:has(.auto-type-speed) .reading-main{height:calc(100svh - var(--bottom-nav-bottom) - var(--bottom-nav-height) - 108px - env(safe-area-inset-bottom))}
body:has(.reader-floating-sync) .toast{bottom:calc(var(--bottom-nav-bottom) + var(--bottom-nav-height) + 72px + env(safe-area-inset-bottom))}
@media(min-width:768px){.reader-sync-dock{width:506px}.reader-sync-dock .bottom-nav-sync{gap:5px}.reader-sync-dock .bottom-nav-sync svg{width:26px;height:26px}}

/* Reader actions occupy the same dock slots as Library navigation and Sync. */
.reader-action-pill{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}
.reader-action-pill .bottom-nav-button{margin:0;min-height:0;height:100%;font-family:var(--font-body)}
.reader-action-pill .bottom-nav-button>svg{width:23px;height:23px;flex-shrink:0}
.reader-action-pill .bottom-nav-button>span{font-size:10px;line-height:1.15;white-space:nowrap}
.reader-action-pill .reader-primary[aria-pressed=true]{background:var(--color-selected,var(--color-accent-soft));color:var(--color-selected-ink,var(--color-accent));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--color-accent) 18%,transparent)}
.reader-action-pill .reader-primary:disabled{opacity:.5;cursor:default}
.reader-bottom-dock .reader-nav{justify-content:flex-end}
.reader-bottom-dock .reader-nav-actions{margin-inline-start:auto}
@media(min-width:768px){.reader-action-pill .bottom-nav-button>svg{width:26px;height:26px}}
@media(min-width:1400px){.reader-bottom-dock .reader-bottom-left,.reader-bottom-dock .reader-bottom-right{bottom:calc(var(--bottom-nav-bottom) + env(safe-area-inset-bottom));min-height:var(--bottom-nav-height);display:flex;align-items:center}}

/* Keep the shared Sync anchor while sizing the reader actions to two controls. */
.reader-bottom-position .bottom-nav-dock{justify-content:flex-end;pointer-events:none}
.reader-bottom-position .reader-action-pill{flex:0 1 180px;width:180px;pointer-events:auto}
.reader-bottom-position .bottom-nav-sync{pointer-events:auto}
@media(min-width:768px){.reader-bottom-position .reader-action-pill{flex-basis:200px;width:200px}}

@media(hover:hover){
 
 
}

/* Quiet, flat surfaces avoid a bright gradient edge around the tray. */
.bottom-nav,.bottom-nav-sync{background:color-mix(in srgb,var(--color-paper) 86%,var(--color-surface));border-color:color-mix(in srgb,var(--color-rule) 70%,transparent);box-shadow:0 5px 18px color-mix(in srgb,var(--color-book-shadow) 40%,transparent)}
.bottom-nav-selection{box-shadow:none}
.bottom-nav-selection::after{background:var(--color-accent-soft)}
.bottom-nav[data-can-back=true]{grid-template-columns:repeat(6,minmax(0,1fr))}
.bottom-nav-back{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:0;border:0;border-radius:999px;background:none;color:var(--color-muted);cursor:pointer;transition:color 160ms ease,transform 160ms ease;touch-action:manipulation}
.bottom-nav-back:active{transform:scale(.92)}
.bottom-nav-back:disabled{opacity:.5;cursor:default}
.app-shell .admin-back-nav{display:none}
@media(hover:hover){}
@media(max-width:359px){.bottom-nav[data-can-back=true]{grid-template-columns:repeat(6,minmax(0,1fr))}.bottom-nav[data-can-back=true] .bottom-nav-label{display:none}}

.bottom-nav-back>svg{width:23px;height:23px}
@media(min-width:768px){.bottom-nav-back>svg{width:26px;height:26px}}

/* Add one slot to the left while keeping all five destinations and Sync anchored. */
.bottom-nav-dock{--bottom-nav-gap:10px}
@media(min-width:768px){.bottom-nav-dock{--bottom-nav-gap:12px}}
@media(min-width:600px){
 .bottom-nav-dock .bottom-nav[data-can-back=true]{
  margin-inline-start:calc((var(--bottom-nav-height) + var(--bottom-nav-gap) + var(--bottom-nav-padding) + var(--bottom-nav-padding) + 2px - 100%)/5);
 }
}

/* Animate the pill skin with transforms while its buttons keep their anchors. */
.bottom-nav:not(.reader-action-pill){background:transparent;border-color:transparent;box-shadow:none}
.bottom-nav-surface{position:absolute;inset:-1px;border:1px solid color-mix(in srgb,var(--color-rule) 70%,transparent);border-radius:inherit;background:color-mix(in srgb,var(--color-paper) 86%,var(--color-surface));box-shadow:0 5px 18px color-mix(in srgb,var(--color-book-shadow) 40%,transparent);pointer-events:none;z-index:-2;transform-origin:right center}
.bottom-nav-back-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;pointer-events:none}
.bottom-nav-back-exit{position:absolute;display:flex;align-items:center;justify-content:center;pointer-events:none;transform-origin:center;z-index:0}

/* Reader mode switches share the action pill and leave Sync at its own anchor. */
.reader-bottom-position .reader-action-pill{flex:0 1 320px;width:320px;grid-template-columns:repeat(5,minmax(0,1fr))}
.reader-action-pill .bottom-nav-button[aria-pressed=true]{background:var(--color-selected,var(--color-accent-soft));color:var(--color-selected-ink,var(--color-accent));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--color-accent) 18%,transparent)}
.reader-action-pill .auto-type-toggle{padding:5px 0;min-width:0}
@media(min-width:768px){.reader-bottom-position .reader-action-pill{flex-basis:380px;width:380px}}
@media(max-width:599px){.reader-action-pill .bottom-nav-button>svg{width:clamp(18px,5.6vw,23px);height:clamp(18px,5.6vw,23px)}.reader-action-pill .bottom-nav-button>span{font-size:9px}}
@media(max-width:359px){.reader-action-pill .bottom-nav-button>span{font-size:8px}.reader-action-pill .bottom-nav-button{gap:3px}}

/* Five reader controls use the same five slots and full pill width as Library. */
.reader-bottom-position .reader-action-pill{flex:1 1 0;width:auto;gap:0}
.reader-action-pill .bottom-nav-button>svg{width:23px;height:23px}
@media(min-width:768px){.reader-action-pill .bottom-nav-button>svg{width:26px;height:26px}}
@media(max-width:359px){.reader-action-pill .bottom-nav-button>svg{width:21px;height:21px}}

/* Reserve the speed-control row in both states, so Auto never moves the passage. */
.reader.reader-bottom-dock .reading-main,.reader.reader-bottom-dock:has(.auto-type-speed) .reading-main{height:calc(100svh - var(--bottom-nav-bottom) - var(--bottom-nav-height) - 108px - env(safe-area-inset-bottom))}
.reader-speed-position{position:fixed;inset-inline:0;bottom:calc(var(--bottom-nav-bottom) + var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom));display:flex;justify-content:center;padding-inline:16px;pointer-events:none;z-index:30}
.reader-speed-dock{width:min(100%,420px);display:grid;grid-template-columns:minmax(0,1fr) var(--bottom-nav-height);column-gap:10px;pointer-events:none}
.reader-speed-panel{grid-column:1;width:min(100%,280px);justify-self:center;pointer-events:auto;min-width:0}
.reader .reader-speed-panel .auto-type-speed{position:static;box-sizing:border-box;width:100%;height:44px;min-height:44px;margin:0;padding:6px 12px;gap:10px;border:1px solid var(--color-rule);border-radius:999px;background:var(--color-surface)}
.reader-speed-panel .auto-type-speed input[type=range]{flex:1;min-width:0;width:auto}
.reader-speed-panel .auto-type-speed>span:first-child{flex-shrink:0}
@media(min-width:768px){.reader-speed-dock{width:506px;column-gap:12px}}
@media(max-width:767px){.reader.reader-bottom-dock .reader-bottom-left,.reader.reader-bottom-dock .reader-bottom-right{bottom:calc(var(--bottom-nav-bottom) + var(--bottom-nav-height) + 64px + env(safe-area-inset-bottom))}}

/* Chapter word progress belongs with the other reading statistics. */
.reader .typing-stats>.word-progress-stat{flex:1.55;min-width:0}
.reader .word-progress-stat strong{display:flex;align-items:center;justify-content:center;min-height:1.1em}
.reader .word-progress-stat strong .word-progress-value{display:block;min-width:0;margin:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;font-family:inherit;font-size:clamp(10px,3.2vw,23px);line-height:1;letter-spacing:-.2px;color:inherit;white-space:nowrap}
.reader .typing-stats .word-progress-label{display:flex;align-items:center;justify-content:center;gap:4px}
.reader .word-progress-label svg{width:12px;height:12px;flex-shrink:0}
.reader .typing-stats>div>span{white-space:nowrap}
@media(max-width:359px){.reader .typing-stats>div>span{font-size:7px}}
.bottom-nav-back svg{width:23px;height:23px}
@media(min-width:768px){.bottom-nav-back svg{width:26px;height:26px}}
/* Narrow screens reserve a full Back slot before it is needed. Destinations,
 * Sync and their artwork keep the same anchors while the pill extends left. */
@media(max-width:599px){
 .bottom-nav-dock,.reader-speed-dock{--mobile-back-slot:calc((100% - var(--bottom-nav-height) - var(--bottom-nav-gap,10px) - var(--bottom-nav-padding) - var(--bottom-nav-padding) - 2px)/6)}
 .bottom-nav-dock>.bottom-nav{margin-inline-start:var(--mobile-back-slot)}
 .bottom-nav-dock>.bottom-nav[data-can-back=true]{margin-inline-start:0}
 .bottom-nav:not(.reader-action-pill) .bottom-nav-label{display:initial;font-size:clamp(7px,1.8vw,9px)}
 .bottom-nav:not(.reader-action-pill) .bottom-nav-icon,.bottom-nav-back svg{width:clamp(17px,5.6vw,23px);height:clamp(17px,5.6vw,23px)}
 .bottom-nav:not(.reader-action-pill) .bottom-nav-button,.bottom-nav-back-content{gap:3px}
 .reader-speed-dock{grid-template-columns:var(--mobile-back-slot) minmax(0,1fr) calc(var(--bottom-nav-height) + var(--bottom-nav-gap,10px));column-gap:0}
 .reader-speed-panel{grid-column:2}
}

/* Hover belongs to the glyph; the full control keeps its click target. */
.bottom-nav .bottom-nav-button:hover,.bottom-nav .bottom-nav-back:hover{background:transparent;color:var(--color-body)}
.bottom-nav .bottom-nav-back:hover{color:var(--color-muted)}
.bottom-nav-dock .bottom-nav-sync:hover{background:color-mix(in srgb,var(--color-paper) 86%,var(--color-surface));color:var(--color-accent)}
.bottom-nav-button[aria-current=page]:hover,.reader-action-pill .reader-primary[aria-pressed=true]:hover,.reader-action-pill .bottom-nav-button[aria-pressed=true]:hover{color:var(--color-selected-ink,var(--color-accent))}
.reader-action-pill .reader-primary[aria-pressed=true]:hover,.reader-action-pill .bottom-nav-button[aria-pressed=true]:hover{background:var(--color-selected,var(--color-accent-soft))}
.tray-icon{--tray-icon-default:23px;display:block;position:relative;flex-shrink:0;width:var(--tray-icon-size,var(--tray-icon-default));height:var(--tray-icon-size,var(--tray-icon-default));pointer-events:auto;transform-origin:center;transition:transform 220ms cubic-bezier(.22,1,.36,1),color 180ms ease,filter 180ms ease}
.tray-icon svg,.bottom-nav-back .tray-icon svg,.bottom-nav-sync .tray-icon svg{position:static;display:block;width:100%;height:100%;pointer-events:none;fill:currentColor;stroke:none}
.bottom-nav-back-content{pointer-events:none}.bottom-nav-back-content .tray-icon{pointer-events:auto}
.bottom-nav-button:disabled .tray-icon,.bottom-nav-sync:disabled .tray-icon,.bottom-nav-back:disabled .tray-icon{pointer-events:none}
.reader-action-pill .bottom-nav-button>.tray-icon{font-size:inherit;line-height:normal}
@media(min-width:768px){.tray-icon{--tray-icon-default:26px}}
@media(max-width:359px){.tray-icon{--tray-icon-default:21px}}
@media(max-width:599px){.bottom-nav .tray-icon{--tray-icon-default:clamp(17px,5.6vw,23px)}}
@media(hover:hover){button:not(:disabled)>.tray-icon:hover,button:not(:disabled)>.bottom-nav-back-content>.tray-icon:hover{color:var(--color-ink);transform:translateY(-1px) scale(1.12);filter:brightness(1.12)}}

.reader-restart,.reader-focus,.reader-restart:hover,.reader-focus:hover{color:var(--color-muted);background:transparent;transform:none}
.reader .chapter-bar>.icon-button,.reader .chapter-bar>.icon-button:hover{background:transparent;color:var(--color-muted);transform:none}

/* Selected artwork stays inside each slot; the full button remains clickable. */
.reader-action-pill .bottom-nav-button{position:relative;isolation:isolate}
.reader-action-pill .reader-primary[aria-pressed=true],.reader-action-pill .bottom-nav-button[aria-pressed=true],
.reader-action-pill .reader-primary[aria-pressed=true]:hover,.reader-action-pill .bottom-nav-button[aria-pressed=true]:hover{background:transparent;box-shadow:none}
.reader-action-pill .reader-primary[aria-pressed=true]::before,.reader-action-pill .bottom-nav-button[aria-pressed=true]::before{content:"";position:absolute;inset:3px;border-radius:999px;background:var(--color-selected,var(--color-accent-soft));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--color-accent) 18%,transparent);z-index:-1;pointer-events:none}
.bottom-nav-selection{top:calc(var(--bottom-nav-padding) + 3px);bottom:calc(var(--bottom-nav-padding) + 3px);background:transparent}
.bottom-nav-selection::before{content:"";position:absolute;inset:0 3px;border-radius:inherit;background:var(--color-selected,var(--color-accent-soft));pointer-events:none}
.bottom-nav-selection::after{inset:0 3px}

/* Keep all six statistic slots anchored in manual and automated modes. */
.reader .typing-stats>div,.reader .automated-stats>div{flex:1;min-width:0}
.reader .typing-stats>.word-progress-stat{flex:1.55}
/* Reclaim the unused desktop footer allowance while reserving the speed row in both states. */
@media(min-width:768px){.reader.reader-bottom-dock .reading-main,.reader.reader-bottom-dock:has(.auto-type-speed) .reading-main{height:calc(100svh - var(--bottom-nav-bottom) - var(--bottom-nav-height) - 64px - env(safe-area-inset-bottom))}}

/* App pages share a 2000px column; site-header.css anchors their brand bar to it. */
