:root {
    /* 缩放比例设置 */
    --scale-desktop: 0.76;           /* 桌面端缩放比例 */
    --scale-mobile: 0.8;             /* 移动端缩放比例 */
    
    /* 基础尺寸设置 */
    --base-height-desktop: 1100px;    /* 桌面端基础高度 */
    --base-height-mobile: 800px;     /* 移动端基础高度 */
    
    /* 自动计算的间距调整 */
    --margin-adjust-desktop: calc((1 - var(--scale-desktop)) * var(--base-height-desktop) * -0.9);
    --margin-adjust-mobile: calc((1 - var(--scale-mobile)) * var(--base-height-mobile) * -0.8);
    
    /* 列表模式全屏样式变量 */
    --fullscreen-list-bg: #1a1a1a;
    --fullscreen-list-padding: max(20px, 2vw);
    --fullscreen-list-gap: max(15px, 1.5vw);
    --thumbnail-aspect-ratio: 0.75; /* 3:4 = 0.75 */
    --thumbnail-min-width: 120px;
    --thumbnail-max-width: 250px;
}

/* 固定高度内容包装器 - 确保相对定位以支持基准线 */
.ebook-content-wrapper {
    width: 100%;
    height: calc(var(--base-height-desktop) * var(--scale-desktop)); /* 自动计算：600px × 0.67 = 402px */
    overflow: hidden; /* 隔离内部高度变化对页面的影响 */
    position: relative; /* 确保基准线可以相对定位 */
    border-radius: 8px; /* 保持圆角一致性 */
}

/* 电子书容器样式 - 移除overflow + 使用CSS变量缩放 */
.ebook-container {
    width: 90%;
    max-width: 1000px;
    margin: 80px auto 20px; /* 增加顶部边距以适应固定导航栏 */
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 20px 15px;
    
    /* 使用CSS变量缩放 */
    transform: scale(var(--scale-desktop));
    transform-origin: top center;
    margin-bottom: var(--margin-adjust-desktop); /* 自动计算调整值 */
}

/* 页面包装器 - 确保相对定位以支持基准线 */
.page-wrapper {
    width: 100%;
    position: relative; /* 确保相对定位以支持基准线 */
    height: 100%; /* 填满包装器高度 */
}

.ebook-pages {
    width: 100%;
    min-height: 300px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    transition: transform 0.3s ease;
    border-radius: 8px;
    box-shadow: none !important;
}

/* 页面样式，添加固定比例的容器 */
.page {
    width: 50%;
    height: auto;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    box-sizing: border-box;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 单页模式固定高宽比容器 */
.single-page-mode .page {
    width: 100%;
    height: 0;
    padding-bottom: 45%; /* 假设图片都是4:5的比例 */
    position: relative;
    margin-bottom: 20px;
    background-color: #ffffff; /* 添加背景色以便在加载前也能看到容器 */
    display: flex !important; /* 强制显示所有页面 */
    opacity: 1 !important; /* 确保所有页面都可见 */
}

/* 单页模式下保持图片全屏显示 */
.single-page-mode .page img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 加载状态样式 */
.page.loading {
    position: relative;
}

.page.loading::after {
    content: "加载中...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 5;
}

/* 加载错误状态样式 */
.page.error::after {
    content: "加载失败";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 5;
}

.page.active {
    display: flex;
    opacity: 1;
}

.page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0;
    transition: transform 0.3s ease;
}

.page:hover img {
    transform: scale(1.02);
}

/* 在全屏模式下禁用图片悬停放大效果 */
.fullscreen-mode .page:hover img {
    transform: none !important; /* 强制覆盖原有的放大效果 */
    transition: none; /* 移除动画效果 */
}

/* 页面连接器样式 */
.page-connector {
    display: flex;
    width: 100%;
    margin-bottom: 0;
}

/* 单页模式下页面悬停效果 */
.single-page-mode .page:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 滚动条样式 - 单页模式 */
.single-page-mode .ebook-pages::-webkit-scrollbar {
    width: 8px;
    background-color: #f5f5f5;
}

.single-page-mode .ebook-pages::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color: rgba(106, 17, 203, 0.5);
    transition: background-color 0.3s ease;
}

