.toast-root {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
  width: min(100vw - 2rem, 380px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--toast-border, #2a2a32);
  background: var(--toast-bg, #1f1f24);
  color: #f4f4f5;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(1.25rem);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(1.25rem);
}

.toast-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.toast-icon svg {
  width: 0.95rem;
  height: 0.95rem;
}

.toast-body {
  flex: 1;
  min-width: 0;
  padding-top: 0.1rem;
}

.toast-message {
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.25rem -0.35rem 0 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.toast-close svg {
  width: 1rem;
  height: 1rem;
}

.toast--success {
  --toast-border: rgba(34, 197, 94, 0.35);
  --toast-bg: linear-gradient(135deg, #1a2e1f 0%, #1f1f24 55%);
}

.toast--success .toast-icon {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.toast--error {
  --toast-border: rgba(239, 68, 68, 0.4);
  --toast-bg: linear-gradient(135deg, #2e1a1a 0%, #1f1f24 55%);
}

.toast--error .toast-icon {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.toast--warning {
  --toast-border: rgba(251, 191, 36, 0.35);
  --toast-bg: linear-gradient(135deg, #2e281a 0%, #1f1f24 55%);
}

.toast--warning .toast-icon {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.toast--info {
  --toast-border: rgba(255, 106, 0, 0.35);
  --toast-bg: linear-gradient(135deg, #2e2218 0%, #1f1f24 55%);
}

.toast--info .toast-icon {
  background: rgba(255, 106, 0, 0.2);
  color: #ff8533;
}

@media (max-width: 480px) {
  .toast-root {
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
    width: auto;
    align-items: stretch;
  }

  .toast {
    transform: translateY(-0.75rem);
  }

  .toast.is-visible {
    transform: translateY(0);
  }

  .toast.is-leaving {
    transform: translateY(-0.75rem);
  }
}
