/* === Modal (theme-matched) =============================================== */

/* Backdrop */
#modal-backdrop {
    position: fixed;
    display: block;
    inset: 0;
    background: rgba(5,7,9,.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .18s ease;
    z-index: 1000;
}
#modal-backdrop[hidden] { display: none; }
#modal-backdrop[open] { opacity: 1; }

/* Root modal container */
#modal-root.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
#modal-root[hidden] { display: none; }
#modal-root[open] {
    opacity: 1;
    pointer-events: auto;
}

/* Dialog panel */
#modal-root .dialog {
    width: min(720px, 92vw);
    max-height: min(80vh, 820px);
    overflow: hidden;
    border-radius: 16px;
    background:
            linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0)),
            var(--layer-1, #14171a);
    border: 1px solid var(--card-border, rgba(255,255,255,.08));
    box-shadow:
            0 30px 80px rgba(0,0,0,.55),
            0 0 0 1px rgba(255,255,255,.02) inset;
    color: var(--fg);
    transform: translateY(6px) scale(.98);
    transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease;
}
#modal-root[open] .dialog {
    transform: translateY(0) scale(1);
}

/* Body content scroll */
#modal-root .modal-body {
    padding: 20px 22px;
    overflow: auto;
    max-height: inherit;
}

/* Close button */
#modal-root .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    height: 36px;
    width: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--card-border, rgba(255,255,255,.08));
    background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
    color: var(--fg);
    cursor: pointer;
    transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
#modal-root .modal-close:hover {
    transform: translateY(-1px);
    border-color: rgba(255,255,255,.14);
    box-shadow: 0 8px 24px var(--ring, rgba(43,124,255,.28));
}
#modal-root .modal-close:focus-visible {
    outline: 2px solid var(--ring-strong, rgba(43,124,255,.5));
    outline-offset: 2px;
}

/* Headings and text inside modal */
#modal-root .modal-body h1,
#modal-root .modal-body h2,
#modal-root .modal-body h3 { color: #f3f6f9; margin-top: 0; }
#modal-root .modal-body p,
#modal-root .modal-body li { color: #c4ccd4; }
#modal-root .modal-body a { color: var(--brand); }

/* Buttons inside modal inherit your .btn but keep compact by default */
#modal-root .modal-body .btn { width: auto; }

/* Size helpers (optional) */
#modal-root .dialog.modal--sm { width: min(520px, 92vw); }
#modal-root .dialog.modal--md { width: min(720px, 92vw); }
#modal-root .dialog.modal--lg { width: min(980px, 94vw); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #modal-backdrop,
    #modal-root,
    #modal-root .dialog {
        transition: none !important;
    }
}

/* Mobile tweaks */
@media (max-width: 700px) {
    #modal-root .dialog { border-radius: 14px; }
    #modal-root .modal-body { padding: 16px 16px 18px; }
}