.toast-stack {
  position: fixed;
  top: var(--toast-top, 4.25rem);
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 500;
  width: min(22rem, calc(100vw - 1.5rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

body.app-body {
  --toast-top: calc(var(--app-nav-h, 3.5rem) + 0.75rem);
}

body.ops-body {
  --toast-top: calc(3.25rem + 0.75rem);
}

body.voice-public {
  --toast-top: calc(4.5rem + 0.5rem);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid transparent;
  font-size: var(--font-size-sm, 0.875rem);
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  animation: toast-enter 0.28s ease-out;
}

.toast.is-leaving {
  animation: toast-leave 0.22s ease-in forwards;
}

.toast__body {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.toast__close {
  flex-shrink: 0;
  margin: -0.15rem -0.2rem 0 0;
  padding: 0.15rem 0.35rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
}

.toast__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.toast--success {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #027a48;
}

.toast--error {
  background: #fef3f2;
  border-color: #fecdca;
  color: #b42318;
}

.toast--warning {
  background: #fffaeb;
  border-color: #fedf89;
  color: #b54708;
}

.toast--info {
  background: #f0f7ff;
  border-color: #c5ddff;
  color: #175cd3;
}

body.ops-body .toast {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

body.ops-body .toast--success {
  background: rgba(6, 118, 71, 0.22);
  border-color: rgba(171, 239, 198, 0.35);
  color: #6ce9a6;
}

body.ops-body .toast--error {
  background: rgba(180, 35, 24, 0.2);
  border-color: rgba(254, 205, 202, 0.35);
  color: #fda29b;
}

body.ops-body .toast--warning {
  background: rgba(181, 71, 8, 0.18);
  border-color: rgba(254, 223, 137, 0.35);
  color: #fec84b;
}

body.ops-body .toast--info {
  background: rgba(23, 92, 211, 0.18);
  border-color: rgba(197, 221, 255, 0.35);
  color: #84caff;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-leave {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }

  .toast.is-leaving {
    animation: none;
    opacity: 0;
  }
}
