@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

/* 페이지 로딩 표시 (본문 영역만, 레이아웃은 보임) */
.page-content-wrap {
    position: relative;
    min-height: 40vh;
}

/* UNIFIED-FIX: .viewer-wrapper가 HTML에서 제거됨 → body 직접 적용 */
body.viewer-body>.page-content-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.viewer-body>.page-content-wrap>.viewer-content {
    flex: 1;
}

.page-loader {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 249, 250, 0.98);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loader.page-loader-dots {
    background-color: #f5f6f8;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12' viewBox='0 0 40 12'%3E%3Cpath fill='none' stroke='rgba(0,0,0,0.04)' stroke-width='0.5' d='M0 6 Q10 2 20 6 T40 6'/%3E%3C/svg%3E");
    background-size: 40px 12px;
}

.page-loader.is-loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.page-loader-text {
    font-size: 0.9375rem;
    color: #333;
}

/* 7개 점 로딩 인디케이터 (파란 그라데이션 + Loading . . .) */
.page-loader-dots .page-loader-inner {
    gap: 18px;
}

.page-loader-dots-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.page-loader-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: page-loader-dot-pulse 1.2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.1s);
}

.page-loader-dot:nth-child(1) {
    background-color: #93c5fd;
}

.page-loader-dot:nth-child(2) {
    background-color: #7ab3fc;
}

.page-loader-dot:nth-child(3) {
    background-color: #60a5fa;
}

.page-loader-dot:nth-child(4) {
    background-color: #3b82f6;
}

.page-loader-dot:nth-child(5) {
    background-color: #2563eb;
}

.page-loader-dot:nth-child(6) {
    background-color: #1d4ed8;
}

.page-loader-dot:nth-child(7) {
    background-color: #1e40af;
}

@keyframes page-loader-dot-pulse {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.page-loader-dots .page-loader-text {
    font-size: 0.9375rem;
    color: #374151;
    letter-spacing: 0.02em;
}

/* 패드/모바일: 점 크기·간격 조정 */
@media (max-width: 768px) {
    .page-loader-dot {
        width: 9px;
        height: 9px;
    }

    .page-loader-dots-row {
        gap: 8px;
    }

    .page-loader-dots .page-loader-text {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .page-loader-dot {
        width: 8px;
        height: 8px;
    }

    .page-loader-dots-row {
        gap: 6px;
    }

    .page-loader-dots .page-loader-inner {
        gap: 14px;
    }

    .page-loader-dots .page-loader-text {
        font-size: 0.8125rem;
    }
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    margin: 0;
    background: #f7f7f7;
    color: #222;
}

a {
    color: #1565c0;
    text-decoration: none;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

/* 롤링배너 (API 연동 시 get_rolling_banners()에서 데이터 반환) */
.rolling-banner-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e1e1e1;
    background: #e9e9e9;
}

.rolling-banner {
    position: relative;
    width: 100%;
    aspect-ratio: 800 / 280;
    min-height: 200px;
}

.rolling-banner-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.rolling-banner-slide.active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

.rolling-banner-slide img,
.rolling-banner-slide .rolling-banner-link {
    display: block;
    width: 100%;
    height: 100%;
}

.rolling-banner-slide img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.rolling-banner-slide .rolling-banner-link {
    text-decoration: none;
}

.rolling-banner-title {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 6px;
}

.rolling-banner-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e1e1e1;
}

.rolling-banner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #ccc;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}

.rolling-banner-dot:hover {
    background: #999;
}

.rolling-banner-dot.active {
    background: #1565c0;
    transform: scale(1.2);
}

/* 목록 페이지 레이아웃 (첨부 이미지 스타일) */
.list-index-body {
    margin: 0;
    min-height: 100vh;
    background: #fff;
}

.list-index-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.list-index-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #eee;
}

.list-index-header-left,
.list-index-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
}

.list-index-header-right {
    justify-content: flex-end;
}

.list-index-brand {
    text-align: center;
}

.list-index-brand-sub {
    display: block;
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 0.05em;
}

.list-index-brand-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #222;
}

.list-index-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #333;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.list-index-icon-btn:hover {
    background: #555;
    transform: scale(1.05);
}

.list-index-search-bar {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.list-index-search-bar.is-open {
    max-height: 80px;
}

.list-index-search-form {
    display: flex;
    gap: 10px;
    padding: 12px 0 16px;
    align-items: center;
}

.list-index-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9375rem;
}

.list-index-search-input:focus {
    outline: none;
    border-color: #3182F6;
    box-shadow: 0 0 0 2px rgba(49, 130, 246, 0.2);
}

.list-index-search-btn {
    padding: 10px 18px;
    background: #3182F6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    cursor: pointer;
}

.list-index-search-btn:hover {
    background: #1b64da;
}

