/* Flipbook CSS - Category: 연구통계사례 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #667eea;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 검색 패널 */
.search-panel {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 10px;
    z-index: 950;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

#searchInput {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
}

#searchInput:focus {
    border-color: #3498db;
    background: rgba(255,255,255,0.15);
}

#searchInput::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-execute-btn, .close-search-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-execute-btn:hover {
    background: rgba(52,152,219,0.8);
}

.close-search-btn:hover {
    background: rgba(231,76,60,0.8);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 0.8rem;
    margin: 0.3rem 0;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid #3498db;
}

.search-result-item:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(5px);
}

.search-result-page {
    font-weight: bold;
    color: #3498db;
    margin-bottom: 0.3rem;
}

.search-result-text {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
    line-height: 1.4;
}

.search-result-text mark {
    background: #f39c12;
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
}

.search-no-results {
    text-align: center;
    padding: 2rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
}

/* 모바일 검색 최적화 */
@media (max-width: 768px) {
    .search-container {
        flex-wrap: nowrap;
    }
    
    #searchInput {
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
    }
    
    .search-execute-btn, .close-search-btn {
        width: 36px;
        height: 36px;
        padding: 0.5rem;
    }
    
    .search-results {
        max-height: 200px;
    }
    
    .search-result-item {
        padding: 0.6rem;
    }
}

/* 헤더 - 높이 줄임 */
/* 헤더 - 모바일에서 더 컴팩트하게 */
.header {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    min-height: 50px;
    flex-wrap: nowrap;  /* 줄바꿈 방지 */
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 300;
    margin: 0;
    white-space: nowrap;  /* 텍스트 줄바꿈 방지 */
    overflow: hidden;
    text-overflow: ellipsis;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: nowrap;  /* 줄바꿈 방지 */
    flex-shrink: 0;     /* 축소 방지 */
}

.controls button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;  /* 버튼 크기 고정 */
}

.controls button:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.controls button.active {
    background: rgba(52,152,219,0.8);
    box-shadow: 0 4px 12px rgba(52,152,219,0.3);
}

.controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#pageInfo {
    background: rgba(0,0,0,0.6);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    min-width: 90px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;  /* 텍스트 줄바꿈 방지 */
    flex-shrink: 0;       /* 축소 방지 */
}


/* 패널 - 높이 줄임 */
.panel {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 5px 10px;  /* 상하 패딩을 5px로 줄임 */
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
    backdrop-filter: blur(10px);
    position: relative;
    visibility: hidden;
    opacity: 0;
    margin: 0;  /* 마진 제거 */
}

.panel.show {
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
}

/* 음성 패널 - 컴팩트하게 */
.voice-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.voice-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    min-height: 36px;
    white-space: nowrap;
}

.voice-btn:hover {
    background: rgba(255,255,255,0.2);
}

