.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: opacity 150ms ease-out, display 150ms allow-discrete;
}

.modal[hidden] {
    display: none;
    opacity: 0;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 150ms ease-out, display 150ms allow-discrete;
}

.modal-backdrop[hidden] {
    display: none;
    opacity: 0;
}

.modal-panel {
    position: relative;
    width: min(400px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    background: var(--background);
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.5);
    overflow: clip;
    animation: modal-in 150ms ease-out;
    transition: transform 150ms ease-out;
}

    .modal-panel p.caption {
        margin-block: 0;
    }

    .modal[hidden] .modal-panel {
        transform: translateY(8px) scale(0.98);
    }

    .modal-panel .modal-close {
        padding: 4px;
        margin: -1rem -0.5rem 0 0;
        font-size: 1.15rem;
        opacity: 60%;
    }

        .modal-panel .modal-close:hover {
            opacity: 100%;
        }

        .modal-panel .modal-close svg {
            width: 1.15rem;
            height: 1.15rem;
        }

.modal-panel > form.stack {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
}

.modal-panel.history-panel {
    width: min(720px, 100%);
}

.history-layout {
    display: flex;
    gap: 1rem;
    min-height: 20rem;
    max-height: 60vh;
    overflow: hidden;
}

.history-versions {
    flex: 0 0 11rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.history-diff {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-removed, .history-added {
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.history-line {
    display: flex;
    align-items: stretch;
}

.history-group {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: clip;
}

    .history-group > .history-removed,
    .history-group > .history-added {
        border: none;
        border-radius: 0;
    }

    .history-group > .history-line + .history-line {
        border-top: 1px solid var(--border);
    }

.history-gutter {
    flex-shrink: 0;
    width: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

    .history-gutter svg {
        width: 1em;
        height: 1em;
    }

.history-removed .history-gutter {
    color: var(--danger);
    border-right-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.history-added .history-gutter {
    color: var(--success);
    border-right-color: color-mix(in srgb, var(--success) 40%, transparent);
}

.history-text {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.history-removed {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
}

.history-added {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 40%, transparent);
}

.modal-panel > .label-row:first-child {
    margin: 0.25rem 0.25rem 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    border-top: 1px solid var(--border);
    margin: 0 -0.75rem -0.75rem;
    padding: 0.75rem;
    background: #ffffff08;
}

    .modal-footer > :first-child {
        margin-right: auto;
    }

    .modal-footer [data-loading-submit] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
    }

        .modal-footer [data-loading-submit] svg {
            width: 1em;
            height: 1em;
        }

.modal-panel [data-vp-picker] > .caption,
.auth-card [data-vp-picker] > .caption {
    margin: 0 0 0.6rem;
}

.verify-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

    .verify-options button {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        width: 100%;
        box-sizing: border-box;
        text-align: left;
    }

        .verify-options button > span:last-child {
            display: flex;
            flex-direction: column;
            gap: 1px;
            min-width: 0;
        }

        .verify-options button strong {
            font-size: 14px;
            font-weight: 600;
        }

        .verify-options button small {
            font-size: 12px;
            opacity: 65%;
        }

.verify-icon {
    flex-shrink: 0;
    display: inline-flex;
    font-size: 1.1rem;
    opacity: 75%;
}

@media (width < 40rem) {
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-panel {
        width: 100%;
        max-height: calc(100vh - 2rem);
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
        border-radius: calc(var(--radius) * 1.5) calc(var(--radius) * 1.5) 0 0;
    }

    .modal-panel.history-panel {
        width: 100%;
    }

    .history-layout {
        flex-direction: column;
        max-height: none;
        overflow: visible;
    }

    .history-versions {
        flex: none;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.25rem;
    }

        .history-versions .btn {
            white-space: nowrap;
        }

    .history-diff {
        overflow: visible;
    }

    .modal-footer {
        flex-wrap: wrap;
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal-panel,
    .modal-backdrop {
        transition: none;
        animation: none;
    }
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 120;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    width: min(19rem, calc(100vw - 2rem));
    padding: 0.6rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    background: color-mix(in srgb, var(--foreground) 5%, var(--background));
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    animation: toast-in 150ms ease-out;
}

    .toast-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 1px;
        border-radius: var(--radius);
        flex-shrink: 0;
    }

        .toast-icon svg {
            width: 0.8rem;
            height: 0.8rem;
        }

    .toast[data-kind="success"] .toast-icon {
        color: var(--success);
        background: color-mix(in srgb, var(--success) 16%, transparent);
    }

    .toast[data-kind="error"] .toast-icon {
        color: var(--danger-text);
        background: color-mix(in srgb, var(--danger) 16%, transparent);
    }

    .toast[data-kind="info"] .toast-icon {
        color: var(--link);
        background: color-mix(in srgb, var(--accent) 18%, transparent);
    }

    .toast-text {
        flex: 1;
        min-width: 0;
    }

        .toast-text strong {
            display: block;
            font-size: 13px;
            font-weight: 600;
            line-height: 1.35;
        }

        .toast-text span {
            display: block;
            margin-top: 1px;
            font-size: 12px;
            line-height: 1.35;
            opacity: 65%;
        }

    .toast-close {
        flex-shrink: 0;
        padding: 2px;
        margin: -2px -4px 0 0;
        font-size: 1rem;
        opacity: 55%;
    }

        .toast-close:hover {
            opacity: 100%;
        }

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
}