.list-index-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px 0 0;
    margin: 0 auto;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.list-index-pill {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    font-size: 0.875rem;
    color: #555;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.list-index-pill:hover {
    border-color: #3182F6;
    color: #3182F6;
}

.list-index-pill.is-active {
    background: #3182F6;
    border-color: #3182F6;
    color: #fff;
}

.list-index-pill i {
    margin-right: 6px;
}

.list-index-main {
    padding: 24px 0 40px;
    background: #fff;
}

.list-index-content {
    position: relative;
    min-height: 200px;
}

.list-index-content.is-loading .list-index-grid {
    opacity: 0.6;
    pointer-events: none;
}

.list-index-results-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.list-index-results-count {
    font-size: 0.9375rem;
    color: #555;
}

.list-index-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-index-sort-label {
    font-size: 0.8125rem;
    color: #666;
}

.list-index-sort {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.8125rem;
    background: #fff;
    color: #333;
}

.list-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    transition: opacity 0.2s;
}

.list-index-grid.is-search-result .list-index-empty {
    display: none !important;
}

.list-index-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 0.9375rem;
}

.list-index-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.15s;
}

.list-index-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.list-index-card-img-wrap {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: #f0f0f0;
    overflow: hidden;
}

.list-index-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.list-index-card-placeholder {
    width: 100%;
    height: 100%;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8e8e8 0%, #f0f0f0 100%);
    font-size: 2rem;
    font-weight: 700;
    color: #999;
}

.list-index-card-placeholder-sm {
    min-height: 120px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #999;
}

.list-index-card-title {
    margin: 0;
    padding: 12px 14px 4px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #222;
    line-height: 1.35;
}

.list-index-card-desc {
    margin: 0;
    padding: 0 14px 8px;
    font-size: 0.8125rem;
    color: #666;
    line-height: 1.4;
    flex: 1;
}

.list-index-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px 12px;
    font-size: 0.75rem;
    color: #888;
    border-top: 1px solid #f0f0f0;
}

.list-index-card-meta-type {
    font-weight: 500;
    color: #555;
}

.list-index-result-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 0.9375rem;
}

@media (max-width: 900px) {
    .list-index-main {
        padding: 20px 0 32px;
    }

    .list-index-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
    overflow: hidden;
}

.card img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
    background: #e9e9e9;
}

.card-body {
    padding: 12px;
}

.viewer {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
    padding: 16px;
}

.viewer img {
    width: 100%;
    height: auto;
    display: block;
}

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.toolbar input[type="number"] {
    width: 80px;
}

.alert {
    padding: 10px 12px;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
}

