@layer components {
  .flashes {
    bottom: var(--space-2xl);
    display: grid;
    justify-items: center;
    left: 50%;
    position: fixed;
    transform: translateX(-50%);
    width: min(28rem, calc(100vw - 2rem));
    z-index: 1000;
  }

  .flash {
    --flash-index: 0;
    align-items: center;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    display: flex;
    gap: var(--space-md);
    grid-area: 1 / 1;
    justify-content: space-between;
    opacity: 1;
    padding: var(--space-md) var(--space-lg);
    transform: translateY(calc(var(--flash-index) * -0.65rem)) scale(calc(1 - min(var(--flash-index), 4) * 0.04));
    transition: opacity var(--transition-normal) ease, transform var(--transition-normal) ease;
    width: 100%;
    z-index: calc(100 - var(--flash-index));
  }

  /* Index >= 4 collapses into a bounded peeking deck: the offset converges so the
     pile stays a small fixed height and only a sliver of each peeks above. */
  .flash:nth-last-child(n+5) {
    opacity: 0.55;
  }

  /* Fully occluded overflow: visibility:hidden (not opacity:0) so it is truly inert
     and absent from the accessibility/visibility tree — opacity:0 still counts as
     "visible". */
  .flash:nth-last-child(n+6) {
    pointer-events: none;
    visibility: hidden;
  }

  .flash-notice {
    background: #e7f6ec;
    border: 1px solid #1f7a44;
    color: #14532d;
  }

  .flash-warning {
    background: #fff4e0;
    border: 1px solid #b45309;
    color: #7c3a06;
  }

  .flash-alert {
    background: #fdecec;
    border: 1px solid #b91c1c;
    color: #7f1d1d;
  }

  .flash-message {
    flex: 1 1 auto;
  }

  .flash-dismiss {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
  }
}
