.editor { max-width: 860px; min-height: 360px; padding: 24px; border: 1px solid #e5e7eb; border-radius: 8px; outline: none; line-height: 1.8; font-size: 16px; overflow-wrap: anywhere; white-space: pre-wrap; cursor: text; }
.editor:focus { border-color: #8daaf0; }
.editor p { min-height: 1.8em; margin: 0; color: #242b38; }
.editor-status { font-size: 13px; min-height: 20px; margin: 12px 0; color: #7b8492; }
.editor .list-item { position: relative; padding-left: calc(28px + var(--list-indent, 0) * 24px); }
.editor .list-item::before { position: absolute; left: calc(var(--list-indent, 0) * 24px); width: 22px; text-align: right; pointer-events: none; user-select: none; }
.editor .list-item[data-kind="unordered"]::before { content: "•"; }
.editor .list-item[data-kind="ordered"]::before { content: attr(data-number) "."; font-variant-numeric: tabular-nums; }
.editor [data-editor-ui="task"] { position: absolute; left: calc(3px + var(--list-indent, 0) * 24px); top: 7px; margin: 0; width: 15px; height: 15px; cursor: pointer; accent-color: #285ccc; user-select: none; }
.editor .task-checked > span { color: #7b8492; text-decoration: line-through; }
.editor p.heading { font-weight: 700; line-height: 1.5; min-height: 1.5em; margin: 16px 0 0; }
.editor p.heading:first-child { margin-top: 0; }
.editor p.heading + p.heading { margin-top: 11px; }
.editor p.heading + p:not(.heading) { margin-top: 8px; }
.editor .heading[data-level="1"] { font-size: 24px; }
.editor .heading[data-level="2"] { font-size: 21px; }
.editor .heading[data-level="3"] { font-size: 19px; }
.editor .heading[data-level="4"] { font-size: 18px; }
.editor .heading[data-level="5"] { font-size: 17px; }
.editor .heading[data-level="6"] { font-size: 16px; }
.editor p.heading { position: relative; scroll-margin-top: 24px; }
.editor [data-editor-ui="fold"] { position: absolute; left: -23px; top: 0; width: 22px; height: 1.5em; padding: 0; border: 0; border-radius: 4px; color: #7b8492; background: transparent; text-align: center; font: inherit; font-weight: 400; cursor: pointer; user-select: none; }
.editor [data-editor-ui="fold"]:hover { color: #285ccc; background: #e6edff; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 860px); gap: 20px; max-width: 1080px; align-items: start; }
.editor-layout.has-toc { grid-template-columns: minmax(0, 860px) 180px; }
.editor-toc { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; padding: 12px 0; border-left: 1px solid #e5e7eb; }
.editor-toc-title { padding: 0 12px 8px; color: #7b8492; font-size: 13px; }
.editor-toc ul { list-style: none; padding: 0; margin: 0; }
.editor-toc button { display: block; width: 100%; padding: 6px 8px 6px calc(12px + var(--heading-depth) * 12px); border-radius: 4px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
@media (max-width: 800px) {
  .editor-layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .editor-toc { position: static; grid-row: 1; max-height: 180px; }
}
.editor-media-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; max-width: 1080px; padding: 8px 0; background: #fff; }
.editor-media-bar button, .editor .media-block button, .editor-image-viewer button { padding: 6px 10px; border: 1px solid #dce2ec; background: #f6f7f9; border-radius: 5px; font: inherit; font-size: 13px; cursor: pointer; }
.editor-upload-status { font-size: 13px; color: #545e70; overflow-wrap: anywhere; }
.image-toolbar { display: flex; gap: 6px; padding-left: 10px; border-left: 1px solid #dce2ec; }
.editor p.media-block { display: block; padding: 8px; margin: 8px 0; border: 1px solid transparent; border-radius: 6px; cursor: pointer; white-space: normal; }
.editor p.media-block[hidden] { display: none !important; }
.editor p.media-selected { border-color: #285ccc; background: #f4f7ff; }
.editor .media-block img { display: block; max-width: 100%; max-height: 560px; object-fit: contain; }
.attachment-card { display: inline-block; padding: 12px 16px; margin-right: 8px; border: 1px solid #dce2ec; border-radius: 6px; background: #f6f7f9; color: #285ccc; text-decoration: none; overflow-wrap: anywhere; }
.editor-image-viewer { max-width: 94vw; max-height: 94vh; border: 0; border-radius: 8px; padding: 16px; }
.editor-image-viewer::backdrop { background: rgb(0 0 0 / 65%); }
.editor-image-viewer img { display: block; max-width: 88vw; max-height: 82vh; object-fit: contain; margin-top: 12px; }
/* UI-5: model-driven run styles and paragraph controls. */
.editor-document-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:5px; width:100%; padding:6px; border:1px solid var(--line); border-radius:var(--r-sm); background:var(--col-bg); color:var(--tx); }
.editor-document-toolbar :is(button,select) { font:inherit; font-size:13px; }
.editor-document-toolbar select { min-width:58px; padding:5px; border:1px solid var(--field-bd); border-radius:var(--r-xs); background:var(--field-bg); color:var(--tx); }
.editor-document-toolbar .editor-paragraph-type { width:100px; }
.editor-document-toolbar button, .editor-rich-popover button { padding:5px 8px; border:0; border-radius:var(--r-xs); background:transparent; white-space:nowrap; cursor:pointer; }
:is(.editor-document-toolbar,.editor-rich-popover) [data-rich-mark="bold"] { font-weight:700; }
:is(.editor-document-toolbar,.editor-rich-popover) [data-rich-mark="italic"] { font-style:italic; }
:is(.editor-document-toolbar,.editor-rich-popover) [data-rich-mark="underline"] { text-decoration:underline; }
:is(.editor-document-toolbar,.editor-rich-popover) [data-rich-mark="strike"] { text-decoration:line-through; }
:is(.editor-document-toolbar,.editor-rich-popover) button[aria-pressed="true"] { background:var(--accent-soft); color:var(--accent); }
.editor-rich-popover { position:fixed; z-index:160; display:flex; align-items:center; flex-wrap:wrap; gap:3px; max-width:calc(100vw - 12px); padding:7px; border:1px solid var(--line); border-radius:var(--r-sm); color:var(--tx); background:var(--panel-bg); box-shadow:var(--sh-pop); font-size:13px; }
.editor-rich-color { display:inline-flex; align-items:center; gap:3px; padding:0 4px; font-size:12px; white-space:nowrap; }
.editor-rich-color input[type="color"] { width:21px; height:23px; padding:0; border:0; cursor:pointer; }
.editor p:not(.list-item) { margin-left:calc(var(--paragraph-indent,0)*24px); }
.editor p.block-quote { border-left:3px solid var(--accent); padding:8px 16px; margin-block:8px; background:var(--tab-bg); }
.editor p.block-code { padding:14px 16px; margin-block:8px; border:1px solid var(--line); border-radius:var(--r-sm); font:14px/1.7 Consolas,"Courier New",monospace; background:var(--col-bg); white-space:pre-wrap; tab-size:4; }
.editor p.block-callout { border:1px solid #ffd29f; border-left:4px solid #ffd29f; border-radius:var(--r-sm); padding:12px 16px; margin-block:8px; background:#fff5e9; }
.editor .editor-inline-code { font-family:Consolas,"Courier New",monospace; padding:1px 4px; border-radius:var(--r-xs); background:var(--tab-bg); }
.editor [data-inline-link] { color:var(--accent); text-decoration:underline; }
.editor :is(.block-quote,.block-code,.block-callout)[hidden] { display:none !important; }
