/* Редактор статьи. */

.page-editor { padding: 0; }
.editor-bar { position: sticky; top: var(--topbar); z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--bg); border-bottom: 1px solid var(--border); }
.save-state { font-size: 13px; color: var(--text-2); }
.save-saved { color: var(--ok); }
.save-saved::before { content: '✓ '; }
.save-offline, .save-conflict { color: var(--danger); font-weight: 500; }
.editor-wrap { max-width: 800px; margin: 0 auto; padding: 28px 40px 140px; }
.editor-banners .banner { margin-bottom: 12px; }
.ed-title { display: block; width: 100%; border: 0; background: transparent; resize: none; overflow: hidden; font: 650 40px/1.15 var(--font-serif); letter-spacing: -0.015em; color: var(--text); outline: none; padding: 0; margin: 4px 0 10px; }
.ed-title::placeholder { color: var(--text-2); opacity: .55; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; margin: 0 0 24px; }
.tag-entry { border: 0; background: transparent; font-size: 14px; color: var(--text); outline: none; min-width: 140px; flex: 1; padding: 4px 0; }
.tag-x { border: 0; background: none; color: var(--text-2); cursor: pointer; margin-left: 4px; padding: 0 2px; font-size: 15px; line-height: 1; }
.editor-help { margin-top: 48px; }

.editor-blocks { font: 18px/1.6 var(--font-serif); counter-reset: oli; }
.blk { position: relative; display: flex; gap: 4px; margin-left: -38px; border-radius: 6px; }
.blk-gutter { width: 34px; flex: none; display: flex; justify-content: flex-end; align-items: flex-start; padding-top: 5px; opacity: 0; }
.blk:hover > .blk-gutter, .blk:focus-within > .blk-gutter, .blk.selected > .blk-gutter { opacity: 1; }
.blk-handle { border: 0; background: none; color: var(--text-2); cursor: grab; font-size: 13px; letter-spacing: -3px; padding: 3px 7px 3px 4px; border-radius: 5px; line-height: 1; font-family: var(--font-ui); }
.blk-handle:hover { background: var(--surface-2); }
.blk-body { flex: 1; min-width: 0; position: relative; }
.blk.dragging { opacity: .4; }
.blk.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.blk.drop-after { box-shadow: 0 2px 0 var(--accent); }
.blk.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.blk:focus { outline: none; }
.blk.selected:focus { outline: 2px solid var(--accent); }

.ed { outline: none; padding: 3px 2px; min-height: 1.6em; white-space: pre-wrap; overflow-wrap: break-word; }
.ed:empty::before { content: attr(data-ph); color: var(--text-2); opacity: 0; pointer-events: none; }
.ed:focus:empty::before, .blk:only-child .ed:empty::before { opacity: .55; }
.ed a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.ed .ilink { text-decoration: none; background: var(--accent-soft); color: var(--accent); padding: 0 .3em; border-radius: 4px; cursor: default; white-space: nowrap; }
.ed .ilink-closed { color: var(--text-2); background: var(--surface-2); font-style: italic; }
.ed code { font: .86em var(--font-mono); background: var(--code-bg); padding: .12em .38em; border-radius: 5px; border: 1px solid var(--border); }
.ed mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }
.ed strong { font-weight: 650; }

