/* Изолированное оформление редактора. Не влияет на читалку и каталог. */
.ws-editor-shell{max-width:100%;min-width:0}.ws-editor-head{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;margin:12px 0 6px;font-size:13px}.ws-editor-actions{display:flex;gap:6px;flex-wrap:wrap}.ws-editor-actions button{font-size:12px;padding:5px 8px}.ws-format-toolbar,.ws-advanced-toolbar{display:flex;align-items:center;gap:5px;flex-wrap:wrap;padding:9px;background:var(--ui);border:1px solid var(--ln);border-radius:10px;margin-bottom:8px}.ws-format-toolbar label{display:flex;align-items:center;gap:5px}.ws-format-toolbar select{max-width:135px}.ws-format-toolbar button{min-width:34px;padding:6px}.ws-paper{max-width:900px;margin:0 auto;min-width:0}.ws-paper #tx{display:block;width:100%;box-sizing:border-box;min-height:58vh;padding:clamp(16px,3vw,38px);line-height:1.7;tab-size:4;background:var(--bg);color:var(--fg);border:1px solid var(--ln);box-shadow:0 5px 25px #00000012}.ws-editor-shell.ws-panels-hidden #ws-format-toolbar,.ws-editor-shell.ws-panels-hidden #ws-advanced-toolbar,.ws-editor-shell.ws-panels-hidden #ws-legacy-tools{display:none!important}.ws-editor-shell.ws-focus .ws-editor-head,.ws-editor-shell.ws-focus #ws-format-toolbar,.ws-editor-shell.ws-focus #ws-advanced-toolbar,.ws-editor-shell.ws-focus #ws-legacy-tools{display:none!important}.ws-editor-shell.ws-focus .ws-paper{max-width:960px}.ws-editor-shell.ws-focus #tx{min-height:75vh}.ws-advanced-toolbar[hidden]{display:none!important}@media(max-width:700px){.ws-paper #tx{min-height:55vh;padding:16px}.ws-format-toolbar{gap:4px}.ws-format-toolbar label{font-size:12px}}

/* v15: editor takes the central canvas; navigation is collapsible and independently scrollable. */
body.ws .wrap{max-width:1680px;width:100%;box-sizing:border-box;grid-template-columns:250px minmax(0,1fr);gap:20px}
body.ws .wrap.ws-sidebar-collapsed{grid-template-columns:46px minmax(0,1fr)}
body.ws #bk{min-width:0;width:100%}
body.ws .cols{grid-template-columns:185px minmax(0,1fr);gap:16px}
body.ws #wed{min-width:0;width:100%}
body.ws .ws-paper{width:100%;max-width:1050px;margin:12px auto 0}
body.ws .ws-paper #tx{width:100%;min-height:65vh;line-height:1.8;padding:clamp(20px,4vw,55px)}
body.ws .ws-editor-shell{max-width:1050px;margin-inline:auto}
body.ws .ws-side-heading{display:flex;align-items:center;justify-content:space-between;gap:6px}
body.ws .ws-side-heading h3{margin:0}
body.ws .ws-side-heading button{padding:5px 9px}
body.ws .ws-side-collapsed #ws-side-content,body.ws .ws-side-collapsed h3{display:none}
body.ws .ws-side-collapsed{overflow:hidden}
body.ws .ws-side-tabs{margin-top:24px;padding-top:12px;border-top:1px solid var(--ln)}
body.ws .ws-side-tabs h4{margin:0 0 8px}
body.ws .ws-side-tabs #tabs{display:flex;flex-direction:column;align-items:stretch;gap:6px}
body.ws .ws-side-tabs #tabs button{text-align:left;width:100%}
body.ws .ws-advanced-toolbar label{display:flex;align-items:center;gap:7px}
body.ws .ws-advanced-toolbar input[type=color]{width:44px;height:34px;padding:2px}
@media(max-width:900px){body.ws .wrap{grid-template-columns:minmax(0,1fr)}body.ws .wrap.ws-sidebar-collapsed{grid-template-columns:minmax(0,1fr)}body.ws .ws-side-collapsed{max-height:42px}body.ws .cols{grid-template-columns:minmax(0,1fr)}body.ws .ws-paper{max-width:100%}}

