/* Sylva 0.999 beta 4: compact workspaces and consistent disclosures. */
.workspace-menu{position:relative;min-width:0;color:var(--text)}
.workspace-menu>summary{display:flex;align-items:center;gap:8px;min-height:44px;padding:9px 12px;list-style:none;cursor:pointer;touch-action:manipulation;font:500 14px/1.4 var(--theme-ui,system-ui);border:1px solid var(--line);border-radius:8px;background:var(--surface);white-space:nowrap}
.workspace-menu>summary::-webkit-details-marker{display:none}
.workspace-menu>summary::after{content:'';flex:none;width:6px;height:6px;margin-left:4px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-2px)}
.workspace-menu[open]>summary{background:var(--accent-soft);border-color:var(--accent)}
.workspace-menu[open]>summary::after{transform:rotate(225deg) translate(-1px,-1px)}
.workspace-menu-panel{position:absolute;right:0;top:calc(100% + 8px);z-index:110;width:300px;max-width:calc(100vw - 24px);max-height:calc(100dvh - 170px);overflow:auto;overscroll-behavior:contain;padding:16px;border:1px solid var(--line);border-radius:10px;background:var(--surface-strong);box-shadow:0 12px 32px #00000022;color:var(--text);font-family:var(--theme-ui,system-ui)}
.workspace-menu-panel[hidden],.workspace-menu:not([open])>.workspace-menu-panel,[data-workspace-panel][hidden]{display:none!important}
.workspace-menu-actions{display:grid;gap:6px;width:260px}
.workspace-menu-actions>button{width:100%;justify-content:flex-start;text-align:left;white-space:normal;line-height:1.5}
.workspace-menu-panel button{touch-action:manipulation}
.workspace-menu>summary:focus-visible,[data-workspace-toggle]:focus-visible,.workspace-panel-head button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.workspace-panel-head{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:10px 16px;border-bottom:1px solid var(--line);flex:none;min-height:60px}
.workspace-panel-head b{font-size:16px;font-weight:550}
.workspace-panel-head button,.navigation-head button{width:44px;height:44px;min-width:44px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--text);font:24px/1 system-ui;cursor:pointer}

/* One rail state for every section. The backdrop also makes touch dismissal explicit. */
html{--workspace-chrome-height:72px}
@media(max-width:900px),(pointer:coarse) and (min-width:561px) and (max-width:1366px){html{--workspace-chrome-height:66px}}
.navigation-backdrop{position:fixed;inset:var(--workspace-chrome-height) 0 0;z-index:270;background:#00000026;border:0;padding:0;cursor:pointer;touch-action:manipulation}
.navigation-backdrop[hidden]{display:none!important}
html.workspace-entered[data-route]:not([data-route="home"]) #rail{position:fixed!important;inset:var(--workspace-chrome-height) auto 0 0!important;display:flex!important;flex-direction:column!important;align-items:stretch!important;width:min(280px,calc(100vw - 56px))!important;height:auto!important;min-height:0!important;padding:0 10px 12px!important;overflow:hidden!important;z-index:280!important;transform:translateX(-105%)!important;opacity:0!important;visibility:hidden!important;pointer-events:none!important;border-radius:0!important;border:0!important;border-right:1px solid var(--line)!important;background:var(--surface-strong)!important;transition:transform .2s ease,opacity .2s ease!important}
html.workspace-entered[data-route]:not([data-route="home"]).writer-chrome-open #rail.open{transform:none!important;opacity:1!important;visibility:visible!important;pointer-events:auto!important}
html.workspace-entered[data-route]:not([data-route="home"]) #rail .brand{display:none!important}
.navigation-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex:none;min-height:62px;padding:8px 2px;border-bottom:1px solid var(--line);color:var(--text)}
.navigation-head b{font:550 16px/1.4 var(--theme-ui,system-ui)}
html.workspace-entered[data-route]:not([data-route="home"]) #rail .rail-nav{flex:1 1 0!important;min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain;gap:4px!important;margin:8px 0!important;scroll-padding:8px}
html.workspace-entered[data-route]:not([data-route="home"]) #rail .rail-btn{display:flex!important;align-items:center!important;min-height:44px!important;height:auto!important;flex:none!important;padding:10px 12px!important;gap:12px!important;border-radius:8px!important}
html.workspace-entered[data-route]:not([data-route="home"]) #rail .rail-btn small{font-size:14px!important;line-height:1.4!important;font-weight:500!important;white-space:normal}
html.workspace-entered[data-route]:not([data-route="home"]) #rail .rail-bottom{flex:none!important;gap:4px!important;margin:0!important;padding-top:8px!important;border-top:1px solid var(--line)}
html.workspace-entered[data-route]:not([data-route="home"]) #writerNavToggle::after{content:'≡';position:absolute;right:-3px;bottom:-3px;display:grid;place-items:center;width:19px;height:19px;border:1px solid var(--line);border-radius:6px;background:var(--surface-strong);color:var(--text);font:17px/1 system-ui}
html[data-route="writer"].review-comparison-active #rail,html[data-route="writer"].review-comparison-active #navigationBackdrop{display:none!important}

