/* ============================================
   映雪读书 - 数字书房样式表
   主题色（默认/青蓝/豆绿/浅黄） × 模式（明/暗）
   ============================================ */

/* ---------- 基础变量 ---------- */
:root {
    --font-body: "Noto Serif SC", "Source Han Serif SC", "SimSun", "STSong", "FangSong", serif;
    --font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-size: 18px;
    --line-height: 1.85;
    --content-width: 720px;
    --paragraph-spacing: 1.4em;
}

/* ---------- 主题色：默认（宣纸 · 朱砂） ---------- */
:root,
:root[data-color="default"] {
    --ink: #2c2c2c;
    --ink-light: #5a5a5a;
    --ink-lighter: #8a8a8a;
    --paper: #f7f5f0;
    --paper-dark: #eceade;
    --card: #ffffff;
    --line: #e2ded4;
    --accent: #c0392b;
    --accent-strong: #a93226;
    --accent-soft: rgba(192, 57, 43, 0.08);
    --accent-line: rgba(192, 57, 43, 0.28);
    --bamboo: #4f7a52;
    --bamboo-soft: rgba(79, 122, 82, 0.10);
    --gold: #a5824f;
    --gold-soft: rgba(165, 130, 79, 0.10);
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-heavy: rgba(0, 0, 0, 0.16);
}

/* ---------- 主题色：青蓝 ---------- */
:root[data-color="blue"] {
    --ink: #26313c;
    --ink-light: #4e5f6e;
    --ink-lighter: #7f92a1;
    --paper: #edf2f6;
    --paper-dark: #dfe8ef;
    --card: #ffffff;
    --line: #d3dde5;
    --accent: #38699c;
    --accent-strong: #2c5580;
    --accent-soft: rgba(56, 105, 156, 0.09);
    --accent-line: rgba(56, 105, 156, 0.30);
    --bamboo: #4f7a52;
    --bamboo-soft: rgba(79, 122, 82, 0.10);
    --gold: #96804e;
    --gold-soft: rgba(150, 128, 78, 0.10);
}

/* ---------- 主题色：豆绿 ---------- */
:root[data-color="green"] {
    --ink: #29352c;
    --ink-light: #526355;
    --ink-lighter: #7f907f;
    --paper: #e9f1e4;
    --paper-dark: #dbe7d3;
    --card: #fbfef9;
    --line: #cddcc4;
    --accent: #477a54;
    --accent-strong: #386243;
    --accent-soft: rgba(71, 122, 84, 0.10);
    --accent-line: rgba(71, 122, 84, 0.30);
    --bamboo: #477a54;
    --bamboo-soft: rgba(71, 122, 84, 0.12);
    --gold: #96804e;
    --gold-soft: rgba(150, 128, 78, 0.10);
}

/* ---------- 主题色：浅黄 ---------- */
:root[data-color="yellow"] {
    --ink: #3a352a;
    --ink-light: #60594a;
    --ink-lighter: #8c8471;
    --paper: #f6efdb;
    --paper-dark: #ece2c6;
    --card: #fffdf6;
    --line: #ddd2b4;
    --accent: #96702a;
    --accent-strong: #7a5a20;
    --accent-soft: rgba(150, 112, 42, 0.10);
    --accent-line: rgba(150, 112, 42, 0.32);
    --bamboo: #5d7a4f;
    --bamboo-soft: rgba(93, 122, 79, 0.10);
    --gold: #96702a;
    --gold-soft: rgba(150, 112, 42, 0.12);
}

/* ---------- 暗色模式：默认 ---------- */
:root[data-mode="dark"],
:root[data-mode="dark"][data-color="default"] {
    --ink: #ddd9cf;
    --ink-light: #aca79c;
    --ink-lighter: #7f7b73;
    --paper: #1b1b1d;
    --paper-dark: #262628;
    --card: #242426;
    --line: #3a3a3d;
    --accent: #d9634f;
    --accent-strong: #e07a68;
    --accent-soft: rgba(217, 99, 79, 0.14);
    --accent-line: rgba(217, 99, 79, 0.38);
    --bamboo: #7fae8b;
    --bamboo-soft: rgba(127, 174, 139, 0.14);
    --gold: #c2a265;
    --gold-soft: rgba(194, 162, 101, 0.14);
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-heavy: rgba(0, 0, 0, 0.55);
}

