.toast-viewport {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  left: auto;
  bottom: auto;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.75rem;
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  min-width: 280px;
  max-width: 360px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.12),
    0 4px 12px rgba(15, 23, 42, 0.072);
  border: 1px solid rgba(148, 163, 184, 0.3);
  transform: translateX(0);
  opacity: 1;
  animation: toast-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.toast--exiting {
  animation: toast-fade-out 0.2s ease forwards;
  pointer-events: none;
}

.toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.toast__content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toast__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.toast__description {
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.3;
}

.toast__close {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 0.35rem;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.toast__close:hover,
.toast__close:focus-visible {
  background-color: rgba(148, 163, 184, 0.2);
}

.toast__close-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toast__progress {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.toast__progress svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.toast__progress-track {
  fill: none;
  stroke: currentColor;
  opacity: 0.2;
  stroke-width: 2;
}

.toast__progress-indicator {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 120ms linear;
}

.toast--success .toast__icon {
  color: #12b76a;
}

.toast--error .toast__icon {
  color: #f04438;
}

.toast--info .toast__icon {
  color: #2e90fa;
}

.toast--loading .toast__icon {
  color: #6366f1;
  animation: toast-spin 900ms linear infinite;
}

.toast--loading .toast__icon svg {
  animation: toast-spin 900ms linear infinite;
}

[data-theme='light'] .toast {
  background: #0f172a;
  color: #f8fafc;
  border-color: rgba(15, 23, 42, 0.4);
}

[data-theme='dark'] .toast {
  background: #ffffff;
  color: #0b1120;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.108),
    0 4px 12px rgba(15, 23, 42, 0.06);
}

[data-theme='dark'] .toast__close:hover,
[data-theme='dark'] .toast__close:focus-visible {
  background-color: rgba(15, 23, 42, 0.08);
}

@keyframes toast-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .toast-viewport {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    align-items: stretch;
  }

  .toast {
    width: 100%;
    max-width: none;
  }
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(2rem);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-fade-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(1rem);
  }
}
