@layer components {
  .singlestage-dialog {
    @apply inset-y-0
    opacity-0
    text-foreground
    transition-all
    transition-discrete;

    &:is([open], :popover-open) {
      @apply opacity-100;

      &::backdrop {
        @apply opacity-100;
      }

      > article {
        @apply scale-100;
      }

      @starting-style {
        @apply opacity-0;

        &::backdrop {
          @apply opacity-0;
        }

        > article {
          @apply scale-95;
        }
      }
    }

    &::backdrop {
      @apply bg-black/50
      opacity-0
      transition-all
      transition-discrete;
    }

    > article {
      @apply -translate-x-1/2
      -translate-y-1/2
      bg-background
      border
      fixed
      flex
      flex-col
      gap-4
      left-[50%]
      max-h-[calc(100%_-_2rem)]
      max-w-[calc(100%_-_2rem)]
      p-6
      rounded-lg
      shadow-lg
      sm:max-w-lg
      top-[50%]
      w-full
      z-50;

      @apply scale-95
      transition-all;

      > header {
        @apply flex
        flex-col
        gap-2
        sm:text-left
        text-center;

        > h2 {
          @apply font-semibold
          leading-none
          text-lg;
        }

        > p {
          @apply text-muted-foreground
          text-sm;
        }
      }

      > section {
        @apply -mx-6
        flex-1
        px-6;
      }

      > footer {
        > form {
          @apply flex
          flex-col-reverse
          gap-2
          sm:flex-row
          sm:justify-end;
        }
      }

      > form[method="dialog"] {
        @apply absolute
        right-4
        top-4;

        > button {
          @apply [&_svg:not([class*='size-'])]:size-4
          [&_svg]:pointer-events-none
          [&_svg]:shrink-0
          data-[state=open]:bg-accent
          data-[state=open]:text-muted-foreground
          disabled:pointer-events-none
          focus:outline-hidden
          focus:ring-2
          focus:ring-offset-2
          focus:ring-ring
          hover:opacity-100
          opacity-70
          ring-offset-background
          rounded-xs
          transition-opacity;
        }
      }
    }
  }
}
