.aoy-toast-region {
  position: fixed;
  z-index: 9999;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  display: grid;
  width: min(25rem, calc(100vw - 2rem));
  gap: 0.7rem;
  pointer-events: none;
}

.aoy-toast {
  --aoy-toast-accent: #4f46e5;
  --aoy-toast-soft: #eef2ff;
  position: relative;
  display: grid;
  min-height: 5rem;
  overflow: hidden;
  grid-template-columns: 2.65rem minmax(0, 1fr) 2rem;
  align-items: start;
  gap: 0.75rem;
  padding: 0.9rem 0.8rem 0.95rem 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  color: #172033;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.2), 0 6px 18px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(16px);
  pointer-events: auto;
  animation: aoy-toast-enter 260ms cubic-bezier(0.2, 0.85, 0.32, 1) both;
}

.aoy-toast--success { --aoy-toast-accent: #059669; --aoy-toast-soft: #d1fae5; }
.aoy-toast--error { --aoy-toast-accent: #e11d48; --aoy-toast-soft: #ffe4e6; }
.aoy-toast--warning { --aoy-toast-accent: #d97706; --aoy-toast-soft: #fef3c7; }
.aoy-toast--info { --aoy-toast-accent: #4f46e5; --aoy-toast-soft: #e0e7ff; }
.aoy-toast.is-leaving { animation: aoy-toast-leave 220ms ease-in both; }

.aoy-toast-icon {
  display: inline-flex;
  width: 2.65rem;
  height: 2.65rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.8rem;
  color: var(--aoy-toast-accent);
  background: var(--aoy-toast-soft);
  font-size: 1rem;
}

.aoy-toast-copy { display: block; min-width: 0; padding-top: 0.08rem; }
.aoy-toast-copy strong { display: block; color: inherit; font: 700 0.82rem/1.35 Inter, Poppins, sans-serif; }
.aoy-toast-copy > span { display: block; margin-top: 0.28rem; color: #64748b; font: 500 0.72rem/1.55 Inter, Poppins, sans-serif; overflow-wrap: anywhere; }

.aoy-toast-close {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.6rem;
  color: #94a3b8;
  background: transparent;
  font: 400 1.35rem/1 sans-serif;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}
.aoy-toast-close:hover { color: #334155; background: #f1f5f9; transform: scale(1.04); }
.aoy-toast-close:focus-visible { outline: 3px solid rgba(79, 70, 229, 0.24); outline-offset: 1px; }

.aoy-toast-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 0.2rem;
  background: var(--aoy-toast-accent);
  transform-origin: left;
  animation: aoy-toast-progress linear forwards;
}

.dark .aoy-toast {
  border-color: rgba(148, 163, 184, 0.18);
  color: #f8fafc;
  background: rgba(30, 41, 59, 0.97);
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.48), 0 7px 20px rgba(2, 6, 23, 0.28);
}
.dark .aoy-toast-copy > span { color: #cbd5e1; }
.dark .aoy-toast-icon { background: rgba(99, 102, 241, 0.16); }
.dark .aoy-toast--success .aoy-toast-icon { background: rgba(5, 150, 105, 0.18); }
.dark .aoy-toast--error .aoy-toast-icon { background: rgba(225, 29, 72, 0.18); }
.dark .aoy-toast--warning .aoy-toast-icon { background: rgba(217, 119, 6, 0.18); }
.dark .aoy-toast-close { color: #94a3b8; }
.dark .aoy-toast-close:hover { color: #f8fafc; background: rgba(148, 163, 184, 0.13); }

@keyframes aoy-toast-enter {
  from { opacity: 0; transform: translate3d(2.5rem, -0.25rem, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes aoy-toast-leave {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to { opacity: 0; transform: translate3d(2.5rem, 0, 0) scale(0.96); }
}

@keyframes aoy-toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 640px) {
  .aoy-toast-region {
    top: max(0.7rem, env(safe-area-inset-top));
    right: max(0.7rem, env(safe-area-inset-right));
    left: max(0.7rem, env(safe-area-inset-left));
    width: auto;
  }
  .aoy-toast { min-height: 4.6rem; grid-template-columns: 2.4rem minmax(0, 1fr) 1.85rem; gap: 0.65rem; padding: 0.78rem 0.68rem 0.85rem 0.78rem; border-radius: 0.9rem; }
  .aoy-toast-icon { width: 2.4rem; height: 2.4rem; border-radius: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .aoy-toast,
  .aoy-toast.is-leaving { animation-duration: 1ms; }
  .aoy-toast-progress { display: none; }
}
