@layer components {
  .flash {
    display: flex;
    inset-block-end: var(--block-space);
    inset-inline-end: var(--block-space);
    justify-content: flex-end;
    position: fixed;
    z-index: var(--z-flash);
  }

  .flash__inner {
    animation: slide-in-fade 3s 300ms both;
    background-color: var(--flash-background, var(--color-ink));
    border-radius: 4em;
    color: var(--flash-color, var(--color-ink-inverted));
    display: inline-flex;
    font-size: var(--font-size-medium);
    padding: 0.7em 1.4em;
  }

  /* Error flash (role="alert") — red background */
  .flash[role="alert"] .flash__inner {
    --flash-background: var(--color-negative);
  }

  /* Success flash (role="status") — green background */
  .flash[role="status"] .flash__inner {
    --flash-background: var(--color-positive);
  }

  /* JS-driven error toast — same bottom-right position */
  .error-toast {
    position: fixed;
    inset-block-end: var(--block-space);
    inset-inline-end: var(--block-space);
    z-index: var(--z-flash);
  }

  .error-toast-content {
    animation: slide-in-right 300ms both;
    background-color: var(--color-negative);
    border-radius: 4em;
    color: var(--color-ink-inverted);
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    font-size: var(--font-size-medium);
    padding: 0.7em 1.4em;
  }

  .error-toast.hiding .error-toast-content {
    animation: slide-out-right 300ms both;
  }

  .error-toast-icon {
    flex-shrink: 0;
  }

  .error-toast-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
  }

  .error-toast-close:hover {
    opacity: 1;
  }
}