.single-page-mode .ebook-pages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(106, 17, 203, 0.7);
}

.single-page-mode .ebook-pages::-webkit-scrollbar-track {
    border-radius: 10px;
    background-color: #f5f5f5;
}

/* 双页无缝连接 - 核心修改 */
.double-page-mode .ebook-pages {
    flex-direction: row;
    overflow: hidden;
    font-size: 0; /* 消除内联元素空白 */
    gap: 0; /* 移除flex间隙 */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); /* 为整体添加阴影 */
    height: auto !important; /* 重置高度，覆盖单页模式的设置 */
}

.double-page-mode .page-connector {
    display: flex !important;
    flex-direction: row;
    width: 100%;
    gap: 0; /* 确保无间隙 */
}

.double-page-mode .page-connector .left-page,
.double-page-mode .page-connector .right-page {
    margin: 0;
    height: 100%;
    width: 50%;
    display: flex;
}

/* 双页模式下重置单页的固定比例设置 */
.double-page-mode .page {
    height: auto;
    padding-bottom: 0;
}

.double-page-mode .page img {
    position: relative;
    top: auto;
    left: auto;
}

/* 左右页面样式 - 无缝连接 */
.double-page-mode .left-page {
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: none; /* 移除右侧阴影 */
    padding-right: 0; /* 移除右侧内边距 */
    margin-right: 0; /* 确保无外边距 */
}

.double-page-mode .right-page {
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: none; /* 移除整体阴影 */
    padding-left: 0; /* 移除左侧内边距 */
    margin-left: 0; /* 确保无外边距 */
}

/* 确保图片无缝对齐 */
.double-page-mode .left-page img {
    margin-right: 0;
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    display: block; /* 消除可能的空白 */
}

.double-page-mode .right-page img {
    margin-left: 0;
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    display: block; /* 消除可能的空白 */
}

/* 消除任何可能的内联元素空白 */
.double-page-mode .page {
    font-size: 0; /* 消除内联元素间隙 */
    line-height: 0;
    letter-spacing: 0;
    word-spacing: 0;
}

/* 恢复页面内其他文本元素的字体大小 */
.double-page-mode .page * {
    font-size: medium;
    line-height: normal;
}

/* 全屏和旋转按钮样式 - 统一样式 */
.fullscreen-btn, .orientation-btn {
    position: absolute;
    top: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.fullscreen-btn {
    right: 10px;
}

.orientation-btn {
    right: 60px;
}

.fullscreen-btn:hover, .orientation-btn:hover {
    opacity: 1;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    box-shadow: 0 2px 8px rgba(106, 17, 203, 0.3);
}

.orientation-icon-svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

.fullscreen-icon {
    font-size: 18px;
}

/* 点击页面区域分层 */
.page-click-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 90;
    cursor: pointer;
    background-color: transparent;
}

.left-overlay {
    left: 0;
}

.right-overlay {
    right: 0;
}

/* 全屏模式样式 - 确保基准线容器正确定位 */
.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    z-index: 9999;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    transform: none !important;
    margin-bottom: 0 !important;
}

/* 全屏模式下的内容包装器 - 确保基准线容器正确 */
.fullscreen-mode .ebook-content-wrapper {
    height: 100vh; /* 全屏时使用视口高度 */
    border-radius: 0; /* 全屏时移除圆角 */
    position: relative; /* 确保相对定位用于基准线 */
}

/* 全屏模式下的页面包装器 */
.fullscreen-mode .page-wrapper {
    position: relative; /* 确保相对定位用于基准线 */
    height: 100%;
}

/* 全屏模式下的连接器 */
.fullscreen-mode .page-connector.fullscreen {
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    display: flex !important;
}

.fullscreen-mode .page-connector.fullscreen .left-page,
.fullscreen-mode .page-connector.fullscreen .right-page {
    border: none;
    box-shadow: none;
    display: flex !important;
}

.fullscreen-mode.single-page-mode .page {
    padding-bottom: 75%;
    background-color: transparent;
}

/* 横屏模式 - 修改后的版本 */
.landscape-mode .ebook-pages {
    flex-direction: row;
    width: 100%;
    gap: 0;
    justify-content: stretch;
    align-items: stretch;
}