/* v16: consistent centered writing canvas; chapter list can be folded independently. */
body.ws .wrap{max-width:1750px;grid-template-columns:230px minmax(0,1fr);gap:16px}
body.ws .cols{grid-template-columns:minmax(0,1fr)}
body.ws .chside{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:10px}
body.ws .chside #chl{display:flex;flex-wrap:wrap;gap:5px;align-items:center}
body.ws .chside .ci{margin:0;min-width:130px}
body.ws .ws-editor-shell{width:min(100%,1050px);max-width:1050px;margin-inline:auto}
body.ws .ws-paper{width:100%;max-width:1050px;margin:8px auto 0}
body.ws #wed{width:100%;min-width:0}
body.ws #wed>.row{width:min(100%,1050px);margin-inline:auto}
body.ws #wed>.meta{width:min(100%,1050px);margin-inline:auto}
body.ws .ws-paper #tx{min-height:70vh;box-sizing:border-box}
body.ws .ws-sidebar-collapsed #side{width:46px}
body.ws #ws-advanced-toolbar select{max-width:190px}
@media(max-width:900px){body.ws .wrap{grid-template-columns:minmax(0,1fr)}body.ws .ws-editor-shell{width:100%}}
/* v17: WYSIWYG canvas and safe fallbacks */
body.ws .ws-paper #tx.ws-source-hidden{display:none!important}
body.ws #ws-canvas{min-height:65vh;outline:none;box-sizing:border-box;width:100%;padding:clamp(22px,4vw,60px);background:var(--bg);color:var(--fg);border:1px solid var(--ln);line-height:1.8;font-family:Georgia,serif;font-size:18px;overflow-wrap:anywhere;white-space:normal}
body.ws #ws-canvas p{margin:0 0 1em}body.ws #ws-canvas table{border-collapse:collapse;width:100%;margin:1em 0}body.ws #ws-canvas td,body.ws #ws-canvas th{border:1px solid #9e8a9e;padding:8px;min-width:40px}body.ws #ws-canvas .ws-entity{border-bottom:2px dotted #c79fdc;background:rgba(160,100,200,.14);cursor:help}body.ws #ws-canvas .ws-drawn{position:relative;display:inline}body.ws #ws-canvas .ws-drawn img{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}body.ws .ws-rich-note{font-size:12px;opacity:.75;margin:8px 0}body.ws .ws-rich-extra{display:flex;gap:6px;flex-wrap:wrap}body.ws .ws-editor-shell.ws-focus .ws-editor-head{display:none}body.ws #ws-focus-exit{position:sticky;top:6px;z-index:3;display:block;margin:4px auto}body.ws .ws-draw-modal{position:fixed;inset:0;background:#000b;display:grid;place-items:center;z-index:9999}body.ws .ws-draw-box{background:#241b2a;padding:20px;border-radius:12px;max-width:95vw;color:#fff}body.ws .ws-draw-box canvas{background:#ffffff14;width:min(650px,85vw);height:180px;touch-action:none;display:block;margin:12px 0;border:1px solid #999}body.ws .ws-draw-box>div{display:flex;gap:10px;align-items:center;flex-wrap:wrap}

/* v18: editor canvas and reading-mode ergonomics */
body.ws #ws-canvas{caret-color:var(--fg);text-align:left;direction:ltr;unicode-bidi:normal;white-space:pre-wrap}
body.ws #ws-canvas p{white-space:pre-wrap}
body.ws .ws-editor-shell.ws-focus #ws-canvas{min-height:85vh}
body.ws .ws-editor-shell.ws-focus .ws-editor-head{display:flex;justify-content:flex-end}
body.ws .ws-editor-shell.ws-focus .ws-editor-head>span{display:none}
body.ws .ws-editor-shell.ws-focus .ws-editor-actions #ws-panel-hide,body.ws .ws-editor-shell.ws-focus .ws-editor-actions #ws-panel-expand{display:none}
body.ws .ws-editor-shell.ws-focus #ws-format-toolbar,body.ws .ws-editor-shell.ws-focus #ws-advanced-toolbar{display:none!important}
body.ws #ws-canvas .ws-drawn img{object-fit:fill}

