/* Chapter controls stay beside the manuscript; floating helpers never enter it. */
.desk-sidebar{position:sticky;top:var(--desk-sidebar-top,72px);max-height:calc(100dvh - var(--desk-sidebar-top,72px) - 14px);overflow:auto;min-width:0;scrollbar-width:thin}
.desk-wrap .desk-sidebar>.sidebar{position:static;padding:18px;margin:0 0 14px;max-width:100%;box-sizing:border-box}
.chapter-sidebar[hidden],.desk-widget[hidden],.coach-bubble[hidden],.chapter-controls-backdrop[hidden]{display:none!important}
.chapter-actions h3{font-size:18px;margin:0 0 8px}.sidebar-chapter-title{font-size:12px;line-height:1.5;margin:0 0 8px;overflow-wrap:anywhere;color:#e2c7ec}
.sidebar-save-state{display:block;margin-bottom:14px}.sidebar-helper-buttons{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 18px}
.chapter-actions .chapter-settings{display:block;margin:12px 0 0}.chapter-actions .field{font-size:12px;margin:0 0 14px;min-width:0}
.chapter-actions select,.chapter-actions input{box-sizing:border-box;width:100%;max-width:100%;padding:10px 7px;font-size:12px;min-height:40px}
.chapter-actions .actions{display:grid;grid-template-columns:1fr;gap:8px;margin-top:10px}.chapter-actions button{max-width:100%;font-size:12px;min-height:40px;padding:10px;white-space:normal}
.chapter-help{margin:16px 0 0;font-size:11px;line-height:1.6}.chapter-help summary{cursor:pointer;color:#dfc0e9}.chapter-help .status,.chapter-help .editor-file-hint{font-size:11px;line-height:1.6;margin:10px 0}
.chapter-help .editor-file-hint::before{content:none}.chapter-actions .attachment-controls>div{display:block;font-size:11px}.chapter-actions .attachment-controls button{display:block;margin-top:8px}
#editorToolbar #moreWritingTools{display:block}
#editorToolbar .desk-widget-dock{display:flex;align-items:center;flex-wrap:wrap;gap:6px;border-top:1px solid #64466f;padding-top:6px;min-width:0}
#editorToolbar:not(.tools-expanded) .desk-widget-dock{display:none}
#editorToolbar .desk-widget-dock button{display:flex;align-items:center;gap:5px;min-height:36px}
#editorToolbar #coachDock img{width:25px;height:25px;object-fit:contain;pointer-events:none}
/* Desktop controls share row space even when helpers still need More. */
@container writing-editor (min-width:821px){
 #editorToolbar{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px}
 #editorToolbar .toolbar-main,#editorToolbar .toolbar-secondary,#editorToolbar .tool-group,#editorToolbar .desk-preferences{display:contents}
 #editorToolbar button,#editorToolbar select,#editorToolbar .desk-preferences>label{flex:0 0 auto}
 #editorToolbar .page-draw-tools{display:flex;align-items:center;gap:4px;flex:0 0 auto}
 #editorToolbar .desk-widget-dock{flex-basis:100%}
 #editorToolbar.tools-inline .desk-widget-dock{display:contents}
 #editorToolbar.tools-inline #moreWritingTools{display:none}
 #editorToolbar.tools-inline .desk-widget-dock>button{height:34px;min-height:34px;padding-block:4px;white-space:nowrap}
 #editorToolbar.tools-inline #coachDock img{width:22px;height:22px}
 #editorToolbar .word-suggestion,#editorToolbar .page-ink-tools{flex-basis:100%}
}
.desk-floating-tools{position:relative;z-index:3500}
.desk-widget{position:fixed;box-sizing:border-box;display:flex;flex-direction:column;width:360px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);background:#2c1e36;color:#f1e2f7;border:1px solid #9166a3;border-radius:12px;box-shadow:0 12px 40px #0b041180;overflow:hidden;z-index:2;font:14px/1.5 'DM Sans',sans-serif}
.desk-widget .widget-heading{position:static;display:flex;align-items:center;justify-content:space-between;gap:4px;flex-wrap:nowrap;padding:5px 7px;min-height:54px;flex-shrink:0;background:#392547;border:0;border-bottom:1px solid #71507e}
.widget-grip{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;flex:1;background:transparent;color:inherit;border:0;border-radius:5px;padding:8px;font:600 14px 'DM Sans',sans-serif;text-align:left;cursor:grab;touch-action:none;user-select:none;min-height:44px}
.widget-grip:active{cursor:grabbing}.widget-grip span{font-size:21px;color:#cba5d9}
.widget-minimize{background:transparent;border:1px solid #8b6599;color:inherit;border-radius:6px;font-size:22px;width:44px;height:44px;flex-shrink:0;padding:0}
.widget-body{padding:14px;overflow:auto;min-height:0;flex:1}.widget-corner{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11px;padding:7px 14px;border-top:1px solid #71507e;flex-shrink:0}
.widget-corner select{width:auto;max-width:185px;padding:7px;font-size:12px;min-height:36px;box-sizing:border-box}
#writingCoachPanel .local-coach{padding:0;margin:0;border:0;background:transparent}.coach-mode{font-size:11px;margin:0;color:#d9b0e9}
#writingCoachPanel .status{font-size:12px;line-height:1.5;margin:8px 0 12px;color:#d3bedf}
#writingCoachPanel .coach-log{max-height:230px;font-size:13px;line-height:1.6;overflow-wrap:anywhere}
#writingCoachPanel .coach-log p{margin:0 0 14px;white-space:pre-wrap}
#writingCoachPanel .coach-form{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:end;margin-top:10px}
#writingCoachPanel .coach-form .field{margin:0;font-size:12px;min-width:0}#writingCoachPanel input{box-sizing:border-box;width:100%;min-width:0;font-size:16px;padding:9px;min-height:44px}
#writingCoachPanel .coach-form button{margin:0;min-height:44px;padding:9px;font-size:12px}
.coach-bubble{position:fixed;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;width:72px;height:86px;padding:0;background:#2b1d37ed;color:#f3e1fa;border:1px solid #956caa;border-radius:18px;box-shadow:0 7px 25px #09020f66;touch-action:none;cursor:grab;z-index:1}
.coach-bubble img{width:62px;height:62px;object-fit:contain;pointer-events:none}.coach-bubble span{font-size:11px;line-height:1.3;pointer-events:none}.coach-bubble:active{cursor:grabbing}
.sticky-note-widget{background:#f6e7aa;color:#352b1c;border-color:#c9ad65;box-shadow:0 10px 35px #0b041166}
.sticky-note-widget .widget-heading{background:#e9d38e;color:#352b1c;border-color:#c4a65d}.sticky-note-widget .widget-grip span{color:#725922}.sticky-note-widget .widget-minimize{border-color:#a88d50}
.sticky-note-content{display:flex;flex-direction:column;min-height:100%;height:100%}.sticky-note-content>label{font-size:12px}.sticky-note-content textarea{box-sizing:border-box;display:block;flex:1;width:100%;min-height:70px;padding:10px 0;font:16px/1.6 'DM Sans',sans-serif;resize:none;background:transparent;color:#352b1c;border:0;border-radius:0;margin-top:5px}
.sticky-note-content textarea::placeholder{color:#79673e}.note-save-status,.note-local-hint{font-size:11px;line-height:1.5;color:#66512c;margin:8px 0}
.note-actions{display:flex;gap:8px;flex-wrap:wrap}.note-actions button{font-size:12px;background:#f9edc3;color:#453615;border:1px solid #b49a59;border-radius:5px;min-height:36px;padding:8px}
.sticky-note-widget .widget-corner{border-color:#c4a65d}.sticky-note-widget .widget-corner select{background:#f9edc3;color:#453615;border-color:#b49a59}
.note-size-controls{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:3px 7px 3px 14px;border-top:1px solid #c4a65d;flex-shrink:0}
.note-size-controls label{display:flex;align-items:center;gap:8px;font-size:11px}.note-size-controls select{width:110px;min-height:36px;padding:6px;background:#f9edc3;color:#453615;border-color:#b49a59;font-size:12px}
#resizeStickyNote{width:44px;height:44px;font-size:23px;border:0;border-radius:6px;background:transparent;color:#725922;cursor:nwse-resize;touch-action:none}
/* A maximized scrollport starts at the top edge, without the old inset. */
#editorPane.desk-maximized{padding-top:0}
#editorToolbar #maximizeWriting{white-space:nowrap}
.widgets-suspended>.desk-widget,.widgets-suspended>.coach-bubble{visibility:hidden;pointer-events:none}
.chapter-controls-backdrop{position:fixed;inset:0;display:flex;justify-content:flex-end;background:#100819a6;z-index:20;padding:12px;box-sizing:border-box}
.chapter-controls-backdrop>section{width:340px;max-width:100%;max-height:100%;display:flex;flex-direction:column;background:#2c1e36;border:1px solid #9166a3;color:#f1e2f7;border-radius:12px;box-shadow:0 10px 40px #09021080;overflow:hidden}
.chapter-controls-backdrop header{position:static;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#392547;padding:10px 14px;border:0;border-bottom:1px solid #71507e;flex-shrink:0}
.chapter-controls-backdrop header h2{font-size:19px;margin:0}.chapter-controls-backdrop header button{width:44px;height:44px;padding:0;font-size:24px;background:transparent;color:#f1e2f7;border:1px solid #9166a3;border-radius:6px}
.chapter-controls-body{overflow:auto;padding:18px;min-height:0}.chapter-controls-body .chapter-actions>h3{display:none}
@container writing-editor (min-width:821px) and (max-width:1000px){
 #editorToolbar .desk-preferences>label:first-child{font-size:0;gap:0}
 #editorToolbar .desk-preferences select{width:64px}
 #editorToolbar .suggestion-label{font-size:0}
 #editorToolbar .suggestion-label::after{content:'Tab';font-size:11px}
 #editorToolbar #maximizeWriting{width:34px;font-size:0;padding:4px}
 #editorToolbar #maximizeWriting::before{content:'⛶';font-size:20px}
 #editorToolbar #maximizeWriting[aria-expanded=true]::before{content:'↙'}
 #editorToolbar .page-preview-toggle{font-size:0;min-width:48px}
 #editorToolbar .page-preview-toggle::before{content:'Pages';font-size:11px}
}
@container writing-editor (max-width:820px){
 #editorToolbar .page-draw-tools{display:contents}
 #editorToolbar .desk-widget-dock{grid-area:3/1/4/-1}
 #editorToolbar .desk-widget-dock button{min-height:44px;height:auto;font-size:12px}
 #editorToolbar .desk-preferences,#editorToolbar.tools-expanded .desk-preferences{gap:4px}
 #editorToolbar .desk-preferences select{width:60px}
 #editorToolbar #writingNight,#editorToolbar.tools-expanded #writingNight{min-width:44px}
 #editorToolbar .suggestion-label::after{content:'Tab'}
 #editorToolbar #maximizeWriting{width:44px;min-width:44px;font-size:0;padding:4px}
 #editorToolbar #maximizeWriting::before{content:'⛶';font-size:21px}
 #editorToolbar #maximizeWriting[aria-expanded=true]::before{content:'↙'}
}
@media(max-width:900px){.desk-sidebar{position:static;max-height:none;overflow:visible}.desk-wrap .desk-sidebar>.sidebar{margin-bottom:16px}.chapter-controls-body input,.chapter-controls-body select{font-size:16px}.chapter-controls-body button{min-height:44px}}
@media(prefers-reduced-motion:reduce){.desk-widget,.coach-bubble{scroll-behavior:auto}}