/* ---------- 暗色模式：青蓝 ---------- */
:root[data-mode="dark"][data-color="blue"] {
    --ink: #d3dde6;
    --ink-light: #9fb0bf;
    --ink-lighter: #718393;
    --paper: #141c25;
    --paper-dark: #1c2632;
    --card: #1c2632;
    --line: #2e3d4d;
    --accent: #6f9fd0;
    --accent-strong: #8ab2dc;
    --accent-soft: rgba(111, 159, 208, 0.14);
    --accent-line: rgba(111, 159, 208, 0.38);
    --bamboo: #7fae8b;
    --bamboo-soft: rgba(127, 174, 139, 0.14);
    --gold: #c2a265;
    --gold-soft: rgba(194, 162, 101, 0.14);
}

/* ---------- 暗色模式：豆绿 ---------- */
:root[data-mode="dark"][data-color="green"] {
    --ink: #d6e0d8;
    --ink-light: #a2b3a6;
    --ink-lighter: #748577;
    --paper: #152019;
    --paper-dark: #1d2b22;
    --card: #1d2b22;
    --line: #2e4034;
    --accent: #7fae8b;
    --accent-strong: #96c2a2;
    --accent-soft: rgba(127, 174, 139, 0.14);
    --accent-line: rgba(127, 174, 139, 0.38);
    --bamboo: #7fae8b;
    --bamboo-soft: rgba(127, 174, 139, 0.16);
    --gold: #c2a265;
    --gold-soft: rgba(194, 162, 101, 0.14);
}

/* ---------- 暗色模式：浅黄 ---------- */
:root[data-mode="dark"][data-color="yellow"] {
    --ink: #e0dac6;
    --ink-light: #b3ab92;
    --ink-lighter: #847c66;
    --paper: #1f1c14;
    --paper-dark: #2a2519;
    --card: #2a2519;
    --line: #3d3722;
    --accent: #c6a45c;
    --accent-strong: #d8ba78;
    --accent-soft: rgba(198, 164, 92, 0.14);
    --accent-line: rgba(198, 164, 92, 0.40);
    --bamboo: #93ac74;
    --bamboo-soft: rgba(147, 172, 116, 0.14);
    --gold: #c6a45c;
    --gold-soft: rgba(198, 164, 92, 0.16);
}

:root {
    --cinnabar: var(--accent);
    --cinnabar-light: var(--accent-soft);
}

/* ---------- 基础重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: var(--font-size);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    line-height: var(--line-height);
    transition: background 0.3s, color 0.3s;
    min-height: 100vh;
}

::selection {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--paper-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-lighter); }

/* ============================================
   顶部导航栏
   ============================================ */
.reader-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: transform 0.3s ease, background 0.3s;
}

@supports (backdrop-filter: blur(12px)) {
    .reader-nav { background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(12px); }
}

.reader-nav.hidden { transform: translateY(-100%); }

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ink-light);
    font-size: 14px;
    transition: color 0.3s;
    font-family: var(--font-ui);
}

.back-btn:hover { color: var(--accent); }

.book-title-nav {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-ui);
}

.nav-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-light);
    transition: all 0.25s;
    font-size: 16px;
    font-family: inherit;
}

.nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

/* ============================================
   目录抽屉
   ============================================ */
.toc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.toc-overlay.show { opacity: 1; pointer-events: auto; }

.toc-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    background: var(--paper);
    border-right: 1px solid var(--line);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.toc-sidebar.open { transform: translateX(0); }

.toc-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}

.toc-book-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 2px;
}

.toc-book-title a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.25s;
}

.toc-book-title a:hover { color: var(--accent); }

.toc-sub-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-lighter);
    font-family: var(--font-ui);
    line-height: 1.6;
}

.toc-sub-row .dot { opacity: 0.5; }

