.toasts {
    position: fixed;
    top: 20px;
    right: 20px;
    /* Выше модалки Bootstrap (1055), чтобы тост был виден поверх неё.
       Клики контейнер не перехватывает — pointer-events отключён, включён
       только на самих тостах. */
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 40px));
    pointer-events: none;
}

/* Пустой контейнер не должен висеть невидимым слоем над интерфейсом. */
.toasts:empty {
    display: none;
}

.toast-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 15px 16px;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-menu);
    overflow: hidden;
    pointer-events: auto;
    animation: toast-in .22s ease-out;
}

.toast-item.is-hiding {
    animation: toast-out .18s ease-in forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
}

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

.toast-icon {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 15px;
}

.toast-item.is-success .toast-icon {
    color: var(--emerald-600);
}

.toast-item.is-danger .toast-icon {
    color: var(--danger);
}

.toast-message {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-faint);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: color .15s, background .15s;
}

.toast-close:hover {
    color: var(--text);
    background: var(--hover);
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
    animation: toast-progress linear forwards;
    animation-duration: inherit;
}

.toast-item.is-success .toast-progress {
    background: var(--emerald-500);
}

.toast-item.is-danger .toast-progress {
    background: var(--danger);
}

/* Наведение приостанавливает и таймер, и полосу — успеть прочитать. */
.toast-item:hover .toast-progress {
    animation-play-state: paused;
}

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

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

@media (max-width: 560px) {
    .toasts {
        top: auto;
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: auto;
    }
}
