:root {
    --reader-bg-color: #f6f7f9;
    /* 外部大背景 */
    --paper-bg-color: #C7EDCC;
    /* 书页背景 - 改为护眼绿 */
    --text-color: #333333;
    --text-secondary: #999999;
    --accent-color: #ff4c4c;
    /* 番茄红 */
    --font-size: 26px;
    --font-weight: 400;
    --line-height: 1.8;
    --content-width: 900px;
    /* Increased to compensate for padding with border-box */
}

/* 支持 html.dark-mode 防止闪烁 */
html.dark-mode {
    --reader-bg-color: #111;
    --paper-bg-color: #1a1a1a;
    --text-color: #bfbfbf;
}

html.dark-mode body {
    background-color: #111;
}

/* Reset & Base */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--reader-bg-color);
    font-family: system-ui, sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-color);
    transition: background-color 0.3s;
    /* 允许滚动 */
    overflow: auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari 动态视口高度 */
}

/* 隐藏滚动条样式 */
html {
    overflow: auto;
    height: auto;
}

body::-webkit-scrollbar,
.reader-wrapper::-webkit-scrollbar,
.reader-main::-webkit-scrollbar {
    display: none;
}

body,
.reader-wrapper,
.reader-main {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    outline: none;
}

/* Layout */
.reader-wrapper {
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding-top: 60px;
    padding-bottom: 120px;
    /* 增加底部间距，为固定底部功能栏留空间 */
    /* PC端增加顶部间距，避开 Header */
    overflow: visible;
}

/* Header (Fixed Top) - Mac Style */
.reader-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    /* Mac毛玻璃效果 */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    /* 精致的底部边框 */
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.5) inset,
        0 1px 3px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s ease,
        box-shadow 0.3s ease;
}

/* 深色模式下的毛玻璃效果 */
body.dark-mode .reader-header {
    background: rgba(40, 40, 42, 0.78);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.05) inset,
        0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 品牌区域 Mac风格 */
.brand {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    letter-spacing: -0.2px;
}

.brand:hover {
    background: rgba(0, 0, 0, 0.04);
}

body.dark-mode .brand:hover {
    background: rgba(255, 255, 255, 0.08);
}

.brand img {
    height: 28px !important;
    width: 28px !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 书籍信息区域 - 面包屑样式 */
.book-info {
    font-size: 13px;
    color: #86868b;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    letter-spacing: -0.1px;
}

.book-info a {
    color: #86868b;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.book-info a:hover {
    color: #1d1d1f;
    background: rgba(0, 0, 0, 0.04);
}

body.dark-mode .book-info a:hover {
    color: #f5f5f7;
    background: rgba(255, 255, 255, 0.08);
}

.book-info span {
    color: #d2d2d7;
}

.chapter-name {
    color: #1d1d1f;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.dark-mode .book-info {
    color: #86868b;
}

body.dark-mode .book-info span {
    color: #48484a;
}

body.dark-mode .chapter-name {
    color: #f5f5f7;
}

/* 右侧操作区域 Mac风格 */
.header-right {
    gap: 4px;
}

.header-right a,
.user-actions a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    border-radius: 8px;
    transition: all 0.2s ease;
    letter-spacing: -0.1px;
}

.header-right a:hover,
.user-actions a:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .header-right a,
body.dark-mode .user-actions a {
    color: #f5f5f7;
}

body.dark-mode .header-right a:hover,
body.dark-mode .user-actions a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-actions {
    display: flex;
    align-items: center;
}

.user-actions i {
    font-size: 18px;
    color: #86868b;
    transition: color 0.2s ease;
}

.user-actions a:hover i {
    color: var(--accent-color);
}

/* 分隔线装饰 */
.header-right::before {
    content: '';
    width: 1px;
    height: 20px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1), transparent);
    margin-right: 8px;
}

body.dark-mode .header-right::before {
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1), transparent);
}

.header-right a i {
    margin-right: 4px;
    font-size: 16px;
}

@media (max-width: 600px) {
    .header-text {
        display: none;
    }

    .header-right a {
        padding: 8px;
    }

    .header-right a i {
        margin-right: 0;
    }
}

/* 移动端底部菜单适配 - 已移动到文件底部以确保覆盖生效 */