.toc-toggle-order {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--line);
    padding: 2px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ink-light);
    transition: all 0.2s;
    font-family: var(--font-ui);
    line-height: 1.6;
}

.toc-toggle-order:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.toc-content {
    padding: 8px 0 16px;
    flex: 1;
}

.toc-item {
    border-bottom: 1px solid var(--paper-dark);
}

.toc-item:last-child { border-bottom: none; }

.toc-item a {
    display: block;
    padding: 10px 18px;
    text-decoration: none;
    color: var(--ink-light);
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    line-height: 1.5;
}

.toc-item a:hover {
    background: var(--paper-dark);
    color: var(--ink);
}

.toc-item.current > a {
    background: var(--accent-soft);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

.toc-sub {
    list-style: none;
    padding: 0;
    margin: 0;
    background: color-mix(in srgb, var(--paper-dark) 45%, transparent);
}

.toc-sub a {
    padding: 7px 18px 7px 34px;
    font-size: 13px;
    color: var(--ink-lighter);
}

/* ============================================
   阅读设置面板
   ============================================ */
.settings-panel {
    position: fixed;
    right: 24px;
    top: 64px;
    width: 296px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px 20px;
    box-shadow: 0 12px 40px var(--shadow-heavy);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.25s, transform 0.25s;
}

.settings-panel.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.settings-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.setting-item { margin-bottom: 18px; }
.setting-item:last-child { margin-bottom: 0; }

.setting-label {
    font-size: 12px;
    color: var(--ink-lighter);
    margin-bottom: 8px;
    display: block;
    font-family: var(--font-ui);
    letter-spacing: 0.5px;
}

.font-size-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.size-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    color: var(--ink);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.size-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.size-display {
    font-size: 14px;
    color: var(--ink-light);
    min-width: 56px;
    text-align: center;
    font-family: var(--font-ui);
}

.option-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.option-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-light);
    transition: all 0.2s;
    text-align: center;
    font-family: var(--font-ui);
    white-space: nowrap;
}

.option-btn:hover { border-color: var(--accent); color: var(--accent); }

.option-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.color-row { gap: 10px; }

.color-btn {
    flex: 1;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--line);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: all 0.2s;
}

.color-btn::after {
    content: '';
    position: absolute;
    left: 7px;
    right: 7px;
    bottom: 6px;
    height: 5px;
    border-radius: 3px;
}

.color-btn:hover { transform: translateY(-1px); }

.color-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-line);
}