.btn {
    display: inline-block;
    padding: 8px 12px;
    background: #1565c0;
    color: #fff;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.btn.secondary {
    background: #6c757d;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.table th,
.table td {
    padding: 10px;
    border: 1px solid #e1e1e1;
    text-align: left;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* 뷰어 레이아웃: 목차 + 본문 */
.viewer-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.toc-sidebar {
    flex: 0 0 220px;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 12px;
}

.toc-sidebar h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list li {
    margin-bottom: 4px;
}

.toc-list li a {
    display: block;
    padding: 6px 8px;
    border-radius: 4px;
}

.toc-list li.active a {
    background: #E8F3FF;
    color: #3182F6;
}

/* 2depth TOC */
.toc-item { position: relative; }
.toc-item-row { display: flex; align-items: center; }
.toc-item-row > a { flex: 1; min-width: 0; }
.toc-sub-toggle {
    flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    padding: 4px 6px; color: #94a3b8;
    transition: transform 0.2s, color 0.15s;
    line-height: 1;
}
.toc-sub-toggle:hover { color: #3182F6; }
.toc-sub-toggle.open { transform: rotate(180deg); }
.toc-sub-list {
    list-style: none;
    margin: 2px 0 4px 12px;
    padding: 0;
    border-left: 2px solid #e2e8f0;
    display: none;
}
.toc-sub-list.open { display: block; }
.toc-sub-item > a {
    display: block;
    padding: 5px 8px 5px 10px;
    font-size: 0.8rem;
    color: #64748b;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.toc-sub-item > a:hover { background: #f1f5f9; color: #1e293b; }
.toc-sub-item.active > a { background: #E8F3FF; color: #3182F6; }
.toc-pg { font-size: 0.72em; color: #94a3b8; margin-left: 4px; }
.toc-sub-item .toc-pg { color: #b0bec5; }
/* 검색 결과 하위 목차 표시 */
.toc-search-sub-item > a { padding-left: 18px; font-size: 0.82rem; color: #64748b; }
.toc-search-sub-mark { color: #b0bec5; margin-right: 4px; font-size: 0.8em; }

.toc-empty {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

.viewer-main {
    flex: 1;
    min-width: 0;
}

.page-info {
    margin-left: 8px;
}

.page-jump {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

/* 썸네일 스트립 */
.thumb-strip {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e1e1e1;
}

.thumb-strip h4 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
}

.thumb-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.thumb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    color: #222;
}

.thumb-item:hover {
    border-color: #ccc;
}

.thumb-item.active {
    border-color: #1565c0;
    background: #e3f2fd;
}

.thumb-item img {
    width: 72px;
    height: 96px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

.thumb-item span {
    font-size: 0.75rem;
    margin-top: 4px;
}

/* 검색 */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.search-section {
    margin-bottom: 24px;
}

.search-section h2 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.search-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.search-desc {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-top: 4px;
}

/* 수정 폼 목차 행 */
.toc-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.toc-thumb-wrap {
    flex-shrink: 0;
    width: 60px;
    height: 85px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.toc-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.toc-thumb-wrap {
    cursor: pointer;
}

.toc-thumb-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.toc-thumb-popup.visible {
    display: flex;
}

.toc-thumb-popup-inner {
    width: 600px;
    height: 850px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toc-thumb-popup-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.toc-row input[type="number"] {
    width: 80px;
}

.toc-row input[type="text"] {
    flex: 1;
}

.form-hint {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 0.9rem;
}

.logo-upload-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.2s, background 0.2s;
}

.logo-upload-zone:hover,
.logo-upload-zone.dragover {
    border-color: #3182F6;
    background: #f0f7ff;
}

.logo-upload-placeholder {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-upload-text {
    color: #666;
    font-size: 0.95rem;
}

.logo-upload-placeholder .logo-preview {
    max-width: 200px;
    max-height: 120px;
    object-fit: contain;
}

.form-section {
    margin-bottom: 24px;
}

.form-section h2 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.form-section select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

/* ===== 이북 뷰어 ===== */
html.viewer-html {
    height: 100%;
    margin: 0;
    padding: 0;
}

html.viewer-html body.viewer-body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.viewer-body {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    /* 최신 모바일 기기의 상하 주소창/메뉴바를 인식하여 동적인 화면 높이 할당 */
}

/* UNIFIED-FIX: .viewer-wrapper 제거됨 → body가 직접 flex 컨테이너 역할 */
body.viewer-body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewer-body {
    background: #e8e8e8;
    overflow: hidden;
}

/* UNIFIED-FIX: .viewer-wrapper 제거됨 — 이 규칙은 body.viewer-body로 병합됨 */

.viewer-header .btn,
.viewer-header .header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    /* 기존 8px -> 6px로 슬림화 */
    font-size: 0.875rem;
    border-radius: 99px;
    /* 더 둥근 버튼으로 변경 */
    border: 1px solid #E2E8F0;
    background: #fff;
    color: #475569;
    min-height: 34px;
    height: 34px;
    box-sizing: border-box;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewer-header .btn:hover,
.viewer-header .header-btn:hover {
    background: #F2F4F6;
    color: #191F28;
}

.viewer-header .btn[href*="download"],
.viewer-header #printBtn {
    background: var(--saas-primary, #6366f1);
    border-color: var(--saas-primary, #6366f1);
    color: #fff;
    font-weight: 600;
}

.viewer-header .btn[href*="download"]:hover,
.viewer-header #printBtn:hover {
    background: #1B64DA;
    border-color: #1B64DA;
    color: #fff;
}

#fullscreenBtn {
    background: #F2F4F6;
}

#fullscreenBtn:hover {
    background: #E8EBEF;
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 24px;
    /* 수직 패딩 제거, height로 제어 */
    height: 64px;
    /* 고정 높이로 슬림화 */
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    /* 블러 효과 추가 */
    border-bottom: 1px solid #E2E8F0;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* 미세한 그림자 */
    z-index: 1000;
}

.viewer-header-left {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
}

.viewer-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 4px;
}

.viewer-header-title-wrap {
    flex: 0 0 auto;
    position: static;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    overflow: hidden;
    pointer-events: none;
    max-width: 240px;
    padding: 0 8px 0 32px;
}

.viewer-header-title-wrap .viewer-header-title {
    pointer-events: auto;
    text-align: center;
}

.viewer-header-logo {
    width: 250px;
    max-width: 250px;
    height: 100%;
    max-height: 64px;
    object-fit: contain;
    object-position: left center;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.viewer-header-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2DD4BF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.viewer-header-title-wrap .viewer-header-title {
    max-width: none;
}

/* === 모바일/패드 헤더 레이아웃 조정 === */

/* 패드 모드 (1366px 이하): 로고 여백 무시하고 무조건 화면의 정중앙에 제목 배치 */
body.viewer-mobile-mode-v23 .viewer-header-title-wrap {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    /* 화면 정중앙 고정 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    flex: none !important;
    width: auto !important;
    max-width: 50% !important;
    /* 가운데에서 차지할 최대 폭 */
    justify-content: center !important;
    z-index: 100 !important;
    padding: 0 !important;
}

body.viewer-mobile-mode-v23 .viewer-header-title-wrap .viewer-header-title {
    display: block !important;
    visibility: visible !important;
    text-align: center !important;
    pointer-events: auto !important;
    color: #191F28 !important;
    max-width: 100% !important;
}

/* 모바일 모드 (768px 이하): 로고 숨기고 제목은 원래 로고가 있던 왼쪽에서 시작 */
@media (max-width: 768px) {
    .viewer-header-brand {
        display: none !important;
    }

    body.viewer-mobile-mode-v23 .viewer-header-title-wrap {
        position: absolute !important;
        left: 24px !important;
        /* 헤더의 좌측 기본 여백과 동일하게 시작 */
        transform: none !important;
        /* 중앙 정렬 해제 */
        justify-content: flex-start !important;
        /* 왼쪽 정렬 */
        width: calc(100% - 100px) !important;
        /* 우측 햄버거 메뉴 공간 확보 */
        max-width: none !important;
    }

    body.viewer-mobile-mode-v23 .viewer-header-title-wrap .viewer-header-title {
        text-align: left !important;
    }
}

.viewer-header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    flex: none;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 2;
}

body.viewer-mobile-mode-v23 .viewer-header-center {
    display: none !important;
}

.viewer-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
}

.viewer-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin-left: auto;
}

.viewer-hamburger {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.viewer-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #333;
    border-radius: 1px;
}

.viewer-hamburger:hover span {
    background: #1565c0;
}

.viewer-header .header-btn i {
    margin-right: 0;
    font-size: 18px;
}

.viewer-header .page-jump-btn i,
.viewer-header .zoom-btn i {
    font-size: 18px;
}

.viewer-hamburger i {
    font-size: 18px;
    color: #333;
}

.viewer-hamburger:hover i {
    color: #1565c0;
}

.page-jump-btn {
    padding: 6px 10px;
    font-size: 1rem;
    min-width: 36px;
}

.page-display {
    font-size: 0.95rem;
    color: #333;
    min-width: 60px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: #f0f0f0;
}

.zoom-btn-1x {
    width: auto;
    min-width: 36px;
    font-size: 0.8rem;
    font-weight: 600;
}

.zoom-slider {
    width: 80px;
    height: 6px;
    accent-color: #3182F6;
}

.zoom-value {
    font-size: 0.85rem;
    color: #666;
    min-width: 36px;
}

.header-slider-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 140px;
}

.header-slider {
    width: 100%;
    height: 4px;
    accent-color: #3182F6;
    cursor: pointer;
}

.zoom-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 10px 16px;
    background: rgba(255, 255, 255, 0.98);
    border-left: 1px solid #e0e0e0;
    box-shadow: -2px 0 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.zoom-panel-close {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #f0f0f0;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    z-index: 10;
}

.zoom-panel-close i {
    pointer-events: none;
}

.zoom-panel-close:hover {
    background: #e0e0e0;
    color: #333;
}

.zoom-control-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.zoom-vertical-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.zoom-slider-vertical-wrap {
    width: 24px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.zoom-slider-vertical {
    width: 120px;
    height: 24px;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    accent-color: #3182F6;
    transform: rotate(-90deg);
    transform-origin: 60px 12px;
    cursor: pointer;
}

.zoom-slider-vertical::-webkit-slider-runnable-track {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
}

.zoom-slider-vertical::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3182F6;
    margin-top: -6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zoom-slider-vertical::-moz-range-track {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
}

.zoom-slider-vertical::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3182F6;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zoom-control-vertical .zoom-btn {
    flex-shrink: 0;
}

.zoom-control-vertical .zoom-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: #3182F6;
}

body.zoom-panel-open .book-area .page-nav-circle,
body.zoom-panel-open .page-nav-circle {
    display: none !important;
}

.viewer-content {
    flex: 1;
    display: flex;
    position: relative;
    min-height: 0;
    overflow: hidden;
    flex: 1 1 0%;
    min-height: 200px;
}

body.fullscreen-mode .viewer-header {
    display: none;
}

.fullscreen-exit-btn {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 42px;
    height: 42px;
    padding: 0;
    background: #3182F6;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-exit-btn:hover {
    background: #1b64da;
}

body.fullscreen-mode .fullscreen-exit-btn {
    display: block !important;
}

/* UNIFIED-FIX: fullscreen 시 body 직접 타겟 */
body.fullscreen-mode {
    height: 100vh;
}

body.fullscreen-mode .viewer-content {
    flex: 1;
    overflow: visible;
}

body.fullscreen-mode .book-area {
    overflow: visible;
}

body.fullscreen-mode .flipbook-wrap {
    flex: none;
}

.page-nav-circle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    background: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
    padding: 0;
}

.page-nav-circle:hover {
    background: #fff;
    border-color: #ccc;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.page-nav-prev {
    left: 16px;
}

.page-nav-next {
    right: 16px;
}

.nav-arrow {
    line-height: 1;
    color: #333;
}

.page-nav-circle .nav-arrow-img {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.page-nav-circle:hover .nav-arrow-img {
    opacity: 1;
}

.book-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-width: 0;
    position: relative;
    overflow: hidden;
    min-height: 300px;
    cursor: pointer;
}

.book-area.pan-mode {
    user-select: none;
    -webkit-user-select: none;
}

.flipbook-wrap {
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 50% 100%;
    padding: 0;
    border-radius: 4px;
    transform-origin: center center;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* 모바일 전용 배경 설정 (싱글 페이지) */
@media (max-width: 1366px) {
    .flipbook-wrap {
        background-position: center center;
        background-size: contain;
    }
}

#pageFlipBook {
    transition: opacity 0.5s ease;
    opacity: 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: transparent !important;
}

.flipbook-wrap.ready #pageFlipBook {
    opacity: 1;
}

#pageFlipBook.stf__parent {
    background: transparent !important;
}

#pageFlipBook .stf__block {
    background: transparent !important;
}

#pageFlipBook .stf__outer {
    background: transparent !important;
}

/* page-flip library overrides */
#pageFlipBook canvas {
    background: transparent !important;
}

