.portal-alert-stack {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 12000;
    display: flex;
    width: min(680px, calc(100vw - 44px));
    max-height: calc(100vh - 44px);
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.portal-toast {
    --portal-alert-accent: #2f80ff;
    position: relative;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 40px;
    min-height: 126px;
    align-items: center;
    gap: 20px;
    padding: 24px 20px 27px 22px;
    overflow: hidden;
    color: #f7f9fc;
    background: #11151c;
    border: 0;
    border-radius: 18px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, .72),
        0 10px 28px rgba(0, 0, 0, .48),
        0 0 22px color-mix(in srgb, var(--portal-alert-accent) 10%, transparent);
    pointer-events: auto;
    animation: portal-toast-enter .22s ease-out both;
}

.portal-toast--success { --portal-alert-accent: #3bcf8e; }
.portal-toast--danger { --portal-alert-accent: #ff6178; }
.portal-toast--warning { --portal-alert-accent: #f2ad4b; }
.portal-toast--info { --portal-alert-accent: #5f9dff; }

.portal-toast__icon {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    color: var(--portal-alert-accent);
    font-size: 30px;
    font-weight: 850;
    line-height: 1;
    background: color-mix(in srgb, var(--portal-alert-accent) 14%, #11151c);
    border-radius: 15px;
}

.portal-toast__content {
    display: grid;
    min-width: 0;
    gap: 7px;
}

.portal-toast__content strong {
    color: #fff;
    font-size: 18px;
    font-weight: 850;
}

.portal-toast__content span {
    color: #aab5c5;
    font-size: 16px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.portal-toast__close {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    align-self: start;
    padding: 0;
    color: #9ca8b8;
    font-family: Arial, sans-serif;
    font-size: 28px;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: 9px;
}

.portal-toast__close:hover,
.portal-toast__close:focus-visible {
    color: #fff;
    background: #1c222c;
    outline: 0;
}

.portal-toast__close span { transform: translateY(-1px); }

.portal-toast__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    background: color-mix(in srgb, var(--portal-alert-accent) 12%, transparent);
}

.portal-toast__progress::after {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--portal-alert-accent);
    transform: scaleX(1);
    transform-origin: left center;
    animation: portal-toast-countdown var(--portal-alert-timeout, 10000ms) linear forwards;
    content: "";
}

.portal-toast.is-closing {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .18s ease, transform .18s ease;
}

@keyframes portal-toast-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes portal-toast-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 640px) {
    .portal-alert-stack {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }

    .portal-toast {
        grid-template-columns: 52px minmax(0, 1fr) 34px;
        gap: 13px;
        min-height: 108px;
        padding: 19px 13px 22px 16px;
    }

    .portal-toast__icon {
        width: 52px;
        height: 52px;
        font-size: 25px;
    }

    .portal-toast__content strong { font-size: 16px; }
    .portal-toast__content span { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .portal-toast { animation: none; }
    .portal-toast.is-closing { transition: none; }
}