.color-btn.color-default { background: #f7f5f0; }
.color-btn.color-default::after { background: #c0392b; }

.color-btn.color-blue { background: #edf2f6; }
.color-btn.color-blue::after { background: #38699c; }

.color-btn.color-green { background: #e9f1e4; }
.color-btn.color-green::after { background: #477a54; }

.color-btn.color-yellow { background: #f6efdb; }
.color-btn.color-yellow::after { background: #96702a; }

.font-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.font-btn {
    padding: 8px 4px;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    transition: all 0.2s;
    text-align: center;
}

.font-btn:hover { border-color: var(--accent); color: var(--accent); }

.font-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.font-btn[data-font="default"]  { font-family: "Noto Serif SC", "Source Han Serif SC", SimSun, serif; }
.font-btn[data-font="song"]     { font-family: SimSun, "Songti SC", serif; }
.font-btn[data-font="yahei"]    { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; }
.font-btn[data-font="fangsong"] { font-family: FangSong, "FangSong_GB2312", "STFangsong", serif; }
.font-btn[data-font="kai"]      { font-family: KaiTi, "Kaiti SC", "STKaiti", serif; }

.shortcut-hint {
    font-size: 12px;
    color: var(--ink-lighter);
    line-height: 1.9;
    font-family: var(--font-ui);
}

/* ============================================
   主内容区
   ============================================ */
.reading-container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 84px 24px 130px;
    position: relative;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    font-size: 13px;
    color: var(--ink-lighter);
    flex-wrap: wrap;
    font-family: var(--font-ui);
}

.breadcrumb a {
    color: var(--ink-light);
    text-decoration: none;
    transition: color 0.25s;
}

.breadcrumb a:hover { color: var(--accent); }

.breadcrumb .current {
    color: var(--ink);
    font-weight: 600;
}

.title-section {
    text-align: center;
    margin-bottom: 44px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.title-section h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 14px;
    color: var(--ink);
}

.book-meta {
    font-size: 13px;
    color: var(--ink-lighter);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px 18px;
    flex-wrap: wrap;
    font-family: var(--font-ui);
}

.book-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.6;
    white-space: nowrap;
}

/* ============================================
   正文排版
   ============================================ */
.content {
    font-size: var(--font-size);
    line-height: var(--line-height);
    text-align: justify;
}

.content-paragraph {
    margin-bottom: var(--paragraph-spacing);
    text-indent: 2em;
}

.content-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 1.8em 0 0.9em;
    color: var(--ink);
    position: relative;
    padding-left: 14px;
    line-height: 1.5;
}

.content-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.32em;
    bottom: 0.32em;
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
}

/* ===== 诗歌块（新设计：居中、留白、装饰符号） ===== */
.poem-block {
    position: relative;
    margin: 2em 0;
    padding: 1.2em 1em;
    text-align: center;
    text-indent: 0;
    line-height: 2.1;
    transition: background 0.2s;
}

.poem-block p {
    text-indent: 0;
    margin-bottom: 0.4em;
}

.poem-block p:last-child {
    margin-bottom: 0;
}

/* 悬停装饰符号变色 */
.poem-block:hover::before,
.poem-block:hover::after {
    color: var(--accent);
}

/* 上下装饰符号 ❋ */
.poem-block::before,
.poem-block::after {
    content: "┈ ❋ ┈";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--line);
    font-size: 0.9rem;
    line-height: 1;
    transition: color 0.2s;
}

.poem-block::before {
    top: 0.15em;
}

.poem-block::after {
    bottom: 0.15em;
}

/* note / trans / annot 块（左缘直边） */
.note-block, .trans-block, .annot-block {
    margin: 1.5em 0;
    padding: 1em 1.4em;
    border-radius: 0;
    position: relative;
}

.note-block {
    background: var(--bamboo-soft);
    border-left: 3px solid var(--bamboo);
}

.trans-block {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
}

.annot-block {
    background: var(--gold-soft);
    border-left: 3px solid var(--gold);
}

.note-block p, .trans-block p, .annot-block p {
    text-indent: 0;
    margin-bottom: 0.7em;
}

.note-block p:last-child,
.trans-block p:last-child,
.annot-block p:last-child { margin-bottom: 0; }

/* 引用块（左缘直边） */
blockquote.blockquote {
    margin: 1.8em 0;
    padding: 1.2em 1.6em;
    background: var(--paper-dark);
    border-left: 3px solid var(--gold);
    border-radius: 0;
    color: var(--ink-light);
}

blockquote.blockquote p {
    text-indent: 0;
    margin-bottom: 0.7em;
}

blockquote.blockquote p:last-child { margin-bottom: 0; }

/* 表格 */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.92em;
}

.table th, .table td {
    padding: 10px 14px;
    border: 1px solid var(--line);
    text-align: left;
}

.table thead {
    background: var(--paper-dark);
    font-weight: 600;
}

.table tbody tr:hover {
    background: var(--accent-soft);
}

/* 代码 */
pre.bg-light {
    background: var(--paper-dark);
    padding: 1.2em 1.4em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5em 0;
    border: 1px solid var(--line);
}

code.bg-light {
    background: var(--paper-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    color: var(--accent);
}

/* 图片 */
.img-fluid {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5em auto;
    display: block;
    box-shadow: 0 4px 14px var(--shadow);
}

/* 分隔线 */
.section-divider {
    border: none;
    text-align: center;
    margin: 2.4em 0;
    color: var(--ink-lighter);
    letter-spacing: 12px;
    font-size: 14px;
}

.section-divider::before { content: '❋ ❋ ❋'; }

/* 脚注标记 */
.note-mark {
    font-size: 0.72em;
    vertical-align: super;
    line-height: 0;
}

.footnote-link {
    color: var(--accent);
    text-decoration: none;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.2s;
    cursor: pointer;
}

.footnote-link:hover { background: var(--accent-soft); }

/* 脚注区（文后） */
.notes-section {
    margin-top: 3em;
    padding-top: 1.8em;
    border-top: 1px solid var(--line);
}

.notes-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.2em;
    color: var(--ink);
}

.note-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--paper-dark);
    font-size: 0.9em;
    color: var(--ink-light);
    line-height: 1.8;
}

