.afc-popup,
.afc-popup * {
    box-sizing: border-box;
}

.afc-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    visibility: hidden;
    opacity: 0;
    transition: opacity .2s ease, visibility .2s ease;
}

.afc-popup.is-open {
    visibility: visible;
    opacity: 1;
}

.afc-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 20, .72);
}

.afc-popup__panel {
    position: relative;
    z-index: 1;
    /* 5:7 팝업 이미지와 하단 조작부가 화면 높이 안에 함께 들어오도록
       패널 자체를 줄여 이미지 양옆에 흰 여백이 남지 않게 한다. */
    width: min(500px, calc(100vw - 40px));
    width: min(500px, calc(71.4286dvh - 97.86px), calc(100vw - 40px));
    max-height: calc(100dvh - 40px);
    overflow: auto;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
    overscroll-behavior: contain;
}

.afc-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .62);
    color: #fff;
    font-size: 30px;
    font-weight: 300;
    line-height: 36px;
    cursor: pointer;
}

.afc-popup__media {
    position: relative;
    overflow: hidden;
    background: #f3f3f3;
}

.afc-popup__swiper,
.afc-popup__slide,
.afc-popup__item,
.afc-popup__item > a {
    width: 100%;
}

.afc-popup__slide,
.afc-popup__item,
.afc-popup__item > a {
    display: flex;
    align-items: center;
    justify-content: center;
}

.afc-popup__item p {
    width: 100%;
    margin: 0;
    font-size: 0;
    line-height: 0;
}

.afc-popup__item img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0 auto;
}

.afc-popup__navigator {
    position: absolute;
    top: 10px;
    right: 56px;
    z-index: 15;
    display: flex;
    align-items: center;
    height: 38px;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(255, 255, 255, .9);
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
}

.afc-popup__navigator button {
    width: 34px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #333;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.afc-popup__counter {
    min-width: 52px;
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
}

.afc-popup__tabs {
    display: grid;
    grid-template-columns: repeat(var(--afc-popup-columns), minmax(0, 1fr));
    border-top: 1px solid #ddd;
    background: #fff;
}

.afc-popup__tab {
    min-height: 50px;
    padding: 9px 8px;
    border: 0;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    background: #fff;
    color: #222;
    font-size: 13px;
    line-height: 1.35;
    word-break: keep-all;
    cursor: pointer;
}

.afc-popup__tab:nth-child(4n),
.afc-popup__tab:last-child {
    border-right: 0;
}

.afc-popup__tab.is-active {
    background: #252525;
    color: #fff;
    font-weight: 700;
}

.afc-popup__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #333;
}

.afc-popup__actions button {
    min-height: 42px;
    padding: 9px 12px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.afc-popup__actions button + button {
    border-left: 1px solid rgba(255, 255, 255, .55);
}

@media (max-width: 768px) {
    .afc-popup {
        padding: 12px;
    }

    .afc-popup__panel {
        width: min(500px, calc(100vw - 24px));
        width: min(500px, calc(71.4286dvh - 117.14px), calc(100vw - 24px));
        max-height: calc(100dvh - 24px);
    }

    .afc-popup__tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 116px;
        overflow-y: auto;
    }

    .afc-popup__tab {
        min-height: 48px;
        padding: 8px 6px;
        font-size: 12px;
    }

    .afc-popup__tab:nth-child(4n) {
        border-right: 1px solid #ddd;
    }

    .afc-popup__tab:nth-child(2n),
    .afc-popup__tab:last-child {
        border-right: 0;
    }

    .afc-popup__actions button {
        min-height: 44px;
        font-size: 12px;
    }
}

@media (max-height: 560px) and (orientation: landscape) {
    .afc-popup__panel {
        width: min(500px, calc(71.4286dvh - 87.14px), calc(100vw - 24px));
    }

    .afc-popup__tabs {
        max-height: 54px;
        overflow-y: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .afc-popup {
        transition: none;
    }
}
