:root {
  --mx-toast-bg: rgba(13, 19, 32, 0.88);
  --mx-toast-border: rgba(255, 255, 255, 0.12);
  --mx-toast-radius: 16px;
  --mx-toast-blur: 16px;
  --mx-toast-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --mx-toast-font: system-ui, -apple-system, 'Segoe UI', Roboto, Inter, 'Helvetica Neue', sans-serif;
  --mx-toast-success: #10b981;
  --mx-toast-error: #ef4444;
  --mx-toast-warn: #f59e0b;
  --mx-toast-info: #38bdf8;
}

/* Контейнер уведомлений */
.mx-toast-container {
  position: fixed;
  top: max(20px, calc(var(--app-safe-top, 0px) + 16px));
  right: max(20px, calc(var(--app-safe-right, 0px) + 16px));
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  width: 380px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
}

/* Базовый элемент уведомления */
.mx-toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--mx-toast-radius);
  background: var(--mx-toast-bg);
  backdrop-filter: blur(var(--mx-toast-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--mx-toast-blur)) saturate(180%);
  border: 1px solid var(--mx-toast-border);
  box-shadow: var(--mx-toast-shadow);
  color: #e6eefc;
  font-family: var(--mx-toast-font);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  box-sizing: border-box;
  transform-origin: top right;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.22s ease,
              opacity 0.22s ease,
              max-height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              margin 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  animation: mx-toast-enter 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.mx-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mx-toast:active {
  transform: translateY(0) scale(0.99);
}

/* Состояние скрытия */
.mx-toast.mx-toast--exiting {
  animation: mx-toast-exit 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  pointer-events: none;
}

/* Фоновое свечение */
.mx-toast__glow {
  position: absolute;
  top: -24px;
  left: -24px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(24px);
  opacity: 0.65;
  transition: opacity 0.3s ease;
}

/* Иконка */
.mx-toast__icon {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.mx-toast__icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Блок контента */
.mx-toast__content {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mx-toast__title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #f8fafc;
  line-height: 1.35;
  margin: 0;
}

.mx-toast__message {
  font-size: 12.5px;
  line-height: 1.45;
  color: #cbd5e1;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
}

/* Бейдж счетчика дублей */
.mx-toast__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  vertical-align: middle;
}

/* Кнопка закрытия */
.mx-toast__close {
  position: relative;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: -2px;
  margin-right: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.mx-toast__close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.mx-toast__close:active {
  transform: scale(0.92);
}

.mx-toast__close svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Прогресс-бар */
.mx-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  transform-origin: left center;
  opacity: 0.85;
}

/* Тема: Успех */
.mx-toast--success {
  border-color: rgba(16, 185, 129, 0.28);
}
.mx-toast--success .mx-toast__glow {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.5) 0%, transparent 70%);
}
.mx-toast--success .mx-toast__icon {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.28);
}
.mx-toast--success .mx-toast__progress {
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* Тема: Ошибка */
.mx-toast--error {
  border-color: rgba(239, 68, 68, 0.35);
}
.mx-toast--error .mx-toast__glow {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.55) 0%, transparent 70%);
}
.mx-toast--error .mx-toast__icon {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.32);
}
.mx-toast--error .mx-toast__progress {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Тема: Предупреждение */
.mx-toast--warning {
  border-color: rgba(245, 158, 11, 0.32);
}
.mx-toast--warning .mx-toast__glow {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.5) 0%, transparent 70%);
}
.mx-toast--warning .mx-toast__icon {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.mx-toast--warning .mx-toast__progress {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

/* Тема: Инфо */
.mx-toast--info {
  border-color: rgba(56, 189, 248, 0.3);
}
.mx-toast--info .mx-toast__glow {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.5) 0%, transparent 70%);
}
.mx-toast--info .mx-toast__icon {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
}
.mx-toast--info .mx-toast__progress {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

/* Анимации */
@keyframes mx-toast-enter {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mx-toast-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 160px;
    margin-bottom: 0;
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.94);
    max-height: 0;
    margin-bottom: -12px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 640px) {
  .mx-toast-container {
    top: max(12px, calc(var(--app-safe-top, 0px) + 8px));
    left: max(12px, calc(var(--app-safe-left, 0px) + 8px));
    right: max(12px, calc(var(--app-safe-right, 0px) + 8px));
    width: auto;
    max-width: 100%;
  }

  .mx-toast {
    padding: 12px 14px;
    border-radius: 14px;
    transform-origin: top center;
  }

  .mx-toast__title {
    font-size: 13px;
  }

  .mx-toast__message {
    font-size: 12px;
  }
}