.note-item:last-child { border-bottom: none; }

.note-item:target {
    background: var(--accent-soft);
    border-radius: 6px;
    padding-left: 8px;
    padding-right: 8px;
}

.note-num {
    color: var(--accent);
    font-weight: 600;
    margin-right: 4px;
}

.back-to-text {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85em;
    margin-left: 8px;
    opacity: 0.75;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.back-to-text:hover { opacity: 1; }

/* ============================================
   徽章（badge，重写）
   ============================================ */
.badge {
    display: inline-block;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 500;
    line-height: 1.9;
    background: var(--paper-dark);
    color: var(--ink-light);
    border: 1px solid var(--accent);
    margin: 0 3px;
    vertical-align: 2px;
    font-family: var(--font-ui);
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-indent: 0;
}

/* 链接 */
.text-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-line);
    transition: all 0.2s;
}

.text-link:hover {
    border-bottom-style: solid;
    background: var(--accent-soft);
}

/* ============================================
   章节导航卡片
   ============================================ */
.chapter-nav {
    margin-top: 3.5em;
    padding-top: 2em;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.nav-card {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--card);
}

.nav-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 18px var(--shadow);
    transform: translateY(-2px);
}

.nav-card.nav-card-next {
    text-align: right !important;
    align-items: flex-end;
}

.nav-card.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.nav-label {
    font-size: 12px;
    color: var(--ink-lighter);
    letter-spacing: 1px;
    font-family: var(--font-ui);
}

.nav-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.5;
}

/* ============================================
   操作按钮
   ============================================ */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 2.5em;
    justify-content: center;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 14px;
    transition: all 0.25s;
    cursor: pointer;
    font-family: var(--font-ui);
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* ============================================
   底部阅读工具栏
   ============================================ */
.reading-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--paper);
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 14px;
    z-index: 100;
    transition: background 0.3s;
}

@supports (backdrop-filter: blur(12px)) {
    .reading-toolbar { background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(12px); }
}

.tool-group {
    display: flex;
    gap: 2px;
    align-items: center;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ink-light);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--paper-dark);
    color: var(--ink);
}

.tool-btn .icon {
    font-size: 15px;
    line-height: 1;
}

.tool-btn svg { display: block; }

/* ============================================
   页脚
   ============================================ */
.site-footer {
    text-align: center;
    padding: 3em 0 1.5em;
    color: var(--ink-lighter);
    font-size: 12px;
    border-top: 1px solid var(--line);
    margin-top: 3em;
    font-family: var(--font-ui);
    letter-spacing: 1px;
}

/* ============================================
   广告面板（保留原有功能）
   ============================================ */
.info-panel {
    position: fixed;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 50;
    max-width: 200px;
    font-size: 13px;
}

.info-panel.top-banner,
.info-panel.bottom-banner,
.info-panel.inline-panel {
    position: relative;
    max-width: 100%;
    margin: 1.5em 0;
}

.panel-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    color: var(--ink-lighter);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.panel-close:hover {
    background: var(--paper-dark);
    color: var(--accent);
}

.side-panel {
    position: fixed;
    top: 80px;
    width: 180px;
    z-index: 50;
}

.side-panel.left { left: 20px; }
.side-panel.right { right: 20px; }

/* ============================================
   无障碍
   ============================================ */
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-100%);
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    z-index: 1000;
    transition: transform 0.25s;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.skip-link:focus { transform: translateY(0); }

/* ============================================
   书籍首页
   ============================================ */
.book-hero {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 44px;
    align-items: start;
    margin-bottom: 52px;
}

.book-cover { width: 300px; }

