.toast-region {
  position: fixed;
  z-index: 2147483647;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: grid;
  width: min(420px, calc(100vw - 32px));
  gap: 10px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  pointer-events: none;
}

.toast-region:empty {
  display: none;
}

.toast {
  --toast-accent: #087a58;
  --toast-soft: #eaf8f2;
  --toast-border: #b9e3d3;
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--toast-border);
  border-inline-start: 4px solid var(--toast-accent);
  border-radius: 12px;
  padding: 12px 12px 14px 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(21, 42, 33, 0.2);
  color: var(--portal-ink, #172b23);
  direction: rtl;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: toast-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast--error {
  --toast-accent: #c83c54;
  --toast-soft: #fff0f3;
  --toast-border: #f2b8c3;
}

.toast--warning {
  --toast-accent: #b76b10;
  --toast-soft: #fff6e8;
  --toast-border: #f0d09e;
}

.toast--info {
  --toast-accent: #2475a8;
  --toast-soft: #edf7fd;
  --toast-border: #b9daee;
}

.toast__icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--toast-soft);
  color: var(--toast-accent);
}

.toast__icon svg {
  width: 22px;
  height: 22px;
}

.toast__message {
  align-self: center;
  margin: 0;
  color: var(--portal-ink, #172b23);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.85;
}

.toast__close {
  width: 30px;
  min-height: 30px !important;
  border: 0 !important;
  border-radius: 8px !important;
  padding: 0 !important;
  background: transparent !important;
  color: #728078;
}

.toast__close:hover {
  background: var(--toast-soft) !important;
  color: var(--toast-accent);
}

.toast__close svg {
  width: 18px;
  height: 18px;
}

.toast__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: var(--toast-accent);
  opacity: 0.65;
  transform-origin: right;
  animation: toast-progress var(--toast-duration) linear forwards;
}

.toast.is-leaving {
  animation: toast-out 220ms ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(110%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(110%);
  }
}

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

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