aes-thread-editor { display: block; }

.aes-thread-editor__panel,
.aes-thread-editor__fallback {
    width: 100%;
    border: 1px solid #d5dce2;
    border-radius: 12px;
    background: #fff;
}

.aes-thread-editor__panel:focus-within,
.aes-thread-editor__fallback:focus {
    border-color: #0063af;
    box-shadow: 0 0 0 2px #0063af26;
}

.aes-thread-editor__fallback {
    padding: 14px;
    min-height: 11rem;
    font: inherit;
    resize: vertical;
}

.aes-thread-editor__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 8px;
    padding: 8px;
    border-bottom: 1px solid #d5dce2;
    border-radius: 11px 11px 0 0;
    background: #f4f7f9;
    font: 600 13px/1.3 system-ui, sans-serif;
}

.aes-thread-editor__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    max-width: 100%;
}

.aes-thread-editor__tools button,
.aes-thread-editor__tools select {
    min-height: 34px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #263848;
    font: inherit;
}

.aes-thread-editor__tools button { min-width: 34px; }
.aes-thread-editor__tools select { cursor: pointer; border-color: #d5dce2; background: #fff; max-width: 100%; }
.aes-thread-editor__tools button:hover,
.aes-thread-editor__tools button[aria-pressed="true"] { background: #e0eef9; color: #004e88; }
.aes-thread-editor__tools button[aria-pressed="true"] { border-color: #9ac5e4; }
.aes-thread-editor__tools :is(button, select):focus-visible { outline: 2px solid #0063af; outline-offset: 1px; }
.aes-thread-editor__tool--bold { font-weight: 800 !important; }
.aes-thread-editor__tool--italic { font-style: italic !important; }
.aes-thread-editor__tool--underline { text-decoration: underline; }
.aes-thread-editor__tool--strike { text-decoration: line-through; }

.aes-thread-editor__input {
    min-height: 176px;
    padding: 12px 14px;
    outline: none;
    font-size: 16px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.aes-thread-editor__input .is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: #647384;
    float: inline-start;
    height: 0;
    pointer-events: none;
}

.aes-thread-editor__error { color: #9f252d; padding: 0 14px 10px; font-size: 14px; }

/* Bound the entire dialog to the viewport, then scroll only the fields.
   The header and actions cannot be pushed outside the visible dialog. */
.popup__box:has(.aes-thread-form) {
    max-block-size: calc(100vh - 2rem);
    max-block-size: calc(100dvh - 2rem);
}

.popup__box:has(.aes-thread-form) .popup__head {
    flex: 0 0 auto;
}

.popup__box:has(.aes-thread-form) :is(.popup__body, .popup__scroll, .customScroll__scroll, .popup__content, .aes-thread-form) {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-block-size: 0;
    max-block-size: none;
    overflow: hidden;
    padding: 0;
}

.aes-thread-form > .popupForm__body {
    flex: 1 1 auto;
    min-block-size: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 1.6rem clamp(1.2rem, 4vw, 2.4rem);
    scroll-padding-block: 1rem;
}

.aes-thread-form > .popupForm__body > .popupForm__field {
    flex: 0 0 auto;
    min-inline-size: 0;
}

.aes-thread-form > .popupForm__foot {
    flex: 0 0 auto;
    gap: clamp(.8rem, 2vw, 1.6rem);
    margin: 0;
    padding: 1rem clamp(1.2rem, 4vw, 2.4rem);
    border-block-start: 1px solid #e3e7eb;
    background: #fff;
}

.aes-thread-form > .popupForm__foot .popupForm__button {
    min-inline-size: 0;
    width: 100%;
}

.aes-thread-formatted { display: flow-root; overflow-wrap: anywhere; }
.aes-thread-formatted :where(p, h2, h3, h4, ul, ol, blockquote) + :where(p, h2, h3, h4, ul, ol, blockquote) { margin-block-start: .65em; }
.aes-thread-formatted :where(h2, h3, h4) { font-weight: 700; line-height: 1.3; }
.aes-thread-formatted :where(h2) { font-size: 1.6em; }
.aes-thread-formatted :where(h3) { font-size: 1.35em; }
.aes-thread-formatted :where(h4) { font-size: 1.16em; }
.aes-thread-formatted :where(ul, ol) { padding-inline-start: 1.65em; }
.aes-thread-formatted :where(ul) { list-style: disc; }
.aes-thread-formatted :where(ol) { list-style: decimal; }
.aes-thread-formatted :where(ul, ol) > li { display: list-item; }
.aes-thread-formatted :where(blockquote) { padding-inline-start: .85em; border-inline-start: 3px solid #83b4d8; }
.aes-thread-formatted :where(strong, b) { font-weight: 700; }
.aes-thread-formatted :where(em, i) { font-style: italic; }
.aes-thread-formatted :where(u) { text-decoration: underline; }
.aes-thread-formatted :where(s, strike) { text-decoration: line-through; }
.aes-thread-formatted .aes-thread-size-small { font-size: .86em; }
.aes-thread-formatted .aes-thread-size-large { font-size: 1.23em; }
.aes-thread-formatted .aes-thread-size-xl { font-size: 1.5em; }
.aes-thread-formatted .aes-thread-color-blue { color: #005c9e; }
.aes-thread-formatted .aes-thread-color-red { color: #a22431; }
.aes-thread-formatted .aes-thread-color-green { color: #206039; }
.aes-thread-formatted .aes-thread-color-purple { color: #6c3599; }
.aes-thread-formatted .aes-thread-highlight-yellow { background-color: #fff1a8; }
.aes-thread-formatted .aes-thread-highlight-mint { background-color: #c7f1d6; }

.aes-thread-editor__media-panel {
    display: grid;
    gap: .65rem;
    padding: 12px;
    background: #f4f7f9;
    border-bottom: 1px solid #d5dce2;
    font: 14px/1.4 system-ui, sans-serif;
}
.aes-thread-editor__media-panel label { display: grid; gap: 4px; min-inline-size: 0; }
.aes-thread-editor__media-panel :is(input, select, textarea) {
    padding: 7px;
    min-inline-size: 0;
    border: 1px solid #a9bac8;
    border-radius: 5px;
    background: #fff;
    font: inherit;
}
.aes-thread-editor__media-panel button { padding: 7px 12px; margin-inline-end: 8px; border: 1px solid #a9bac8; border-radius: 5px; }
.aes-thread-editor__media-panel button:focus-visible,
.aes-thread-editor__media-panel :is(input, select, textarea):focus-visible { outline: 2px solid #0063af; }
.aes-thread-editor__media-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.aes-thread-editor__media-panel p:empty { display: none; }
.aes-thread-editor__input .ProseMirror-selectednode { outline: 2px solid #0063af; }

.aes-thread-formatted .umb-embed-holder:has(> :is(.aes-thread-image, .aes-thread-video)) { display: block; margin-block: .75em; clear: both; }
.aes-thread-formatted .aes-thread-image { display: flex; margin: 0; }
.aes-thread-formatted .aes-thread-image img { display: block; width: auto; max-width: 100%; height: auto; border-radius: 6px; }
.aes-thread-formatted .aes-thread-image--left { justify-content: flex-start; direction: ltr; }
.aes-thread-formatted .aes-thread-image--right { justify-content: flex-end; direction: ltr; }
.aes-thread-formatted .aes-thread-image--center { justify-content: center; }
.aes-thread-formatted .umb-embed-holder:has(> .aes-thread-image--float-left) { float: left; clear: left; max-width: 42%; margin: .3em 1em .6em 0; }
.aes-thread-formatted .umb-embed-holder:has(> .aes-thread-image--float-right) { float: right; clear: right; max-width: 42%; margin: .3em 0 .6em 1em; }
.aes-thread-formatted .aes-thread-image--center-text {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 42%) minmax(0, 1fr);
    align-items: start;
    gap: .8em;
    direction: ltr;
}
.aes-thread-formatted .aes-thread-image--center-text p { white-space: pre-wrap; }
.aes-thread-formatted .aes-thread-video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 6px;
}
@media (max-width: 580px) {
    .aes-thread-formatted .aes-thread-image--center-text { grid-template-columns: minmax(0, 1fr); }
    .aes-thread-formatted .aes-thread-image--center-text img { grid-row: 1; justify-self: center; }
}