/* 북마크 리본 스타일 */
.page-bookmark-btn {
    position: absolute;
    top: -1px !important;
    /* 틈새 제거 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 100;
    line-height: 0;
    display: block;
    transition: transform 0.2s ease;
}

.bookmark-ribbon {
    width: 16px;
    height: 24px;
    fill: #E0E0E0;
    /* 기본 상태: 연회색 */
    transition: fill 0.3s ease;
}

.page-bookmark-btn.bookmarked .bookmark-ribbon {
    fill: #3182F6;
    /* 활성 상태: 메인 블루 */
}

.page-bookmark-btn:hover {
    transform: translateY(2px);
}

.pf-page {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
    /* 배경색 제거로 흰색 여백 노출 방지 */
}

.pf-page .pf-page-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pf-page .pf-page-img img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* 여백 없이 꽉 채우기 위해 fill 적용 - 1px 소수점 오차 해결 */
    display: block;
}



/* 레거시 (page-flip 미사용시) */
.book-scene {
    position: relative;
    width: 1108px;
    margin: 0 auto;
    cursor: pointer;
    perspective: 1200px;
    overflow: hidden;
}

.book-spread {
    display: flex;
    width: 1108px;
    height: 786px;
    margin: 0 auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.book-spread.cover-mode .page-left {
    flex: 0 0 554px;
    width: 554px;
    min-width: 554px;
}

.book-spread .page-left,
.book-spread .page-right {
    flex: 0 0 554px;
    width: 554px;
    height: 786px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.book-spread .page-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-spread .page-blank {
    background: #e8e8e8 !important;
}



.book-spread .page-content img {
    width: 100%;
    height: 100%;
    min-height: 786px;
    object-fit: fill;
    display: block;
}

/* 3D 페이지 넘기기 */
.flip-container {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    perspective: 1200px;
    transform-style: preserve-3d;
    overflow: hidden;
}

.flip-container.flip-next {
    display: flex;
    justify-content: flex-end;
}

.flip-container.flip-prev {
    display: flex;
    justify-content: flex-start;
}

.flip-page {
    width: 50%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    border-radius: 0 2px 2px 0;
}

.flip-page.flip-prev {
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    border-radius: 2px 0 0 2px;
}

.flip-page .flip-front::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: linear-gradient(to right, transparent 60%, rgba(0, 0, 0, 0.04) 80%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
}

.flip-page.animating .flip-front::after {
    opacity: 1;
}

.flip-page.flip-prev .flip-front::after {
    background: linear-gradient(to left, transparent 60%, rgba(0, 0, 0, 0.04) 80%, rgba(0, 0, 0, 0.1) 100%);
}

.flip-img-wrap {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.flip-img-wrap img {
    width: 100%;
    height: 100%;
    min-height: 786px;
    object-fit: contain;
    display: block;
}

.flip-page .flip-shadow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0%, transparent 40%);
    transform: translateZ(-1px);
    opacity: 0;
}

.flip-page.animating .flip-shadow {
    opacity: 1;
}

.flip-page.flip-prev .flip-shadow {
    left: auto;
    right: 0;
    background: linear-gradient(270deg, rgba(0, 0, 0, 0.1) 0%, transparent 40%);
}

.flip-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
}