.book-cover-img {
    display: block;
    width: 300px;
    height: 450px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 18px 44px var(--shadow-heavy);
    border: 1px solid var(--line);
    background: var(--paper-dark);
}

.book-cover-card {
    width: 300px;
    height: 450px;
    border-radius: 8px;
    box-shadow: 0 18px 44px var(--shadow-heavy);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 26px;
    color: #f5efe2;
    background: linear-gradient(160deg, #3a4a5c 0%, #26313c 100%);
}

.book-cover-card .cover-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.35;
}

.book-cover-card .cover-author {
    font-size: 13px;
    opacity: 0.85;
}

.book-info h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.4;
}

.book-meta-row {
    display: flex;
    align-items: center;
    gap: 8px 20px;
    margin-bottom: 18px;
    color: var(--ink-light);
    font-size: 14px;
    flex-wrap: wrap;
    font-family: var(--font-ui);
}

.book-meta-row .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.6;
    white-space: nowrap;
}

.book-meta-row .meta-item .meta-ico {
    font-size: 15px;
    line-height: 1;
}

.book-intro {
    font-size: 15px;
    color: var(--ink-light);
    line-height: 1.9;
    margin-bottom: 24px;
    text-align: justify;
}

.book-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-radius: 10px;
    border: 1px solid var(--line);
    margin-bottom: 24px;
}
.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    display: block;
    font-family: var(--font-ui);
}

.stat-label {
    font-size: 12px;
    color: var(--ink-lighter);
    margin-top: 2px;
    font-family: var(--font-ui);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 30px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.25s;
    border: none;
    cursor: pointer;
    font-family: var(--font-ui);
}

.btn-primary:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--shadow-heavy);
}

.btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header { margin-bottom: 18px; }

.section-title {
    font-size: 1.35rem;
    font-weight: 700;
    padding-left: 14px;
    position: relative;
    color: var(--ink);
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.28em;
    bottom: 0.28em;
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
}

.toc-list-index {
    list-style: none;
    background: var(--card);
    border-radius: 10px;
    border: 1px solid var(--line);
    overflow: hidden;
}

.toc-item-index {
    border-bottom: 1px solid var(--paper-dark);
    transition: background 0.2s;
}

.toc-item-index:last-child { border-bottom: none; }

.toc-item-index a {
    display: flex;
    align-items: center;
    padding: 13px 20px;
    text-decoration: none;
    color: var(--ink);
    transition: background 0.2s;
    gap: 14px;
}

.toc-item-index a:hover { background: var(--accent-soft); }

.toc-num-index {
    font-size: 12px;
    color: var(--accent);
    font-family: var(--font-ui);
    min-width: 52px;
    flex: none;
    letter-spacing: 0.5px;
}

.toc-name-index {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
}

.toc-item-index.toc-special .toc-name-index { color: var(--ink-light); }

/* ============================================
   脚注抽屉
   ============================================ */
.footnote-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 290;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.footnote-overlay.show { opacity: 1; pointer-events: auto; }

.fn-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    max-width: 90vw;
    background: var(--paper);
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 32px var(--shadow);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.fn-drawer.show { transform: translateX(0); }

.fn-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    flex: none;
}

.fn-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fn-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.fn-count {
    font-size: 12px;
    color: var(--ink-lighter);
    font-family: var(--font-ui);
}

.fn-pin {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 9px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-light);
    transition: all 0.2s;
    line-height: 1.4;
}

.fn-pin:hover { border-color: var(--accent); color: var(--accent); }

.fn-pin.pinned {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.fn-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 16px;
}