.blk-p { margin-top: 2px; margin-bottom: 2px; }
.blk-h1 { margin-top: 1.1em; } .blk-h1 .ed { font-size: 28px; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
.blk-h2 { margin-top: .9em; } .blk-h2 .ed { font-size: 22px; font-weight: 650; line-height: 1.3; }
.blk-h3 { margin-top: .7em; } .blk-h3 .ed { font-size: 19px; font-weight: 600; line-height: 1.35; }
.blk-li > .blk-body, .blk-oli > .blk-body { padding-left: 1.5em; }
.blk-li > .blk-body::before { content: '•'; position: absolute; left: .45em; top: 3px; color: var(--text-2); }
.blk:not(.blk-oli) { counter-reset: oli; }
.blk-oli { counter-increment: oli; }
.blk-oli > .blk-body::before { content: counter(oli) '.'; position: absolute; left: 0; top: 3px; min-width: 1.2em; color: var(--text-2); font-variant-numeric: tabular-nums; }
.blk-todo > .blk-body { display: flex; gap: 10px; align-items: flex-start; }
.blk-todo .ed { flex: 1; }
.todo-check { margin-top: .5em; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.blk-todo[data-done="1"] .ed { text-decoration: line-through; color: var(--text-2); }
.blk-quote .ed { border-left: 3px solid var(--border-strong); padding-left: 18px; color: var(--text-2); font-style: italic; }
.blk-callout > .blk-body { padding: 8px 14px 10px; border-radius: 10px; border-left: 4px solid var(--note-line); background: var(--note-bg); font-family: var(--font-ui); font-size: 16px; margin: 6px 0; }
.blk-callout[data-kind="warn"] > .blk-body { border-color: var(--warn-line); background: var(--warn-bg); }
.blk-callout[data-kind="danger"] > .blk-body { border-color: var(--danger-line); background: var(--danger-bg); }
.callout-kind { border: 0; background: none; padding: 0; font: 700 11px/1.8 var(--font-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--note-text); cursor: pointer; }
.blk-callout[data-kind="warn"] .callout-kind { color: var(--warn-text); }
.blk-callout[data-kind="danger"] .callout-kind { color: var(--danger); }
.blk-hr { padding: 10px 0; cursor: pointer; }
.blk-hr hr { border: 0; border-top: 1px solid var(--border-strong); margin: 0; }

.blk-code > .blk-body { border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); overflow: hidden; margin: 8px 0; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); font-family: var(--font-ui); }
.code-lang { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12px; padding: 2px 4px; }
.ed-code { margin: 0; padding: 12px 14px; font: 14px/1.6 var(--font-mono); white-space: pre; overflow-x: auto; tab-size: 2; min-height: 3.4em; }

.blk-toggle > .blk-body { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 6px 0; background: var(--surface); }
.toggle-mark { position: absolute; left: 12px; top: 11px; color: var(--text-2); font-size: 13px; }
.toggle-sum { font: 600 16px/1.5 var(--font-ui); padding-left: 18px; }
.toggle-body { margin-top: 4px; padding: 6px 0 0 18px; border-top: 1px dashed var(--border); font-size: 17px; }

.blk-table > .blk-body { margin: 8px 0; }
.ed-table { border-collapse: collapse; width: 100%; font: 15px/1.5 var(--font-ui); }
.ed-table td { border: 1px solid var(--border); padding: 0; vertical-align: top; min-width: 80px; }
.ed-table td .ed { padding: 6px 9px; min-height: 2.2em; }
.ed-table tr:first-child td { background: var(--surface-2); font-weight: 600; }
.table-tools, .img-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; opacity: 0; font-family: var(--font-ui); }
.blk:focus-within .table-tools, .blk:hover .table-tools, .blk:focus-within .img-tools, .blk:hover .img-tools, .blk.selected .img-tools { opacity: 1; }
.img-tools { justify-content: center; }
.img-tools .sep { width: 1px; background: var(--border); margin: 2px 4px; }

.blk-img > .blk-body { margin: 10px 0; }
.blk-img figure.img { margin: 0 auto; }
.blk-img figure.img img { cursor: default; }
.img-caption { display: block; width: 100%; border: 0; background: transparent; text-align: center; font: 14px var(--font-ui); color: var(--text-2); outline: none; padding: 6px 4px 0; }

.ed-toolbar { position: absolute; z-index: 150; display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.tb-btn { min-width: 32px; height: 30px; border: 0; background: none; color: inherit; border-radius: 6px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.tb-btn:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }
.tb-btn code { font-family: var(--font-mono); font-size: 12px; }
.tb-btn mark { background: var(--mark-bg); color: var(--text); padding: 0 3px; border-radius: 2px; }
.tb-btn .icon { width: 16px; height: 16px; }

.ed-menu { width: 320px; max-height: 340px; overflow-y: auto; }
.menu-glyph { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 24px; border: 1px solid var(--border); border-radius: 6px; font: 12px var(--font-mono); color: var(--text-2); flex: none; }

@media (max-width: 900px) {
  .editor-bar { padding: 8px 14px; }
  .editor-wrap { padding: 20px 20px 100px; }
}
@media (max-width: 600px) {
  .blk { margin-left: 0; }
  .blk-gutter { display: none; }
  .ed-title { font-size: 30px; }
  .editor-bar .btn-ghost { padding: 0 6px; }
}
