.toast-stack {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 372px;
  max-width: calc(100vw - 32px);
  padding: 0;
  margin: 0;
  list-style: none;
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow: hidden;
  padding: 16px 16px 18px 18px;
  border-radius: var(--radius-2xl);
  background: var(--color-background);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.5s var(--ease-calm) both;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast-success::before {
  background: var(--color-success);
}

.toast-error::before {
  background: var(--color-accent-red);
}

.toast-out {
  animation: toast-out 0.26s var(--ease-soft) both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: none;
  }

  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

.toast-icon {
  flex: none;
  margin-top: 1px;
  font-size: 20px;
}

.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error .toast-icon {
  color: var(--color-accent-red);
}

.toast-text {
  flex: 1;
  min-width: 0;
}

.toast-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 20px;
  color: var(--color-primary-dark);
}

.toast-body {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 19px;
  color: var(--color-muted);
}

.toast-close {
  flex: none;
  padding: 4px;
  border: none;
  margin: -4px -4px 0 0;
  background: transparent;
  font-size: 14px;
  color: var(--color-icon-muted);
  cursor: pointer;
  transition: color 0.16s var(--ease-soft);
}

.toast-close:hover {
  color: var(--color-primary-dark);
}

.toast-bar {
  position: absolute;
  left: 4px;
  right: 0;
  bottom: 0;
  height: 3px;
  transform-origin: left;
  animation: toast-drain 5.2s linear both;
}

.toast-success .toast-bar {
  background: var(--color-success-tint);
}

.toast-error .toast-bar {
  background: var(--color-warning-tint);
}

@keyframes toast-drain {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-out,
  .toast-bar {
    animation: none;
  }

  .toast-out {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .toast-stack {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}
