:root {
  --sagsuns-toast-blue: #0d83fd;
  --sagsuns-toast-ink: #23364a;
  --sagsuns-toast-muted: #64748b;
  --sagsuns-toast-surface: rgba(255, 255, 255, 0.97);
  --sagsuns-toast-success: #168a55;
  --sagsuns-toast-success-soft: #eaf8f1;
  --sagsuns-toast-danger: #c83b4d;
  --sagsuns-toast-danger-soft: #fff0f2;
  --sagsuns-toast-warning: #c78312;
  --sagsuns-toast-warning-soft: #fff7df;
  --sagsuns-toast-info: #2878c8;
  --sagsuns-toast-info-soft: #edf6ff;
}

[data-sagsuns-toast] {
  display: none !important;
}

.sagsuns-toast-region {
  position: fixed;
  z-index: 10950;
  top: max(28px, env(safe-area-inset-top));
  left: 50%;
  width: min(520px, calc(100vw - 40px));
  display: grid;
  gap: 12px;
  transform: translateX(-50%);
  pointer-events: none;
}

.sagsuns-toast {
  --toast-accent: var(--sagsuns-toast-info);
  --toast-soft: var(--sagsuns-toast-info-soft);
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 34px;
  gap: 13px;
  align-items: center;
  min-height: 88px;
  padding: 17px 15px 17px 17px;
  overflow: hidden;
  color: var(--sagsuns-toast-ink);
  background:
    linear-gradient(110deg, var(--toast-soft) 0, rgba(255, 255, 255, 0.82) 35%, transparent 68%),
    var(--sagsuns-toast-surface);
  border: 1px solid color-mix(in srgb, var(--toast-accent) 22%, #dbe5ef);
  border-left: 5px solid var(--toast-accent);
  border-radius: 19px;
  box-shadow: 0 18px 50px rgba(35, 54, 74, 0.17), 0 4px 14px rgba(35, 54, 74, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-18px) scale(0.97);
  transition: opacity 220ms ease, transform 280ms cubic-bezier(.2, .85, .25, 1);
}

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

.sagsuns-toast.is-leaving {
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
}

.sagsuns-toast--success {
  --toast-accent: var(--sagsuns-toast-success);
  --toast-soft: var(--sagsuns-toast-success-soft);
}

.sagsuns-toast--danger,
.sagsuns-toast--error {
  --toast-accent: var(--sagsuns-toast-danger);
  --toast-soft: var(--sagsuns-toast-danger-soft);
}

.sagsuns-toast--warning {
  --toast-accent: var(--sagsuns-toast-warning);
  --toast-soft: var(--sagsuns-toast-warning-soft);
}

.sagsuns-toast--info {
  --toast-accent: var(--sagsuns-toast-info);
  --toast-soft: var(--sagsuns-toast-info-soft);
}

.sagsuns-toast__icon {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--toast-accent);
  border-radius: 15px;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--toast-accent) 26%, transparent);
  font-size: 1.28rem;
}

.sagsuns-toast__body {
  min-width: 0;
}

.sagsuns-toast__title {
  margin: 0 0 3px;
  color: var(--sagsuns-toast-ink);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.sagsuns-toast__message {
  margin: 0;
  color: var(--sagsuns-toast-muted);
  font-size: 0.93rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sagsuns-toast__action {
  display: inline-flex;
  margin-top: 8px;
  padding: 0;
  color: var(--toast-accent);
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.sagsuns-toast__close {
  align-self: start;
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  margin: -4px -3px 0 0;
  padding: 0;
  color: #718096;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(100, 116, 139, 0.16);
  border-radius: 10px;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.sagsuns-toast__close:hover,
.sagsuns-toast__close:focus-visible {
  color: var(--sagsuns-toast-ink);
  background: #fff;
  transform: scale(1.05);
}

.sagsuns-toast__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  background: color-mix(in srgb, var(--toast-accent) 12%, transparent);
}

.sagsuns-toast__progress::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: var(--toast-accent);
  transform-origin: left;
  animation: sagsuns-toast-progress var(--toast-duration, 5000ms) linear forwards;
}

.sagsuns-toast.is-paused .sagsuns-toast__progress::after {
  animation-play-state: paused;
}

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

@media (max-width: 767.98px) {
  .sagsuns-toast-region {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    gap: 9px;
  }

  .sagsuns-toast {
    grid-template-columns: 42px minmax(0, 1fr) 30px;
    gap: 11px;
    min-height: 78px;
    padding: 14px 12px 14px 14px;
    border-radius: 17px;
    transform: translateY(18px) scale(0.98);
  }

  .sagsuns-toast.is-visible { transform: translateY(0) scale(1); }
  .sagsuns-toast.is-leaving { transform: translateY(12px) scale(0.98); }
  .sagsuns-toast__icon { width: 41px; height: 41px; border-radius: 13px; font-size: 1.12rem; }
  .sagsuns-toast__title { font-size: 0.96rem; }
  .sagsuns-toast__message { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sagsuns-toast { transition: opacity 100ms linear; transform: none !important; }
  .sagsuns-toast__progress::after { animation: none; }
}
