* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #f8f4f0; 
    display: flex; 
    min-height: 100vh;
    font-family: 'Arial', -apple-system, sans-serif;
    overflow: hidden;
    color: #333333;
}

/* ==================== 左侧竖向 Header 栏 ==================== */
.sidebar-header {
    width: 240px;
    background-color: rgba(255, 255, 255, 0.75);
    border-right: 2px solid rgba(194, 24, 7, 0.2); 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 24px;
    z-index: 100;
    flex-shrink: 0;
    box-shadow: 2px 0 15px rgba(194, 24, 7, 0.05);
}

.brand-zone {
    border-bottom: 2px solid rgba(194, 24, 7, 0.15);
    padding-bottom: 20px;
}

.magazine-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #c21807; 
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9);
}

.magazine-subtitle {
    font-size: 16px;
    color: #d32f2f;
    margin-top: 4px;
    letter-spacing: 1px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0px;
    margin-top: -600px;
}

.nav-item {
    color: #e53935;
    text-decoration: none;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    transition: all 0.25s ease;
    letter-spacing: 1px;
    font-weight: 600;
}

.nav-item:hover {
    color: #c21807;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(194, 24, 7, 0.1);
}

.nav-item.active {
    color: #ffffff;
    background-color: #e53935;
    font-weight: 600;
}

.sidebar-footer {
    color: #9c8c82;
    font-size: 12px;
}

.page-indicator {
    font-family: monospace;
    font-size: 13px;
    color: #c21807;
    font-weight: bold;
}

/* ==================== 中央主展示区 ==================== */
.main-content {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 80px 0 20px; 
    position: relative;
    height: 100vh;
}

.book {
    position: relative;
    height: 96vh;             
    width: 140.48vh;          
    perspective: 2500px;      
    background: transparent;
}

.page {
    position: absolute;
    width: 50%;
    height: 100%;
    top: 0;
    right: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 1;
    will-change: transform, z-index;
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.front {
    z-index: 2;
}

.back {
    transform: rotateY(180deg);
}

.front img, .back img {
    width: 100%;
    height: 100%;
    object-fit: fill; 
    image-rendering: -webkit-optimize-contrast; 
    display: block;
}

.blank-page {
    background: #fdfcfb;
    color: #baa79c;
    font-size: 13px;
    letter-spacing: 2px;
}

/* ==================== 右侧竖向悬浮控制面板 ==================== */
.right-controls {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
}

.control-btn {
    width: 54px;
    height: 120px; 
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 0, 0, 0.2);
    color: #e53935;
    border-radius: 27px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.control-btn .arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.control-btn .btn-text {
    writing-mode: vertical-lr; 
    font-size: 12px;
    letter-spacing: 2px;
    font-weight: 600;
}

.control-btn:hover:not(:disabled) {
    background: #c21807;
    color: #ffffff;
    border-color: #c21807;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
}

#prevBtn:hover .arrow { transform: translateY(-3px); }
#nextBtn:hover .arrow { transform: translateY(3px); }

.control-btn:disabled {
    background: rgba(230, 220, 215, 0.4);
    color: #baa79c;
    border-color: rgba(0,0,0,0.05);
    cursor: not-allowed;
    box-shadow: none;
}


/* ==================== 📱 手机端极限极简适配 (屏幕宽度小于 768px) ==================== */
@media (max-width: 768px) {
    
    body {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar-header {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 2px solid rgba(194, 24, 7, 0.15);
        position: sticky;
        top: 0;
    }

    .brand-zone {
        border-bottom: none;
        padding-bottom: 0;
    }

    .magazine-title { font-size: 20px; }
    .magazine-subtitle { display: none; } 

    .sidebar-nav {
        margin-top: 0 ;
        flex-direction: row;
        gap: 8px;
    }

    .nav-item {
        font-size: 12px;
        padding: 6px 10px;
    }

    .main-content {
        padding: 20px 16px 100px 16px;
        height: auto;
        min-height: calc(100vh - 140px);
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* 手机端杂志外框：严格按单页比例锁定 */
    .book {
        width: 90vw;                     
        height: calc(90vw / 0.7316);     
        max-height: 65vh;                
        width: calc(min(90vw, calc(65vh * 0.7316))); 
        height: calc(min(65vh, calc(90vw / 0.7316)));
        perspective: none;               
    }

    /* 手机端容器降维：所有的纸张全部原地撑满 100% 宽度，且默认隐藏 */
    .page {
        width: 100% !important;
        height: 100% !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        display: none; /* 默认隐藏所有纸张 */
    }

    /* 当 JS 判定当前页属于这张纸时，显示该纸张 */
    .page.active-page {
        display: block !important;
        z-index: 10 !important;
    }

    /* 手机端重置正反两面：让他们在 2D 状态下重叠铺满 */
    .front, .back {
        width: 100% !important;
        height: 100% !important;
        position: absolute;
        top: 0; left: 0;
        backface-visibility: visible !important;
        transform: none !important; /* 强制清空 3D 旋转旋转 */
    }

    /* 🌟 核心显隐逻辑：通过简单干净的 2D display 切换，彻底杜绝空白 */
    .page.active-page .front { display: block; }
    .page.active-page .back { display: none; }

    /* 当激活背面（左侧页）时：隐藏正面，直接把背面翻转校正并展现 */
    .page.active-page.show-back .front {
        display: none;
    }
    .page.active-page.show-back .back {
        display: block;
        transform: none; 
    }

    .front img, .back img {
        width: 100%;
        height: 100%;
        object-fit: contain; 
    }

    /* 固定底栏控制面板 */
    .right-controls {
        position: fixed;
        bottom: 0; left: 0; right: 0; top: auto;
        transform: none;
        flex-direction: row; 
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        padding: 12px 20px;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
        justify-content: space-between;
        gap: 16px;
        z-index: 9999;
    }

    .control-btn {
        flex: 1;            
        height: 44px;       
        width: auto;
        border-radius: 8px;
        flex-direction: row; 
    }

    .control-btn .btn-text {
        writing-mode: horizontal-tb; 
        font-size: 13px;
    }

    #prevBtn:hover .arrow, #nextBtn:hover .arrow {
        transform: none;    
    }
    
    .control-btn .arrow {
        font-size: 10px;
    }
}