.flip-front {
    transform: rotateY(0deg);
    background: transparent;
}

.flip-back {
    transform: rotateY(180deg);
    background: transparent;
}

.flip-back .flip-inner {
    transform: rotateY(180deg);
    transform-style: preserve-3d;
}

.flip-back .flip-inner,
.flip-back .flip-img-wrap {
    width: 100%;
    height: 100%;
}

.flip-back .flip-inner img,
.flip-back .flip-img-wrap img {
    width: 100%;
    height: 100%;
    min-height: 786px;
    object-fit: fill;
    display: block;
}

.flip-inner {
    width: 100%;
    height: 100%;
}

.flip-inner img {
    width: 100%;
    height: 100%;
    min-height: 786px;
    object-fit: contain;
    display: block;
}

.side-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
}

.side-backdrop.visible {
    display: block;
}

/* 공유 패널 (오른쪽 슬라이드) */
.share-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
}

.share-backdrop.visible {
    display: block;
}

.share-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 90vw;
    /* MOBILE-FIX: 100vh -> 100dvh 교체 */
    height: calc(var(--real-vh, 1vh) * 100);
    height: 100dvh;
    background: #fff;
    border-left: 1px solid #e1e1e1;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.share-panel.open {
    transform: translateX(0);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.share-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e1e1e1;
    flex-shrink: 0;
}