.voice-btn.active {
    background: rgba(46,204,113,0.8);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46,204,113,0.7); }
    70% { box-shadow: 0 0 0 10px rgba(46,204,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

.voice-settings {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: white;
    font-size: 0.8rem;
}

.speed-control input {
    width: 100px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.speed-control input::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #2ecc71;
    border-radius: 50%;
    cursor: pointer;
}

/* 주석 패널 - 컴팩트하게 */
.annotation-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tools {
    display: flex;
    gap: 0.4rem;
}

.tool {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.tool:hover {
    background: rgba(255,255,255,0.2);
}

.tool.active {
    background: rgba(52,152,219,0.8);
    transform: scale(1.05);
}

.colors {
    display: flex;
    gap: 0.4rem;
}

.color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.color:hover {
    transform: scale(1.1);
}

.color.active {
    border-color: white;
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.thickness-control {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: white;
    font-size: 0.8rem;
}

.thickness-control input {
    width: 80px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.thickness-control input::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

.clear-btn {
    background: rgba(231,76,60,0.8);
    border: 1px solid rgba(231,76,60,1);
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    min-height: 36px;
}

.clear-btn:hover {
    background: rgba(192,57,43,0.8);
}

/* 메인 뷰어 - 패딩 10px 고정 */
.book-viewer {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;  /* 10px에서 2px로 대폭 감소 */
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.1) 0%, transparent 70%);
    overflow: hidden;
    min-height: 0;
}

.book-container {
    display: flex;
    gap: 1px;  /* 4px에서 1px로 감소 */
    perspective: 1500px;
    max-width: 99%;  /* 95%에서 99%로 증가 */
    max-height: 98%;  /* 90%에서 98%로 증가 */
    position: relative;
    transform-origin: center center;
    transition: transform 0.3s ease;
    cursor: grab;
}

.book-container.dragging {
    cursor: grabbing;
}

.book-container.zoomed {
    cursor: move;
}

.page-wrapper {
    position: relative;
    background: white;
    border-radius: 4px;  /* 8px에서 4px로 감소 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);  /* 그림자 감소 */
    overflow: hidden;
    width: 100%;  /* 고정 크기 대신 유연한 크기 */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.left-page {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.right-page {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

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

.page-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;  /* 원본 비율 유지하면서 맞춤 */
    display: block;
}

.annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    touch-action: none;
    cursor: crosshair;
    z-index: 10;
}

.annotation-canvas.active {
    pointer-events: auto;
}

.annotation-canvas.text-mode {
    cursor: text;
}

/* 페이지 그림자 */
.page-shadow {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    opacity: 0.3;
    z-index: 5;
}

.left-shadow {
    right: 0;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.15));
}

.right-shadow {
    left: 0;
    background: linear-gradient(to left, transparent, rgba(0,0,0,0.15));
}

/* 네비게이션 버튼 */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.8);  /* 더 진한 배경 */
    border: 2px solid rgba(255,255,255,0.3);  /* 흰색 테두리 추가 */
    color: white;
    padding: 1.2rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    opacity: 0.9;  /* 불투명도 증가 */
    transition: all 0.3s;
    z-index: 20;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);  /* 그림자 추가 */
}

.book-viewer:hover .nav-btn {
    opacity: 0.8;
}

.nav-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.9);
    transform: translateY(-50%) scale(1.1);
}

.nav-prev {
    left: 2rem;
}