.landscape-mode .page {
    width: 50%;
    height: 100vh;
    display: flex;
    align-items: center;
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
}

.landscape-mode .left-page {
    justify-content: flex-end;  /* 左页内容向右对齐,贴着中线左侧 */
}

.landscape-mode .right-page {
    justify-content: flex-start; /* 右页内容向左对齐,贴着中线右侧 */
}

/* 竖屏模式 - 修改后的版本 */
.portrait-mode .ebook-pages {
    flex-direction: column;
    height: 100vh;
    gap: 0;
    justify-content: stretch;
    align-items: stretch;
}

.portrait-mode .page {
    width: 100%;
    height: 50vh;
    display: flex;
    justify-content: center;
    padding:0;
    margin: 0;
    border: none;
    box-shadow: none;
}

.portrait-mode .left-page {
    align-items: flex-end;      /* 上页内容向下对齐,贴着中线上方 */
}

.portrait-mode .right-page {
    align-items: flex-start;    /* 下页内容向上对齐,贴着中线下方 */
}

.portrait-mode .page-click-overlay {
    width: 100%;
    height: 50%;
}

.portrait-mode .left-overlay {
    top: 0;
}

.portrait-mode .right-overlay {
    top: 50%;
}

.fullscreen-mode .ebook-pages {
    height: 100%;
    width: 100%;
}

.fullscreen-mode .page {
    background-color: #1a1a1a;
}

.fullscreen-mode .page img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 0;
}

.fullscreen-mode .fullscreen-btn,
.fullscreen-mode .orientation-btn {
    position: fixed;
    z-index: 1002;
}

.fullscreen-mode .fullscreen-btn {
    top: 20px;
    right: 20px;
}

.fullscreen-mode .orientation-btn {
    top: 20px;
    right: 70px;
}

/* 全屏单页模式样式 - 修改以支持滚动并解决白色边框问题 */
.fullscreen-mode.single-page-mode .ebook-pages {
    height: 100vh !important; /* 调整全屏模式下的高度 */
    padding: 20px;
    background-color: #1a1a1a;
    overflow-y: auto !important; /* 确保在全屏模式下仍可滚动 */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* 在iOS上改善滚动体验 */
    display: flex;
    flex-direction: column;
    gap: 30px; /* 增加页面间距,但不使用背景色 */
}

/* 修复全屏单页模式下的白色边框问题 */
.fullscreen-mode.single-page-mode .page {
    background-color: transparent; /* 透明背景替代白色背景 */
    margin-bottom: 0;
    width: 100%;
    max-width: 100%; /* 使用全宽 */
    padding: 0 0 120%; /* 只保留底部padding用于维持比例 */
    box-shadow: none; /* 移除阴影 */
    border-radius: 0; /* 移除圆角 */
    justify-content: center; /* 确保内容居中 */
}

/* 增强全屏单页模式下的图片显示 */
.fullscreen-mode.single-page-mode .page img {
    margin: 0 auto;
    display: block;
    border-radius: 0; /* 确保没有圆角 */
    box-shadow: none; /* 确保没有阴影 */
}

/* 禁止页面滚动但允许内容区域滚动 */
body.no-scroll {
    overflow: hidden;
}

/* 图片放大模式样式 */
.image-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9998;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.image-zoom-overlay.active {
    display: flex;
    opacity: 1;
}

.zoomed-image-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.zoomed-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.zoom-close-btn {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 20px;
}

/* 拖拽图片样式 */
.img-dragging {
    transition: none !important;
}

/* ===================================================== */
/* ========= 列表视图样式 - 修复后的完整版本 =========== */
/* ===================================================== */

/* 基础列表视图 - 非全屏模式（已修复） */
.thumbnail-view {
    width: 100%;
    min-height: 300px;
    position: relative;
    border-radius: 8px;
    box-sizing: border-box;
    
    /* 列表模式特有样式 */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    
    /* 🔧 修复1: 改善间距设置 - 从gap: 20px改为分别设置 */
    row-gap: 30px;      /* 行间距30px,比原来的20px更舒适 */
    column-gap: 20px;   /* 列间距20px,保持原有设计 */
    
    padding: 0;
    overflow-y: auto;
    
    /* 🔧 修复2: 移除高度限制 - 这是关键问题! */
    max-height: none;         /* 允许容器根据内容自适应高度 */
    
    scroll-behavior: smooth;
    background: transparent;
}