.fn-list .note-item {
    padding: 12px 18px;
    border-bottom: 1px solid var(--paper-dark);
    font-size: 0.9em;
    color: var(--ink-light);
    line-height: 1.85;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.fn-list .note-item:last-child { border-bottom: none; }

.fn-list .note-item.active-note {
    background: var(--accent-soft);
    border-left-color: var(--accent);
    color: var(--ink);
}

.fn-list .note-item.active-note .note-num { color: var(--accent); }

.fn-grip { display: none; }

@media (max-width: 768px) {
    .fn-drawer {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-width: none;
        max-height: 52vh;
        border-left: none;
        border-top: 1px solid var(--line);
        border-radius: 14px 14px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -8px 32px var(--shadow-heavy);
    }

    .fn-drawer.show { transform: translateY(0); }

    .fn-grip {
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: var(--line);
        margin: 8px auto 0;
        flex: none;
    }
}

/* ============================================
   分享弹窗
   ============================================ */
.share-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.share-overlay.show { opacity: 1; pointer-events: auto; }

.share-card {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px 22px 18px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
    z-index: 410;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.share-card.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.share-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 14px;
}

.share-qr {
    width: 180px;
    height: 180px;
    margin: 0 auto 12px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-qr img {
    display: block;
    width: 100%;
    height: 100%;
}

.share-url {
    font-size: 12px;
    color: var(--ink-lighter);
    word-break: break-all;
    line-height: 1.7;
    margin-bottom: 14px;
    font-family: var(--font-ui);
    max-height: 3.4em;
    overflow: hidden;
}

.share-actions {
    display: flex;
    gap: 10px;
}

.share-actions .action-btn {
    flex: 1;
    justify-content: center;
    padding: 9px 0;
    font-size: 13px;
}

/* ============================================
   轻提示 Toast
   ============================================ */
.toast-msg {
    position: fixed;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 500;
    font-family: var(--font-ui);
    animation: toastIn 0.25s ease;
    box-shadow: 0 8px 24px var(--shadow-heavy);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 900px) {
    .book-hero {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .book-cover, .book-cover-img, .book-cover-card {
        width: min(260px, 72vw);
        margin: 0 auto;
    }

    .book-cover-img, .book-cover-card {
        height: auto;
        aspect-ratio: 300 / 450;
    }
}

@media (max-width: 768px) {
    :root {
        --font-size: 16px;
        --content-width: 100%;
    }

    .reading-container { padding: 72px 16px 110px; }
    .title-section h1 { font-size: 1.55rem; }
    .reader-nav { padding: 0 14px; }
    .book-title-nav { display: none; }

    .settings-panel {
        right: 12px;
        left: 12px;
        width: auto;
        top: 62px;
        max-height: calc(100vh - 140px);
    }

    .toc-sidebar { width: min(300px, 85vw); }
    .chapter-nav { grid-template-columns: 1fr; }
    .book-info h1 { font-size: 1.6rem; }
    .book-stats { padding: 14px 12px; gap: 8px; }
    .side-panel { display: none; }
    .action-buttons { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .tool-btn { padding: 8px 9px; font-size: 12px; gap: 4px; }
    .tool-btn .icon { font-size: 14px; }
    .content-title { font-size: 1.2rem; }
    .book-meta { gap: 6px 12px; }
}

/* ============================================
   打印
   ============================================ */
@media print {
    .reader-nav, .reading-toolbar,
    .toc-sidebar, .toc-overlay, .settings-panel,
    .side-panel, .info-panel, .action-buttons,
    .fn-drawer, .footnote-overlay,
    .share-card, .share-overlay {
        display: none !important;
    }
    .reading-container { padding: 0; max-width: 100%; }
    body { background: #fff; color: #000; }
    .content-paragraph { text-indent: 2em; }
}

/* ============================================
   目录抽屉页签（目录 / 划线）
   ============================================ */
.toc-tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    flex: none;
}

.toc-tab {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-lighter);
    font-family: var(--font-ui);
    transition: all 0.2s;
}

.toc-tab:hover { color: var(--ink); }

.toc-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.marks-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    flex-direction: column;
}

.toc-sidebar.show-marks .toc-content { display: none; }
.toc-sidebar.show-marks .marks-content { display: flex; }

.marks-list { flex: 1; padding: 8px 0; }

.marks-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-lighter);
    font-size: 13px;
    line-height: 2;
}