/* Sidebars (Fixed Right Only) */
.sidebar-right {
    position: fixed;
    bottom: 40px;
    top: auto;
    /* Position relative to the center, pushing it OUTSIDE the content */
    /* Content width/2 + Gap (30px) */
    /* With border-box, content-width includes padding, so this is the true edge of the paper */
    left: calc(50% + min(var(--content-width), calc(100vw - 160px))/2 + 30px);
    right: auto;
    width: 60px;
    /* Wider to match screenshot */
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* More spacing */
    z-index: 900;
    transform: none;
}

.side-btn {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 12px;
    /* Softer rounded corners */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    /* Softer, larger shadow */
    transition: all 0.2s;
}

.side-btn:hover {
    color: var(--accent-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.side-btn i {
    font-size: 20px;
    margin-bottom: 4px;
}

/* Main Content */
.reader-main {
    /* Use min to ensure it shrinks if viewport is too narrow, leaving space for sidebars */
    /* 140px = 60px sidebar + 20px gap + extra margin */
    width: min(var(--content-width), calc(100vw - 160px));
    background-color: var(--paper-bg-color);
    padding: 12px 40px;
    padding-bottom: 40px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    min-height: calc(100vh - 160px);
    /* 适应父容器高度 */
    position: relative;
    transition: background-color 0.3s, color 0.3s;
    /* Ensure it centers properly */
    margin: 0 auto;
    overflow: visible;
    /* Flex layout for dynamic height */
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .reader-main {
        width: 100%;
        padding: 8px 12px;
        padding-bottom: 120px;
    }
}

/* 章节头部区域 - 极简设计 */
.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 8px;
    flex-shrink: 0;
    /* 防止被压缩 */
}

.chapter-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 章节元信息（字数统计等） */
.chapter-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding-top: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.word-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
}

.word-count i {
    font-size: 12px;
    opacity: 0.7;
}

.chapter-origin {
    display: inline-flex;
    align-items: center;
    max-width: 220px;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: 20px;
    color: #059669;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 深色模式下的字数显示 */
body.dark-mode .chapter-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .word-count {
    background: rgba(255, 255, 255, 0.08);
    color: #999;
}

body.dark-mode .chapter-origin {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.24);
    color: #34d399;
}

/* 移动端章节头部样式 */
@media (max-width: 1024px) {
    .chapter-header {
        flex-direction: row;
        align-items: center;
        margin-bottom: 6px;
        padding-bottom: 6px;
        gap: 8px;
    }

    .chapter-title {
        font-size: 16px;
    }

    .chapter-meta {
        font-size: 11px;
        padding-top: 0;
        gap: 6px;
    }

    .word-count {
        font-size: 11px;
        padding: 2px 8px;
    }

    .chapter-origin {
        font-size: 11px;
        padding: 2px 8px;
        max-width: 112px;
    }

    .chapter-origin-author,
    .chapter-origin-date {
        display: none;
    }
}

.chapter-content p {
    font-size: var(--font-size);
    line-height: var(--line-height);
    margin-bottom: 24px;
    text-align: justify;
    text-indent: 40px !important;
}

/* ========================================
   电子书翻页模式样式
   ======================================== */

/* 翻页容器 - 一屏显示 */
.paged-reader {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    flex: 1;
    /* 占据剩余空间 */
    display: flex;
    flex-direction: column;
}

/* 页面容器 */
.page-container {
    position: relative;
    width: 100%;
    flex: 1;
    /* 占据剩余空间 */
    overflow: hidden;
}

.chapter-content {
    flex: 1;
    overflow: visible;
    display: block;
}

/* 滚动阅读器样式 */
.scroll-reader,
.scroll-reader-content,
.paged-reader-content {
    width: 100%;
    /* 禁用浏览器自动滚动锚定，由JS手动控制补偿，避免双重补偿导致跳动 */
    overflow-anchor: none;
    /* iOS Safari惯性滚动优化 */
    -webkit-overflow-scrolling: touch;
}

/* 翻页模式内容区域 */
.paged-reader-content {
    min-height: 50vh;
}

.scroll-reader p,
.paged-reader-content p,
.chapter-content .scroll-reader p,
.chapter-content .paged-reader-content p,
.reader-main .scroll-reader p,
.reader-main .paged-reader-content p,
.chapter-content p,
.reader-main p {
    font-size: var(--font-size);
    font-weight: var(--font-weight);
    line-height: var(--line-height);
    margin-bottom: 24px;
    text-align: justify;
    text-indent: 2em !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* 页面内容 */
.page-content {
    height: 100%;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .paged-reader {
        height: calc(100vh - 100px);
    }

    .page-container {
        height: 100%;
    }
}

/* 单页内容 */
.page-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(30px);
}