/* 🔧 修复3: 容器贴合修复（不影响间距） */
.ebook-container.list-mode .thumbnail-view {
    /* 容器尺寸 - 基本填充父容器 */
    width: calc(100% - 20px) !important;  /* 减去一点边距避免完全贴边 */
    height: auto !important;               /* 高度自适应内容 */
    
    /* 定位 - 轻微偏移确保视觉效果 */
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    
    /* 边距 - 最小化边距 */
    margin: 0 !important;
    padding: 10px !important;              /* 保留最小padding让布局正常 */
    
    /* 确保高度不受限制 */
    max-height: calc(100% - 20px) !important;  /* 减去padding的高度 */
    min-height: auto !important;
}

/* 基础缩略图项目样式 */
.thumbnail-item {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: white;
    aspect-ratio: var(--thumbnail-aspect-ratio);
    
    /* 确保项目无额外间距影响 */
    margin: 0 !important;
}

.thumbnail-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.thumbnail-item:hover img {
    transform: scale(1.05);
}

.thumbnail-number {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
}

/* 列表视图滚动条样式 */
.thumbnail-view::-webkit-scrollbar {
    width: 8px;
    background-color: #f5f5f5;
}

.thumbnail-view::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color: rgba(106, 17, 203, 0.5);
    transition: background-color 0.3s ease;
}

.thumbnail-view::-webkit-scrollbar-thumb:hover {
    background-color: rgba(106, 17, 203, 0.7);
}

.thumbnail-view::-webkit-scrollbar-track {
    border-radius: 10px;
    background-color: #f5f5f5;
}

/* ===================================================== */
/* ========= 全屏列表模式 - 保持原有设计不变 =========== */
/* ===================================================== */

/* 全屏列表模式容器 - 保持原有设置 */
.fullscreen-mode.list-mode .thumbnail-view {
    /* 容器尺寸和定位 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    
    /* 布局和间距 - 保持原有设置不变 */
    padding: 0px;
    gap: 25px;
    row-gap: 25px !important;
    column-gap: 25px !important;    /* 保持原有的25px列间距 */
    
    /* 视觉样式 */
    background-color: var(--fullscreen-list-bg);
    
    /* 网格布局 - 调整为更合理的列数和尺寸 */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    
    /* 滚动和溢出 */
    overflow-y: auto;
    overflow-x: hidden;
    
    /* 性能优化 */
    box-sizing: border-box;
    will-change: scroll-position;
    
    /* 移除任何可能的变换 */
    transform: none;
    
    /* Z轴层级 */
    z-index: 9999;
}

/* 全屏列表模式缩略图项目 - 保持原有设置 */
.fullscreen-mode.list-mode .thumbnail-item {
    /* 尺寸控制 */
    aspect-ratio: var(--thumbnail-aspect-ratio);
    width: 100%;
    height: auto;
    min-width: var(--thumbnail-min-width);
    max-width: var(--thumbnail-max-width);
    
    /* 布局修复 - 清除可能影响垂直间距的属性 */
    display: block;
    position: relative;
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    
    /* 视觉样式 */
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    
    /* 溢出控制 */
    overflow: hidden;
    
    /* 移除不必要的变换 */
    transform: none;
    
    /* 过渡效果 */
    transition: all 0.3s ease;
}

/* 全屏列表模式缩略图悬停效果 */
.fullscreen-mode.list-mode .thumbnail-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(106, 17, 203, 0.5);
    transform: translateY(-3px) scale(1.02);
}

/* 全屏列表模式图片样式 - 防止变形 */
.fullscreen-mode.list-mode .thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    
    /* 防止图片变形 */
    flex-shrink: 0;
    
    /* 移除不必要的变换 */
    transform: none;
    transition: filter 0.3s ease;
}

