@layer components {
  /* Confirmation dialog (lib/confirm_dialog.js), after the design system's alert dialog. */
  .confirm-dialog {
    /* Darker than --jx-no in dark mode so white button text keeps 4.5:1. */
    --confirm-danger: light-dark(oklch(0.50 0.18 25), oklch(0.52 0.18 25));
    width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-xl);
    background: var(--popover); color: var(--popover-foreground);
    box-shadow: 0 16px 40px -12px light-dark(oklch(0 0 0 / 0.25), oklch(0 0 0 / 0.6)), var(--shadow-sm);
  }
  .confirm-dialog::backdrop { background: oklch(0 0 0 / 0.45); }
  .confirm-dialog:not([open]) { display: none; }
  .confirm-dialog-body { display: flex; flex-direction: column; gap: 8px; padding: 24px; }
  .confirm-dialog-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; text-wrap: balance; }
  .confirm-dialog-message { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted-foreground); }
  .confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
  .confirm-dialog[data-variant="danger"] .confirm-dialog-accept {
    background: var(--confirm-danger); color: oklch(0.99 0 0); border-color: transparent;
  }
  .confirm-dialog[data-variant="danger"] .confirm-dialog-accept:hover { background: color-mix(in oklch, var(--confirm-danger) 88%, black); }
  .confirm-dialog[data-variant="danger"] .confirm-dialog-accept:focus-visible {
    border-color: var(--jx-no); box-shadow: 0 0 0 3px color-mix(in oklch, var(--jx-no) 45%, transparent);
  }

  /* Phones: an action sheet at the bottom, its buttons across the width, the choice above « Annuler ». */
  @media (max-width: 767px) {
    .confirm-dialog {
      width: 100%; max-width: none; margin: auto 0 0; border-width: 1px 0 0;
      border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    .confirm-dialog-body { padding-bottom: calc(24px + var(--safe-bottom)); }
    .confirm-dialog-actions { flex-direction: column-reverse; }
    .confirm-dialog-actions .button { width: 100%; height: var(--tap); }
  }
  @media (prefers-reduced-motion: no-preference) {
    .confirm-dialog[open] { animation: confirm-dialog-in 0.14s ease-out; }
    .confirm-dialog[open]::backdrop { animation: confirm-dialog-fade 0.14s ease-out; }
  }
  @keyframes confirm-dialog-in { from { opacity: 0; transform: scale(0.96); } }
  @keyframes confirm-dialog-fade { from { opacity: 0; } }
  /* On a phone the action sheet rises from the bottom instead of growing in place. */
  @media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
    .confirm-dialog[open] { animation-name: confirm-dialog-rise; }
  }
  @keyframes confirm-dialog-rise { from { translate: 0 100%; } }
}
