.text-editor { max-width: 1600px; margin: 0 auto; padding: 16px 24px 32px; }
.text-editor-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; background: white; border: 1px solid #dce2e8; border-radius: 12px 12px 0 0; }
.text-editor-toolbar .button--filled { border: 2px solid transparent; }
.text-editor-toolbar .button--filled:disabled { background: #e8edf2; color: #68717c; border-color: #c1c9d2; box-shadow: none; opacity: 1; }
.text-editor-toolbar-options { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-left: auto; }
.text-editor-toolbar-options label { display: flex; align-items: center; gap: 8px; }
.text-editor input, .text-editor select, .text-editor textarea { font: inherit; padding: 8px; border: 1px solid #c1c9d2; border-radius: 6px; max-width: 100%; }
.text-editor input[type=checkbox] { accent-color: #2459c4; }
.text-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; border: 1px solid #dce2e8; border-top: 0; }
.text-editor-view { background: #e8edf2; min-width: 0; }
.text-editor-pages { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 24px; padding: 6px 12px; border-bottom: 1px solid #d0d8e0; }
.text-editor-pagination { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 600; white-space: nowrap; }
.text-editor-pagination label, .text-editor-zoom { display: flex; align-items: center; gap: 8px; }
.text-editor-pages .button--compact { min-height: 36px; padding: 0 12px; font-size: 14px; }
.text-editor-pages input { box-sizing: border-box; width: 56px; height: 36px; padding: 2px 4px; border-color: #c7a749; border-radius: 10px; background: #fffdf7; color: var(--color-ink); text-align: center; }
.text-editor-zoom { color: var(--color-primary-dark); font-size: 15px; font-weight: 600; }
.text-editor-pages select {
    appearance: none; width: auto; min-width: 134px; height: 36px; padding: 0 32px 0 16px;
    border-color: #c7a749; border-radius: 999px; color: var(--color-primary-dark); background-color: #fffdf7;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.text-editor-pages select:enabled:hover { border-color: var(--color-primary); background-color: var(--color-primary-soft); }
.text-editor-pages input:disabled, .text-editor-pages select:disabled { opacity: 0.55; }
.text-editor-viewport { height: min(76vh, 1000px); overflow: auto; padding: 24px; }
.text-editor-empty { display: grid; place-content: center; text-align: center; min-height: 380px; color: #506070; }
.text-editor-empty[hidden] { display: none; }
.text-editor-paper { position: relative; margin: 0 auto; box-shadow: 0 2px 14px #0002; background: white; }
.text-editor-paper[hidden] { display: none; }
.text-editor-paper canvas { display: block; width: 100%; height: 100%; }
.text-editor-boxes { position: absolute; inset: 0; }
.text-editor-box { position: absolute; background: transparent; border: 1px solid transparent; border-radius: 2px; padding: 0; cursor: text; }
.text-editor-box:hover, .text-editor-box:focus-visible, .text-editor-box[aria-pressed=true] { border-color: #2459c4; background: #2459c411; outline: 2px solid #2459c4; z-index: 2; }
.text-editor-box--edited { border-color: #18924e; background: #18924e0c; }
.text-editor-box[aria-pressed=true] { visibility: hidden; }
.text-editor-inline { position: absolute; z-index: 4; margin: 0; padding: 0; }
.text-editor-inline[hidden] { display: none; }
.text-editor .text-editor-inline textarea {
    display: block; box-sizing: border-box; width: 100%; max-width: none; min-height: 0;
    margin: 0; padding: 0; border: 0; border-radius: 0; outline: 2px solid #2459c4;
    background: transparent; box-shadow: 0 0 0 3px #fff8; resize: none; overflow: hidden;
    caret-color: #2459c4; text-align: left; letter-spacing: normal;
}
.text-editor-inline[data-error=true] textarea { outline-color: #b42318; }
.text-editor-inline-actions { position: absolute; top: calc(100% + 6px); left: 0; display: flex; gap: 4px; white-space: nowrap; padding: 4px; border-radius: 6px; background: white; box-shadow: 0 2px 8px #0003; }
.text-editor-inline[data-actions-above=true] .text-editor-inline-actions { top: auto; bottom: calc(100% + 6px); }
.text-editor-inline-actions button { font: 500 12px/1.2 Arial, sans-serif; padding: 6px 8px; border: 1px solid #d0d8e0; border-radius: 4px; background: white; color: #2459c4; cursor: pointer; }
.text-editor-inline-actions button:disabled { cursor: wait; opacity: 0.6; }
.text-editor-sidebar { padding: 20px; display: flex; flex-direction: column; gap: 16px; background: white; }
.text-editor-sidebar label, .text-editor-sidebar textarea, .text-editor-sidebar input[type=text] { display: block; width: 100%; }
.text-editor-sidebar h2 { margin: 0 0 12px; font-size: 18px; }
.text-editor-sidebar p { margin: 0; font-size: 13px; line-height: 1.45; color: #526070; overflow-wrap: anywhere; }
.text-editor-instructions { display: grid; gap: 8px; }
.text-editor-instructions h2 { margin: 0; }
.text-editor-sidebar textarea { margin: 8px 0; resize: vertical; }
.text-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.text-editor-sidebar .text-editor-check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.text-editor-sidebar .text-editor-check input { width: auto; }
.text-editor-sidebar .text-editor-find { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--color-line); }
.text-editor-sidebar .text-editor-find h2 { margin: 0; color: var(--color-primary-dark); font-size: 1.25rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.035em; }
.text-editor-sidebar .text-editor-find-row { display: grid; gap: 7px; margin: 4px 0; }
.text-editor-find-row .field__label { font-size: 1rem; }
.text-editor-sidebar .text-editor-find-row input {
    box-sizing: border-box; min-height: 42px; padding: 0 13px; font-weight: 700;
    background: var(--color-primary-wash); border: 1px solid #d9c381; border-bottom: 3px solid #c49027; border-radius: 12px 12px 3px 3px;
}
.text-editor-sidebar .text-editor-find-row input:focus { background: var(--color-primary-soft); border-bottom-color: var(--color-primary); }
.text-editor-find input[type=checkbox] { accent-color: var(--color-primary-dark); }
.text-editor-find .button:disabled { color: #68717c; background: #e8edf2; border: 1px solid #c1c9d2; box-shadow: none; opacity: 1; }
.text-editor-status { margin: 0; padding: 12px 16px; min-height: 48px; background: #f5f8fb; border: 1px solid #dce2e8; border-top: 0; border-radius: 0 0 12px 12px; overflow-wrap: anywhere; }
.text-editor-status[data-error=true] { color: #b42318; }
.text-editor-help { max-width: 960px; margin: 28px auto; }
@media (max-width: 850px) {
    .text-editor { padding: 12px; }
    .text-editor-layout { grid-template-columns: 1fr; }
    .text-editor-viewport { height: 58vh; padding: 12px; }
    .text-editor-sidebar { border-top: 1px solid #dce2e8; }
}
@media (max-width: 500px) {
    /* Localized Previous/Next labels can be long. Their translated accessible
       names remain intact while compact arrows leave room for the page count. */
    .text-editor-pages .button--compact { min-width: 32px; padding: 0 8px; font-size: 0; }
    .text-editor-pages #prev::before { content: "‹"; font-size: 24px; line-height: 1; }
    .text-editor-pages #next::before { content: "›"; font-size: 24px; line-height: 1; }
}
