/* 阅读页特有样式 v16 - 護眼黃底 */
html, body {
    background: var(--reader-bg, #f5edd4);
    overflow-x: clip;
}

:root {
    --reading-font-size: 30px;
    --reader-bg: #f5edd4;
}

/* ===== 夜间模式 ===== */
body.night-mode {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* ===== 容器（全屏布局，垂直排列各区块） ===== */
.container {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 860px;
    margin: 0 auto;
}

/* ===== 頂部工具栏 ===== */
.reading-header {
    background: var(--reader-bg, #f5edd4);
    padding: 12px 16px;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,.08);
    position: relative;
}

.night-mode .reading-header {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

.reading-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.book-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.book-title {
    font-size: 17px;
    font-weight: 700;
    color: #e74c3c;
}

.night-mode .book-title {
    color: #ff7675;
}

.book-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #888;
    flex-wrap: wrap;
}

.night-mode .book-meta {
    color: #aaa;
}

.book-meta a {
    color: #e74c3c;
    text-decoration: none;
}

.book-meta a:hover {
    color: #c0392b;
}

.tools-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.font-controls {
    display: flex;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 4px;
    gap: 2px;
}

.night-mode .font-controls {
    background: #252545;
}

.tool-btn {
    background: #fff5f5;
    border: 1.5px solid rgba(231,76,60,.2);
    border-radius: 8px;
    padding: 9px 13px;
    color: #e74c3c;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: .15s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.night-mode .tool-btn {
    background: rgba(231,76,60,.1);
    border-color: rgba(231,76,60,.25);
    color: #ff7675;
}

.tool-btn:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

.font-btn {
    background: transparent;
    border: none;
    padding: 7px 10px;
    border-radius: 14px;
    color: #e74c3c;
    font-weight: 700;
    cursor: pointer;
    transition: .15s;
    font-size: 13px;
}

.night-mode .font-btn {
    color: #ff7675;
}

.font-btn:hover {
    background: #e74c3c;
    color: #fff;
}

/* ===== 设置面板 ===== */
#text_control {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    border: 1px solid #eee;
    z-index: 1000;
    min-width: 200px;
    transform: translateY(10px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all .2s ease;
}

.night-mode #text_control {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

#text_control.show {
    transform: translateY(10px) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ===== 章节标题 ===== */
.chapter-header {
    background: var(--reader-bg, #f5edd4);
    padding: 20px 16px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.night-mode .chapter-header {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

.chapter-title {
    font-size: 24px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.3;
}

.night-mode .chapter-title {
    color: #e8e8e8;
}

.chapter-progress {
    color: #999;
    font-size: 14px;
}

/* ===== 阅读内容 ===== */
.reading-content {
    background: var(--reader-bg, #f5edd4);
    padding: 24px 16px 32px;
    border: none;
    line-height: 2.1;
    font-size: var(--reading-font-size);
    color: #2c2218;
    text-align: justify;
    min-height: 500px;
}

.night-mode .reading-content {
    background: #1e1e3a;
    color: #ddd;
    border-color: rgba(255,255,255,.06);
}

.reading-content p {
    margin-bottom: 1.5em;
    text-indent: 2em;
}

/* ===== 极简模式 ===== */
body.mini-mode .reading-header,
body.mini-mode .chapter-header,
body.mini-mode .reading-nav,
body.mini-mode .footer,
body.mini-mode .latest-books-section {
    display: none;
}

body.mini-mode .reading-content {
    margin-top: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    padding: 30px;
}

/* ===== 极简模式退出按钮 ===== */
.mini-exit-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(231,76,60,.35);
    transition: .2s;
    z-index: 1000;
    display: none;
}

body.mini-mode .mini-exit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-exit-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* ===== 底部导航 ===== */
.reading-nav {
    background: var(--reader-bg, #f5edd4);
    padding: 12px 14px;
    border: none;
    border-top: 1px solid rgba(0,0,0,.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.night-mode .reading-nav {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

.nav-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: .15s;
    cursor: pointer;
    background: #e74c3c;
    color: #fff;
    flex: 1;
    justify-content: center;
    min-width: 120px;
}

.nav-btn:hover {
    background: #c0392b;
}

.nav-btn.disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

.night-mode .nav-btn.disabled {
    background: #2a2a4a;
    color: #666;
}

.nav-btn.disabled:hover {
    background: #e0e0e0;
}

.night-mode .nav-btn.disabled:hover {
    background: #2a2a4a;
}

.nav-btn.center {
    background: #fff5f5;
    color: #e74c3c;
    border: 1.5px solid rgba(231,76,60,.2);
}

.night-mode .nav-btn.center {
    background: rgba(231,76,60,.1);
    color: #ff7675;
    border-color: rgba(231,76,60,.3);
}

.nav-btn.center:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

/* ===== 举报按钮 ===== */
.report-section {
    text-align: center;
    margin: 20px 0;
}

.report-btn {
    color: #e74c3c;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: .15s;
}

.report-btn:hover {
    color: #c0392b;
}

/* ===== 页脚 ===== */
.footer {
    background: var(--reader-bg, #fff);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border: 1px solid #eee;
}

.night-mode .footer {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

.footer p {
    color: #888;
    font-size: 13px;
    line-height: 2;
    margin: 0;
}

.night-mode .footer p {
    color: #aaa;
}

.footer a {
    color: #e74c3c;
    text-decoration: none;
    font-weight: 600;
}

/* ===== 分页选择器 ===== */
.page-selector {
    flex: 1;
    max-width: 180px;
    min-width: 120px;
}

.page-selector-inner {
    background: #fff5f5;
    border: 1.5px solid rgba(231,76,60,.2);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: .15s;
    cursor: pointer;
}

.night-mode .page-selector-inner {
    background: rgba(231,76,60,.1);
    border-color: rgba(231,76,60,.3);
}

.page-selector-inner:hover {
    border-color: #e74c3c;
}

.page-selector-inner i {
    color: #e74c3c;
    font-size: 14px;
    flex-shrink: 0;
}

.night-mode .page-selector-inner i {
    color: #ff7675;
}

.page-select {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: #e74c3c;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
}

.night-mode .page-select {
    color: #ff7675;
}

.page-select option {
    background: #fff;
    color: #333;
}

.night-mode .page-select option {
    background: #2a2a4a;
    color: #e0e0e0;
}

.page-total {
    color: #999;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

/* ===== 最新更新推荐 ===== */
.latest-books-section {
    background: var(--reader-bg, #fff);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border: 1px solid #eee;
}

.night-mode .latest-books-section {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

.section-header {
    margin-bottom: 18px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.night-mode .section-title {
    color: #e8e8e8;
}

.section-title i {
    color: #e74c3c;
    -webkit-text-fill-color: unset;
    background: none;
}

.section-subtitle {
    font-size: 13px;
    color: #aaa;
    margin-top: 4px;
}

.latest-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.book-card {
    background: #f8f8f8;
    border-radius: 10px;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
}

.night-mode .book-card {
    background: #252545;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.book-card-cover {
    position: relative;
    width: 100%;
    padding-top: 133%;
    overflow: hidden;
    background: #e0e0e0;
}

.night-mode .book-card-cover {
    background: #2a2a4a;
}

.book-card-cover img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.book-card:hover .book-card-cover img {
    transform: scale(1.04);
}

.book-card-badge {
    position: absolute;
    top: 6px; right: 6px;
    background: #e74c3c;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.book-card-content {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.book-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.night-mode .book-card-title {
    color: #e0e0e0;
}

.book-card-author {
    font-size: 12px;
    color: #e74c3c;
    font-weight: 600;
    margin: 0;
}

.book-card-chapter {
    font-size: 11px;
    color: #888;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.night-mode .book-card-chapter {
    color: #aaa;
}

.book-card-time {
    font-size: 11px;
    color: #aaa;
    margin: 0;
    margin-top: auto;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .reading-header {
        padding: 10px 14px;
    }

    .reading-tools {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .book-info {
        text-align: center;
    }

    .tools-group {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chapter-header {
        padding: 14px 16px;
    }

    .chapter-title {
        font-size: 20px;
    }

    .reading-content {
        font-size: 30px;
        padding: 20px 16px;
        line-height: 2;
    }

    .reading-nav {
        flex-direction: column;
        gap: 8px;
        padding: 12px 14px;
    }

    .nav-btn {
        width: 100%;
        min-width: auto;
    }

    .page-selector {
        width: 100%;
        max-width: none;
    }

    .page-selector-inner {
        justify-content: center;
    }

    #text_control {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        right: auto;
        width: 90%;
        max-width: 300px;
    }

    #text_control.show {
        transform: translate(-50%, -50%) scale(1);
    }

    .latest-books-section {
        padding: 16px;
    }

    .latest-books-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .reading-content {
        font-size: 28px;
        line-height: 1.95;
    }

    .chapter-title {
        font-size: 18px;
    }

    .latest-books-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== 背景顏色面板 ===== */
#bg-color-panel {
    position: absolute;
    top: 100%;
    right: 0;
    background: #f0f0f0;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    border: 1px solid #ccc;
    z-index: 1000;
    min-width: 230px;
    transform: translateY(10px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all .2s ease;
}

.night-mode #bg-color-panel {
    background: #1e1e3a;
    border-color: rgba(255,255,255,.08);
}

#bg-color-panel.show {
    transform: translateY(10px) scale(1);
    opacity: 1;
    visibility: visible;
}

.bg-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.night-mode .bg-panel-title {
    color: #e0e0e0;
}

.bg-swatches {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.bg-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.25);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
    cursor: pointer;
    transition: transform .15s, border-color .15s, box-shadow .15s;
    position: relative;
    flex-shrink: 0;
    outline: none;
}

.bg-swatch:hover {
    transform: scale(1.15);
    border-color: #e74c3c;
}

.bg-swatch.active {
    border-color: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231,76,60,.3);
}

.bg-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    color: #e74c3c;
    font-weight: 700;
    line-height: 1;
}

.bg-swatch[data-dark].active::after {
    color: #fff;
}

@media (max-width: 768px) {
    #bg-color-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        right: auto;
        width: 90%;
        max-width: 280px;
    }

    #bg-color-panel.show {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ===== 黃色模式（默認）背景與文字 ===== */
body:not(.night-mode) .reading-header,
body:not(.night-mode) .chapter-header,
body:not(.night-mode) .reading-content,
body:not(.night-mode) .reading-nav,
body:not(.night-mode) .footer {
    background: var(--reader-bg, #f5edd4);
    border-color: #e0d3a8;
}

body:not(.night-mode) .reading-content {
    color: #2c2218;
}

/* ===== 點擊菜單遮罩 ===== */
#tap-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 800;
}
#tap-menu {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 32px rgba(0,0,0,.18);
    padding: 0 0 env(safe-area-inset-bottom, 12px);
}
.night-mode #tap-menu {
    background: #1e1e3a;
}
.tap-menu-drag {
    width: 40px; height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 12px auto 16px;
}
.night-mode .tap-menu-drag { background: #444; }
.tap-menu-title {
    font-size: 13px; color: #aaa; text-align: center;
    margin-bottom: 14px; font-weight: 600;
}
.tap-menu-rows {
    display: flex; gap: 0;
    flex-direction: column;
    padding: 0 16px;
}
.tap-menu-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px; color: #333; font-weight: 600;
}
.night-mode .tap-menu-row { color: #ddd; border-color: #2a2a4a; }
.tap-menu-row:last-child { border-bottom: none; }
.tap-menu-row i { color: #e74c3c; width: 22px; text-align: center; margin-right: 12px; }
.tap-menu-row-left { display: flex; align-items: center; gap: 0; }
.tap-menu-nav-btns {
    display: flex; gap: 10px;
    padding: 14px 16px 8px;
}
.tap-menu-nav-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 13px 10px;
    border-radius: 10px; font-size: 14px; font-weight: 700;
    text-decoration: none; color: #fff;
    background: #e74c3c;
}
.tap-menu-nav-btn.secondary {
    background: #f5f0e8; color: #e74c3c;
    border: 1.5px solid rgba(231,76,60,.25);
}
.night-mode .tap-menu-nav-btn.secondary {
    background: rgba(231,76,60,.1); border-color: rgba(231,76,60,.3); color: #ff7675;
}
/* 字體大小滑塊 */
.tap-font-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.night-mode .tap-font-row { border-color: #2a2a4a; }
.tap-font-label { font-size: 13px; color: #999; white-space: nowrap; }
.tap-font-btns { display: flex; gap: 6px; }
.tap-font-btn {
    width: 36px; height: 36px; border-radius: 8px;
    border: 1.5px solid rgba(231,76,60,.25);
    background: #fff5f5; color: #e74c3c;
    font-weight: 700; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.night-mode .tap-font-btn { background: rgba(231,76,60,.1); border-color: rgba(231,76,60,.3); color: #ff7675; }
.tap-font-btn:active { background: #e74c3c; color: #fff; }
/* 背景色選色器 */
.tap-bg-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px 14px;
}
.tap-bg-swatches { display: flex; gap: 10px; }
.tap-bg-swatch {
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid rgba(0,0,0,.15);
    cursor: pointer; transition: transform .15s, border-color .15s;
}
.tap-bg-swatch:active, .tap-bg-swatch.active { transform: scale(1.2); border-color: #e74c3c; }

/* 閱讀頁隱藏頂部/底部導航欄 */
body.reader-page .nt-topbar,
body.reader-page .nt-tabbar {
    display: none !important;
}


.icon-sun { display: none; }
.icon-moon { display: inline; }
.night-mode .icon-sun { display: inline; }
.night-mode .icon-moon { display: none; }

/* ===== 工具类 ===== */
.hidden {
    display: none !important;
}

/* ===== 夜間模式：評論區 ===== */
/* 評論區保持亮色，不受夜間模式影響（與詳情頁一致） */
.nc-section-wrap {
    background: #fff !important;
    color: #333 !important;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border: 1px solid #eee;
}

@media (max-width: 768px) {
    .nc-section-wrap {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        padding: 16px;
    }
}
