html.tqg-popup-open { overflow: hidden; }

dialog.tqg-popup:not([open]) { display: none; }

dialog.tqg-popup[open] {
    position: fixed;
    box-sizing: border-box;
    inset: 0;
    display: block;
    width: min(var(--tqg-popup-width, 560px), calc(100% - 2rem));
    max-width: none;
    max-height: calc(100% - 2rem);
    max-height: calc(100dvh - 2rem);
    margin: auto;
    padding: 0;
    overflow: visible;
    overscroll-behavior: contain;
    border: 0;
    border-radius: 6px;
    background: var(--tqg-popup-bg, #fff);
    color: #202124;
    box-shadow: 0 12px 48px rgb(0 0 0 / 25%);
}

dialog.tqg-popup--corner[open] {
    inset: auto 1rem 1rem auto;
    margin: 0;
}

.tqg-popup::backdrop { background: rgb(0 0 0 / 55%); }

.tqg-popup__body {
    box-sizing: border-box;
    max-height: inherit;
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: inherit;
}

.tqg-popup__body > h2 {
    padding-right: 2.75rem;
    margin: 0 0 1rem;
}

.tqg-popup__close {
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    background: #fff;
    color: #202124;
    font: 1.125rem/1 sans-serif;
    cursor: pointer;
    outline: none;
}

dialog.tqg-popup button.tqg-popup__close:is(:focus, :focus-visible, :hover) {
    outline: none !important;
    box-shadow: none !important;
}

.tqg-popup__close:focus-visible {
    background-color: #f0f2f5;
}

.tqg-popup__close-icon {
    display: block;
    transition: transform 420ms ease-in-out;
}

.tqg-popup__close:hover .tqg-popup__close-icon {
    transform: rotate(360deg);
}

@media (prefers-reduced-motion: reduce) {
    .tqg-popup__close-icon { transition: none; }
}


.tqg-popup__image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 0 1rem;
}

.tqg-popup__form { padding: 12px clamp(12px, 4vw, 20px) 20px; }
