/* --- 全体レイアウト --- */
.viewer-wrapper {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 60px);
    overflow: hidden;
    background-color: #333;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* --- サイドバー --- */
.sidebar {
    width: 320px;
    min-width: 320px;
    background-color: rgba(248, 249, 250, 0.98);
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    transition: transform 0.3s ease;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f1f1f1;
}

.sidebar-tab {
    flex: 1;
    padding: 12px 5px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    border: none;
    background: none;
    font-size: 0.85rem;
}

.sidebar-tab.active {
    background: #fff;
    color: #007bff;
    border-bottom: 3px solid #007bff;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: none;
}

.sidebar-content.active {
    display: block;
}

/* --- サムネイル一覧 --- */
.thumbnail-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.thumbnail-item {
    width: 120px;
    cursor: pointer;
    text-align: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.thumbnail-item.active {
    opacity: 1;
    outline: 3px solid #007bff;
    border-radius: 4px;
}

/* --- メイン表示エリア --- */
.main-area {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
    position: relative;
    background-color: #333;
}

/* 透明なタップ領域（ページめくり用） */
.tap-layer {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 100;
}

.tap-left {
    left: 0;
    width: 30%;
    cursor: e-resize; /* 右開きがデフォルトのため */
}

.tap-right {
    right: 0;
    width: 30%;
    cursor: w-resize;
}

.tap-center {
    left: 30%;
    width: 40%;
}

/* --- コンテンツコンテナ（PDF & Image共通） --- */
.canvas-container,
.image-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding: 0;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.2s ease-out;
    will-change: transform;
    transition: transform 0.1s ease-out; 
    cursor: grab;
}
.main-area:active {
    cursor: grabbing;
}
/* PDF Canvas */
canvas {
    display: block;
    transition: filter 0.1s;
}

/* WebP Images */
.viewer-img {
    display: block;
    width: auto;
    height: auto;
    max-height: none; /* 制限を解除 */
    max-width: none;  /* 制限を解除 */
    object-fit: contain;
    margin: 0;
    padding: 0;
}

/* サムネイルの画像サイズ固定 */
.thumbnail-item img {
    height: 150px;
    object-fit: cover;
    background: #eee;
}

/* --- 操作パネルのパーツ --- */
.control-section {
    border-bottom: 1px solid #ccc;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.section-title {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
    font-size: 0.9rem;
}

/* --- モバイル対応 --- */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        height: 100%;
        width: 85%;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .menu-toggle-btn {
        display: flex;
        position: absolute;
        bottom: 20px;
        right: 20px;
        z-index: 3000;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        align-items: center;
        justify-content: center;
    }
}

/* オーバーレイ背景 */
.overlay-bg {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
}

.overlay-bg.show {
    display: block;
}

#page-controls-wrapper {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    transition: flex-direction 0.2s ease;
}

#page-controls-wrapper .text-dark {
    min-width: 60px;
    text-align: center;
}