
.rte {
    --rte-loaded: 1;
    --rte-bg: #ffffff;
    --rte-fg: #1f2328;
    --rte-muted: #59636e;
    --rte-border: #d0d7de;
    --rte-toolbar-bg: #f6f8fa;
    --rte-status-bg: #f6f8fa;
    --rte-hover: #e6eaef;
    --rte-pressed: #d3e3ff;
    --rte-accent: #0b5fff;
    --rte-accent-fg: #ffffff;
    --rte-focus: #0b5fff;
    --rte-popup-bg: #ffffff;
    --rte-shadow: 0 8px 28px rgba(15, 25, 45, .22);
    --rte-backdrop: rgba(15, 20, 30, .5);
    --rte-radius: 8px;
    --rte-control-radius: 6px;
    --rte-gap: 4px;
    --rte-pad: 16px;
    --rte-btn-size: 32px;
    --rte-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --rte-content-font: var(--rte-font);
    --rte-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --rte-danger: #c62828;
    --rte-code-bg: #eef1f5;
    --rte-selection: rgba(11, 95, 255, .22);
    --rte-callout-info: #0b5fff;
    --rte-callout-info-bg: #eaf1ff;
    --rte-callout-success: #1a7f37;
    --rte-callout-success-bg: #e8f6ec;
    --rte-callout-warning: #b25e00;
    --rte-callout-warning-bg: #fff3df;
    --rte-comment-bg: #fff3a8;
    --rte-merge-bg: #e8ddff;
    --rte-chip-bg: #e6eaef;
    --rte-transition: 120ms ease;

    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: 0;
    color: var(--rte-fg);
    background: var(--rte-bg);
    border: 1px solid var(--rte-border);
    border-radius: var(--rte-radius);
    font-family: var(--rte-font);
    font-size: 15px;
    line-height: 1.4;
}
.rte *, .rte *::before, .rte *::after { box-sizing: border-box; }

.rte[data-theme="dark"] {
    --rte-bg: #151a21;
    --rte-fg: #e6e9ee;
    --rte-muted: #a0a9b6;
    --rte-border: #333c49;
    --rte-toolbar-bg: #1c222b;
    --rte-status-bg: #1c222b;
    --rte-hover: #2a323e;
    --rte-pressed: #27406e;
    --rte-accent: #5b9bff;
    --rte-accent-fg: #0b1220;
    --rte-focus: #8ab6ff;
    --rte-popup-bg: #1f2630;
    --rte-shadow: 0 8px 28px rgba(0, 0, 0, .6);
    --rte-code-bg: #232b36;
    --rte-selection: rgba(91, 155, 255, .35);
    --rte-danger: #ff8a80;
    --rte-callout-info: #7fb0ff;
    --rte-callout-info-bg: #1b2a44;
    --rte-callout-success: #62d082;
    --rte-callout-success-bg: #17301f;
    --rte-callout-warning: #ffb454;
    --rte-callout-warning-bg: #3a2a10;
    --rte-comment-bg: #5a4d00;
    --rte-merge-bg: #3b2f63;
    --rte-chip-bg: #2a323e;
    color-scheme: dark;
}

