.ui-toast-viewport {
    position: fixed;
    top: calc(var(--topbar-height, 64px) + 14px);
    right: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.ui-toast {
    position: relative;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 24px;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px 17px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    overflow: hidden;
    pointer-events: auto;
    --toast-progress-color: var(--primary);
    animation: uiToastIn 320ms var(--ease-spring) both;
    animation-delay: calc(var(--toast-index, 0) * 80ms);
}

.ui-toast.is-exiting {
    animation: uiToastOut 180ms var(--ease-out) both;
}

.ui-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.ui-toast--success .ui-toast-icon {
    background: var(--success-bg);
    color: var(--success-fg);
}

.ui-toast--success {
    --toast-progress-color: var(--success-fg);
}

.ui-toast--error .ui-toast-icon {
    background: var(--error-bg);
    color: var(--error-fg);
}

.ui-toast--error {
    --toast-progress-color: var(--error-fg);
}

.ui-toast--warning .ui-toast-icon {
    background: var(--warning-bg);
    color: var(--warning-fg);
}

.ui-toast--warning {
    --toast-progress-color: var(--warning-fg);
}

.ui-toast--info .ui-toast-icon {
    background: var(--info-bg);
    color: var(--info-fg);
}

.ui-toast--info {
    --toast-progress-color: var(--info-fg);
}

.ui-toast-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ui-toast-copy strong {
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.25;
}

.ui-toast-copy span {
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.35;
}

.ui-toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.ui-toast-close:hover,
.ui-toast-close:focus-visible {
    background: var(--surface-alt);
    color: var(--primary);
    outline: none;
}

.ui-toast-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--toast-progress-color);
    transform-origin: left center;
    animation: uiToastProgress var(--toast-duration, 5000ms) linear forwards;
}

@keyframes uiToastIn {
    from {
        transform: translateY(-8px);
        opacity: 0;
    }

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

@keyframes uiToastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-8px);
        opacity: 0;
    }
}

@keyframes uiToastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@media (max-width: 720px) {
    .ui-toast-viewport {
        top: 72px;
        right: 12px;
        width: calc(100vw - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ui-toast,
    .ui-toast.is-exiting,
    .ui-toast-progress {
        animation-duration: 1ms;
        animation-delay: 0ms;
    }
}