/* 全屏列表模式图片悬停效果 */
.fullscreen-mode.list-mode .thumbnail-item:hover img {
    filter: brightness(1.1) contrast(1.05);
    transform: none; /* 防止图片自身缩放导致布局问题 */
}

/* 全屏列表模式页码标签 */
.fullscreen-mode.list-mode .thumbnail-number {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    backdrop-filter: blur(4px);
    border-radius: 0 0 8px 8px;
}

/* 全屏列表模式滚动条样式 */
.fullscreen-mode.list-mode .thumbnail-view::-webkit-scrollbar {
    width: 12px;
    background-color: rgba(255, 255, 255, 0.1);
}

.fullscreen-mode.list-mode .thumbnail-view::-webkit-scrollbar-thumb {
    background-color: rgba(106, 17, 203, 0.6);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.fullscreen-mode.list-mode .thumbnail-view::-webkit-scrollbar-thumb:hover {
    background-color: rgba(106, 17, 203, 0.8);
}

.fullscreen-mode.list-mode .thumbnail-view::-webkit-scrollbar-track {
    background-color: transparent;
}

/* ===================================================== */
/* ========= 响应式设计 - 新增和优化部分 =============== */
/* ===================================================== */

/* 🔧 修复4: 非全屏模式响应式优化 */
@media (max-width: 768px) {
    .thumbnail-view {
        /* 移动端间距调整 */
        row-gap: 25px;      /* 移动端行间距稍小 */
        column-gap: 15px;   /* 移动端列间距稍小 */
        
        /* 移动端网格调整 */
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    /* 移动端全屏列表模式 - 保持原有设置 */
    .fullscreen-mode.list-mode .thumbnail-view {
        /* 移动端网格调整 - 更大的缩略图和更清晰的间距 */
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        
        /* 移动端间距调整 - 保持原有设置 */
        padding: 30px;
        gap: 20px;
        row-gap: 15px !important;    /* 保持原有的180px设置 */
        column-gap: 20px !important;  /* 保持原有的20px设置 */
        
        /* 确保完全占满屏幕 */
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* 动态视口高度,避免移动端地址栏问题 */
        
        /* 防止水平滚动 */
        overflow-x: hidden;
        
        /* 移动端滚动优化 */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* 移动端缩略图尺寸调整 */
    .fullscreen-mode.list-mode .thumbnail-item {
        min-width: 140px;
        max-width: 220px;
        
        /* 移动端触摸目标尺寸 */
        min-height: 187px; /* 保持3:4比例 */
        
        /* 确保移动端也清除margin */
        margin: 0 !important;
    }
    
    /* 移动端图片优化 */
    .fullscreen-mode.list-mode .thumbnail-item img {
        /* 移动端图片加载优化 */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* 移动端页码标签调整 */
    .fullscreen-mode.list-mode .thumbnail-number {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    /* 移动端滚动条隐藏（可选） */
    .fullscreen-mode.list-mode .thumbnail-view::-webkit-scrollbar {
        width: 0;
        background: transparent;
    }
    
    /* 移动端全屏单页模式 - 添加右侧padding补偿滚动条空间 */
    .fullscreen-mode.single-page-mode .ebook-pages {
        /* 添加右侧padding,防止内容贴边 */
        padding-right: 15px !important;  /* 模拟滚动条占位 */
        box-sizing: border-box;
    }
    
    /* 确保页面容器不会超出 */
    .fullscreen-mode.single-page-mode .page {
        max-width: calc(100% - 5px);  /* 留出一点安全边距 */
        margin: 0 auto;  /* 居中显示 */
    }
    
    /* 移动端横屏时的特殊处理 */
    .fullscreen-mode.landscape-mode .ebook-content-wrapper {
        transform: translateY(0vh); /* 减小偏移量 */
    }
    .fullscreen-mode.portrait-mode .ebook-content-wrapper {
        transform: translateY(4vh);
    }
}

@media (max-width: 480px) {
    .thumbnail-view {
        /* 超小屏间距 */
        row-gap: 20px;      /* 超小屏行间距更小 */
        column-gap: 12px;   /* 超小屏列间距更小 */
        
        /* 超小屏网格 */
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    /* 超小屏幕优化 - 保持原有设置 */
    .fullscreen-mode.list-mode .thumbnail-view {
        /* 超小屏幕网格布局 - 保持清晰的行列 */
        grid-template-columns: repeat(2, 1fr);
        
        /* 更合适的间距 - 保持原有设置 */
        padding: 25px;
        gap: 18px;
        row-gap: 15px !important;    /* 保持原有的100px设置 */
        column-gap: 18px !important;  /* 保持原有的18px设置 */
    }
    
    .fullscreen-mode.list-mode .thumbnail-item {
        /* 超小屏幕尺寸调整 */
        min-width: 120px;
        min-height: 160px; /* 保持3:4比例 */
        
        /* 确保超小屏幕也清除margin */
        margin: 0 !important;
    }
}

/* ===================================================== */
/* ========= 全屏模式通用修复 ========================== */
/* ===================================================== */

/* 隐藏非列表元素 - 确保纯净的全屏体验 */
.fullscreen-mode.list-mode .control-frame,
.fullscreen-mode.list-mode .ebook-info {
    display: none;
}

/* 确保全屏列表模式下退出按钮显示 */
.fullscreen-mode.list-mode .fullscreen-btn {
    display: flex !important;
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 10001 !important;
}

/* 隐藏页面内容 */
.fullscreen-mode.list-mode .ebook-pages {
    display: none;
}

/* 全屏时隐藏页面其他元素 */
body.fullscreen-active nav,
body.fullscreen-active .navbar,
body.fullscreen-active header,
body.fullscreen-active footer,
body.fullscreen-active .footer,
body.fullscreen-active #footer-container {
    display: none;
}

/* 确保body在全屏列表模式下的正确样式 */
body.fullscreen-active {
    overflow: hidden;
    margin: 0;
    padding: 0;
    background-color: var(--fullscreen-list-bg);
}

/* ===================================================== */
/* ========= 控制栏样式 ================================ */
/* ===================================================== */

.control-frame {
    width: 90%;
    max-width: 1000px;
    margin: 30px auto 0px;
    display: flex;
    flex-direction: column;
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    
    transform: scale(var(--scale-desktop));
    transform-origin: top center;
}

.control-upper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.prev-page-btn,
.next-page-btn {
    padding: 10px 20px;
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.prev-page-btn:hover,
.next-page-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.prev-page-btn:active,
.next-page-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.page-slider {
    flex-grow: 1;
    margin: 0 20px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #eee;
    border-radius: 4px;
    outline: none;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.page-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
    border: none;
}

.current-left-page,
.current-right-page {
    padding: 5px;
    margin-top: 8px;
    font-size: 14px;
    color: #666;
}

/* 视图选项容器样式 */
.view-options-container {
    display: flex;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 5px;
}

/* 视图选项按钮样式 */
.view-option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 15px;
    margin: 0 2px;
    border: none;
    border-radius: 6px;
    background: none;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-option-btn.active {
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.view-option-btn .option-icon {
    font-size: 16px;
    margin-right: 5px;
}

/* 修复全屏模式问题 */
.fullscreen-mode {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

/* 修复移动端竖屏模式下的问题 */
.portrait-mode .page {
    width: 100% !important;
    height: 50vh !important;
    padding: 0 !important;
}

.portrait-mode .page-click-overlay {
    width: 100% !important;
    height: 50% !important;
}

.portrait-mode .right-overlay {
    top: 50% !important;
    left: 0 !important;
    right: 0 !important;
}

/* 全屏模式下的布局修复 */
body.fullscreen-active {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* 响应式设计 - 电子书容器部分 */
@media (max-width: 576px) {
    /* 移动端固定容器高度 - 使用CSS变量 */
    .ebook-content-wrapper {
        height: calc(var(--base-height-mobile) * var(--scale-mobile));
    }

    .fullscreen-mode.double-page-mode .ebook-pages {
        height: 100vh !important;
    }
    
    .ebook-container {
        width: 110%;
        margin-left: -7%; 
        margin-top: 70px;
        padding: 8px;
        
        transform: scale(var(--scale-mobile));
        margin-bottom: var(--margin-adjust-mobile);
    }

    .control-frame {
        width: 108%;
        margin-left: -7%;
        padding: 12px;
        
        transform: scale(var(--scale-mobile));
        margin-bottom: calc(var(--margin-adjust-mobile) * 0.3);
        margin-top: 2px !important;
    }
    
    .control-upper {
        flex-wrap: wrap;
    }

    .prev-page-btn,
    .next-page-btn {
        padding: 8px 15px;
        font-size: 14px;
    }

    .page-slider {
        width: 100% !important;
        max-width: 350px !important;
        margin: 15px auto !important;
        order: 3;
        flex-grow: 0 !important;
    }

    .control-group {
        width: 48%;
    }

    .current-left-page,
    .current-right-page {
        font-size: 12px;
    }
    
    .control-lower {
        justify-content: center;
        margin-top: 10px;
    }
    
    .view-option-btn {
        padding: 6px 10px;
    }
    
    /* 移动端单页视图调整 */
    .single-page-mode .ebook-pages {
        height: 630px !important;
    }
    
    .double-page-mode .ebook-pages {
        height: 630px !important;
    }

    .single-page-mode .page {
        padding-bottom: 45%;
    }
    
    .single-page-mode .page.vertical-type {
        padding-bottom: 100%;
        margin-bottom: 25px;
    }

    .single-page-mode .page.horizontal-type {
        padding-bottom: 45%;
        margin-bottom: 15px;
    }

    .single-page-mode .page.square-type {
        padding-bottom: 65%;
        margin-bottom: 20px;
    }
    
    .fullscreen-mode.single-page-mode .ebook-pages {
        height: 100vh !important;
        padding: 15px 10px;
    }
    
    .fullscreen-mode {
        position: fixed !important;
        width: 100vw !important;
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .portrait-mode .ebook-pages {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    .fullscreen-mode.single-page-mode .ebook-pages {
        padding-right: 12px !important;
    }
    
    /* 移动端给子元素添加外边距 */
    .share-btn {
        margin-left: 25px;
        margin-right: auto;
    }

    .view-options-container {
        margin-right: 25px;
    }
    
    .share-toast {
        padding: 14px 24px;
        font-size: 14px;
        max-width: 80%;
    }
    
    /* 移动端分享按钮文字可能隐藏 */
    .share-btn .option-text {
        display: inline;
    }
}

/* 简单的缩放动画效果 */
@keyframes zoomIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 强制修复双页模式垂直居中 - 修改版本,只对双页模式生效 */
@media (min-width: 577px) {
    .ebook-container:not(.fullscreen-mode).double-page-mode .ebook-pages {
        height: 100% !important;
        align-items: center !important;
        justify-content: center !important;
        transform: translateY(-25px) !important;
    }
    
    .ebook-container:not(.fullscreen-mode).single-page-mode .ebook-pages {
        height: 838px !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        transform: none !important;
        overflow-y: auto !important;
        flex-direction: column !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
}

/* 确保单页模式下页面从容器顶部开始显示 */
.single-page-mode .ebook-pages {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    transform: none !important;
    padding-top: 0 !important;
}

/* 确保单页模式下第一个页面从容器顶部开始 */
.single-page-mode .page:first-child {
    margin-top: 0 !important;
}

/* 全屏单页模式固定比例 */
.fullscreen-mode.single-page-mode .page.vertical-type {
  padding-bottom: 120% !important;
  background-color: transparent;
}

/* 横图类型 (长宽比 < 0.8) */
.fullscreen-mode.single-page-mode .page.horizontal-type {
  padding-bottom: 75% !important;
  background-color: transparent;
}

/* 方图类型 (0.8 <= 长宽比 <= 1.2) */
.fullscreen-mode.single-page-mode .page.square-type {
  padding-bottom: 90% !important;
  background-color: transparent;
}

/* 默认未分类图片 */
.fullscreen-mode.single-page-mode .page:not(.vertical-type):not(.horizontal-type):not(.square-type) {
  padding-bottom: 85% !important;
  background-color: transparent;
}

/* iPad Pro 11寸紧急修复*/
@media (min-width: 769px) and (max-width: 1194px) {
    .list-mode .thumbnail-view {
        grid-template-columns: repeat(4, 1fr) !important;
        grid-auto-rows: minmax(200px, auto);
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .list-mode .thumbnail-item {
        max-height: 250px;
        aspect-ratio: 3/4;
    }
}

/* 添加横屏模式专门修复 */
@media (min-width: 769px) and (max-width: 1194px) and (orientation: landscape) {
    .list-mode .thumbnail-view {
        grid-template-columns: repeat(5, 1fr) !important;
        grid-auto-rows: minmax(200px, max-content) !important;
        row-gap: 35px !important;
    }
    
    .list-mode .thumbnail-item {
        max-height: 220px !important;
        overflow: hidden !important;
        position: relative;
    }
    
    .list-mode .thumbnail-item img {
        width: 100%;
        height: 100%;
        object-fit: cover !important;
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* 只针对横屏双页模式 */
.fullscreen-mode.landscape-mode .ebook-content-wrapper {
    transform: translateY(2vh);
}

/* 只针对竖屏双页模式 */
.fullscreen-mode.portrait-mode .ebook-content-wrapper {
    transform: translateY(2vh);
}

/* 移动端横屏时的特殊处理 针对现代手机按照我的s24ultra*/
@media (max-width: 1100px) and (orientation: landscape) {
    .fullscreen-mode.landscape-mode .ebook-content-wrapper {
        transform: translateY(6vh);
    }
}

/* ===================================================== */
/* ========= 分享功能样式（新增） ====================== */
/* ===================================================== */

/* 调整 control-lower 为 flex 布局,支持左右分布 */
.control-lower {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* 分享按钮样式（复用视图按钮样式 + 添加容器背景） */
.share-btn {
    margin-right: auto;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 13px 20px;
    transition: all 0.2s ease;
}

/* 分享按钮悬停效果 */
.share-btn:hover {
    background-color: #e8e8e8;
}

/* 分享按钮激活状态（可选） */
.share-btn.active {
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Toast 提示框基础样式 */
.share-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: linear-gradient(135deg, rgba(106, 17, 203, 0.95), rgba(37, 117, 252, 0.95));
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 24px rgba(106, 17, 203, 0.4);
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

/* Toast 显示状态 */
.share-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Toast 图标 */
.share-toast::before {
    content: '✓';
    display: inline-block;
    margin-right: 8px;
    font-size: 18px;
    animation: checkPulse 0.5s ease;
}

@keyframes checkPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 分享按钮点击反馈动画 */
.share-btn.clicked {
    animation: shareClick 0.3s ease;
}

@keyframes shareClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* 超小屏幕优化 */
@media (max-width: 380px) {
    .share-btn .option-text {
        display: none;
    }
    
    .share-btn {
        padding: 6px 10px;
    }
}

/* 全屏模式下的 Toast 样式调整 */
.fullscreen-mode .share-toast {
    z-index: 10002;
}

/* 打印时隐藏分享按钮和Toast */
@media print {
    .share-btn,
    .share-toast {
        display: none !important;
    }
}
/* ===================================================== */
/* ========= 图片放大浮层导航功能样式 ================== */
/* ===================================================== */

/* 箭头按钮基础样式 */
.zoom-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

/* 左箭头位置 */
.zoom-prev-btn {
    left: -70px;
}

/* 右箭头位置 */
.zoom-next-btn {
    right: -70px;
}

/* 箭头悬停效果 */
.zoom-nav-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-50%) scale(1.1);
}

/* 箭头激活效果 */
.zoom-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* 页码指示器样式 */
.zoom-page-indicator {
    position: absolute;
    top: 20px;
    right: 70px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1002;
    backdrop-filter: blur(5px);
    user-select: none;
}

/* 缩放比例指示器样式（左上角） */
.zoom-scale-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1002;
    backdrop-filter: blur(5px);
    user-select: none;
}

/* 隐藏状态工具类 */
.zoom-nav-btn.hidden {
    display: none !important;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .zoom-nav-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .zoom-prev-btn {
        left: -50px;
    }
    
    .zoom-next-btn {
        right: -50px;
    }
    
    .zoom-page-indicator {
        top: 15px;
        right: 60px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .zoom-scale-indicator {
        top: 15px;
        left: 15px;
        padding: 6px 12px;
        font-size: 12px;
    }
}