.page-content.active {
    position: relative;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.page-content.prev {
    transform: translateX(-30px);
}

.page-content.next {
    transform: translateX(30px);
}

/* 翻页动画 - 淡入淡出 */
.page-content.fade-out {
    opacity: 0;
    transform: translateX(-30px);
}

.page-content.fade-in {
    opacity: 1;
    transform: translateX(0);
}

/* 翻页控制区域 - 隐藏，使用底部功能栏 */
.page-controls {
    display: none;
}


/* 进度条 */
.page-progress {
    width: 200px;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

body.dark-mode .page-progress {
    background: rgba(255, 255, 255, 0.1);
}

.page-progress-bar {
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* 移动端翻页样式 */
@media (max-width: 1024px) {
    .paged-reader {
        min-height: 50vh;
    }

    .page-container {
        min-height: 50vh;
    }

    .page-controls {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 0;
        margin-top: 20px;
    }

    .page-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .page-indicator {
        font-size: 13px;
        min-width: 80px;
    }

    .page-progress {
        width: 100%;
        order: -1;
        margin-bottom: 8px;
    }

    /* 移动端隐藏左右点击区域提示 */
    .page-tap-left::after,
    .page-tap-right::after {
        display: none;
    }

    /* 移动端点击区域更大 */
    .page-tap-left,
    .page-tap-right {
        width: 30%;
    }
}

/* 滑动翻页动画 - 上下方向 */
.page-content.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-content.slide-down {
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

@keyframes slideInFromBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.page-content.slide-in-bottom {
    animation: slideInFromBottom 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-content.slide-in-top {
    animation: slideInFromTop 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ========================================
   移动端上下滑动翻页动画（抖音风格）
   ======================================== */
.paged-reader-content {
    transition: none;
}

/* 上滑翻出（下一页） — 不再使用 */
/* 上滑翻入（下一页新内容从下方进入） */
.paged-reader-content.page-flip-in-up {
    animation: pageFlipInUp 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
/* 下滑翻出（上一页） — 不再使用 */
/* 下滑翻入（上一页新内容从上方进入） */
.paged-reader-content.page-flip-in-down {
    animation: pageFlipInDown 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes pageFlipInUp {
    from { transform: translateY(30px); }
    to   { transform: translateY(0); }
}
@keyframes pageFlipInDown {
    from { transform: translateY(-30px); }
    to   { transform: translateY(0); }
}

/* Footer Navigation */
.chapter-nav {
    margin-top: 40px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* 移动端隐藏上方章节导航，使用底部菜单代替 */
@media (max-width: 1024px) {
    .chapter-nav {
        display: none;
    }
}

.nav-btn {
    padding: 10px 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-size: 16px;
    color: #333;
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* 下一章按钮 - 存在下一章时的淡绿色字体样式 */
.nav-btn.nav-next-active {
    color: #22c55e !important;
    border-color: #86efac;
    font-weight: 600;
    transition: all 0.25s ease;
}

.nav-btn.nav-next-active:hover {
    color: #16a34a !important;
    border-color: #22c55e;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

body.dark-mode .nav-btn.nav-next-active {
    color: #4ade80 !important;
    border-color: rgba(74, 222, 128, 0.3);
    background: transparent;
}

/* 下一章按钮 - 不存在下一章时的绿色可点击样式 */
.nav-btn.nav-next-disabled {
    color: #22c55e !important;
    border-color: #86efac;
    font-weight: 600;
    transition: all 0.25s ease;
    cursor: pointer;
}

.nav-btn.nav-next-disabled:hover {
    color: #16a34a !important;
    border-color: #22c55e;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

body.dark-mode .nav-btn.nav-next-disabled {
    color: #4ade80 !important;
    border-color: rgba(74, 222, 128, 0.3);
    background: transparent;
}

/* Settings Panel (Popup) - Mac Style */
.settings-panel {
    position: fixed;
    bottom: 100px;
    /* Align to left of sidebar */
    /* Sidebar Left - Settings Width (280px) - Gap (10px) */
    left: auto;
    right: calc(100% - (50% + min(var(--content-width), calc(100vw - 160px))/2 + 30px) + 10px);

    top: auto;
    transform: none;
    width: 280px;
    /* Mac风格毛玻璃背景 */
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 20px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
        0 0 1px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 2101;
}

/* 深色模式设置面板 */
body.dark-mode .settings-panel {
    background: rgba(44, 44, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 1px rgba(255, 255, 255, 0.1);
}

.settings-panel.active {
    display: block;
}

.setting-item {
    margin-bottom: 18px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-title {
    font-size: 13px;
    color: #1d1d1f;
    font-weight: 600;
    margin-bottom: 12px;
    display: block;
    letter-spacing: -0.1px;
}

body.dark-mode .setting-title {
    color: #f5f5f7;
}

.theme-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px;
}

.theme-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.theme-dot:hover {
    transform: scale(1.1);
}

.theme-dot.active {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(255, 76, 76, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* 确保主题色点在深色背景上可见 */
.theme-dot[data-theme="beige"] {
    background: #C7EDCC !important;
}

.theme-dot[data-theme="white"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.theme-dot[data-theme="dark"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .theme-dot[data-theme="beige"],
body.dark-mode .theme-dot[data-theme="white"],
body.dark-mode .theme-dot[data-theme="green"] {
    background: #fdf6e3 !important;
}

.theme-dot[data-theme="dark"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.font-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 4px;
}

body.dark-mode .font-controls {
    background: rgba(255, 255, 255, 0.1);
}

.font-btn {
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    color: #1d1d1f;
    transition: all 0.2s ease;
}

body.dark-mode .font-btn {
    color: #f5f5f7;
}

.font-btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

body.dark-mode .font-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.font-btn:active {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(0.95);
}

body.dark-mode .font-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.font-val {
    font-size: 13px;
    color: #86868b;
    min-width: 36px;
    text-align: center;
}

body.dark-mode .font-val {
    color: #98989d;
}

/* 底部功能栏 - 始终显示 */
.mobile-menu {
    display: block;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(var(--content-width), calc(100vw - 160px));
    background: #fff;
    padding: 8px 16px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    border-radius: 12px 12px 0 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    opacity: 1;
    pointer-events: auto;
    /* iOS Safari: 防止浏览器工具栏收起时底部菜单飘移 */
    -webkit-transform: translateX(-50%) translateZ(0);
}

.mobile-menu.visible {
    transform: translateX(-50%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    opacity: 1;
    pointer-events: auto;
}

body.dark-mode .mobile-menu {
    background: #1f1f1f;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

/* 底部操作按钮 */
.mobile-actions {
    display: flex;
    justify-content: space-around;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    color: #666;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    min-width: 56px;
}

.mobile-action-btn:hover,
.mobile-action-btn:active {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}

body.dark-mode .mobile-action-btn {
    color: #999;
}

body.dark-mode .mobile-action-btn:hover,
body.dark-mode .mobile-action-btn:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

.mobile-action-btn i {
    font-size: 18px;
    margin-bottom: 3px;
}

.mobile-action-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* 移动端下一章按钮 - 存在下一章时的淡绿色字体样式 */
.mobile-action-btn.mobile-next-active {
    color: #22c55e !important;
    font-weight: 600;
}

.mobile-action-btn.mobile-next-active:hover,
.mobile-action-btn.mobile-next-active:active {
    color: #16a34a !important;
    background: rgba(34, 197, 94, 0.08) !important;
}

body.dark-mode .mobile-action-btn.mobile-next-active {
    color: #4ade80 !important;
}

/* 移动端下一章按钮 - 不存在下一章时的绿色可点击样式 */
.mobile-action-btn.mobile-next-disabled {
    color: #22c55e !important;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
}

.mobile-action-btn.mobile-next-disabled:hover,
.mobile-action-btn.mobile-next-disabled:active {
    color: #16a34a !important;
    background: rgba(34, 197, 94, 0.08) !important;
}

body.dark-mode .mobile-action-btn.mobile-next-disabled {
    color: #4ade80 !important;
}


/* Mobile Styles */
@media (max-width: 1024px) {

    .sidebar-left,
    .sidebar-right {
        display: none;
    }

    .reader-main {
        width: 100%;
        padding: 20px;
        box-shadow: none;
        padding-bottom: 120px;
    }

    .reader-wrapper {
        padding-top: 0;
        padding-bottom: 80px;
    }

    .reader-header {
        transform: translateY(-100%);
        transition: transform 0.3s;
    }

    .reader-header.visible {
        transform: translateY(0);
    }

    .mobile-menu {
        display: block;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        opacity: 1 !important;
        pointer-events: auto !important;
        box-shadow: 0 -0.5px 0.5px rgba(0, 0, 0, 0.1);
    }

    /* .mobile-menu.visible { ... }  <-- No longer needed to toggle, simpler to just force visible above */
    /* But keeping it won't hurt, just overridden */

    /* 移动端设置面板 - 从底部弹出 */
    .settings-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 60vh;
        border-radius: 20px 20px 0 0;
        padding: 24px 20px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2101;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .settings-panel.active {
        transform: translateY(0);
        display: block;
    }

    /* 设置面板拖动指示条 */
    .settings-panel::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }

    body.dark-mode .settings-panel::before {
        background: rgba(255, 255, 255, 0.3);
    }

    /* 设置项样式优化 */
    .setting-item {
        margin-bottom: 24px;
    }

    .setting-title {
        font-size: 15px;
        margin-bottom: 14px;
    }

    .theme-options {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.04);
        border-radius: 12px;
    }

    body.dark-mode .theme-options {
        background: rgba(255, 255, 255, 0.08);
    }

    .theme-dot {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .font-controls {
        padding: 8px;
    }

    .font-btn {
        padding: 12px 16px;
        font-size: 16px;
    }

    .font-val {
        font-size: 14px;
        min-width: 50px;
    }

    /* 遮罩层 */
    .settings-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        z-index: 2100;
    }

    .settings-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Tap Zone */
    .tap-zone {
        position: fixed;
        top: 30%;
        bottom: 30%;
        left: 20%;
        right: 20%;
        z-index: 900;
        /* background: rgba(255,0,0,0.1); Debug */
    }
}

/* 移动端深色模式下的章节标题 */
@media (max-width: 1024px) {
    body.dark-mode .chapter-title {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
}

/* ========================================
   自定义弹窗组件样式 (从 style.css 提取)
   ======================================== */

/* 弹窗遮罩层 */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-modal-overlay.show {
    opacity: 1;
}

/* 弹窗容器 */
.custom-modal {
    background: #fff;
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .custom-modal {
    background: #2C2C2E;
}

.custom-modal.show {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* 弹窗内容 */
.custom-modal-content {
    text-align: center;
}

/* 弹窗图标 */
.custom-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.2));
    color: #007AFF;
}

.custom-modal-icon-warning {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(249, 115, 22, 0.2));
    color: #FF9500;
}

.custom-modal-icon-input {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
    color: #34C759;
}

/* 弹窗消息 */
.custom-modal-message {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 24px;
    word-break: break-word;
}

/* 弹窗输入框 */
.custom-modal-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(60, 60, 67, 0.12);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-color);
    background: #F2F2F7;
    outline: none;
    transition: all 0.2s ease;
    margin-bottom: 24px;
}

.custom-modal-input:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

body.dark-mode .custom-modal-input {
    background: #374151;
    border-color: #4B5563;
}

/* 弹窗按钮容器 */
.custom-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* 弹窗按钮 */
.custom-modal-btn {
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    min-width: 100px;
}

.custom-modal-btn-primary {
    background: linear-gradient(135deg, #007AFF, #2563EB);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.custom-modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.45);
}

.custom-modal-btn-primary:active {
    transform: translateY(0);
}

.custom-modal-btn-secondary {
    background: #F2F2F7;
    color: #8E8E93;
    border: 2px solid rgba(60, 60, 67, 0.12);
}

.custom-modal-btn-secondary:hover {
    background: rgba(60, 60, 67, 0.12);
    color: var(--text-color);
}

body.dark-mode .custom-modal-btn-secondary {
    background: #374151;
    border-color: #4B5563;
}

/* Toast 通知样式 */
.custom-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.custom-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    border-left: 4px solid #007AFF;
}

body.dark-mode .custom-toast {
    background: #2C2C2E;
}

.custom-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.custom-toast-success {
    border-left-color: #34C759;
}

.custom-toast-success .custom-toast-icon {
    color: #34C759;
}

.custom-toast-error {
    border-left-color: #FF3B30;
}

.custom-toast-error .custom-toast-icon {
    color: #FF3B30;
}

.custom-toast-warning {
    border-left-color: #FF9500;
}

.custom-toast-warning .custom-toast-icon {
    color: #FF9500;
}

.custom-toast-info {
    border-left-color: #007AFF;
}

.custom-toast-info .custom-toast-icon {
    color: #007AFF;
}

.custom-toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.custom-toast-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

/* 弹窗响应式 */
@media (max-width: 768px) {
    .custom-modal {
        padding: 24px;
        margin: 16px;
    }

    .custom-modal-buttons {
        flex-direction: column-reverse;
    }

    .custom-modal-btn {
        width: 100%;
    }

    .custom-toast-container {
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 80px;
    }

    .custom-toast {
        transform: translateY(120%);
    }

    .custom-toast.show {
        transform: translateY(0);
    }
}



/* PC端底部菜单优化 - 彻底隐藏底部移动端菜单 */
@media (min-width: 1025px) {
    .mobile-menu {
        display: none !important;
    }
}

/* 付费章节客户端下载弹窗（与小说详情页付费章节点击一致） */
.paid-block-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 20px;
}

.paid-block-overlay.show {
    display: flex;
    animation: paidBlockFadeIn 0.25s ease;
}

.paid-block-modal {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: paidBlockSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.paid-block-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s;
}

.paid-block-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.paid-block-icon {
    text-align: center;
    margin-bottom: 16px;
}

.paid-block-icon svg {
    width: 56px;
    height: 56px;
    stroke: #f59e0b;
}

.paid-block-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.paid-block-desc {
    text-align: center;
    font-size: 14px;
    color: #666;
    line-height: 1.7;
    margin-bottom: 8px;
}

.paid-block-ios {
    color: #e67e22;
    font-weight: 500;
    margin-bottom: 16px;
}

.paid-block-steps {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.paid-block-step {
    font-size: 13px;
    color: #e67e22;
    line-height: 1.6;
    margin-bottom: 6px;
}

.paid-block-step:last-child {
    margin-bottom: 0;
}

.paid-block-step-green {
    color: #10b981;
}

.paid-block-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.paid-block-btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #3DDC84, #2bc270);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(61, 220, 132, 0.35);
}

.paid-block-btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(61, 220, 132, 0.45);
    color: white;
}

.paid-block-btn-download-win {
    background: linear-gradient(135deg, #007aff, #2563eb);
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35);
}

.paid-block-btn-download-win:hover {
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.45);
}

.paid-block-btn-back {
    padding: 12px 24px;
    background: #f3f4f6;
    color: #333;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.paid-block-btn-back:hover {
    background: #e5e7eb;
}

@keyframes paidBlockFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes paidBlockSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========================================
   付费弹窗深色模式适配 (Override Inline Styles)
   ======================================== */
body.dark-mode .paid-block-modal {
    background: #1c1c1e;
}

body.dark-mode .paid-block-title {
    color: #f5f5f7;
}

body.dark-mode .paid-block-desc {
    color: #aaa;
}

body.dark-mode .paid-block-close {
    color: #aaa;
}

body.dark-mode .paid-block-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .paid-block-steps {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.20);
}

body.dark-mode .paid-block-btn-back {
    background: #2c2c2e;
    color: #f5f5f7;
}

body.dark-mode .paid-block-btn-back:hover {
    background: #3a3a3c;
}

body.dark-mode .purchase-box {
    background: linear-gradient(135deg, #1c1c1e, #2c2c2e) !important;
    border-color: #38383a !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark-mode .purchase-title {
    color: #f5f5f7 !important;
}

body.dark-mode .purchase-word-count {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #999 !important;
}

body.dark-mode .purchase-price {
    color: #999 !important;
}

body.dark-mode .purchase-price strong {
    color: #fbbf24 !important;
}

body.dark-mode .balance-info {
    color: #aaa !important;
}

body.dark-mode .purchase-tip {
    color: #666 !important;
}


/* 移动端底部菜单适配 - 放在最后以确保覆盖基础样式 */
@media (max-width: 1024px) {
    .mobile-actions {
        gap: 2px;
        justify-content: space-between;
    }

    .mobile-action-btn {
        min-width: 48px;
        /* 稍微减小宽度以容纳更多按钮 */
        padding: 6px 4px;
    }
}
