.toast-stack {
  position: fixed;
  top: var(--sp-5, 1.25rem);
  right: var(--sp-5, 1.25rem);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: min(384px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast-stack--left { right: auto; left: var(--sp-5, 1.25rem); }
.toast-stack--bottom { top: auto; bottom: var(--sp-5, 1.25rem); }

.toast {
  --toast-2: var(--accent, #206bc4);
  --toast-rgb: var(--accent-rgb, 32, 107, 196);

  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 24px;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.9rem 0.95rem;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface, #1f2733);
  border: 1px solid var(--border, rgba(159, 180, 208, 0.14));
  border-left: 4px solid var(--toast-2);
  box-shadow:
    0 12px 30px -14px rgba(8, 14, 24, 0.45),
    0 4px 12px -8px rgba(8, 14, 24, 0.3);
  opacity: 0;
  transform: translateX(118%) scale(0.96);
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease;
}
.toast.is-in { opacity: 1; transform: translateX(0) scale(1); }
.toast.is-out { opacity: 0; transform: translateX(118%) scale(0.96); }
.toast.is-in:hover {
  box-shadow:
    0 18px 40px -14px rgba(8, 14, 24, 0.55),
    0 6px 16px -8px rgba(8, 14, 24, 0.38);
}

.toast-stack--left .toast { transform: translateX(-118%) scale(0.96); }
.toast-stack--left .toast.is-in { transform: translateX(0) scale(1); }
.toast-stack--left .toast.is-out { transform: translateX(-118%) scale(0.96); }

.toast.is-bump { animation: toastBump 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes toastBump {
  0% { transform: translateX(0) scale(1); }
  35% { transform: translateX(0) scale(1.025); }
  100% { transform: translateX(0) scale(1); }
}

.toast--success { --toast-2: var(--success, #2fb344); --toast-rgb: var(--success-rgb, 47, 179, 68); }
.toast--error   { --toast-2: var(--danger, #d63939);  --toast-rgb: var(--danger-rgb, 214, 57, 57); }
.toast--warning { --toast-2: var(--warning, #f59f00); --toast-rgb: var(--warning-rgb, 245, 159, 0); }
.toast--info    { --toast-2: var(--accent, #206bc4); --toast-rgb: var(--accent-rgb, 32, 107, 196); }

.toast__icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--toast-2);
  background: rgba(var(--toast-rgb), 0.14);
}
.toast__icon svg {
  width: 18px;
  height: 18px;
}
.toast.is-in .toast__icon { animation: toastIconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes toastIconPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.toast__body {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  gap: 0.14rem;
  padding-top: 0.05rem;
}
.toast__title {
  color: var(--text, #eef3fa);
  font-size: var(--fs-sm, 0.8125rem);
  font-weight: var(--fw-bold, 700);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.toast__text {
  color: var(--text-secondary, #aab8c9);
  font-size: var(--fs-xs, 0.75rem);
  font-weight: var(--fw-medium, 500);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast__close {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 0.05rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #74839a);
  cursor: pointer;
  transition:
    background var(--transition-fast, 0.15s ease),
    color var(--transition-fast, 0.15s ease),
    transform var(--transition-fast, 0.15s ease);
}
.toast__close:hover {
  background: var(--surface-hover, rgba(46, 58, 74, 0.7));
  color: var(--text, #eef3fa);
  transform: rotate(90deg);
}
.toast__close svg { width: 14px; height: 14px; }

.toast__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  transform-origin: left center;
  background: var(--toast-2);
  opacity: 0.9;
}
.toast.is-in .toast__bar { animation: toastBar linear forwards; }
.toast.is-paused .toast__bar { animation-play-state: paused; }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.toast:has(.toast__bar) { padding-bottom: 1.05rem; }

[data-bs-theme="light"] .toast {
  border-color: var(--border, rgba(15, 36, 64, 0.1));
  border-left-color: var(--toast-2);
  box-shadow:
    0 12px 30px -14px rgba(15, 36, 64, 0.2),
    0 4px 12px -8px rgba(15, 36, 64, 0.12);
}
[data-bs-theme="light"] .toast.is-in:hover {
  box-shadow:
    0 18px 40px -14px rgba(15, 36, 64, 0.26),
    0 6px 16px -8px rgba(15, 36, 64, 0.16);
}

@media (max-width: 480px) {
  .toast-stack {
    top: var(--sp-3, 0.75rem);
    right: var(--sp-3, 0.75rem);
    left: auto;
    width: calc(100vw - 1.5rem);
  }
  .toast {
    grid-template-columns: 32px minmax(0, 1fr) 24px;
    gap: 0.7rem;
    padding: 0.8rem 0.85rem;
    border-radius: 11px;
  }
  .toast:has(.toast__bar) { padding-bottom: 1rem; }
  .toast__bar { left: 0; right: 0; }
  .toast__icon { width: 32px; height: 32px; border-radius: 9px; }
  .toast__icon svg { width: 17px; height: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast__icon { animation: none; transition: opacity 0.2s ease; transform: none; }
  .toast.is-in,
  .toast.is-out { transform: none; }
  .toast.is-in .toast__bar { animation: none; }
  .toast.is-bump { animation: none; }
}
