.toast-stack {
  position: fixed;
  top: max(20px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 10010;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  --toast-accent: var(--color-primary-500);
  --toast-accent-bg: var(--color-primary-alpha-10);
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--color-black-alpha-10);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  font-size: 15px;
  font-family: PingFang SC, sans-serif;
  font-weight: 500;
  line-height: 22px;
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  transition:
    opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
  overflow: hidden;
}

.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--toast-accent);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast--leaving {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition-duration: 0.2s;
}

.toast__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--toast-accent-bg);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toast__icon::before,
.toast__icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
}

.toast__text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  line-height: 22px;
}

.toast--success {
  --toast-accent: #22c55e;
  --toast-accent-bg: #22c55e;
  border-color: rgba(34, 197, 94, 0.14);
  background:
    linear-gradient(180deg, rgba(34, 197, 94, 0.05) 0%, rgba(255, 255, 255, 0.98) 38%),
    rgba(255, 255, 255, 0.96);
}

.toast--success .toast__icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(145deg, #34d399 0%, #22c55e 100%);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.28);
}

.toast--success .toast__icon::before {
  width: 6px;
  height: 10px;
  margin: 0;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -58%) rotate(45deg);
}

.toast--error {
  --toast-accent: #fd2e33;
  --toast-accent-bg: rgba(253, 46, 51, 0.12);
}

.toast--error .toast__icon::before,
.toast--error .toast__icon::after {
  width: 2px;
  height: 12px;
  border-radius: 999px;
  background: #fd2e33;
}

.toast--error .toast__icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.toast--error .toast__icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.toast--info {
  --toast-accent: var(--color-primary-500);
  --toast-accent-bg: var(--color-primary-alpha-10);
}

.toast--info .toast__icon::before {
  width: 2px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-primary-500);
  transform: translate(-50%, calc(-50% + 2px));
}

.toast--info .toast__icon::after {
  width: 2px;
  height: 2px;
  border-radius: 999px;
  background: var(--color-primary-500);
  transform: translate(-50%, -50%);
  top: calc(50% - 5px);
}

.toast--warning {
  --toast-accent: #f59e0b;
  --toast-accent-bg: rgba(245, 158, 11, 0.14);
}

.toast--warning .toast__icon::before {
  width: 2px;
  height: 10px;
  border-radius: 999px;
  background: #f59e0b;
  transform: translate(-50%, calc(-50% - 2px));
}

.toast--warning .toast__icon::after {
  width: 2px;
  height: 2px;
  border-radius: 999px;
  background: #f59e0b;
  transform: translate(-50%, -50%);
  top: calc(50% + 6px);
}

@media (max-width: 768px) {
  .toast-stack {
    top: max(12px, env(safe-area-inset-top, 0px));
    width: min(343px, calc(100vw - 24px));
    gap: 8px;
  }

  .toast {
    min-height: 44px;
    padding: 10px 14px 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
  }

  .toast__icon {
    width: 20px;
    height: 20px;
  }

  .toast__text {
    line-height: 20px;
  }

  .toast--success .toast__icon {
    width: 22px;
    height: 22px;
  }

  .toast--success .toast__icon::before {
    width: 5px;
    height: 9px;
  }
}