.mark-item {
    padding: 10px 18px;
    border-bottom: 1px solid var(--paper-dark);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.mark-item:hover { background: var(--paper-dark); }

.mark-text {
    font-size: 13px;
    color: var(--ink);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mark-chapter {
    font-size: 11px;
    color: var(--ink-lighter);
    margin-top: 4px;
    font-family: var(--font-ui);
}

.mark-del {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: var(--ink-lighter);
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
}

.mark-item:hover .mark-del { opacity: 1; }
.mark-del:hover { color: var(--accent); background: var(--accent-soft); }

.marks-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    flex: none;
}

.marks-footer .action-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 0;
    font-size: 13px;
}

.toc-item.read > a { color: var(--ink-lighter); }

.toc-item.read > a::after {
    content: '✓';
    float: right;
    color: var(--bamboo);
    font-size: 13px;
}

.toc-item-index.read .toc-name-index {
    color: var(--ink-lighter);
    position: relative;
}

.toc-item-index.read a::after {
    content: '已读';
    font-size: 11px;
    color: var(--bamboo);
    font-family: var(--font-ui);
    flex: none;
}

/* ============================================
   划线高亮样式
   ============================================ */
.user-mark {
    background: linear-gradient(to top, var(--accent-line) 0%, var(--accent-line) 30%, transparent 30%);
    border-bottom: 2px solid var(--accent-line);
    cursor: pointer;
    padding-bottom: 1px;
}

/* ============================================
   底部固定划线菜单（新版，替代旧悬浮菜单）
   ============================================ */
.sel-pop-bottom {
    position: fixed;
    bottom: 70px;                  /* 阅读工具栏高度 56px + 间距 14px */
    left: 50%;
    transform: translateX(-50%);
    z-index: 380;
    background: rgba(30, 30, 30, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 40px;
    padding: 8px 24px;
    display: flex;
    gap: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.sel-pop-bottom.show {
    opacity: 1;
    pointer-events: auto;
}

.sel-pop-bottom button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 24px;
    font-family: var(--font-ui);
    transition: background 0.15s;
    white-space: nowrap;
}

.sel-pop-bottom button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sel-pop-bottom button:active {
    background: rgba(255, 255, 255, 0.25);
}

/* 移动端微调 */
@media (max-width: 768px) {
    .sel-pop-bottom {
        bottom: 60px;
        padding: 6px 16px;
        gap: 8px;
    }
    .sel-pop-bottom button {
        font-size: 15px;
        padding: 8px 16px;
    }
}

/* ============================================
   金句分享卡片
   ============================================ */
.quote-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 420;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.quote-overlay.show { opacity: 1; pointer-events: auto; }

.quote-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    z-index: 430;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
    max-width: calc(100vw - 32px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    text-align: center;
}

.quote-modal.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.quote-modal canvas {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: 12px;
}

.quote-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ============================================
   工具栏小屏隐藏文字
   ============================================ */
@media (max-width: 768px) {
    .tool-btn .lbl { display: none; }
    .tool-btn { padding: 8px 11px; }
}

.fn-close {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    color: var(--ink-lighter);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.fn-close:hover {
    background: var(--paper-dark);
    color: var(--accent);
}

.btn-row-main {
    margin-bottom: 12px;
}

.btn-row-main .btn-primary {
    min-width: 220px;
    justify-content: center;
}

/* ============================================
   自定义字符（custom-char，仿 badge 但无圆角）
   ============================================ */
.custom-char {
    display: inline-block;
    padding: 0 8px;
    border-radius: 0;
    font-size: 0.9em;
    font-weight: 500;
    line-height: 1.9;
    color: var(--ink-light);
    border: 1px dotted var(--accent);
    margin: 0 3px;
    vertical-align: 2px;
    font-family: var(--font-body);
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-indent: 0;
}

.custom-char:hover {
    background: var(--accent-soft);
}

/* ============================================
   居中对齐与右对齐文本块
   ============================================ */
.text-center {
    text-align: center;
    text-indent: 0;
}

.text-right {
    text-align: right;
    text-indent: 0;
}

/* 纯文字导航链接 */
.nav-link {
    color: var(--ink-light);
    text-decoration: none;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    font-family: var(--font-ui);
}
.nav-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
}
.nav-link.active {
    color: var(--accent);
    font-weight: 600;
}