/* Maps use the entire stage; the collection and tools open only on demand. */
#mapsView .sylva-map-view{position:relative;display:block;grid-template-columns:minmax(0,1fr)}
#mapsView .sylva-map-main{width:100%;height:100%;min-height:0}
#mapsView .sylva-map-sidebar{position:absolute;inset:60px auto 0 0;z-index:60;width:min(350px,calc(100% - 24px));max-width:none;transform:none;box-shadow:8px 0 28px #00000022;border-right:1px solid var(--line);display:flex;flex-direction:column;overflow:hidden}
#mapsView .sylva-map-sidebar-head{padding:12px 16px}
#mapsView .sylva-map-sidebar-head>.sylva-map-kicker{display:none}
#mapsView .sylva-map-title-row{margin:0}
#mapsView .sylva-map-storage{margin-top:10px}
#mapsView .sylva-map-search{padding-top:10px;flex:none}
#mapsView .sylva-map-side-pane{flex:1 1 0}
#mapsView .sylva-map-sidebar-foot{flex:none;padding:0 16px;border-top:1px solid var(--line)}
#mapsView .sylva-map-sidebar-foot summary{min-height:44px;display:flex;align-items:center;cursor:pointer}
#mapsView .sylva-map-sidebar-foot p{margin:0 0 12px;line-height:1.6}
#mapsView .sylva-map-top-actions{min-height:60px;flex-wrap:nowrap;gap:8px;padding:8px 12px;justify-content:flex-start;overflow:visible;z-index:50}
#mapsView .sylva-map-mobile-side{display:flex!important;position:static!important;width:auto;height:44px;min-height:44px;padding:8px 12px;gap:8px;flex:none;font-size:14px;z-index:auto}
.workspace-current-title{flex:1;min-width:0;font-size:15px;font-weight:550;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#mapsView .sylva-map-top-actions>#sylvaMapEdit{margin:0;flex:none;font-size:14px;min-height:44px}
#mapsView .sylva-map-toolbar{position:static;transform:none;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;max-width:none;border:0;padding:0;box-shadow:none;overflow:visible;opacity:1;pointer-events:auto}
#mapsView .sylva-map-toolbar .sylva-map-tool{min-width:0;width:100%;height:auto;min-height:62px;padding:8px 4px;font-size:12px}
#mapsView .sylva-map-toolbar .sylva-map-tool span{font-size:12px}
#mapsView .sylva-map-tool-sep{display:none}
#mapsView .sylva-map-zoom{position:static;display:flex;align-items:center;justify-content:center;gap:16px;margin-top:12px;border:0;border-top:1px solid var(--line);padding:12px 0 0;box-shadow:none}
#mapsView .sylva-map-zoom button{width:44px;height:44px;border:1px solid var(--line);border-radius:7px}
#mapsView .sylva-map-empty{grid-row:2;grid-column:1;padding:18px;overflow:auto}
#mapsView .sylva-map-empty-card{max-width:480px;padding:24px}
#mapsView .sylva-map-empty-card h2{font-size:26px;line-height:1.2}
#mapsView .sylva-map-empty-card img{width:48px;height:48px}
#mapsView .sylva-map-draw-actions{top:12px;left:12px;max-width:calc(100% - 24px);z-index:25}
#mapsView .sylva-map-measure-card{bottom:18px}

/* Boards: collection, drawing tools and view controls share a compact header. */
#boardsView .board-head{flex-wrap:nowrap;gap:12px;min-height:60px;padding:8px 12px;position:relative;overflow:visible;z-index:50}
#boardsView .board-head>.board-head-actions{flex:none;flex-wrap:nowrap;gap:8px}
#boardsView .board-collection-menu{flex:1 1 0;max-width:580px;margin-right:auto}
#boardsView .board-collection-menu>summary{min-width:0;justify-content:flex-start;width:100%}
#boardActiveTitle{font-size:14px;font-weight:550;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
#boardsView .board-collection-menu>summary>span{color:var(--muted);font-size:13px}
#boardsView .board-collection-menu>summary::after{margin-left:auto}
#boardsView #boardCollectionPanel{left:0;right:auto;width:380px}
#boardsView #boardCollectionPanel .board-identity{min-width:0;max-width:none;margin-bottom:16px;display:block}
#boardsView #boardCollectionPanel>.board-head-actions{display:grid;grid-template-columns:1fr 1fr}
#boardsView .board-dock{position:static;transform:none;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;width:100%;max-width:none;padding:0;border:0;box-shadow:none;background:none;overflow:visible}
#boardsView #boardToolsPanel{width:350px}
#boardsView .board-tool{min-width:0;width:100%;padding:8px 3px;min-height:64px;font-size:12px!important}
#boardsView .board-footer-actions{display:flex;flex-wrap:wrap;overflow:visible;gap:8px;justify-content:center;margin:0}
#boardsView .board-footer-actions>.board-button{min-width:44px;min-height:44px}
#boardsView .board-footer-actions>#boardUndo,#boardsView .board-footer-actions>#boardRedo{flex:1 1 100px}
#boardsView .board-footer{padding:5px 12px;min-height:30px;gap:0;font-size:12px}
#boardsView .board-save-copy{display:flex;align-items:center;gap:16px;min-width:0}
#boardsView #boardSaveStatus{font-size:12px;flex:none}
#boardsView .board-hint{font-size:12px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#boardsView .board-side{bottom:12px}
#boardsView .board-head-actions .board-label,#boardsView .board-footer-actions .board-label{display:inline!important}

/* Reader dropdowns must escape their header, which used to clip overflow. */
#readerView .reader-bar{width:100%!important;max-width:none!important;height:auto!important;min-height:60px;padding:8px 16px!important;overflow:visible!important;flex-wrap:wrap;gap:8px 14px}
#readerView .reader-position{flex:1 1 180px;min-width:0;max-width:100%}
#readerView .reader-position h1{font-size:17px;line-height:1.3;margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#readerView .reader-position small{font-size:12px!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#readerView .reader-main-actions{flex:0 1 auto;width:auto;max-width:100%;flex-wrap:wrap;justify-content:flex-end;gap:6px}
#readerView .reader-options{margin:0}
#readerView .reader-options-body{width:300px;max-height:calc(100dvh - 160px);overflow:auto;gap:8px}
#readerView .reader-options .reader-book-format{display:block}
#readerView .reader-viewport.book-active{padding:8px 12px 12px!important}
#readerView .reader-book-stage{gap:12px}
#readerView .reader-book-nav{position:static;transform:none;flex:0 0 44px;width:44px;min-width:44px;height:48px;min-height:44px}
#readerView .reader-book-frame{position:relative;flex:none;min-width:0;min-height:0}
#readerView .reader-book-spread{position:absolute;left:0;top:0;transform-origin:top left}
/* Visible, animated and measuring pages share logical dimensions and styles.
   Scale is applied once, to the spread; mobile text inflation stays disabled. */
#readerView .reader-book-page-inner{padding:44px 40px 32px!important}
#readerView .reader-book-heading{min-height:43px;margin-bottom:17px}
#readerView .reader-book-heading small{font-size:10.5px!important;line-height:1.25}
#readerView .reader-book-heading b{font-size:13.5px!important;line-height:1.3}
#readerView .reader-book-page-number{font-size:11px!important;min-height:18px;margin-top:12px}
#readerView .reader-book-copy{font-size:var(--reader-book-font-size,12.8px)!important;line-height:var(--reader-book-line-height,1.5)!important;font-family:var(--reading-font,var(--editor-font))!important;overflow-wrap:anywhere}
#readerView .reader-book-copy,#readerView .reader-book-heading,#readerView .reader-book-page-number{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none}
#readerView .reader-book-status{min-height:24px;padding-top:8px;gap:8px}
#readerView .reader-document{container-type:inline-size}
#readerView .reader-editor:not(.reader-book-editor){font-size:clamp(16px,3.1cqi,20px)!important;line-height:1.75!important;overflow-wrap:anywhere}
#readerView #readerToolsPanel{width:270px}
#readerView #readerToolsPanel>button{display:flex;align-items:center;gap:10px;justify-content:flex-start;width:100%;min-height:44px;white-space:normal}
#readerView #readerToolsPanel #readerNotesCount{margin-left:auto}
#readerView .reader-main-actions>.workspace-menu{flex:none}
@media(max-width:760px){
 #readerView .reader-bar{padding:8px 12px!important;gap:6px 10px}
 #readerView .reader-main-actions button,#readerView .reader-main-actions summary{font-size:13px!important;padding:8px 10px}
}
@media(max-height:650px){
 #readerView .reader-position small{display:none}
 #mapsView .sylva-map-empty-card{padding:16px}
 #mapsView .sylva-map-empty-card p{margin-bottom:12px}
 #mapsView .sylva-map-sidebar{overflow-y:auto}
 #mapsView .sylva-map-side-pane{min-height:120px;flex:1 0 auto}
}
@media(max-width:700px){
 #mapsView .workspace-current-title{display:none}
 #mapsView .sylva-map-mobile-side{margin-right:auto}
 #boardsView .board-collection-menu>summary>span{display:none}
 #boardsView .board-head{gap:6px}
 #boardsView .board-head>.board-head-actions{gap:4px}
 #boardsView .workspace-menu>summary{padding-inline:8px}
 #boardsView .board-hint{display:none}
}
@media(prefers-reduced-motion:reduce){html.workspace-entered #rail{transition:none!important}}

html.workspace-entered[data-route]:not([data-route="home"]) #rail .tablet-home-link{display:flex!important}