.nav-next {
    right: 2rem;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 줌 정보 */
.zoom-info {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.zoom-info.show {
    opacity: 1;
}

/* 썸네일 슬라이더 - 패딩 10px 고정 */
.thumbnail-slider {
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px;  /* 고정 */
    z-index: 900;
    min-height: auto;  /* 높이 제한 제거 */
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.slider-nav {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.slider-nav:hover {
    background: rgba(255,255,255,0.2);
}

.slider-track {
    flex: 1;
    height: 4px;
    background: transparent;  /* rgba(255,255,255,0.2)에서 변경 */
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.slider-progress {
    height: 100%;
    background: linear-gradient(to right, #3498db, #2ecc71);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.slider-handle:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.handle-indicator {
    position: absolute;
    top: -25px;  /* 핸들 위쪽으로 이동 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    width: auto;
    height: auto;
}

.thumbnails-container {
    display: none;
}

.thumbnails-wrapper {
    display: flex;
    gap: 0.4rem;
    transition: transform 0.3s ease;
    padding: 0.3rem 0;
}

.thumbnail {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    min-width: 45px;
    height: 60px;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.thumbnail:hover {
    transform: scale(1.05);
    border-color: rgba(255,255,255,0.3);
}

.thumbnail.active {
    border-color: #3498db;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(52,152,219,0.4);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-number {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 1px 3px;
    font-size: 0.6rem;
    border-radius: 2px;
    font-weight: 500;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
}

.modal-content textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 1.5rem;
    outline: none;
}

.modal-content textarea:focus {
    border-color: #3498db;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-primary, .btn-secondary {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    min-height: 44px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-secondary:hover {
    background: #d5dbdb;
}

/* 전체화면 */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 3000;
}

.fullscreen .book-viewer {
    padding: 1rem;
}

/* 모바일 최적화 - 768px 이하 */
@media (max-width: 768px) {
    .header {
        padding: 3px 8px;
        min-height: 45px;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow: hidden;
    }
    
    .panel {
        padding: 3px 8px;
        margin: 0;
    }
    
    .book-viewer {
        padding: 0 8px 8px 8px;
    }
    
    .thumbnail-slider {
        padding: 10px;
        max-height: none;
        min-height: auto;
    }
    
    .header h1 {
        font-size: 1rem;
        flex: 1;
        min-width: 0;
        margin-right: 8px;
    }
    
    .controls {
        gap: 0.4rem;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
    }
    
    .controls button {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
        padding: 0.3rem;
        flex-shrink: 0;
    }
    
    #pageInfo {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        min-width: 60px;
        margin-right: 4px;
        flex-shrink: 0;
    }

    .controls button:nth-child(n+7) {
        display: none;
    }
    
    .book-viewer {
        padding: 1px;
    }
    
    .book-container {
        flex-direction: column;
        gap: 0.3rem;
        max-width: 100%;
        max-height: 100%;
    }
    
    .left-page {
        display: none;
    }
    
    .right-page {
        border-radius: 8px;
    }
    
    .page-wrapper {
        width: 99vw;
        height: 85vh;
        border-radius: 2px;
    }
    
    .nav-btn {
        width: 48px;
        height: 48px;
        padding: 0.8rem;
        font-size: 1.2rem;
        opacity: 0.85;
        position: fixed;
        background: rgba(0,0,0,0.85);
        border: 2px solid rgba(255,255,255,0.4);
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    }
    
    .nav-prev {
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 30;
    }
    
    .nav-next {
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 30;
    }
    
    .book-viewer:hover .nav-btn {
        opacity: 0.85;
    }
    
    .nav-btn:disabled {
        opacity: 0.3 !important;
        cursor: not-allowed;
        background: rgba(100,100,100,0.5) !important;
        border-color: rgba(255,255,255,0.2) !important;
    }
    
    .nav-btn:hover {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
    
    .zoom-info {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .panel {
        padding: 0.6rem;
        max-height: 25vh;
        overflow-y: auto;
    }
    
    .voice-controls {
        gap: 0.6rem;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .voice-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.7rem;
        min-height: 36px;
        justify-content: center;
    }
    
    .voice-settings {
        justify-content: center;
        margin-top: 0.3rem;
        width: 100%;
    }
    
    .speed-control {
        gap: 0.4rem;
        font-size: 0.8rem;
    }
    
    .speed-control input {
        width: 80px;
    }
    
    .annotation-controls {
        gap: 0.8rem;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .tools {
        justify-content: center;
        gap: 0.5rem;
        order: 1;
    }
    
    .tool {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    
    .colors {
        justify-content: center;
        gap: 0.5rem;
        order: 2;
    }
    
    .color {
        width: 28px;
        height: 28px;
    }
    
    .thickness-control {
        justify-content: center;
        gap: 0.4rem;
        font-size: 0.8rem;
        order: 3;
    }
    
    .thickness-control input {
        width: 60px;
    }
    
    .clear-btn {
        align-self: center;
        padding: 0.5rem 0.8rem;
        font-size: 0.7rem;
        order: 4;
    }

    #navNext {
        display: flex !important;
        visibility: visible !important;
        opacity: 0.8 !important;
        position: fixed !important;
        right: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 30 !important;
    }
    
    #navPrev {
        display: flex !important;
        visibility: visible !important;
        opacity: 0.8 !important;
        position: fixed !important;
        left: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 30 !important;
    }
    
    .thumbnail-slider {
        display: block !important;
        padding: 6px;
        background: rgba(0,0,0,0.95);
    }
    
    .slider-container {
        display: flex !important;
        gap: 0.4rem;
        margin-bottom: 0.4rem;
    }
    
    .handle-indicator {
        top: -20px;
        font-size: 0.6rem;
        padding: 1px 3px;
    }
    
    .slider-nav {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .slider-track {
        height: 6px;
    }
    
    .slider-handle {
        width: 20px;
        height: 20px;
    }
    
    .thumbnail {
        min-width: 40px;
        height: 50px;
    }
    
    .thumbnails-wrapper {
        gap: 0.2rem;
    }
    
    .page-number {
        font-size: 0.6rem;
        padding: 1px 2px;
    }
    
    .modal-content {
        min-width: 280px;
        padding: 1.2rem;
        margin: 0.8rem;
        max-width: calc(100vw - 1.6rem);
        max-height: calc(100vh - 1.6rem);
        overflow-y: auto;
    }
    
    .modal-content h3 {
        font-size: 1rem;
    }
    
    .modal-content textarea {
        min-height: 80px;
        font-size: 0.9rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        min-height: 36px;
    }
}

/* 작은 모바일 화면 - 480px 이하 */
@media (max-width: 480px) {
    .header {
        padding: 2px 6px;
        min-height: 40px;
    }
    
    .panel {
        padding: 2px 6px;
    }
    
    .book-viewer {
        padding: 0 6px 6px 6px;
    }
    
    .thumbnail-slider {
        padding: 10px;
    }
        
    .header h1 {
        font-size: 0.9rem;
    }
    
    .controls {
        position: relative;
    }
    
    .controls button:not(#prevBtn):not(#nextBtn):not(#pageInfo):nth-child(n+4) {
        display: none;
    }
    
    .controls::after {
        content: "⋯";
        background: rgba(255,255,255,0.1);
        border: 1px solid rgba(255,255,255,0.2);
        color: white;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        font-size: 1rem;
        cursor: pointer;
    }    
    
    .controls button {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
        padding: 0.2rem;
    }
    
    #pageInfo {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        min-width: 50px;
    }
    
    .controls button:nth-child(n+6) {
        display: none;
    }
    
    .page-wrapper {
        min-width: 250px;
        min-height: 300px;
    }
    
    .nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
        padding: 0.7rem;
    }
    
    .nav-prev {
        left: 10px;
    }
    
    .nav-next {
        right: 10px;
    }
    
    .thumbnail {
        min-width: 45px;
        height: 55px;
    }
    
    .thumbnails-wrapper {
        gap: 0.2rem;
    }
    
    .voice-btn {
        font-size: 0.7rem;
        padding: 0.5rem 0.8rem;
    }
    
    .tool {
        width: 36px;
        height: 36px;
    }
    
    .color {
        width: 28px;
        height: 28px;
    }
    
    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
    }

    .nav-btn i {
        text-shadow: 0 1px 2px rgba(0,0,0,0.5);
        filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
    }
}

/* 매우 작은 화면 - 360px 이하 */
@media (max-width: 360px) {
    .header h1 {
        font-size: 0.8rem;
    }
    
    .controls button {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }
    
    #pageInfo {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
        min-width: 45px;
    }
    
    .controls button:nth-child(n+5) {
        display: none;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .controls button:hover,
    .nav-btn:hover,
    .tool:hover,
    .color:hover,
    .thumbnail:hover,
    .voice-btn:hover,
    .slider-nav:hover,
    .clear-btn:hover {
        transform: none;
        background: rgba(255,255,255,0.15);
    }
    
    .nav-btn {
        opacity: 0.85 !important;
        position: fixed !important;
        background: rgba(0,0,0,0.85) !important;
        border: 2px solid rgba(255,255,255,0.4) !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    }
    
    .book-viewer .nav-btn {
        opacity: 0.85 !important;
    }
    
    .nav-btn:active {
        opacity: 1 !important;
        transform: translateY(-50%) scale(1.1) !important;
        background: rgba(0,0,0,0.95) !important;
        border-color: rgba(255,255,255,0.6) !important;
        box-shadow: 0 6px 16px rgba(0,0,0,0.5) !important;
    }
    
    .nav-prev {
        left: 10px !important;
    }
    
    .nav-next {
        right: 10px !important;
    }  
    
    .controls button,
    .tool,
    .color {
        min-width: 44px;
        min-height: 44px;
    }
}

/* 가로 모드 최적화 */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 2px 6px;
        min-height: 35px;
    }
    
    .header h1 {
        font-size: 0.8rem;
    }
    
    .controls {
        width: auto;
    }

    .controls button {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    #pageInfo {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }   
    
    .book-container {
        flex-direction: row;
        gap: 4px;
    }
    
    .page-wrapper {
        min-height: 250px;
    }
    
    .thumbnail-slider {
        padding: 0.5rem;
    }
    
    .slider-container {
        margin-bottom: 0.5rem;
    }
    
    .thumbnail {
        height: 50px;
        min-width: 40px;
    }
}