.share-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.share-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.share-panel-close:hover {
    color: #222;
}

.share-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.share-panel-desc {
    margin: 0 0 16px;
    font-size: 0.875rem;
    color: #666;
}

.share-sns-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.share-sns-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background 0.2s, transform 0.15s;
    border: 1px solid #eee;
    background: #fff;
}

.share-sns-btn:hover {
    background: #f5f5f5;
    transform: translateX(-2px);
}

.share-sns-btn:active {
    transform: translateX(0);
}

.share-sns-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
}

.share-sns-icon svg {
    width: 24px;
    height: 24px;
}

.share-sns-kakao .share-sns-icon {
    background: #FEE500;
    color: #3C1E1E;
}

.share-sns-facebook .share-sns-icon {
    background: #1877F2;
    color: #fff;
}

.share-sns-twitter .share-sns-icon {
    background: #000;
    color: #fff;
}

.share-sns-line .share-sns-icon {
    background: #00B900;
    color: #fff;
}

.share-sns-band .share-sns-icon {
    background: #00C73C;
    color: #fff;
}

.share-toast {
    margin: 12px 0 0;
    padding: 10px 12px;
    font-size: 0.8125rem;
    color: #0c5460;
    background: #d1ecf1;
    border-radius: 8px;
    border: 1px solid #bee5eb;
}

/* 모바일 슬라이드 뷰 (1페이지씩) - 1366px 이하에서 CSS로 표시 */
.mobile-slide-view {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    width: 100%;
    height: 100%;
}

.mobile-slide-track {
    display: flex;
    height: 100%;
    width: 100%;
    min-height: 0;
    transition: none;
    will-change: transform;
    flex-shrink: 0;
}

.mobile-slide-view .mobile-page {
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* VERTICAL-SLIDE: safe-area는 상위 헤더/푸터에서 처리하므로 mobile-page에서 제거 */

.mobile-slide-view .mobile-page img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* 원본 비율을 유지하며 화면에 맞춤 (찌그러짐 방지) */
    object-position: center;
    display: block;
    margin: 0;
    transform: translateZ(0);
    backface-visibility: hidden;
}

body.viewer-mobile-mode-v23 .flipbook-wrap {
    display: none !important;
    visibility: hidden;
    position: absolute;
    pointer-events: none;
}

body.viewer-mobile-mode-v23 .mobile-slide-view {
    display: block !important;
    visibility: visible !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

body.viewer-mobile-mode-v23 .page-nav-circle {
    display: none;
}

/* 하단 페이지 진행 슬라이더 (모바일/패드) */
.viewer-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #E8EBEF;
    font-size: 0.875rem;
    color: #333;
    min-height: 56px;
    box-sizing: border-box;
}

@supports (padding: max(1px, env(safe-area-inset-bottom))) {
    .viewer-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

.viewer-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

.viewer-footer-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: #F2F4F6;
    color: #4E5968;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    touch-action: manipulation;
}

.viewer-footer-btn:hover {
    background: #E8EBEF;
    color: #191F28;
}

.viewer-footer-btn:active {
    background: #D1D5DB;
}

.viewer-footer-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.viewer-footer-btn svg {
    display: block;
}

.viewer-footer-slider-wrap {
    flex: 1;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin: 0 8px;
}

.viewer-footer-page-num {
    font-size: 0.6875rem;
    color: #6B7280;
    line-height: 1;
    font-weight: 500;
}

.viewer-footer-slider-wrap .viewer-footer-slider {
    width: 100%;
    margin: 0;
}

