#toast {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

#toast.hidden {
  display: none;
}

.toast-panel {
  --toast-rgb: 96, 165, 250;
  --toast-accent: #60a5fa;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  overflow: hidden;
  padding: 14px 13px 14px 14px;
  border: 1px solid rgba(var(--toast-rgb), 0.25);
  border-radius: 19px;
  color: #f8fafc;
  background:
    linear-gradient(135deg, rgba(var(--toast-rgb), 0.1), transparent 46%),
    rgba(17, 24, 39, 0.94);
  box-shadow:
    0 22px 55px rgba(2, 6, 23, 0.34),
    0 8px 20px rgba(2, 6, 23, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  pointer-events: auto;
  transform-origin: right bottom;
}

.toast-panel::before {
  content: '';
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--toast-accent);
  box-shadow: 0 0 18px rgba(var(--toast-rgb), 0.42);
}

.toast-panel::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: -42px;
  left: -34px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(var(--toast-rgb), 0.14);
  filter: blur(24px);
  pointer-events: none;
}

.toast-panel.is-success {
  --toast-rgb: 16, 185, 129;
  --toast-accent: #10b981;
}

.toast-panel.is-error {
  --toast-rgb: 244, 63, 94;
  --toast-accent: #f43f5e;
}

.toast-panel.is-warning {
  --toast-rgb: 245, 158, 11;
  --toast-accent: #f59e0b;
}

.toast-panel.is-info {
  --toast-rgb: 59, 130, 246;
  --toast-accent: #3b82f6;
}

.toast-panel.is-entering {
  animation: adminToastIn 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast-panel.exit {
  animation: adminToastOut 220ms cubic-bezier(0.4, 0, 1, 1) both;
}

.toast-icon-wrap {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid rgba(var(--toast-rgb), 0.24);
  border-radius: 14px;
  color: var(--toast-accent);
  background: rgba(var(--toast-rgb), 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.toast-icon-wrap i,
.toast-icon-wrap svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.35;
}

.toast-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.toast-title {
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 820;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.toast-message {
  overflow-wrap: anywhere;
  color: #aeb8c8;
  font-size: 12px;
  font-weight: 520;
  line-height: 1.45;
}

.toast-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  align-self: start;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #7f8ba0;
  background: transparent;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.toast-close:hover {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.1);
}

.toast-close:active {
  transform: scale(0.94);
}

.toast-close:focus-visible {
  outline: 3px solid rgba(var(--toast-rgb), 0.25);
  outline-offset: 2px;
}

.toast-close i,
.toast-close svg {
  width: 15px;
  height: 15px;
}

.toast-progress {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 2px;
  overflow: hidden;
  border-radius: 999px 999px 0 0;
  background: rgba(148, 163, 184, 0.12);
}

.toast-progress::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--toast-accent);
  box-shadow: 0 0 9px rgba(var(--toast-rgb), 0.5);
  transform-origin: left center;
}

.toast-panel.is-entering .toast-progress::after {
  animation: adminToastProgress var(--toast-duration, 4000ms) linear forwards;
}

[data-theme='light'] .toast-panel {
  color: #172033;
  background:
    linear-gradient(135deg, rgba(var(--toast-rgb), 0.09), transparent 48%),
    rgba(255, 255, 255, 0.97);
  border-color: rgba(var(--toast-rgb), 0.24);
  box-shadow:
    0 22px 48px rgba(15, 23, 42, 0.13),
    0 7px 16px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

[data-theme='light'] .toast-title {
  color: #172033;
}

[data-theme='light'] .toast-message {
  color: #64748b;
}

[data-theme='light'] .toast-close {
  color: #94a3b8;
}

[data-theme='light'] .toast-close:hover {
  color: #334155;
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(148, 163, 184, 0.1);
}

@keyframes adminToastIn {
  from {
    opacity: 0;
    transform: translate3d(18px, 12px, 0) scale(0.96);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0);
  }
}

@keyframes adminToastOut {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate3d(14px, 8px, 0) scale(0.97);
  }
}

@keyframes adminToastProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 640px) {
  #toast {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    width: auto;
  }

  .toast-panel {
    min-height: 72px;
    padding: 12px 11px 12px 12px;
    border-radius: 17px;
  }

  .toast-icon-wrap {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast-panel.is-entering,
  .toast-panel.exit,
  .toast-panel.is-entering .toast-progress::after {
    animation: none;
  }
}
