.flash {
  align-items: center;
  animation: appear-then-fade 4s 300ms both;
  backdrop-filter: var(--blur-sm) var(--contrast-75);
  background-color: var(--flash-background, rgb(from var(--color-text) r g b / .78));
  border-radius: var(--rounded-full);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  color: var(--flash-color, var(--color-text-reversed));
  column-gap: var(--size-2);
  display: flex;
  font-size: var(--text-fluid-base);
  justify-content: center;
  line-height: var(--leading-none);
  /* Ensure flash is above header (z-index 1000) */
  position: fixed;
  z-index: 9999;
  /* env(safe-area-inset-top) on top of the caller's offset, not instead of
     it — a notch/Dynamic-Island (or a translucent native nav bar the
     webview draws under) eats into that offset otherwise, and the message
     ends up clipped behind it. Harmless where there's no inset (web, most
     Android). */
  top: calc(var(--flash-position, var(--size-4)) + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  margin-block-start: 0;
  margin-inline: 0;
  min-block-size: var(--size-11);
  padding: var(--size-1) var(--size-4);
  text-align: center;
  max-width: calc(100vw - 2rem);
  width: auto;

  [data-turbo-preview] & {
    display: none;
  }
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .flash {
    max-width: calc(100vw - 1rem);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: 0.5rem;
    white-space: normal;
    word-wrap: break-word;
  }
}

.flash--positive {
  --flash-background: var(--color-positive);
  --flash-color: white;
}

.flash--negative {
  --flash-background: var(--color-negative);
  --flash-color: white;
}

.flash--extended {
  animation-name: appear-then-fade-extended;
  animation-duration: 12s;
}

@keyframes appear-then-fade {

  0%,
  100% {
    opacity: 0;
  }

  5%,
  60% {
    opacity: 1;
  }
}

@keyframes appear-then-fade-extended {

  0%,
  100% {
    opacity: 0;
  }

  2%,
  90% {
    opacity: 1;
  }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}