.viewer-footer-slider {
    flex: 1;
    min-width: 60px;
    height: 6px;
    margin: 0 8px;
    accent-color: #3182F6;
}

.viewer-footer-page {
    flex-shrink: 0;
    min-width: 2ch;
    font-weight: 600;
    color: #191F28;
}

.viewer-footer-mobile {
    display: none;
}

/* == UNIFIED-FIX: 통합 모바일 배경 균일화 (viewer-wrapper 제거 반영) == */
html.viewer-html.viewer-mobile-mode-v23,
body.viewer-mobile-mode-v23,
body.viewer-mobile-mode-v23 .page-content-wrap,
body.viewer-mobile-mode-v23 .viewer-content,
body.viewer-mobile-mode-v23 .book-area {
    /* VERTICAL-SLIDE: 모든 레이어 흰 배경 통일 — 회색 플래시 근절 */
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 모바일 푸터를 강제 고정이 아닌, 플렉스 하단 배치 요소로 둠 */
body.viewer-mobile-mode-v23 .viewer-footer-mobile {
    display: flex !important;
    position: relative !important;
    flex: 0 0 auto !important;
    z-index: 9999 !important;
    background: #fff;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

/* 도화지 영역은 부모 플렉스 컨테이너 안에서 남은 공간 전체를 정확히 차지함 */
body.viewer-mobile-mode-v23 .mobile-slide-view {
    position: relative !important;
    display: block !important;
    flex: 1 1 0% !important;
    width: 100% !important;
    height: auto !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

body.viewer-mobile-mode-v23 .mobile-slide-view .mobile-page {
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.viewer-mobile-mode-v23 .mobile-slide-view .mobile-page img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    margin: 0 !important;
}

/* 사이드 패널 메뉴 (모바일) */
.side-panel-menu {
    display: none;
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid #e1e1e1;
}

.side-panel-menu-item {
    display: block;
    padding: 12px 14px;
    text-align: left;
    font-size: 1rem;
    color: #222;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
}

.side-panel-menu-item:hover {
    background: #f2f4f6;
}

.side-panel-menu-item i {
    margin-right: 8px;
}

/* SOUND-TOGGLE: 효과음 토글 버튼 스타일 */
.side-panel-sound-toggle {
    display: flex !important;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f0f0f0;
    margin-top: 4px;
    padding-top: 12px !important;
    color: #3182F6;
    transition: color 0.2s;
}

/* 사이드 패널 (목차/썸네일 토글) */
.side-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 85vw;
    /* MOBILE-FIX: 100vh -> 100dvh 교체 */
    height: calc(var(--real-vh, 1vh) * 100);
    height: 100dvh;
    background: #fff;
    border-right: 1px solid #e1e1e1;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.side-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e1e1e1;
    flex-shrink: 0;
}

.side-panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.side-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.side-panel-close:hover {
    color: #222;
}

.side-panel-body {
    flex: 1;
    overflow-y: auto;
}

.side-panel-toc {
    padding: 12px;
}

.side-panel-search {
    padding: 12px;
}

.toc-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.toc-search-empty {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

.side-panel-thumb {
    padding: 12px;
}

.side-panel-thumb .thumb-panel-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.side-panel-toc .toc-list li a {
    padding: 8px 10px;
}

.side-panel-bookmark {
    padding: 12px;
}

.btn-add-bookmark {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #3182F6;
    background: #fff;
    color: #3182F6;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-add-bookmark:hover {
    background: #F2F4F6;
}

.bookmark-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bookmark-list li a {
    flex: 1;
    padding: 8px 10px;
}

.bookmark-remove {
    background: none;
    border: none;
    color: #8B95A1;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
}

.bookmark-remove:hover {
    color: #3182F6;
}

.bookmark-empty {
    margin: 0;
    color: #8B95A1;
    font-size: 0.9rem;
}

.thumb-panel-list {
    display: grid;
    align-content: start;
}

.thumb-panel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    color: #222;
    transition: border-color 0.2s, background 0.2s;
}

.thumb-panel-item:hover {
    border-color: #ccc;
    background: #f9f9f9;
}

.thumb-panel-item.active {
    border-color: #3182F6;
    background: #E8F3FF;
}

.thumb-panel-item img {
    width: 100%;
    max-width: 90px;
    height: auto;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.thumb-panel-item span {
    font-size: 0.75rem;
    margin-top: 4px;
}

/* 패드/모바일 반응형 (1366px 이하 = 모바일·패드 동일 레이아웃, Chrome 패드 대응) */
@media (max-width: 1366px) {

    /* UNIFIED-FIX: min-height: 100vh 제거 — dvh 기반 높이가 이미 적용됨 */
    body.viewer-body {
        min-height: 0;
    }

    .viewer-header {
        padding: 10px 12px;
        gap: 8px;
        min-height: auto;
    }

    @supports (padding: max(1px, env(safe-area-inset-left))) {
        .viewer-header {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
            padding-top: max(10px, env(safe-area-inset-top));
        }
    }

    .viewer-header-left {
        flex: 0 0 auto;
    }

    .viewer-header-brand {
        flex: none;
    }

    .viewer-header-title-wrap {
        position: static;
        left: auto;
        width: auto;
        flex: 1;
        min-width: 0;
        justify-content: center;
        align-items: center;
        padding: 0 8px;
    }

    .viewer-header-title-wrap .viewer-header-title {
        text-align: center;
        font-size: 0.9rem;
        padding: 0;
    }

    .viewer-header-logo {
        flex-shrink: 0;
        width: 250px;
        max-width: 250px;
        max-height: 44px;
    }

    .viewer-header-title {
        max-width: none;
    }

    .viewer-header-center {
        display: flex !important;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        gap: 8px;
        z-index: 10;
    }

    .viewer-header-center .page-jump-btn {
        padding: 4px 6px;
        min-width: 32px;
    }

    .header-slider-wrap {
        min-width: 100px;
        display: flex;
    }

    .header-slider {
        display: block !important;
        height: 4px;
    }

    .viewer-header-title-wrap {
        display: flex;
        flex: 1;
        justify-content: center;
        align-items: center;
        padding: 0 10px;
        min-width: 0;
        z-index: 100;
    }

    .viewer-header-right {
        flex: 0 0 auto;
        justify-content: flex-end;
    }

    .viewer-header-btns {
        display: none !important;
    }

    .viewer-hamburger {
        display: flex;
    }

    .book-area {
        padding: 12px;
        min-height: 0;
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 120px;
    }

    @supports (padding: max(1px, env(safe-area-inset-left))) {
        .book-area {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
            padding-top: max(12px, env(safe-area-inset-top));
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }

    .flipbook-wrap {
        display: none !important;
        padding: 12px;
        /* MOBILE-FIX: 100vh -> 100dvh 교체 */
        max-height: calc(calc(var(--real-vh, 1vh) * 100) - 180px);
        max-height: calc(100dvh - 180px);
        min-height: 0;
    }

    .book-area {
        height: 100%;
    }

    .mobile-slide-view {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        z-index: 2;
        /* VERTICAL-SLIDE: #e8e8e8 → #fff 회색 플래시 원인 제거 */
        background: #fff;
    }

    .mobile-slide-track {
        height: 100%;
        width: 100%;
        min-height: 100%;
    }

    .page-nav-circle {
        display: none !important;
    }

    .side-panel {
        left: auto;
        right: 0;
        width: 280px;
        max-width: 92vw;
        border-right: none;
        border-left: 1px solid #e1e1e1;
        box-shadow: none;
        transform: translateX(100%);
    }

    .side-panel.open {
        transform: translateX(0);
    }

    .side-panel-menu {
        display: flex;
    }

    .viewer-footer,
    .viewer-footer-mobile {
        display: flex !important;
        flex-shrink: 0;
        visibility: visible !important;
        min-height: 56px;
    }

    /* UNIFIED-FIX: .viewer-wrapper 제거됨 → body 직접 타겟 */
    body.viewer-body {
        display: flex;
        flex-direction: column;
        height: calc(var(--real-vh, 1vh) * 100);
        height: 100dvh;
        max-height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        touch-action: pan-y pinch-zoom;
    }

    /* UNIFIED-FIX: 푸터가 body의 직접 자식이므로 > 선택자 수정 */
    body.viewer-body>.viewer-footer {
        flex-shrink: 0;
    }

    body.viewer-body .viewer-content {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    body.viewer-body .viewer-content .book-area {
        flex: 1;
        min-height: 200px;
    }
}

@media (max-width: 768px) {
    .viewer-header {
        padding: 8px 12px;
    }

    .viewer-header-title {
        max-width: 120px;
        font-size: 0.875rem;
    }

    .viewer-header-logo {
        max-height: 38px;
        max-width: 160px;
    }

    .book-area {
        padding: 8px;
    }

    .flipbook-wrap {
        padding: 8px;
        /* MOBILE-FIX: 100vh -> 100dvh 교체 */
        max-height: calc(calc(var(--real-vh, 1vh) * 100) - 160px);
        max-height: calc(100dvh - 160px);
    }

    .viewer-footer {
        padding: 10px 12px;
    }

    .viewer-footer-btn {
        width: 36px;
        height: 36px;
    }

    .viewer-footer-btn svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .viewer-header-title {
        max-width: 100px;
    }

    .flipbook-wrap {
        /* MOBILE-FIX: 100vh -> 100dvh 교체 */
        max-height: calc(calc(var(--real-vh, 1vh) * 100) - 150px);
        max-height: calc(100dvh - 150px);
    }
}