/* 초기화 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body, html { margin: 0; padding: 0; background: #222; overflow: hidden; font-family: sans-serif; }

/* 전체 레이아웃: 모바일 크롬 대응 */
.app-layout {
    width: 100%;
    height: 100vh; /* 구형 브라우저용 fallback */
    display: flex;
    flex-direction: column;
}

/* dvh 지원 브라우저용 - @supports로 안전하게 적용 */
@supports (height: 100dvh) {
    .app-layout {
        height: 100dvh;
    }
}

/* 1. 카탈로그 영역 */
.catalog-area {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    width: 100%;
}

#flipbook {
    box-shadow: 0 5px 20px rgba(0,0,0,0.6);
    background: #fff;
    /* PC에서 너무 커지지 않도록 최대 높이 제한 */
    max-height: 100%;
}

/* PC 화면에서 카탈로그 크기 제한 */
@media (min-width: 768px) {
    .catalog-area {
        padding: 20px;
    }
    
    #flipbook {
        max-height: calc(100vh - 130px); /* 컨트롤바 + 여백 고려 */
    }
}

.page img {
    width: 100%; 
    height: 100%;
    object-fit: cover;
    -webkit-user-drag: none;
    user-select: none;
}

/* 2. 하단 컨트롤 바 */
.control-bar {
    height: 70px;
    flex-shrink: 0;
    background: #111;
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 10px;
    color: #fff;
    padding-bottom: env(safe-area-inset-bottom); 
    z-index: 50;
}

button { 
    padding: 8px 16px; 
    border-radius: 4px; 
    background: #444; 
    border: none; 
    color: #fff; 
    font-size: 14px; 
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #555;
}

button:active {
    background: #333;
}

.active-btn { 
    background: #d35400; 
    font-weight: bold; 
}

.active-btn:hover {
    background: #e67e22;
}

/* 3. 확대 모달 */
.modal-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh;
    background: #000; 
    z-index: 9999;
}

@supports (height: 100dvh) {
    .modal-overlay {
        height: 100dvh;
    }
}

.modal-center {
    width: 100%; 
    height: 100%;
    overflow: auto;
    padding: 0;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

/* PC: 드래그 커서 */
@media (min-width: 768px) {
    .modal-center {
        cursor: grab;
    }
    
    .modal-center:active {
        cursor: grabbing;
    }
}

#zoomTarget {
    display: block;
    width: 200%;
    height: auto;
    margin: 0;
    padding: 0;
    transform-origin: 0 0;
}

.close-btn { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    color: #fff; 
    font-size: 40px; 
    cursor: pointer; 
    z-index: 10000; 
    padding: 10px;
    line-height: 1;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 0.7;
}

.guide-text { 
    position: absolute; 
    bottom: 30px; 
    width: 100%; 
    text-align: center; 
    color: #888; 
    font-size: 13px; 
    pointer-events: none;
    /* 아이폰 하단 여백 대응 */
    padding-bottom: env(safe-area-inset-bottom);
}