:root {
    --kw-toast-bg: rgba(17, 17, 19, .94);
    --kw-toast-border: rgba(255, 255, 255, .085);
    --kw-toast-shadow: 0 18px 48px rgba(0, 0, 0, .28);
    --kw-toast-title: #f4f4f5;
    --kw-toast-text: #b9b9c3;
    --kw-toast-muted: #8b8b95;
    --kw-toast-close-hover: rgba(255, 255, 255, .055);
    --kw-toast-track: rgba(255, 255, 255, .06);
}

html[data-theme="light"] {
    --kw-toast-bg: rgba(255, 255, 255, .96);
    --kw-toast-border: rgba(15, 23, 42, .105);
    --kw-toast-shadow: 0 18px 44px rgba(15, 23, 42, .12);
    --kw-toast-title: #111827;
    --kw-toast-text: #475467;
    --kw-toast-muted: #98a2b3;
    --kw-toast-close-hover: rgba(15, 23, 42, .055);
    --kw-toast-track: rgba(15, 23, 42, .07);
}

.kw-toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

.kw-toast {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 12px;
    overflow: hidden;
    min-height: 72px;
    padding: 14px 14px 14px 13px;
    border-radius: 14px;
    border: 1px solid var(--kw-toast-border);
    background: var(--kw-toast-bg);
    backdrop-filter: blur(18px);
    box-shadow: var(--kw-toast-shadow);
    pointer-events: auto;
    transform: translateY(16px);
    opacity: 0;
    animation: kwToastIn .28s ease forwards;
    animation-delay: calc(var(--kw-toast-index) * 0.04s);
}

.kw-toast-success {
    border-color: color-mix(in srgb, #22c55e 24%, var(--kw-toast-border));
}

.kw-toast-error {
    border-color: color-mix(in srgb, #ef4444 24%, var(--kw-toast-border));
}

html[data-theme="light"] .kw-toast-success {
    background:
        linear-gradient(0deg, rgba(34, 197, 94, .035), rgba(34, 197, 94, .035)),
        var(--kw-toast-bg);
}

html[data-theme="light"] .kw-toast-error {
    background:
        linear-gradient(0deg, rgba(239, 68, 68, .035), rgba(239, 68, 68, .035)),
        var(--kw-toast-bg);
}

.kw-toast-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    margin-top: 7px;
    background: #f59e0b;
    box-shadow: 0 0 0 5px rgba(245, 158, 11, .12);
}

.kw-toast-success .kw-toast-dot {
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .12);
}

.kw-toast-error .kw-toast-dot {
    background: #ef4444;
    box-shadow: 0 0 0 5px rgba(239, 68, 68, .12);
}

html[data-theme="light"] .kw-toast-success .kw-toast-dot {
    background: #16a34a;
    box-shadow: 0 0 0 5px rgba(22, 163, 74, .105);
}

html[data-theme="light"] .kw-toast-error .kw-toast-dot {
    background: #dc2626;
    box-shadow: 0 0 0 5px rgba(220, 38, 38, .105);
}

.kw-toast-body {
    min-width: 0;
}

.kw-toast-title {
    color: var(--kw-toast-title);
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: .01em;
    font-weight: 620;
    margin-bottom: 4px;
}

.kw-toast-message {
    color: var(--kw-toast-text);
    font-size: 13px;
    line-height: 1.52;
    font-weight: 410;
    word-break: break-word;
}

.kw-toast-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--kw-toast-muted);
    width: 28px;
    height: 28px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    margin: -4px -4px 0 0;
    transition: background .16s ease, color .16s ease;
}

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

.kw-toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--kw-toast-track);
}

.kw-toast-progress::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    animation: kwToastProgress linear forwards;
    animation-duration: var(--kw-toast-duration, 4s);
    background: rgba(245, 158, 11, .82);
}

.kw-toast-success .kw-toast-progress::after {
    background: rgba(34, 197, 94, .82);
}

.kw-toast-error .kw-toast-progress::after {
    background: rgba(239, 68, 68, .82);
}

html[data-theme="light"] .kw-toast-success .kw-toast-progress::after {
    background: rgba(22, 163, 74, .82);
}

html[data-theme="light"] .kw-toast-error .kw-toast-progress::after {
    background: rgba(220, 38, 38, .82);
}

.kw-toast.is-hiding {
    animation: kwToastOut .22s ease forwards;
}

@keyframes kwToastIn {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes kwToastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(12px);
        opacity: 0;
    }
}

@keyframes kwToastProgress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@media (max-width: 640px) {
    .kw-toast-stack {
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
    }

    .kw-toast {
        min-height: 68px;
        padding: 13px 13px 13px 12px;
    }
}
