@layer aster.elements {
  aster-rich-text { display: block; min-inline-size: 0; }
  .aster-rich-text {
    border: 1px solid var(--aster-rule);
    border-radius: var(--aster-r-ctl);
    background: var(--aster-surface);
    color: var(--aster-text);
  }
  .aster-rich-text[data-invalid] { border-color: var(--aster-negative); }
  .aster-rich-text[data-disabled] { background: var(--aster-sunk); color: var(--aster-text-2); }
  .aster-rich-text-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    padding: 4px 6px;
    border-bottom: 1px solid var(--aster-rule);
  }
  .aster-rich-text-actions button {
    display: grid;
    place-items: center;
    inline-size: 30px;
    block-size: 30px;
    border: 1px solid transparent;
    border-radius: var(--aster-r-ctl);
    background: transparent;
    color: var(--aster-text);
  }
  .aster-rich-text-actions button:enabled { cursor: pointer; }
  .aster-rich-text-actions button:disabled { opacity: .45; }
  .aster-rich-text-actions button:hover:enabled { background: var(--aster-sunk); }
  .aster-rich-text-actions button[aria-pressed="true"] { background: var(--aster-accent-soft); border-color: var(--aster-rule); }
  .aster-rich-text-actions button:focus-visible, .aster-rich-text-input [role="textbox"]:focus-visible {
    outline: 2px solid var(--aster-focus);
    outline-offset: -2px;
  }
  .aster-rich-text-actions svg {
    inline-size: 16px;
    block-size: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.45;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .aster-rich-text-action-group {
    display: flex;
    gap: 3px;
    padding-inline-end: 5px;
    margin-inline-end: 2px;
    border-inline-end: 1px solid var(--aster-rule);
  }
  button.aster-rich-text-style {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    inline-size: auto;
    min-inline-size: 7.5rem;
    padding-inline: 7px 4px;
    border-color: var(--aster-rule);
  }
  .aster-rich-text-input [role="textbox"] {
    min-block-size: 5rem;
    padding: 8px 10px;
    overflow-wrap: anywhere;
    font: inherit;
    line-height: 1.55;
  }
  .aster-rich-text-input :is(code, pre) { font-family: ui-monospace, monospace; }
  .aster-rich-text-input pre { max-inline-size: 100%; overflow-x: auto; overflow-wrap: normal; }
  .aster-rich-text-input [role="textbox"] > :first-child { margin-block-start: 0; }
  .aster-rich-text-input [role="textbox"] > :last-child { margin-block-end: 0; }
  .aster-rich-text-error { margin: 6px 10px; color: var(--aster-negative); }
  @media (forced-colors: active) {
    .aster-rich-text-actions button[aria-pressed="true"] { border-color: Highlight; }
    .aster-rich-text-actions button:focus-visible, .aster-rich-text-input [role="textbox"]:focus-visible { outline-color: Highlight; }
  }
}