.rte[data-theme="classic"] {
    --rte-bg: #ffffff;
    --rte-border: #9aa0a6;
    --rte-toolbar-bg: #e4e4e4;
    --rte-status-bg: #e4e4e4;
    --rte-hover: #f4f4f4;
    --rte-pressed: #c9d6ea;
    --rte-radius: 0;
    --rte-control-radius: 0;
    --rte-accent: #1f4f9a;
    --rte-font: Tahoma, Verdana, "Segoe UI", Arial, sans-serif;
    --rte-content-font: Georgia, "Times New Roman", serif;
}
.rte[data-theme="classic"] .rte-toolbar { box-shadow: inset 0 1px 0 #fff; }
.rte[data-theme="classic"] .rte-btn { border: 1px solid transparent; }
.rte[data-theme="classic"] .rte-btn:hover { border-color: #9aa0a6; background: linear-gradient(#fff, #e9e9e9); }
.rte[data-theme="classic"] .rte-btn.rte-active { border-color: #6b7f9e; background: #c9d6ea; }

.visually-hidden, .rte .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.rte [hidden] { display: none !important; }

.rte-toolbar {
    display: flex; flex-wrap: nowrap; align-items: center; gap: var(--rte-gap);
    padding: 4px 6px; background: var(--rte-toolbar-bg); border-bottom: 1px solid var(--rte-border);
    border-radius: var(--rte-radius) var(--rte-radius) 0 0; overflow: hidden; min-height: 42px;
}
.rte-tb-sep { flex: none; width: 1px; align-self: stretch; margin: 6px 4px; background: var(--rte-border); }
.rte-btn {
    position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
    min-width: var(--rte-btn-size); height: var(--rte-btn-size); padding: 0 6px; margin: 0;
    color: inherit; background: transparent; border: 0; border-radius: var(--rte-control-radius);
    font: inherit; cursor: pointer; transition: background var(--rte-transition), color var(--rte-transition);
}
.rte-btn:hover { background: var(--rte-hover); }
.rte-btn.rte-active, .rte-btn[aria-pressed="true"] { background: var(--rte-pressed); color: var(--rte-accent); }
.rte-btn[aria-expanded="true"] { background: var(--rte-hover); }
.rte-btn.rte-disabled, .rte-btn[aria-disabled="true"] { opacity: .42; cursor: default; }
.rte-btn.rte-disabled:hover, .rte-btn[aria-disabled="true"]:hover { background: transparent; }
.rte-btn-icon { display: inline-flex; }
.rte-icon { width: 20px; height: 20px; flex: none; display: block; }
.rte-btn-chevron .rte-icon { width: 14px; height: 14px; }
.rte-btn-label { white-space: nowrap; }
.rte-btn-value .rte-btn-label { display: inline-block; text-align: start; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; max-width: 11em; }
.rte-btn-value .rte-btn-icon { display: none; }
.rte-btn-swatch { position: absolute; inset-inline: 7px; bottom: 4px; height: 3px; border-radius: 1px; background: var(--rte-current, transparent); pointer-events: none; }

:where(.rte) :focus-visible { outline: 2px solid var(--rte-focus); outline-offset: 1px; }
.rte-btn:focus-visible { outline-offset: -2px; }
.rte-surface:focus-visible { outline: none; }
.rte.rte-focused { border-color: var(--rte-accent); box-shadow: 0 0 0 1px var(--rte-accent); }

.rte-main { position: relative; display: flex; flex: 1 1 auto; min-height: var(--rte-min-height, 200px); min-width: 0; }
.rte[data-fixed-height] { height: var(--rte-height); }
.rte[data-fixed-height] .rte-main { min-height: 0; }
.rte-surface, .rte-source, .rte-preview {
    position: relative; flex: 1 1 0; min-width: 0; margin: 0; padding: var(--rte-pad); overflow: auto; outline: 0;
    color: var(--rte-fg); background: var(--rte-bg); border: 0; border-radius: 0;
    font-family: var(--rte-content-font); font-size: 1em; line-height: 1.6; overflow-wrap: anywhere;
    container-type: inline-size;
}
.rte[data-fixed-height] .rte-surface, .rte[data-fixed-height] .rte-source, .rte[data-fixed-height] .rte-preview { height: 100%; }
.rte-source { font-family: var(--rte-mono); font-size: 13px; line-height: 1.5; resize: none; white-space: pre; tab-size: 2; width: 100%; container-type: normal; }
.rte-surface::selection, .rte-surface *::selection { background: var(--rte-selection); }
.rte-surface[data-empty]::before {
    content: attr(data-placeholder); position: absolute; inset-inline-start: var(--rte-pad); top: var(--rte-pad);
    color: var(--rte-muted); pointer-events: none; opacity: .8;
}
.rte[data-readonly] .rte-surface { cursor: default; }

:where(.rte-surface, .rte-preview) > :first-child { margin-top: 0; }
:where(.rte-surface, .rte-preview) p { margin: 0 0 .75em; }
:where(.rte-surface, .rte-preview) h1, :where(.rte-surface, .rte-preview) h2, :where(.rte-surface, .rte-preview) h3,
:where(.rte-surface, .rte-preview) h4, :where(.rte-surface, .rte-preview) h5, :where(.rte-surface, .rte-preview) h6 { margin: 1em 0 .5em; line-height: 1.25; font-weight: 650; }
:where(.rte-surface, .rte-preview) h1 { font-size: 2em; }
:where(.rte-surface, .rte-preview) h2 { font-size: 1.6em; }
:where(.rte-surface, .rte-preview) h3 { font-size: 1.3em; }
:where(.rte-surface, .rte-preview) h4 { font-size: 1.1em; }
:where(.rte-surface, .rte-preview) h5 { font-size: 1em; }
:where(.rte-surface, .rte-preview) h6 { font-size: .9em; text-transform: uppercase; letter-spacing: .04em; }
:where(.rte-surface, .rte-preview) blockquote { margin: 0 0 .75em; padding: .25em 1em; border-inline-start: 4px solid var(--rte-border); color: var(--rte-muted); }
:where(.rte-surface, .rte-preview) ul, :where(.rte-surface, .rte-preview) ol { margin: 0 0 .75em; padding-inline-start: 1.8em; }
:where(.rte-surface, .rte-preview) li { margin: .15em 0; }
:where(.rte-surface, .rte-preview) hr { border: 0; border-top: 2px solid var(--rte-border); margin: 1.2em 0; }
:where(.rte-surface, .rte-preview) a { color: var(--rte-accent); text-decoration: underline; }
:where(.rte-surface, .rte-preview) img { max-width: 100%; height: auto; }
:where(.rte-surface, .rte-preview) code { font-family: var(--rte-mono); font-size: .9em; background: var(--rte-code-bg); padding: .1em .35em; border-radius: 4px; }
:where(.rte-surface, .rte-preview) pre { margin: 0 0 .75em; padding: .8em 1em; background: var(--rte-code-bg); border-radius: var(--rte-control-radius); overflow: auto; font-family: var(--rte-mono); font-size: .9em; line-height: 1.5; white-space: pre; tab-size: 2; }
:where(.rte-surface, .rte-preview) pre code { padding: 0; background: none; font-size: inherit; }
:where(.rte-surface, .rte-preview) mark { background: #fff3a8; color: #1f2328; padding: 0 .1em; }
:where(.rte-surface, .rte-preview) sub, :where(.rte-surface, .rte-preview) sup { line-height: 0; }
:where(.rte-surface, .rte-preview) figure { margin: 0 0 .75em; }
:where(.rte-surface, .rte-preview) figcaption { color: var(--rte-muted); font-size: .85em; text-align: center; padding-top: .3em; }

:where(.rte-surface, .rte-preview) table { border-collapse: collapse; width: 100%; max-width: 100%; margin: 0 0 .75em; table-layout: auto; }
:where(.rte-surface, .rte-preview) th, :where(.rte-surface, .rte-preview) td { border: 1px solid var(--rte-border); padding: .4em .6em; vertical-align: top; min-width: 2em; }
:where(.rte-surface, .rte-preview) th { background: var(--rte-toolbar-bg); font-weight: 650; text-align: start; }
.rte-surface table.rte-table-bordered th, .rte-surface table.rte-table-bordered td,
.rte-preview table.rte-table-bordered th, .rte-preview table.rte-table-bordered td { border: 1px solid var(--rte-border); }
.rte-surface table.rte-table-borderless th, .rte-surface table.rte-table-borderless td,
.rte-preview table.rte-table-borderless th, .rte-preview table.rte-table-borderless td { border-color: transparent; }
.rte-surface table.rte-table-borderless td, .rte-surface table.rte-table-borderless th { outline: 1px dashed var(--rte-border); outline-offset: -1px; }
.rte-preview table.rte-table-borderless td, .rte-preview table.rte-table-borderless th { outline: 0; }
.rte-surface .rte-selected, .rte-surface td.rte-selected, .rte-surface th.rte-selected { background: var(--rte-selection) !important; outline: 2px solid var(--rte-accent); outline-offset: -2px; }
.rte-surface table { position: relative; }

.rte-surface ul.rte-todo, .rte-preview ul.rte-todo { list-style: none; padding-inline-start: 0; }
.rte-surface ul.rte-todo > li, .rte-preview ul.rte-todo > li { position: relative; padding-inline-start: 30px; min-height: 1.5em; }
.rte-surface ul.rte-todo > li::before, .rte-preview ul.rte-todo > li::before {
    content: ""; position: absolute; inset-inline-start: 4px; top: .28em; width: 17px; height: 17px; border: 2px solid var(--rte-muted); border-radius: 4px;
    background: transparent; cursor: pointer; transition: background var(--rte-transition), border-color var(--rte-transition);
}
.rte-surface ul.rte-todo > li[data-checked="true"]::before, .rte-preview ul.rte-todo > li[data-checked="true"]::before {
    background: var(--rte-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / 80% no-repeat;
    border-color: var(--rte-accent);
}
.rte-surface ul.rte-todo > li[data-checked="true"], .rte-preview ul.rte-todo > li[data-checked="true"] { color: var(--rte-muted); text-decoration: line-through; }
.rte-preview ul.rte-todo > li::before { cursor: default; }

.rte-callout { margin: 0 0 .75em; padding: .6em 1em; border-inline-start: 4px solid var(--rte-callout-info); border-radius: var(--rte-control-radius); background: var(--rte-callout-info-bg); }
.rte-callout[data-type="success"] { border-color: var(--rte-callout-success); background: var(--rte-callout-success-bg); }
.rte-callout[data-type="warning"] { border-color: var(--rte-callout-warning); background: var(--rte-callout-warning-bg); }
.rte-callout-body > :last-child { margin-bottom: 0; }

.rte-columns { display: grid; gap: 1em; margin: 0 0 .75em; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rte-columns[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rte-columns[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rte-column { min-width: 0; }
.rte-column > :last-child { margin-bottom: 0; }
.rte-surface .rte-column { outline: 1px dashed var(--rte-border); outline-offset: 4px; }
@container (max-width: 600px) {
    .rte-columns, .rte-columns[data-cols="3"], .rte-columns[data-cols="4"] { grid-template-columns: minmax(0, 1fr); }
}

.rte-toggle { margin: 0 0 .75em; border: 1px solid var(--rte-border); border-radius: var(--rte-control-radius); padding: 0 .8em; }
.rte-toggle > summary { cursor: pointer; padding: .5em 0; font-weight: 600; }
.rte-toggle[open] > summary { border-bottom: 1px solid var(--rte-border); margin-bottom: .5em; }
.rte-toggle-body > :last-child { margin-bottom: 0; }

.rte-equation, .rte-mermaid { background: var(--rte-code-bg); border-radius: 4px; font-family: var(--rte-mono); }
.rte-equation::before { content: attr(data-tex); white-space: pre-wrap; }
.rte-mermaid::before { content: attr(data-source); white-space: pre; }
div.rte-equation { display: block; padding: .6em 1em; margin: 0 0 .75em; text-align: center; }
span.rte-equation { padding: 0 .35em; }
div.rte-mermaid { display: block; padding: .8em 1em; margin: 0 0 .75em; font-size: .85em; overflow: auto; }
div.rte-mermaid:empty::after, div.rte-equation:empty::after { content: ""; }
.rte-equation:not([data-tex])::before, .rte-mermaid:not([data-source])::before { content: "…"; color: var(--rte-muted); }
.rte-equation svg, .rte-mermaid svg { max-width: 100%; height: auto; }

.rte-bookmark { margin: 0 0 .75em; border: 1px solid var(--rte-border); border-radius: var(--rte-radius); overflow: hidden; }
.rte-bookmark-link { display: block; padding: .7em 1em; text-decoration: none !important; color: inherit !important; }
.rte-bookmark-title { display: block; font-weight: 650; color: var(--rte-accent); }
.rte-bookmark-description { display: block; color: var(--rte-muted); font-size: .9em; margin-top: .2em; }
.rte-bookmark-domain { display: block; color: var(--rte-muted); font-size: .8em; margin-top: .4em; }

.rte-chip { display: inline-block; padding: 0 .55em; border-radius: 999px; background: var(--rte-chip-bg); font-size: .92em; white-space: nowrap; user-select: all; }
.rte-chip[data-kind="person"]::before { content: "@"; opacity: .7; }
.rte-merge { padding: 0 .3em; border-radius: 4px; background: var(--rte-merge-bg); font-family: var(--rte-mono); font-size: .9em; }
.rte-comment { background: var(--rte-comment-bg); border-bottom: 2px solid #e0b400; cursor: pointer; }
.rte-comment.rte-active { outline: 2px solid var(--rte-accent); }

a.rte-file::before { content: "\1F4CE"; margin-inline-end: .3em; text-decoration: none; display: inline-block; }
.rte-embed { position: relative; aspect-ratio: 16 / 9; width: 100%; max-width: 100%; margin: 0 0 .75em; background: #000; border-radius: var(--rte-control-radius); overflow: hidden; }
.rte-embed iframe, .rte-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.rte-surface .rte-embed iframe { pointer-events: none; }
:where(.rte-surface, .rte-preview) video, :where(.rte-surface, .rte-preview) audio { max-width: 100%; }

.rte-handle { position: absolute; width: 12px; height: 12px; background: var(--rte-accent); border: 2px solid var(--rte-bg); border-radius: 3px; z-index: 5; touch-action: none; }
.rte-handle[data-pos="se"] { cursor: nwse-resize; } .rte-handle[data-pos="e"] { cursor: ew-resize; } .rte-handle[data-pos="s"] { cursor: ns-resize; }
.rte-resize-box { position: absolute; outline: 2px solid var(--rte-accent); pointer-events: none; z-index: 4; }
.rte-drag-handle { position: absolute; display: inline-flex; width: 22px; height: 26px; align-items: center; justify-content: center; color: var(--rte-muted); cursor: grab; border-radius: 4px; background: transparent; }
.rte-drag-handle:hover { background: var(--rte-hover); }
.rte-block-toolbar { position: absolute; display: flex; gap: 2px; padding: 2px; background: var(--rte-popup-bg); border: 1px solid var(--rte-border); border-radius: var(--rte-control-radius); box-shadow: var(--rte-shadow); z-index: 6; }
.rte-drop-indicator { position: absolute; height: 3px; background: var(--rte-accent); border-radius: 2px; pointer-events: none; z-index: 6; }
.rte-find-hit { background: #ffe58f; color: #1f2328; border-radius: 2px; }
.rte-find-hit.rte-current { background: #ff9632; }

.rte-popup {
    z-index: 2100; min-width: 160px; max-width: min(92vw, 420px); padding: 4px; overflow: auto;
    color: var(--rte-fg); background: var(--rte-popup-bg); border: 1px solid var(--rte-border); border-radius: var(--rte-radius); box-shadow: var(--rte-shadow);
    font-family: var(--rte-font); font-size: 14px; line-height: 1.3;
}
.rte-popup:focus { outline: 0; }
.rte-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 10px 4px 6px; margin: 0; text-align: start;
    color: inherit; background: transparent; border: 0; border-radius: var(--rte-control-radius); font: inherit; cursor: pointer; white-space: nowrap;
}
.rte-menu-item:hover, .rte-menu-item:focus-visible, .rte-menu-item:focus { background: var(--rte-hover); outline: 0; }
.rte-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--rte-focus); }
.rte-menu-item[aria-disabled="true"] { opacity: .45; cursor: default; }
.rte-menu-item[aria-checked="true"] { font-weight: 600; }
.rte-menu-icon { flex: none; display: inline-flex; width: 20px; justify-content: center; }
.rte-menu-label { flex: 1 1 auto; }
.rte-menu-shortcut { margin-inline-start: 18px; color: var(--rte-muted); font-size: 12px; }
.rte-menu-chevron { display: inline-flex; margin-inline-start: 10px; }
.rte-menu-chevron .rte-icon { width: 14px; height: 14px; }
[dir="rtl"] .rte-menu-chevron .rte-icon { transform: scaleX(-1); }
.rte-menu-sep { height: 1px; margin: 4px 2px; background: var(--rte-border); }
.rte-menu-h1 { font-size: 1.5em; font-weight: 700; } .rte-menu-h2 { font-size: 1.3em; font-weight: 700; } .rte-menu-h3 { font-size: 1.15em; font-weight: 650; }
.rte-menu-h4 { font-weight: 650; } .rte-menu-h5 { font-size: .95em; font-weight: 650; } .rte-menu-h6 { font-size: .85em; font-weight: 650; text-transform: uppercase; }

.rte-colors { padding: 8px; width: 232px; }
.rte-palette { display: grid; grid-template-columns: repeat(8, 24px); gap: 4px; margin: 6px 0; }
.rte-swatch { width: 24px; height: 24px; padding: 0; background: var(--rte-swatch); border: 1px solid rgba(0, 0, 0, .25); border-radius: 4px; cursor: pointer; }
.rte-swatch:hover, .rte-swatch:focus-visible { transform: scale(1.15); outline: 2px solid var(--rte-focus); outline-offset: 1px; }
.rte-palette-custom { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.rte-hex { flex: 1; min-width: 0; }
.rte-color-native { flex: none; width: 34px; height: 30px; padding: 0; border: 1px solid var(--rte-border); border-radius: 4px; background: none; cursor: pointer; }

.rte-sheet-backdrop { position: fixed; inset: 0; z-index: 2090; background: var(--rte-backdrop); }
.rte-popup.rte-sheet {
    position: fixed; inset: auto 0 0 0; width: auto; max-width: none; max-height: 70vh; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0; z-index: 2100;
}
.rte-popup.rte-sheet .rte-menu-item { min-height: 48px; font-size: 16px; }
.rte-popup.rte-sheet .rte-palette { grid-template-columns: repeat(8, 1fr); }
.rte-popup.rte-sheet .rte-swatch { width: 100%; height: 36px; }
.rte-popup.rte-sheet.rte-colors { width: auto; }

.rte-dialog-backdrop { position: fixed; inset: 0; z-index: 2200; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--rte-backdrop); }
.rte-dialog {
    width: min(100%, 460px); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
    color: var(--rte-fg); background: var(--rte-popup-bg); border: 1px solid var(--rte-border); border-radius: calc(var(--rte-radius) + 2px); box-shadow: var(--rte-shadow);
    font-family: var(--rte-font); font-size: 14px;
}
.rte-dialog-wide { width: min(100%, 860px); }
.rte-dialog:focus { outline: 0; }
.rte-dialog-form { display: flex; flex-direction: column; min-height: 0; }
.rte-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px; }
.rte-dialog-title { margin: 0; font-size: 17px; font-weight: 650; }
.rte-dialog-close, .rte-panel-close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; color: inherit; background: transparent; border: 0; border-radius: var(--rte-control-radius); cursor: pointer; }
.rte-dialog-close:hover, .rte-panel-close:hover { background: var(--rte-hover); }
.rte-dialog-body { padding: 8px 16px 12px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.rte-dialog-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--rte-border); }
.rte-spacer { flex: 1; }
.rte-field { display: flex; flex-direction: column; gap: 4px; }
.rte-label { font-weight: 600; font-size: 13px; }
.rte-required { color: var(--rte-danger); }
.rte-check-row { display: flex; align-items: center; gap: 8px; }
.rte-check { width: 18px; height: 18px; accent-color: var(--rte-accent); }
.rte-input {
    width: 100%; min-height: 34px; padding: 6px 10px; color: var(--rte-fg); background: var(--rte-bg); border: 1px solid var(--rte-border); border-radius: var(--rte-control-radius); font: inherit;
}
textarea.rte-input { resize: vertical; }
.rte-input:focus { outline: 2px solid var(--rte-focus); outline-offset: -1px; border-color: var(--rte-focus); }
.rte-input[aria-invalid="true"] { border-color: var(--rte-danger); }
.rte-hint { color: var(--rte-muted); font-size: 12px; }
.rte-error { color: var(--rte-danger); font-size: 12.5px; font-weight: 500; }
.rte-error:empty { display: none; }
.rte-btn-text {
    min-height: 34px; padding: 0 14px; color: inherit; background: var(--rte-toolbar-bg); border: 1px solid var(--rte-border); border-radius: var(--rte-control-radius); font: inherit; font-weight: 550; cursor: pointer;
}
.rte-btn-text:hover { background: var(--rte-hover); }
.rte-btn-primary { color: var(--rte-accent-fg); background: var(--rte-accent); border-color: var(--rte-accent); }
.rte-btn-primary:hover { background: var(--rte-accent); filter: brightness(1.08); }
.rte-btn-danger { color: var(--rte-danger); }

.rte-panel { flex: 0 0 320px; width: 320px; max-width: 45%; display: flex; flex-direction: column; background: var(--rte-popup-bg); border-inline-start: 1px solid var(--rte-border); min-height: 0; }
.rte-panel[hidden] { display: none !important; }
.rte-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--rte-border); }
.rte-panel-title { margin: 0; font-size: 15px; font-weight: 650; }
.rte-panel-body { flex: 1; overflow: auto; padding: 10px 14px; }

.rte-statusbar { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; padding: 4px 12px; min-height: 28px; background: var(--rte-status-bg); border-top: 1px solid var(--rte-border); border-radius: 0 0 var(--rte-radius) var(--rte-radius); color: var(--rte-muted); font-size: 12.5px; }
.rte-status-item { color: inherit; background: none; border: 0; padding: 0; font: inherit; }
button.rte-status-item { cursor: pointer; text-decoration: underline dotted; }
.rte-status-item[data-id="mode"] { margin-inline-start: auto; }
.rte-over { color: var(--rte-danger); font-weight: 650; }

.rte-toasts { position: absolute; inset-inline: 0; bottom: 40px; z-index: 2300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.rte-toast {
    display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 14px; color: var(--rte-fg); background: var(--rte-popup-bg); border: 1px solid var(--rte-border);
    border-inline-start: 4px solid var(--rte-accent); border-radius: var(--rte-control-radius); box-shadow: var(--rte-shadow); pointer-events: auto; cursor: pointer; font-size: 14px;
    animation: rte-toast-in 160ms ease-out;
}
.rte-toast-success { border-inline-start-color: var(--rte-callout-success); }
.rte-toast-warning { border-inline-start-color: var(--rte-callout-warning); }
.rte-toast-error { border-inline-start-color: var(--rte-danger); }
@keyframes rte-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.rte-draftbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 6px 12px; background: var(--rte-callout-warning-bg); border-bottom: 1px solid var(--rte-border); font-size: 13.5px; }
.rte-draftbar-text { flex: 1 1 auto; }

.rte-licensebar { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-bottom: 1px solid var(--rte-border); font-size: 12.5px; }
.rte-licensebar-text { flex: 1 1 auto; }
.rte-licensebar-trial { background: var(--rte-callout-info-bg); color: var(--rte-callout-info); }
.rte-licensebar-missing, .rte-licensebar-expired, .rte-licensebar-invalid, .rte-licensebar-wrongdomain, .rte-licensebar-validbutupdatesended { background: var(--rte-callout-warning-bg); color: var(--rte-callout-warning); }

html.rte-lock-scroll { overflow: hidden; }
.rte[data-fullscreen="true"] { position: fixed; inset: 0; z-index: 2147483000; width: 100%; height: 100%; height: 100dvh; max-width: none; border: 0; border-radius: 0; }
.rte[data-fullscreen="true"] .rte-main { min-height: 0; }
.rte[data-fullscreen="true"] .rte-surface, .rte[data-fullscreen="true"] .rte-source, .rte[data-fullscreen="true"] .rte-preview { height: 100%; }
.rte[data-fullscreen="true"] .rte-toolbar, .rte[data-fullscreen="true"] .rte-statusbar { border-radius: 0; }

.rte[data-compact="true"] { --rte-btn-size: 44px; font-size: 16px; }
.rte[data-compact="true"] .rte-toolbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding: 4px; }
.rte[data-compact="true"] .rte-btn { min-width: 44px; height: 44px; }
.rte[data-compact="true"] .rte-btn-value .rte-btn-label { max-width: 8em; }
.rte[data-compact="true"] .rte-surface { padding: 12px; }
.rte[data-compact="true"] .rte-panel { position: absolute; inset: 0; width: auto; max-width: none; flex: none; z-index: 8; }
.rte[data-compact="true"] .rte-dialog-footer .rte-btn-text, .rte[data-compact="true"] .rte-input { min-height: 44px; }
.rte[data-compact="true"] .rte-statusbar { padding: 4px 8px; }

.rte[dir="rtl"] .rte-surface, .rte[dir="rtl"] .rte-source { text-align: start; }
.rte[dir="rtl"] .rte-source { direction: ltr; text-align: left; }
.rte[dir="rtl"] .rte-icon[data-mirror], .rte[dir="rtl"] .rte-btn[data-name="undo"] .rte-icon, .rte[dir="rtl"] .rte-btn[data-name="redo"] .rte-icon,
.rte[dir="rtl"] .rte-btn[data-name="indent"] .rte-icon, .rte[dir="rtl"] .rte-btn[data-name="outdent"] .rte-icon { transform: scaleX(-1); }

@media (prefers-reduced-motion: reduce) {
    .rte, .rte *, .rte *::before, .rte *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
    .rte-swatch:hover, .rte-swatch:focus-visible { transform: none; }
}
@media (forced-colors: active) {
    .rte-btn.rte-active, .rte-btn[aria-pressed="true"] { outline: 2px solid Highlight; }
    .rte-btn.rte-disabled { opacity: 1; color: GrayText; }
    .rte-menu-item:focus-visible, .rte-menu-item:hover { outline: 2px solid Highlight; }
    .rte-surface ul.rte-todo > li::before { border-color: CanvasText; forced-color-adjust: none; }
    .rte-surface ul.rte-todo > li[data-checked="true"]::before { background-color: Highlight; }
    .rte-swatch { forced-color-adjust: none; }
}
@media (prefers-contrast: more) {
    .rte { --rte-border: #000; --rte-muted: #222; }
    .rte[data-theme="dark"] { --rte-border: #fff; --rte-muted: #eee; }
}
@media print { .rte-toolbar, .rte-statusbar, .rte-toasts, .rte-panel { display: none !important; } .rte { border: 0; } }
