@layer components {
  /* The formatting the rich field shows without its Markdown symbols: as the message will read once sent. */
  .composer-input--rich :is(ul, ol) { margin: 2px 0; padding-left: 22px; }
  .composer-input--rich li > p { margin: 0; }
  .composer-input--rich blockquote { margin: 2px 0; padding-left: 10px; border-left: 2px solid var(--border); color: var(--muted-foreground); }
  .composer-input--rich code { padding: 1px 4px; border-radius: 4px; background: var(--muted); font-family: var(--font-mono); font-size: 0.92em; }
  .composer-input--rich pre { margin: 2px 0; padding: 6px 8px; border-radius: var(--radius-md); background: var(--muted); white-space: pre-wrap; }
  .composer-input--rich pre code { padding: 0; background: none; }
  .composer-input--rich a { color: var(--jx-accent); text-decoration: underline; text-underline-offset: 2px; }

  /* The bar, under the field as in Slack. */
  .composer-format {
    display: flex; flex-wrap: wrap; align-items: center; gap: 1px; margin: 6px -4px 0; padding-top: 4px;
    border-top: 1px solid var(--border);
  }
  .composer-format[hidden] { display: none; }
  .composer-format-tool {
    display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0;
    border-radius: var(--radius-sm); background: transparent; color: var(--muted-foreground); cursor: pointer;
  }
  .composer-format-tool:is(:hover, :active) { background: var(--muted); color: var(--foreground); }
  /* Pressed: a tint and an underline, not the tint alone. */
  .composer-format-tool[aria-pressed="true"] {
    background: color-mix(in oklch, var(--primary) 14%, transparent); color: var(--foreground); box-shadow: inset 0 -2px 0 var(--primary);
  }
  .composer-format-tool:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: 1px; }
  .composer-format-separator { flex: none; width: 1px; height: 18px; margin-inline: 4px; background: var(--border); }
  .composer-format-toggle .composer-format-glyph { font-weight: 600; letter-spacing: -0.02em; }
  .composer-format-toggle[aria-expanded="true"] { background: color-mix(in oklch, var(--primary) 14%, transparent); color: var(--foreground); }
  .message-edit .composer-format { margin: 0; padding-top: 0; border-top: 0; }

  /* The link field, over the composer. */
  .composer-link {
    position: absolute; left: 8px; bottom: calc(100% + 8px); z-index: 20; display: grid; gap: 4px;
    width: min(340px, calc(100% - 16px)); padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--popover, var(--card)); color: var(--foreground); box-shadow: var(--shadow-float);
  }
  .composer-link[hidden] { display: none; }
  .message-edit { position: relative; }
  .composer-link-title { margin: 0 0 4px; font-weight: 600; }
  .composer-link-label { font-weight: 500; }
  .composer-link-input { width: 100%; }
  .composer-link-error { margin: 0; color: var(--jx-no); font-size: var(--text-meta); }
  .composer-link-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 8px; }
  .composer-link-remove { margin-right: auto; color: var(--jx-no); }

  .composer-format-notice {
    display: flex; align-items: center; gap: 6px; margin: 6px 0 0; color: var(--muted-foreground); font-size: var(--text-meta);
  }
  .composer-format-notice[hidden] { display: none; }

  @media (pointer: coarse) {
    /* The foot keeps only icons on a phone; « Aa » is its own glyph, so it stays drawn. */
    .composer-format-toggle { justify-content: center; align-items: center; }
    .composer-format-toggle > .composer-format-glyph {
      position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: 15px;
    }
    /* Above the keyboard, one line that scrolls, finger-sized. */
    .composer-format { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -10px; padding-inline: 6px; }
    .composer-format-tool { flex: none; width: var(--tap); height: var(--tap); }
    .composer-format-tool svg { width: 20px; height: 20px; }
    /* A sheet from the bottom, as the phone's other menus. */
    .composer-link {
      position: fixed; inset: auto 0 0 0; width: auto; padding: 14px 16px max(20px, var(--safe-bottom));
      border-radius: 18px 18px 0 0; gap: 6px;
    }
    .composer-link-input { min-height: var(--tap); font-size: max(16px, 1em); }
    .composer-link-actions .button { min-height: var(--tap); flex: 1; }
    .composer-link-remove { flex-basis: 100%; }
  }
}
