@layer components {
  /* « Nouveau message »: 640 × 516 over the voile; a full-screen sheet on phones. */
  .new-message {
    width: min(640px, calc(100vw - 32px)); height: min(516px, calc(100dvh - 32px)); max-width: none; max-height: none;
    padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden;
    background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-lifted); font-size: 14px;
  }
  .new-message[open] { display: flex; flex-direction: column; }
  .new-message::backdrop { background: var(--scrim); }
  .new-message-search {
    display: flex; align-items: center; gap: 10px; flex: none; padding: 14px 14px 14px 16px; min-height: 52px; box-sizing: border-box;
    border-bottom: 1px solid var(--border); color: var(--muted-foreground);
  }
  .new-message-search { flex-wrap: wrap; }
  .new-message-search svg { flex: none; }
  .new-message-to { flex: none; color: var(--muted-foreground); font-size: 14px; }
  .new-message-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
  .new-message-pills[hidden] { display: none; }
  .new-message-pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px;
    background: var(--jx-accent-soft); border: 1px solid var(--jx-accent-line); color: var(--foreground); font-size: 14px;
  }
  .new-message-pill-remove {
    display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0;
    border-radius: 999px; background: transparent; color: var(--muted-foreground); font: inherit; cursor: pointer;
  }
  .new-message-pill-remove:is(:hover, :focus-visible) { background: var(--muted); color: var(--foreground); }
  .new-message-pill-remove:focus-visible { outline: 2px solid var(--jx-accent); }
  .new-message-filters { display: flex; flex: none; gap: 6px; padding: 8px 14px 0; }
  .new-message-filter {
    padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: transparent;
    color: var(--muted-foreground); font: inherit; font-size: 13px; cursor: pointer;
  }
  .new-message-filter[hidden] { display: none; }
  .new-message-filter[aria-pressed=true] { background: var(--jx-accent-soft); border-color: var(--jx-accent-line); color: var(--foreground); }
  .new-message-filter:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: 1px; }
  .new-message-help { flex: none; margin: 0; padding: 8px 16px 0; color: var(--muted-foreground); font-size: 13px; }
  .new-message-refusal { flex: none; margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--jx-no); }
  .new-message-refusal[hidden], .new-message-footer[hidden] { display: none; }
  .new-message-footer {
    display: flex; flex: none; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .new-message-count { flex: 1; margin: 0; min-width: 0; color: var(--foreground); font-size: 13px; }
  .new-message-input {
    flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--foreground);
    font: inherit; font-size: 16px; box-shadow: none;
  }
  .new-message-input::placeholder { color: var(--muted-foreground); opacity: 1; }
  .new-message-esc, .new-message kbd {
    display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border: 1px solid var(--border);
    border-radius: 6px; background: var(--surface); color: var(--muted-foreground); font: inherit; font-size: 13px;
  }
  .new-message-esc { cursor: pointer; }
  .new-message-esc:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: 1px; }
  .new-message-results { display: block; flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
  .new-message-heading { padding: 8px 8px 4px; color: var(--muted-foreground); font-size: 13px; font-weight: 500; }
  .new-message-option {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
  }
  .new-message-option:hover { background: var(--muted); }
  .new-message-option[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
  .new-message-option[aria-disabled=true]:hover { background: none; }
  .new-message-option[data-active] { background: var(--jx-accent-soft); outline: 1px solid var(--jx-accent-line); outline-offset: -1px; }
  .new-message-check { display: none; flex: none; margin-left: auto; color: var(--jx-accent); }
  .new-message-option[aria-selected=true] .new-message-check { display: inline-flex; }
  .new-message-agent-icon {
    display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px;
    border-radius: 999px; color: var(--agent-color); background: color-mix(in oklch, var(--agent-color) 14%, transparent);
  }
  .new-message-name { min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  .new-message-meta { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-foreground); }
  .new-message-enter {
    display: none; flex: none; margin-left: auto; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px;
    background: var(--background); color: var(--muted-foreground);
  }
  .new-message-option[data-active] .new-message-enter { display: inline-flex; }
  .new-message-option[aria-selected=true] .new-message-enter { display: none; }
  .new-message-none { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 64px 24px; text-align: center; }
  .new-message-none-title { margin: 0; font-weight: 500; }
  .new-message-none-hint { margin: 0; color: var(--muted-foreground); }
  .new-message-error {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--jx-no);
  }
  .new-message-error[hidden] { display: none; }
  .new-message-hints {
    display: flex; flex: none; gap: 14px; padding: 8px 14px; min-height: 40px; box-sizing: border-box; border-top: 1px solid var(--border);
    background: var(--surface); color: var(--muted-foreground); font-size: 13px;
  }
  .new-message-hints > span { display: inline-flex; align-items: center; gap: 6px; }

  @media (prefers-reduced-motion: no-preference) {
    .new-message[open] { animation: new-message-in 150ms var(--ease-out); }
    @keyframes new-message-in { from { opacity: 0; } }
  }

  /* Phones: the dialog fills the screen like a sheet, clear of the home indicator. */
  @media (max-width: 767px) {
    .new-message {
      width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; max-width: 100vw; max-height: 100dvh;
    }
    .new-message-search { padding-top: env(safe-area-inset-top, 0px); }
    .new-message-esc { min-height: var(--tap); }
    .new-message-option { min-height: var(--tap); }
    .new-message-pill-remove { width: var(--tap); height: var(--tap); }
    .new-message-filter { min-height: var(--tap); }
    .new-message-hints { padding-bottom: calc(10px + var(--safe-bottom)); }
    @media (prefers-reduced-motion: no-preference) {
      .new-message[open] { animation-name: new-message-rise; }
      @keyframes new-message-rise { from { opacity: 0; transform: translateY(8px); } }
    }
  }
}
