.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 5200;

    width: min(420px, calc(100vw - 28px));

    display: grid;
    gap: 10px;

    pointer-events: none;
}

.toast {
    --toast-tone: #21C063;
    --toast-tone-soft: rgba(33, 192, 99, 0.11);
    --toast-tone-border: rgba(33, 192, 99, 0.18);

    position: relative;

    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: start;

    gap: 12px;

    padding: 13px 12px 15px 14px;

    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;

    background:
        linear-gradient(
            180deg,
            rgba(30, 34, 33, 0.95),
            rgba(24, 28, 27, 0.96)
        );

    box-shadow:
        0 18px 46px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.025);

    backdrop-filter: blur(14px);

    pointer-events: auto;

    animation: toast-enter 220ms cubic-bezier(.22, .61, .36, 1) both;
}

.toast--success {
    --toast-tone: #5ABB86;
    --toast-tone-soft: rgba(90, 187, 134, 0.10);
    --toast-tone-border: rgba(90, 187, 134, 0.17);
}

.toast--warning {
    --toast-tone: #D9A441;
    --toast-tone-soft: rgba(217, 164, 65, 0.10);
    --toast-tone-border: rgba(217, 164, 65, 0.17);
}

.toast--error {
    --toast-tone: #E27579;
    --toast-tone-soft: rgba(226, 117, 121, 0.10);
    --toast-tone-border: rgba(226, 117, 121, 0.16);
}

.toast--loading {
    --toast-tone: #F59E0B;
    --toast-tone-soft: rgba(245, 158, 11, 0.10);
    --toast-tone-border: rgba(245, 158, 11, 0.17);
}

.toast-accent {
    position: absolute;

    left: 0;
    top: 10px;
    bottom: 10px;

    width: 2px;

    border-radius: 0 2px 2px 0;

    background: var(--toast-tone);
}

.toast-icon {
    width: 30px;
    height: 30px;

    display: grid;
    place-items: center;

    border: 1px solid var(--toast-tone-border);
    border-radius: 9px;

    color: var(--toast-tone);

    background: var(--toast-tone-soft);
}

.toast-icon svg {
    width: 15px;
    height: 15px;

    stroke-width: 2;
}

.toast--loading .toast-icon svg {
    animation: toast-spin 900ms linear infinite;
}

.toast-content {
    min-width: 0;
    padding-top: 1px;
}

.toast-title {
    display: block;

    margin-bottom: 2px;

    color: rgba(255, 255, 255, 0.94);

    font-size: 0.83rem;
    font-weight: 700;

    line-height: 1.35;
    letter-spacing: -0.012em;
}

.toast-message {
    margin: 0;

    color: rgba(255, 255, 255, 0.68);

    font-size: 0.79rem;
    font-weight: 500;

    line-height: 1.48;
}

.toast-close {
    width: 30px;
    height: 30px;

    margin: 0;
    padding: 0;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 8px;

    color: rgba(255, 255, 255, 0.40);
    background: transparent;

    cursor: pointer;

    transition:
        color 140ms ease,
        background 140ms ease;
}

.toast-close:hover {
    color: rgba(255, 255, 255, 0.84);
    background: rgba(255, 255, 255, 0.045);
}

.toast-close:focus-visible {
    outline: 2px solid rgba(33, 192, 99, 0.42);
    outline-offset: 2px;
}

.toast-close svg {
    width: 16px;
    height: 16px;

    stroke-width: 1.8;
}

.toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    height: 2px;

    background: rgba(255, 255, 255, 0.03);
}

.toast-progress::after {
    content: "";

    position: absolute;
    inset: 0;

    background:
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.04),
            var(--toast-tone)
        );

    transform-origin: left center;

    animation-name: toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
    animation-duration: var(--toast-duration, 4200ms);
}

.toast.is-leaving {
    animation: toast-exit 170ms ease both;
}

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

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-exit {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-5px) scale(0.99);
    }
}

@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@keyframes toast-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .toast-stack {
        top: 14px;
        right: 14px;
        left: 14px;

        width: auto;
    }

    .toast {
        grid-template-columns: 28px minmax(0, 1fr) auto;

        gap: 10px;

        padding: 12px 10px 14px 13px;

        border-radius: 11px;
    }

    .toast-icon {
        width: 28px;
        height: 28px;
    }

    .toast-message {
        font-size: 0.78rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast-close,
    .toast-icon svg,
    .toast-progress::after {
        animation: none !important;
        transition: none !important;
    }
}