/* v19: reliable sidebar, recovery and independent illustration layer */
body.ws #ws-focus-exit[hidden]{display:none!important}
body.ws #ws-focus-exit{position:fixed;right:18px;top:82px;z-index:1000;background:#4a304f;color:white;padding:10px 18px;border:1px solid #b28bb7;border-radius:9px}
body.ws .ws-history{display:inline-flex;gap:5px;flex-wrap:wrap}
body.ws .ws-side-tabs #tabs{display:flex!important;flex-direction:column!important;gap:6px}
body.ws .ws-side-tabs #tabs button{display:block!important;width:100%;text-align:left}
body.ws .ws-side-collapsed #ws-side-content{display:none!important}
body.ws #ws-canvas p,body.ws #ws-canvas li,body.ws #ws-canvas blockquote{position:relative}
body.ws #ws-canvas .ws-art-selected{outline:2px dashed #d9a4e0}
/* v22 phase 1: keep the writing column closer to a comfortable reader measure. */
body.ws .ws-paper{max-width:800px!important;width:100%;margin-inline:auto}
body.ws .ws-editor-shell.ws-focus .ws-paper{max-width:800px!important}
@media(max-width:700px){body.ws .ws-paper{max-width:100%!important}body.ws #ws-canvas{padding:18px!important}}

/* v22.4: author preferences and distraction-free preview. */
body.ws .ws-paper{max-width:var(--ws-paper-width,800px)!important}
body.ws .ws-editor-shell.ws-focus .ws-paper{max-width:var(--ws-paper-width,800px)!important}
body.ws .ws-preview #ws-canvas{cursor:default;user-select:text;box-shadow:0 6px 28px #0002}
body.ws .ws-preview #ws-format-toolbar,body.ws .ws-preview #ws-advanced-toolbar{display:none!important}
body.ws .ws-preview .ws-rich-extra{display:none!important}
body.ws #ws-format-toolbar{flex-wrap:wrap}
body.ws #ws-format-toolbar label{white-space:nowrap}
@media(max-width:700px){body.ws .ws-paper,body.ws .ws-editor-shell.ws-focus .ws-paper{max-width:100%!important}body.ws .ws-editor-actions{flex-wrap:wrap}body.ws #ws-format-toolbar{gap:5px}body.ws #ws-canvas{min-height:65vh}}
/* v22.5 artwork placement */
body.ws #ws-canvas{position:relative}
body.ws #ws-canvas .bs-art-placement{position:absolute;inset:0;pointer-events:none;z-index:10}
body.ws #ws-canvas .bs-art-stage{position:absolute;min-width:120px;min-height:90px;max-width:100%;resize:both;overflow:hidden;border:2px dashed #caa0e4;background:#ffffff16;pointer-events:auto;box-sizing:border-box}
body.ws #ws-canvas .bs-art-handle{background:#33223e;color:white;padding:6px;font:12px sans-serif;cursor:move;touch-action:none;user-select:none}
body.ws #ws-canvas .bs-art-stage canvas{width:100%;height:calc(100% - 30px);pointer-events:none}
body.ws #ws-canvas .bs-art-controls{position:sticky;top:10px;display:flex;justify-content:center;gap:8px;pointer-events:auto}
body.ws #ws-canvas .bs-art-draw-canvas{position:absolute;z-index:12;touch-action:none;border:1px dashed #caa0e4;background:transparent;max-width:100%}
body.ws .bs-art-draw-panel{position:fixed;bottom:12px;left:50%;transform:translateX(-50%);z-index:9998;background:#241b2a;color:#fff;padding:12px;border:1px solid #886a94;border-radius:10px;display:flex;flex-wrap:wrap;gap:8px;align-items:center;max-width:95vw}

/* v22.5.1: brush position and editable artwork */
body.ws #ws-canvas .bs-art-draw-canvas{cursor:none}
.bs-art-brush-cursor{position:fixed;z-index:10001;pointer-events:none;border:1px solid #fff;outline:1px solid #222;border-radius:50%;transform:translate(-50%,-50%);box-sizing:border-box;box-shadow:0 0 3px #000}
/* v22.5.2: artwork follows its paragraph rather than the page origin. */
body.ws .bs-art-edit-button{margin-left:6px}
/* v22.5.3: bounded paint selection and separate editable background/ink layers */
body.ws #ws-canvas .bs-art-selection{position:absolute;pointer-events:none;border:1px dashed #ffe49b;background:#ffe49b18;z-index:14;box-sizing:border-box}
body.ws #ws-canvas .bs-art-selection[hidden]{display:none}
body.ws .bs-art-draw-panel [aria-pressed="true"]{outline:2px solid #e0b4ff}
