/**
 * D4 — native Roundcube composer presentation.
 *
 * This presentation layer does not replace recipient widgets, the editor,
 * attachment upload, draft/save/send commands, or responsive pane behavior.
 * Phone and small layouts remain owned by Elastic.
 */

/* Naming/keyboard enhancement uses the native compact controls too; do not
   change their geometry or replace Elastic's phone navigation. */
body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient a.remove:focus-visible {
  outline: 2px solid var(--cm-color-focus);
  outline-offset: 1px;
}

/* An editor initialized wide keeps registered icons after compact resize.
   Preserve their outline rendering without changing compact layout/chrome. */
body.task-mail.action-compose :is(#composebodycontainer, .tox-tinymce-aux) svg.lucide {
  fill: none !important;
  stroke: currentColor;
}

@media screen and (min-width: 769px) {
  body.task-mail.action-compose #layout-content,
  body.task-mail.action-compose #layout-sidebar {
    color: var(--cm-color-text);
    background: var(--cm-color-surface) !important;
  }

  body.task-mail.action-compose #layout-content > .header,
  body.task-mail.action-compose #layout-sidebar > .header {
    box-sizing: border-box;
    min-height: 58px;
    color: var(--cm-color-text);
    background: var(--cm-color-surface) !important;
    border-bottom: 1px solid var(--cm-color-border) !important;
  }

  body.task-mail.action-compose #layout-content > .header {
    justify-content: flex-start !important;
    padding: 0 14px !important;
  }

  body.task-mail.action-compose #layout-sidebar {
    border-left: 1px solid var(--cm-color-border) !important;
    background: color-mix(in srgb, var(--cm-color-surface-subtle) 55%, var(--cm-color-surface)) !important;
    /* Respect Roundcube's resizable inline width while keeping the composer
       comfortably readable at desktop and safe at the 769 px boundary. */
    min-width: clamp(240px, 26vw, 288px);
    max-width: clamp(240px, 30vw, 360px);
  }

  body.task-mail.action-compose #layout-sidebar > .header {
    justify-content: flex-start;
    padding-inline: 20px;
    color: var(--cm-color-text-muted);
    font-size: 12px;
    font-weight: 550;
    background: transparent !important;
    border-bottom-color: transparent !important;
  }

  /* The native labels remain in the DOM and feed the existing tooltip layer. */
  body.task-mail.action-compose #toolbar-menu {
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    gap: 4px;
    width: auto !important;
    height: 57px;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.task-mail.action-compose #toolbar-menu > li:not(.hidden-big) {
    display: flex !important;
    align-items: center;
    flex: 0 0 auto;
    height: 57px !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: visible !important;
  }

  body.task-mail.action-compose #toolbar-menu > li:has(> a:is(.hidden, .hidden-big, .hidden-large)) {
    display: none !important;
  }

  body.task-mail.action-compose #toolbar-menu > li.spacer {
    flex: 0 0 1px;
    width: 1px !important;
    height: 22px !important;
    margin: 0 6px !important;
    background: var(--cm-color-border);
  }

  body.task-mail.action-compose #toolbar-menu .dropbutton:not(.disabled) {
    display: inline-flex !important;
    align-items: center;
    height: 40px;
    background: transparent !important;
  }

  body.task-mail.action-compose #toolbar-menu a:is(.save, .attach, .signature, .responses, .spellcheck, .dropdown) {
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    float: none !important;
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--cm-color-text-muted) !important;
    line-height: 1 !important;
    border: 0 !important;
    border-radius: 10px;
    background: transparent !important;
    overflow: visible !important;
    transition: color var(--cm-motion-fast) ease, background-color var(--cm-motion-fast) ease;
  }

  body.task-mail.action-compose #toolbar-menu .dropbutton > a.dropdown {
    width: 26px !important;
    min-width: 26px !important;
    margin-left: -2px !important;
    border-radius: 7px 10px 10px 7px;
  }

  body.task-mail.action-compose #toolbar-menu a:is(.save, .attach, .signature, .responses, .spellcheck, .dropdown):not(.disabled):is(:hover, :focus-visible),
  body.task-mail.action-compose #toolbar-menu a[aria-expanded="true"] {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose #toolbar-menu a:focus-visible {
    outline: 2px solid var(--cm-color-focus) !important;
    outline-offset: -2px;
  }

  body.task-mail.action-compose #toolbar-menu a:is(.disabled, [aria-disabled="true"]) {
    opacity: 0.4;
    background: transparent !important;
  }

  body.task-mail.action-compose #toolbar-menu a .inner {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }

  /* Keep native commands; exchange only their decorative font glyphs. */
  body.task-mail.action-compose #toolbar-menu a:is(.save, .attach, .signature, .responses, .spellcheck, .dropdown)::before {
    display: block !important;
    float: none !important;
    flex: 0 0 16px;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: var(--cm-compose-toolbar-icon) center / contain no-repeat;
    mask: var(--cm-compose-toolbar-icon) center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
    line-height: 1 !important;
  }

  body.task-mail.action-compose #toolbar-menu a.save {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/save.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.attach {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/paperclip.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.signature {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/signature.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.responses {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/message-square.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.spellcheck {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/spell-check.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.dropdown {
    --cm-compose-toolbar-icon: url("../assets/icons/ui/lucide/regular/chevron-down.svg");
  }

  body.task-mail.action-compose #toolbar-menu a.dropdown::before {
    width: 13px !important;
    height: 13px !important;
    flex-basis: 13px;
  }

  body.task-mail.action-compose #compose-content {
    color: var(--cm-color-text);
    background: var(--cm-color-surface) !important;
  }

  /* D4i: fit the native writer to the space below the actual headers.
     Keep the form scrollable when short windows or expanded headers need it. */
  body.task-mail.action-compose #compose-content > .scroller {
    display: flex;
    flex: 1 1 0%;
    flex-direction: column;
    min-height: 0;
    padding: 8px clamp(16px, 2.1vw, 28px) 0;
  }

  body.task-mail.action-compose #compose-headers {
    flex: 0 0 auto;
    width: 100%;
    max-width: 960px;
    align-self: center;
    margin-bottom: 12px;
    --cm-compose-label-width: 60px;
  }

  /* Keep the usual four headers compact, but reserve room for the native
     translated long labels when any optional long header is visible. */
  body.task-mail.action-compose #compose-headers:has(:is(#compose_bcc, #compose_replyto, #compose_followupto):not(.hidden)) {
    --cm-compose-label-width: 128px;
  }

  body.task-mail.action-compose #composebodycontainer {
    box-sizing: border-box;
    flex: 1 0 180px;
    min-height: 180px;
    width: 100%;
    max-width: 960px;
    align-self: center;
    /* One shared frame stays outside the native plain-mode toolbar overlay. */
    border: 1px solid #dedede;
    border-radius: 10px;
    background: #ffffff;
  }

  /* Roundcube mirrors iframe focus on .tox-tinymce.focused; CSS focus-within
     alone does not cross the editing document boundary. */
  body.task-mail.action-compose #composebodycontainer:focus-within,
  body.task-mail.action-compose #composebodycontainer:has(> .tox-tinymce.focused) {
    border-color: #525252;
    box-shadow: 0 0 0 3px rgb(82 82 82 / 12%);
  }

  html:not(.dark-mode) body.task-mail.action-compose #composebodycontainer:focus-within,
  html:not(.dark-mode) body.task-mail.action-compose #composebodycontainer:has(> .tox-tinymce.focused) {
    box-shadow: inset 0 0 0 1px #525252;
  }

  body.task-mail.action-compose #composebodycontainer > :is(#composebody, .tox-tinymce) {
    height: 100% !important;
  }

  body.task-mail.action-compose :is(#compose-content, #layout-sidebar) > .scroller {
    scrollbar-color: color-mix(in srgb, var(--cm-color-text-muted) 55%, var(--cm-color-surface)) var(--cm-color-surface);
  }

  body.task-mail.action-compose #compose-headers .col-form-label {
    color: var(--cm-color-text-muted);
    font-size: 12px;
    font-weight: 450;
  }

  /* Avoid the inherited 2/10 split and excessive short-label whitespace. */
  body.task-mail.action-compose #compose-headers .form-group.row {
    display: grid;
    grid-template-columns: var(--cm-compose-label-width) minmax(0, 1fr);
    column-gap: 8px;
    align-items: start;
    margin-bottom: 0;
    padding-block: 3px;
    border-bottom: 1px solid color-mix(in srgb, var(--cm-color-border) 72%, transparent);
    transition: border-color var(--cm-motion-fast) ease;
  }

  body.task-mail.action-compose #compose-headers .form-group.row:focus-within {
    border-bottom-color: var(--cm-color-focus);
  }

  body.task-mail.action-compose #compose-headers .form-group.row:focus-within > .col-form-label {
    color: var(--cm-color-accent-strong);
  }

  body.task-mail.action-compose #compose-headers .form-group.row > :is(.col-form-label, .col-10) {
    flex: none;
    width: auto;
    max-width: none;
    min-width: 0;
    padding-inline: 0;
  }

  body.task-mail.action-compose #compose-headers .form-group.row > .col-form-label {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding-block: 0;
    line-height: 1.45;
    hyphens: none;
    overflow-wrap: anywhere;
  }

  /* Keep Roundcube's native select and recipient-chip behavior intact. */
  body.task-mail.action-compose #compose-headers :is(select.form-control, ul.recipient-input, #compose-subject) {
    box-sizing: border-box;
    min-height: 34px;
    font-size: 13px;
    line-height: 20px;
    color: var(--cm-color-text) !important;
    border: 1px solid transparent !important;
    border-radius: 0 !important;
    background-color: transparent !important;
    box-shadow: none !important;
  }

  body.task-mail.action-compose #compose-headers :is(select.form-control, #compose-subject) {
    height: 34px;
    padding-block: 3px;
    padding-left: 0;
  }

  /* Preserve native wrapping and input sizing; only normalize vertical rhythm. */
  body.task-mail.action-compose #compose-headers ul.recipient-input {
    height: auto;
    padding: 3px 0;
    row-gap: 4px;
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.input {
    display: flex;
    align-items: center;
    min-height: 26px;
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.input input {
    box-sizing: border-box;
    height: 26px;
    margin-top: 0;
    padding-block: 2px;
    font-size: 13px;
    line-height: 20px;
  }

  body.task-mail.action-compose #compose-headers :is(select.form-control:focus, ul.recipient-input.focus, ul.recipient-input:focus-within, #compose-subject:focus) {
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none;
  }

  /* Roundcube owns recipient insertion/removal. Only the completed chip's
     visual language is adapted; native invalid/error states are left alone. */
  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient:not(.invalid, .error) {
    box-sizing: border-box;
    min-width: 0;
    max-width: min(100%, 360px);
    min-height: 26px;
    height: auto;
    margin: 0 4px 0 0;
    padding: 0 4px 0 8px;
    color: var(--cm-color-text) !important;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--cm-color-accent-soft);
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient:not(.invalid, .error):is(:hover, :focus-within) {
    border-color: color-mix(in srgb, var(--cm-color-accent) 40%, transparent);
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient .name {
    min-width: 0;
    padding: 2px 0;
    color: inherit !important;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    text-overflow: ellipsis;
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient a.remove {
    box-sizing: border-box;
    display: grid;
    flex: 0 0 24px;
    align-self: center;
    align-items: center;
    justify-items: center;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    color: var(--cm-color-text-muted) !important;
    border-radius: 6px;
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient a.remove:is(:hover, :focus-visible) {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-surface);
  }

  body.task-mail.action-compose #compose-headers ul.recipient-input li.recipient a.remove::before {
    display: block !important;
    width: 14px;
    height: 14px;
    margin: 0 !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: url("../assets/icons/ui/lucide/regular/x.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/x.svg") center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
  }

  /* Native identity/recipient/header commands keep their handlers and names. */
  body.task-mail.action-compose #compose-headers .input-group-append {
    align-self: flex-start;
  }

  body.task-mail.action-compose #compose-headers .input-group-append > a.input-group-text.icon {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    min-height: 34px;
    padding: 0 !important;
    color: var(--cm-color-text-muted) !important;
    border: 0 !important;
    border-radius: 7px !important;
    background: transparent !important;
  }

  body.task-mail.action-compose #compose-headers .input-group-append > a.input-group-text.icon:hover {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose #compose-headers .input-group-append > a.input-group-text.icon:focus-visible {
    z-index: 1;
    outline: 2px solid var(--cm-color-focus);
    outline-offset: -2px;
  }

  body.task-mail.action-compose #compose-headers .input-group-append > a.input-group-text.icon::before {
    display: block !important;
    flex: 0 0 16px;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: var(--cm-compose-header-icon) center / contain no-repeat;
    mask: var(--cm-compose-header-icon) center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
    line-height: 1 !important;
  }

  body.task-mail.action-compose #compose-headers a.input-group-text.icon.edit {
    --cm-compose-header-icon: url("../assets/icons/ui/lucide/regular/pencil.svg");
  }

  body.task-mail.action-compose #compose-headers a.input-group-text.icon.add.recipient {
    --cm-compose-header-icon: url("../assets/icons/ui/lucide/regular/users-round.svg");
  }

  body.task-mail.action-compose #compose-headers a.input-group-text.icon.add:not(.recipient) {
    --cm-compose-header-icon: url("../assets/icons/ui/lucide/regular/plus.svg");
  }

  body.task-mail.action-compose #compose-headers a.input-group-text.icon.delete {
    --cm-compose-header-icon: url("../assets/icons/ui/lucide/regular/trash-2.svg");
  }

  /* The editable canvas stays white and dark-inked in either app theme. */
  body.task-mail.action-compose #composebody {
    color: #262626 !important;
    padding-inline: 12px;
    border: 0 !important;
    border-radius: 9px !important;
    background: #ffffff !important;
  }

  body.task-mail.action-compose #composebodycontainer .editor-toolbar {
    color: #606060;
    border-bottom: 0 !important;
    border-radius: 8px 8px 0 0;
    background: #ffffff !important;
  }

  body.task-mail.action-compose #composebodycontainer .editor-toolbar a.mce-i-html {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 2px 4px;
    color: #606060;
    border-radius: 7px;
  }

  body.task-mail.action-compose #composebodycontainer .editor-toolbar a.mce-i-html:hover {
    color: #343434;
    background: #eeeeee;
  }

  body.task-mail.action-compose #composebodycontainer .editor-toolbar a.mce-i-html::before {
    display: block !important;
    width: 17px;
    height: 17px;
    margin: 0 !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: url("../assets/icons/ui/lucide/regular/code-xml.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/code-xml.svg") center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
  }

  body.task-mail.action-compose #composebody:focus {
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none;
  }

  body.task-mail.action-compose #compose-attachments {
    box-sizing: border-box;
    margin: 8px 18px 0 !important;
    padding: 0 0 18px !important;
    color: var(--cm-color-text-muted);
    border: 0 !important;
    border-bottom: 1px solid var(--cm-color-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    text-align: left !important;
  }

  /* Keep the native drop target and controls, with one quiet section divider. */
  body.task-mail.action-compose #compose-attachments.droptarget.active {
    outline: 1px dashed var(--cm-color-focus);
    outline-offset: 4px;
  }

  body.task-mail.action-compose #compose-attachments.droptarget.hover {
    outline: 2px solid var(--cm-color-focus);
    outline-offset: 4px;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose #compose-attachments::after {
    display: none !important;
    content: none !important;
  }

  body.task-mail.action-compose #compose-attachments .upload-form {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
  }

  body.task-mail.action-compose #compose-attachments .hint {
    order: 1;
    margin: 8px 4px 0 !important;
    color: var(--cm-color-text-muted);
    font-size: 11px;
    line-height: 1.4;
    text-align: left;
  }

  body.task-mail.action-compose #compose-attachments button.attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    margin: 0 !important;
    padding: 6px 8px !important;
    color: var(--cm-color-accent-strong) !important;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    background: var(--cm-color-accent-soft) !important;
    box-shadow: none !important;
  }

  body.task-mail.action-compose #compose-attachments button.attach:hover {
    border-color: color-mix(in srgb, var(--cm-color-accent) 30%, transparent) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose #compose-attachments button.attach:focus-visible {
    outline: 2px solid var(--cm-color-focus);
    outline-offset: 2px;
  }

  body.task-mail.action-compose #attachment-list:not(:empty) {
    margin: 14px 0 0 !important;
    padding: 0 !important;
    border-top: 0;
  }

  /* Limit the row treatment to completed native rows; upload-progress and
     error rows retain Elastic's own lifecycle presentation. */
  body.task-mail.action-compose #attachment-list li:has(> a.filename) {
    box-sizing: border-box;
    display: block !important;
    position: relative;
    min-height: 56px;
    margin: 0 0 4px !important;
    padding: 7px 7px 30px !important;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
  }

  body.task-mail.action-compose #attachment-list li:has(> a.filename):last-child {
    margin-bottom: 0 !important;
  }

  body.task-mail.action-compose #attachment-list li:has(> a.filename):is(:hover, :focus-within) {
    border-color: transparent;
    background: var(--cm-color-surface-hover);
  }

  body.task-mail.action-compose #attachment-list li:has(> a.filename)::before {
    display: block !important;
    position: absolute;
    top: 10px;
    left: 8px;
    width: 16px;
    height: 16px;
    content: "" !important;
    background-color: var(--cm-color-text-muted);
    -webkit-mask: url("../assets/icons/ui/lucide/regular/file-text.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/file-text.svg") center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
  }

  body.task-mail.action-compose #attachment-list li.image:has(> a.filename)::before {
    -webkit-mask-image: url("../assets/icons/ui/lucide/regular/image.svg");
    mask-image: url("../assets/icons/ui/lucide/regular/image.svg");
  }

  body.task-mail.action-compose #attachment-list li a.filename {
    box-sizing: border-box;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-width: 0;
    padding: 0 0 0 23px !important;
    color: var(--cm-color-text) !important;
    line-height: 1.35;
    overflow: visible !important;
    text-decoration: none;
  }

  body.task-mail.action-compose #attachment-list li a.filename:hover .attachment-name {
    color: var(--cm-color-accent-strong);
  }

  body.task-mail.action-compose #attachment-list li .attachment-name {
    display: -webkit-box;
    overflow: hidden;
    color: inherit !important;
    font-size: 11.5px;
    font-weight: 550;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.task-mail.action-compose #attachment-list li .attachment-size {
    display: block;
    position: absolute;
    bottom: 8px;
    left: 31px;
    max-width: calc(100% - 94px);
    margin: 0;
    padding: 0;
    color: var(--cm-color-text-muted) !important;
    font-size: 10.5px;
    white-space: nowrap;
  }

  body.task-mail.action-compose #attachment-list li a:is(.dropdown, .delete) {
    display: grid !important;
    position: absolute !important;
    top: auto !important;
    bottom: 3px;
    align-items: center;
    justify-items: center;
    width: 25px !important;
    height: 25px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--cm-color-text-muted) !important;
    border-radius: 6px;
    z-index: 1;
  }

  body.task-mail.action-compose #attachment-list li a.dropdown {
    right: 33px;
  }

  body.task-mail.action-compose #attachment-list li a.delete {
    right: 5px;
  }

  body.task-mail.action-compose #attachment-list li a:is(.dropdown, .delete):hover {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft);
  }

  body.task-mail.action-compose #attachment-list li a.delete:hover {
    color: var(--cm-color-danger) !important;
    background: var(--cm-color-danger-soft);
  }

  body.task-mail.action-compose #attachment-list li a:is(.filename, .dropdown, .delete):focus-visible {
    outline: 2px solid var(--cm-color-focus);
    outline-offset: 1px;
  }

  body.task-mail.action-compose #attachment-list li a:is(.dropdown, .delete)::before {
    display: block !important;
    width: 14px;
    height: 14px;
    margin: 0 !important;
    content: "" !important;
    background-color: currentColor;
    font-family: inherit !important;
    font-size: 0 !important;
  }

  body.task-mail.action-compose #attachment-list li a.dropdown::before {
    -webkit-mask: url("../assets/icons/ui/lucide/regular/chevron-down.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/chevron-down.svg") center / contain no-repeat;
  }

  body.task-mail.action-compose #attachment-list li a.delete::before {
    -webkit-mask: url("../assets/icons/ui/lucide/regular/trash-2.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/trash-2.svg") center / contain no-repeat;
  }

  body.task-mail.action-compose #compose-options {
    color: var(--cm-color-text);
    padding: 14px 18px !important;
  }

  /* Elastic's half-width columns leave only 105px for long native labels. */
  body.task-mail.action-compose #compose-options > .form-group.form-check {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    column-gap: 8px;
    align-items: center;
    min-height: 32px;
    margin: 0 0 4px;
    padding: 0;
  }

  body.task-mail.action-compose #compose-options > .form-group.form-check > .col-form-label {
    width: auto;
    max-width: none;
    padding: 0;
    color: var(--cm-color-text-muted);
    font-size: 12px;
    line-height: 1.4;
    hyphens: none;
  }

  body.task-mail.action-compose #compose-options > .form-group.form-check > .col-6.form-check {
    width: 42px;
    max-width: none;
    padding: 0;
    justify-self: end;
  }

  body.task-mail.action-compose #compose-options > .form-group:not(.form-check) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(100px, 45%);
    column-gap: 8px;
    align-items: center;
    margin: 8px 0 0;
    padding: 0;
  }

  body.task-mail.action-compose #compose-options > .form-group:not(.form-check) > .col-form-label,
  body.task-mail.action-compose #compose-options > .form-group:not(.form-check) > .col-6 {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  body.task-mail.action-compose #compose-options > .form-group:not(.form-check) > .col-form-label {
    color: var(--cm-color-text-muted);
    font-size: 12px;
    line-height: 1.4;
    /* Short UI labels should wrap at spaces, not split translated words. */
    hyphens: none;
  }

  body.task-mail.action-compose #compose-options select.form-control {
    box-sizing: border-box;
    width: 100%;
    height: 32px;
    min-height: 32px;
    padding: 4px 22px 4px 6px;
    font-size: 12px;
    color: var(--cm-color-text);
    border: 1px solid transparent;
    border-radius: 6px;
    background-color: transparent;
  }

  body.task-mail.action-compose #compose-options select.form-control:hover {
    background-color: var(--cm-color-surface-hover);
  }

  body.task-mail.action-compose #compose-options select.form-control:focus-visible {
    border-color: var(--cm-color-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-color-focus) 15%, transparent);
  }

  /* TinyMCE chrome only. Preserve measured geometry, overflow engine, native
     tooltips and message iframe. D4p registers a bounded Lucide SVG subset. */
  body.task-mail.action-compose #composebodycontainer .tox-tinymce {
    border: 0 !important;
    border-radius: 9px !important;
    background: #ffffff;
    box-shadow: none !important;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow) {
    background: #ffffff !important;
  }

  body.task-mail.action-compose #composebodycontainer .tox-editor-header {
    box-shadow: none !important;
  }

  body.task-mail.action-compose #composebodycontainer .tox-toolbar__group {
    border-color: transparent !important;
    padding-inline: 6px !important;
  }

  /* Space independent controls, never the two halves of a split button. */
  body.task-mail.action-compose #composebodycontainer .tox-toolbar__group > :is(.tox-tbtn, .tox-split-button) {
    margin-inline: 2px !important;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-tbtn, .tox-split-button) {
    color: #606060 !important;
    border-radius: 7px !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.task-mail.action-compose #composebodycontainer .tox-tbtn svg:not(.lucide) {
    fill: currentColor !important;
  }

  body.task-mail.action-compose #composebodycontainer .tox-tbtn__icon-wrap svg {
    /* Keep the native 24 px canvas and click target; paint an 18 px glyph. */
    width: 24px;
    height: 24px;
    transform: scale(0.75);
    transform-origin: center;
  }

  /* The native menu portal is a BODY child, not part of the writing iframe.
     Never replace its position/max-height/overflow or the color swatches. */
  body.task-mail.action-compose .tox-tinymce-aux .tox-menu {
    color: var(--cm-color-text);
    border: 1px solid var(--cm-color-border) !important;
    border-radius: 12px !important;
    background: var(--cm-color-surface) !important;
    box-shadow: var(--cm-shadow-popover) !important;
    font-family: var(--cm-font-sans);
    font-size: 13px;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__group {
    padding-block: 4px;
    border-color: var(--cm-color-border) !important;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__item {
    min-height: 32px;
    margin: 2px 6px;
    box-sizing: border-box;
    padding: 4px 10px;
    color: var(--cm-color-text) !important;
    border-radius: 7px;
    background: transparent !important;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__item:not([aria-disabled="true"]):is(:hover, .tox-collection__item--active) {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__item--enabled {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__item:focus-visible {
    outline: 2px solid var(--cm-color-focus);
    outline-offset: -2px;
  }

  body.task-mail.action-compose .tox-tinymce-aux .tox-collection--list .tox-collection__item[aria-disabled="true"] {
    color: var(--cm-color-text-muted) !important;
    background: transparent !important;
  }

  body.task-mail.action-compose .tox-tinymce-aux :is(.tox-collection__item-icon, .tox-collection__item-caret, .tox-collection__item-checkmark) {
    color: inherit;
  }

  body.task-mail.action-compose .tox-tinymce-aux :is(.tox-collection__item-icon, .tox-collection__item-caret, .tox-collection__item-checkmark) svg {
    fill: currentColor;
  }

  body.task-mail.action-compose #composebodycontainer .tox-tbtn__select-label {
    font-family: var(--cm-font-sans);
    font-size: 12px;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-tbtn, .tox-split-button):not([aria-disabled="true"]):hover {
    color: #343434 !important;
    background: #eeeeee !important;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-tbtn--enabled, .tox-tbtn[aria-pressed="true"], .tox-split-button[aria-expanded="true"]) {
    color: #343434 !important;
    background: #e7e7e7 !important;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-tbtn, .tox-split-button):focus-visible {
    outline: 2px solid #525252 !important;
    outline-offset: -2px;
  }

  body.task-mail.action-compose #composebodycontainer :is(.tox-tbtn--disabled, .tox-tbtn[aria-disabled="true"], .tox-split-button[aria-disabled="true"]) {
    color: #999999 !important;
    background: transparent !important;
  }

  body.task-mail.action-compose #composebodycontainer .editor-toolbar a.mce-i-html:focus-visible {
    outline: 2px solid #525252;
    outline-offset: -2px;
  }

  body.task-mail.action-compose #compose-content button.send {
    min-height: 40px;
    padding-inline: 16px;
    color: var(--cm-color-on-action) !important;
    font-weight: 600;
    border: 1px solid var(--cm-color-accent-strong) !important;
    border-radius: 10px !important;
    background: var(--cm-color-accent-strong) !important;
  }

  body.task-mail.action-compose #compose-content .formbuttons {
    box-sizing: border-box;
    width: 100%;
    max-width: 1016px;
    margin-inline: auto;
    padding: 12px clamp(16px, 2.1vw, 28px);
  }

  body.task-mail.action-compose #compose-content button.send:is(:hover, :focus-visible) {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-color-focus) 18%, transparent);
  }

  body.task-mail.action-compose #compose-content .formbuttons a.extwin {
    min-height: 36px;
    padding: 7px 10px;
    color: var(--cm-color-text-muted) !important;
    font-size: 12.5px;
    font-weight: 550;
    border: 0 !important;
    border-radius: 9px;
  }

  body.task-mail.action-compose #compose-content .formbuttons a.extwin:is(:hover, :focus-visible) {
    color: var(--cm-color-accent-strong) !important;
    background: var(--cm-color-accent-soft) !important;
  }

  body.task-mail.action-compose #compose-content .formbuttons a.extwin:focus-visible {
    outline: 2px solid var(--cm-color-focus);
    outline-offset: -2px;
  }

  body.task-mail.action-compose #compose-content .formbuttons a.extwin::before {
    display: inline-block !important;
    width: 16px;
    height: 16px;
    margin: 0 7px 0 0 !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: url("../assets/icons/ui/lucide/regular/external-link.svg") center / contain no-repeat;
    mask: url("../assets/icons/ui/lucide/regular/external-link.svg") center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
    vertical-align: -3px;
  }

  body.task-mail.action-compose :is(#compose-attachments button.attach, #compose-content button.send)::before {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    margin-right: 7px !important;
    content: "" !important;
    background-color: currentColor;
    -webkit-mask: var(--cm-compose-button-icon) center / contain no-repeat;
    mask: var(--cm-compose-button-icon) center / contain no-repeat;
    font-family: inherit !important;
    font-size: 0 !important;
    line-height: 1 !important;
    vertical-align: -3px;
  }

  body.task-mail.action-compose #compose-attachments button.attach {
    --cm-compose-button-icon: url("../assets/icons/ui/lucide/regular/paperclip.svg");
  }

  body.task-mail.action-compose #compose-content button.send {
    --cm-compose-button-icon: url("../assets/icons/ui/lucide/regular/send.svg");
  }
}
