:root{--editor-toolbar-height:46px;--page:#fff;--text:#222;--surface:#fff;--border:#ddd;--separator:#eee;--hover:#f5f5f5;--selected:#f2f2f2;--pressed:#eaeaea;--muted:#777;--hint:#888;--placeholder:#777;--focus:#245d9b;--error:#9c2525;--drag:#f1f5fa;color-scheme:light;font:16px/1.6 system-ui,sans-serif;color:var(--text);background:var(--page)}
*{box-sizing:border-box}body{margin:0}button,input,textarea{font:inherit;color:inherit}button,summary{min-height:44px;touch-action:manipulation}button{padding:8px 12px;border:1px solid var(--border);border-radius:4px;background:var(--page);cursor:pointer}button:hover,summary:hover{background:var(--hover)}button:disabled{opacity:.45;cursor:default}.quiet{border-color:transparent;background:transparent}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,summary:focus-visible,#editor-tail:focus-visible{outline:2px solid var(--focus);outline-offset:2px}textarea{display:block;width:100%;min-width:0;border:0;border-radius:0;padding:6px 0;background:transparent;resize:none;overflow:hidden;line-height:1.6}h1{margin:0;font-size:22px;line-height:1.3}[hidden]{display:none!important}
.layout{max-width:1100px;margin:24px auto 0;padding:0 24px;display:grid;grid-template-columns:240px minmax(0,1fr);gap:40px;min-height:65vh}aside{border-right:1px solid var(--separator);padding-right:20px}.nav-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:16px}.nav-heading h1{font-size:17px}.nav-heading button{font-size:14px}nav{display:grid;gap:4px}.page-link{display:block;padding:8px 12px;min-height:44px;color:inherit;text-decoration:none;text-align:left;border:0;overflow-wrap:anywhere}.page-link[aria-current=page]{background:var(--selected);font-weight:600}summary{padding:8px 10px;cursor:pointer}#archive{margin-top:16px}main{min-width:0}.page-navigation{display:flex;align-items:center;gap:8px;min-height:32px;margin-bottom:12px}.menu{display:grid;gap:4px}.menu button{border:0;text-align:left;white-space:nowrap}.title{margin:0 0 20px}#page-title{font-size:30px;font-weight:650;line-height:1.3;padding:0;min-height:44px}#page-title::placeholder{color:var(--muted)}#toolbar-slot{position:sticky;top:env(safe-area-inset-top,0px);z-index:10;height:var(--editor-toolbar-height);margin-bottom:12px}#toolbar{display:flex;flex-wrap:wrap;align-content:flex-start;align-items:center;min-height:46px;background:var(--page);border-top:1px solid var(--separator);border-bottom:1px solid var(--separator);padding:0}#toolbar button{min-height:40px;border:0;background:transparent;padding:6px 10px;font-size:14px;line-height:20px;white-space:nowrap}#toolbar button:hover{background:var(--selected)}#blocks{position:relative;padding:0;margin:0;list-style:none}.block{display:flex;align-items:start;gap:8px;position:relative;margin:0}.block-text{flex:1;padding:5px 0;min-height:36px;min-width:0;overflow-wrap:anywhere}.block.heading .block-text{font-size:var(--heading-size);font-weight:650;line-height:1.4;padding-top:8px}.block.done .block-text{color:var(--muted);text-decoration:line-through}.check-target{display:flex;justify-content:center;align-items:center;flex:none;width:44px;min-height:36px;cursor:pointer}.check-target input{width:21px;height:21px;accent-color:var(--text);margin:0}#editor-tail{min-height:100px}.feedback{max-width:1100px;margin:0 auto;padding:8px 24px calc(24px + env(safe-area-inset-bottom));display:flex;align-items:center;flex-wrap:wrap;gap:8px}#status{flex-basis:100%;margin:0;color:var(--error);overflow-wrap:anywhere}#conflict{flex-basis:100%}#server-content{white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;padding:12px;background:var(--hover);max-height:240px;overflow:auto}
@media(max-width:700px){.layout{display:block;margin:0;padding:12px 16px 0;min-height:0}aside{border:0;padding:0}.nav-heading{margin-bottom:16px}.nav-heading h1{font-size:22px}.nav-heading button{font-size:16px}.page-link{padding:12px 8px}.page-navigation{justify-content:flex-start;margin-bottom:12px}#page-title{font-size:28px}.title{margin-bottom:20px}.feedback{padding:8px 16px calc(24px + env(safe-area-inset-bottom))}.block{gap:4px}.check-target{width:44px}#editor-tail{min-height:90px}}
/* Block handles reserve a small gutter, leaving the writing surface unframed. */
.block{gap:0;padding-left:24px}.block-handle{position:absolute;left:0;top:0;display:flex;align-items:center;justify-content:center;width:24px;min-height:36px;padding:0;border:0;background:transparent;color:var(--muted);cursor:grab;touch-action:none;opacity:0}.block:hover .block-handle,.block:focus-within .block-handle,.block-handle:focus-visible{opacity:1}.grip{width:8px;height:12px;background:radial-gradient(circle,currentColor 1px,transparent 1.2px) 0 0/4px 4px}.block.dragging{background:var(--drag);opacity:.3}.block.dragging .block-handle{cursor:grabbing;opacity:1}.drag-active{user-select:none;cursor:grabbing}.block-text:focus-visible{outline:none}.block:focus-within .block-text::placeholder{color:var(--placeholder)}.check-target{width:44px}.block.heading{margin-top:8px}.feedback:has(> :not([hidden])){padding-top:8px}.feedback:not(:has(> :not([hidden]))){display:none}
@media(pointer:coarse){.block{padding-left:28px}.block .block-handle{width:28px;opacity:1;color:var(--hint)}.block-handle::before{content:"";position:absolute;inset:0 0 0 -16px}.check-target{width:44px}}

.drag-preview{position:fixed;z-index:20;pointer-events:none;margin:0;background:var(--page);box-shadow:0 5px 18px #0002;will-change:transform;outline:0}.drag-preview-text{flex:1;min-width:0;min-height:36px;padding:5px 0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.6}.drag-preview.heading .drag-preview-text{font-size:var(--heading-size);font-weight:650;line-height:1.4;padding-top:8px}.drag-preview.done .drag-preview-text{color:var(--muted);text-decoration:line-through}
@media(prefers-reduced-motion:reduce){.drag-preview{will-change:auto}}

.drag-preview.block{margin:0}

.page-link:hover{background:var(--hover)}



.block.heading>.block-handle{top:calc(8px + var(--heading-size)*.7 - 18px)}

button,a,input,textarea,summary{-webkit-tap-highlight-color:transparent}
button:focus,a:focus,input:focus,textarea:focus,summary:focus{outline:none;box-shadow:none}
body.keyboard-focus :is(button,a,input,textarea,summary):not(.block-text):focus-visible{outline:2px solid var(--focus);outline-offset:2px}
:root{-webkit-tap-highlight-color:transparent}

#new-section{margin:0;min-height:36px;padding:5px 0 5px 24px;line-height:1.6}#new-section::placeholder{color:var(--placeholder)}#new-section:focus{outline:none}
@media(pointer:coarse){#new-section{padding-left:28px}}

#back{min-height:32px;padding:4px 8px;font-size:14px;line-height:20px}
html{scroll-padding-top:calc(var(--editor-toolbar-height) + 12px + env(safe-area-inset-top,0px))}.block-text{scroll-margin-top:calc(var(--editor-toolbar-height) + 12px + env(safe-area-inset-top,0px))}

textarea:focus::placeholder,#page-title:focus::placeholder,#blocks .block-text:focus::placeholder,#new-section:focus::placeholder{color:transparent}

#toolbar button{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;padding:0}
#toolbar svg{display:block;width:18px;height:18px;pointer-events:none}

#back{display:inline-flex;align-items:center;gap:3px}#back svg{width:17px;height:17px}#sidebar-close{display:grid;place-items:center}#sidebar-close svg{width:20px;height:20px}#sidebar-close.points-right svg{transform:rotate(180deg)}
.block-text[contenteditable]{white-space:pre-wrap;word-break:break-word;outline:none;cursor:text}.block-text[contenteditable]:empty::before{content:"\200b"}.block-text a{color:var(--focus);text-decoration:underline}.block-text img{display:block;width:auto;max-width:100%;max-height:65vh;object-fit:contain;border-radius:3px}.block.image .block-text{cursor:default}.list-marker{flex:none;min-width:26px;padding:5px 5px 5px 0;text-align:right;line-height:1.6;color:var(--muted);user-select:none}#toolbar button[aria-pressed=true]{background:var(--pressed);color:var(--text)}
body.keyboard-open #toolbar{position:fixed;z-index:25;margin:0;padding:0 4px;border-top:1px solid var(--border);box-shadow:0 -2px 6px #00000008}body.keyboard-open :is(.block-text,#new-section){scroll-margin-bottom:calc(var(--editor-toolbar-height) + 16px)}body.keyboard-open #page{padding-bottom:calc(var(--editor-keyboard-inset,0px) + var(--editor-toolbar-height) + 24px + env(safe-area-inset-bottom,0px))}
#link-editor{border:1px solid var(--border);border-radius:6px;width:min(360px,calc(100vw - 32px));padding:20px}#link-editor::backdrop{background:#0003}#link-form{display:grid;gap:14px}#link-form label{display:grid;gap:4px;font-size:14px}#link-form input{width:100%;min-height:44px;border:1px solid var(--border);border-radius:3px;padding:8px;font-size:16px}.dialog-actions{display:flex;justify-content:flex-end;gap:8px}

/* Theme behavior follows Browser Games; colors remain specific to this editor. */
:root[data-theme=dark]{color-scheme:dark;--page:#161c22;--text:#e6edf3;--surface:#202931;--border:#485764;--separator:#35424f;--hover:#202931;--selected:#28333e;--pressed:#35424f;--muted:#a4b0bd;--hint:#a4b0bd;--placeholder:#a4b0bd;--focus:#8fb4f0;--error:#f0a0a5;--drag:#293c56}
.theme-toggle{display:grid;place-items:center;flex:none;width:44px;height:44px;padding:0;border:0;color:var(--text)}
.theme-toggle,.theme-toggle:hover,.theme-toggle:active{background:transparent;box-shadow:none;filter:none}
.theme-toggle svg{width:18px;height:18px;grid-area:1/1;pointer-events:none}.theme-toggle .sun-icon{display:none}:root[data-theme=dark] .theme-toggle .sun-icon{display:block}:root[data-theme=dark] .theme-toggle .moon-icon{display:none}
.page-navigation>.theme-toggle{margin-left:auto}
@media(max-width:700px){.nav-heading h1{margin-right:auto}}
#link-editor{background:var(--surface);color:var(--text)}#link-form input{background:var(--page);color:var(--text)}

/* Typography controls use complete letterforms, rather than outline approximations. */
.format-glyph,.heading-glyph{display:block;font-family:Arial,sans-serif;font-size:17px;font-weight:500;line-height:1;pointer-events:none}
.format-bold{font-weight:750}.format-italic{font-family:Georgia,serif;font-size:19px;font-style:italic}.format-underline{text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:1.5px}.format-strike{text-decoration:line-through;text-decoration-thickness:1.5px}
.heading-glyph{font-size:16px;font-weight:600}.heading-glyph sub{font-size:10px;vertical-align:baseline;margin-left:1px}
.block.heading{--heading-size:30px}.block.heading[data-level="2"]{--heading-size:25px}.block.heading[data-level="3"]{--heading-size:21px}.block.heading[data-level="4"]{--heading-size:18px}
.heading-content{flex:1;min-width:0;margin:0;font:inherit}

/* Controls sit inside the rendered image, without adding a row to the document. */
.image-surface{position:relative;width:fit-content;max-width:100%;line-height:0}.image-surface>img{width:100%;height:auto;max-height:none}
.image-actions{position:absolute;right:4px;top:4px;display:flex;gap:0;border:1px solid var(--separator);border-radius:4px;background:var(--surface);line-height:1}
.image-actions button,#image-editor button{display:grid;place-items:center;width:44px;height:44px;min-height:44px;padding:0;border:0;background:transparent;color:var(--text)}
.image-actions button:hover,#image-editor button:hover{background:var(--hover)}
.image-actions svg,#image-editor button svg{display:block;width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.block.image:not(:focus-within) .image-actions{display:none}
@media(hover:hover){.block.image:hover .image-actions{display:flex}}
.block.image:focus-within .image-surface>img{outline:2px solid var(--border);outline-offset:2px}
#image-editor{width:min(600px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;padding:12px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text)}
#image-editor::backdrop{background:#0006}.image-edit-tools{display:flex;align-items:center;gap:2px;margin:8px 0 0}.image-edit-spacer{flex:1}#image-edit-save{color:var(--focus)!important}
#image-edit-status{position:absolute;top:12px;left:12px;right:12px;z-index:2;font-size:13px;color:var(--text);background:var(--surface);margin:0;padding:8px}#image-edit-status:empty{display:none}
#crop-stage{position:relative;width:100%;height:min(60svh,520px);min-height:180px;overflow:hidden;touch-action:none;line-height:0}
#crop-plane{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);isolation:isolate;overflow:hidden}
#crop-preview{display:block;width:100%;height:100%}
#crop-frame{position:absolute;border:1px solid #fff;outline:1px solid #0005;box-shadow:0 0 0 9999px #0007;cursor:move;touch-action:none}
#image-editor.rotating #crop-frame{visibility:hidden}
#crop-frame span{position:absolute;width:32px;height:32px;touch-action:none}
#crop-frame span::after{content:"";position:absolute;width:18px;height:18px;border:solid #fff;filter:drop-shadow(0 0 1px #000)}
#crop-frame [data-corner=nw]{left:0;top:0;cursor:nwse-resize}#crop-frame [data-corner=nw]::after{left:0;top:0;border-width:3px 0 0 3px}
#crop-frame [data-corner=ne]{right:0;top:0;cursor:nesw-resize}#crop-frame [data-corner=ne]::after{right:0;top:0;border-width:3px 3px 0 0}
#crop-frame [data-corner=sw]{left:0;bottom:0;cursor:nesw-resize}#crop-frame [data-corner=sw]::after{left:0;bottom:0;border-width:0 0 3px 3px}
#crop-frame [data-corner=se]{right:0;bottom:0;cursor:nwse-resize}#crop-frame [data-corner=se]::after{right:0;bottom:0;border-width:0 3px 3px 0}

#image-editor .image-edit-action{display:inline-flex;align-items:center;justify-content:center;gap:6px;width:72px;padding:0 8px;font-size:14px;line-height:20px}
#image-editor #image-edit-save{width:100px;background:var(--selected)}
#image-edit-save::before{content:"";display:none;width:13px;height:13px;flex:none;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:image-saving-spin .8s linear infinite}
#image-edit-save.is-saving::before{display:block}
@keyframes image-saving-spin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){#image-edit-save::before{animation:none}}

.image-surface.local-preview>img{position:absolute;inset:0;width:100%;height:100%;opacity:0}
.image-preview{display:block;width:100%;height:auto;pointer-events:none;border-radius:3px}
.block.image:focus-within .image-preview{outline:2px solid var(--border);outline-offset:2px}
.image-actions{z-index:2}.image-sync{position:absolute;bottom:4px;right:4px;z-index:2;display:grid;place-items:center;width:32px;height:32px;min-height:32px;padding:0;border:0;background:var(--surface);color:var(--text)}
.image-sync svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.image-sync.uploading svg{animation:image-saving-spin .8s linear infinite}
@media(prefers-reduced-motion:reduce){.image-sync.uploading svg{animation:none}}

.image-open-error{position:absolute;z-index:3;top:54px;right:4px;max-width:calc(100% - 8px);margin:0;padding:8px;background:var(--surface);border:1px solid var(--border);border-radius:3px;color:var(--error);font-size:13px;line-height:1.4;overflow-wrap:anywhere}


.block.image.image-selected .image-actions{display:flex}
.block.image.image-selected .image-surface>img,.block.image.image-selected .image-preview{outline:2px solid var(--border);outline-offset:2px}
#image-editor #image-edit-save{background:var(--focus);color:var(--page)!important;font-weight:650}
#image-editor #image-edit-save:hover:not(:disabled){filter:brightness(1.08)}
#image-editor #image-edit-save:active:not(:disabled){filter:brightness(.94)}
#image-editor #image-edit-save:disabled{opacity:.65}
#image-editor #image-edit-save.is-saving:disabled{opacity:1;cursor:progress}



.image-actions [data-image-action=edit]{color:var(--focus)}.image-actions [data-image-action=remove]{color:var(--action-trash)}
.editor-author{margin:-10px 0 16px;font-size:12px;line-height:1.5;color:var(--muted)}
