/* ========== 《神临山海》Web阅读器 V6.0 - 最终完美版 ========== */

:root {
    --bg-main: #fcfbf8;
    --bg-paper: #ffffff;
    --bg-sidebar: #f7f5f0;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: #e8e4e0;
    --copper: #b87333;
    --copper-hover: #a05a2c;
    --copper-light: rgba(184, 115, 51, 0.1);
    --sidebar-width: 280px;
    --header-height: 70px;
    --footer-height: 48px;
    --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
    --bg-main: #121212;
    --bg-paper: #1e1e1e;
    --bg-sidebar: #181818;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #2a2a2a;
    --copper: #d4935c;
    --copper-hover: #e5a972;
    --copper-light: rgba(212, 147, 92, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ========== 统一页眉 ========== */
.unified-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    z-index: 1000;
    gap: 2rem;
}

[data-theme="dark"] .unified-header {
    background: rgba(18, 18, 18, 0.95);
}

.header-brand {
    width: calc(var(--sidebar-width) - 4rem);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s;
}

.header-brand:hover .main-title {
    color: var(--copper-hover);
    transform: translateX(3px);
}

.main-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--copper);
    letter-spacing: 0.1em;
    transition: all 0.3s;
}

.main-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-weight: 300;
    letter-spacing: 0.02em;
}

.header-nav {
    flex: 1;
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.nav-link {
    position: relative;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--copper);
    transform: translateX(-50%);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
    color: var(--copper);
    transform: translateY(-3px);
}

.nav-link:hover::after {
    width: 80%;
}

.nav-link.active {
    color: var(--copper);
}

.nav-link.active::after {
    width: 80%;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 精致搜索框 */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.4rem 0.75rem;
    width: 120px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.search-box:focus-within {
    width: 280px;
    border-color: var(--copper);
    box-shadow: 0 0 0 3px var(--copper-light);
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 0;
}

.search-box button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.search-box button:hover {
    transform: scale(1.15);
}

.header-icon-btn, .settings-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header-icon-btn:hover, .settings-toggle:hover {
    color: var(--copper);
    background: var(--copper-light);
}
.settings-toggle:hover { transform: rotate(90deg); }
.header-icon-btn.panel-open { color: var(--copper); background: var(--copper-light); }

/* ========== 侧边栏 ========== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 900;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-toggle-mobile {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    z-index: 10;
}

.menu-toggle-mobile:hover {
    background: var(--copper-light);
    color: var(--copper);
}

.chapter-nav {
    padding: 1rem 0;
}

.encyclopedia-section {
    margin-bottom: 2px;
}

.section-title {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-sans);
    letter-spacing: 0.02em;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
    background: transparent;
}

.section-title:hover {
    background: var(--copper-light);
    color: var(--copper);
    padding-left: 1.25rem;
}

.section-title::after {
    content: '›';
    font-size: 0.875rem;
    font-weight: 400;
    transition: transform 0.15s ease;
    opacity: 0.5;
}

.section-title.active {
    background: var(--copper-light);
    color: var(--copper);
}

.section-title.active::after {
    transform: rotate(90deg);
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
    background: rgba(0,0,0,0.015);
}

.section-content.open {
    max-height: 3000px;
}

.book-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-sans);
    letter-spacing: 0.03em;
    color: var(--copper);
    background: rgba(0,0,0,0.02);
    text-transform: uppercase;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
    line-height: 1.4;
}

.chapter-item .nav-icon {
    flex-shrink: 0;
    font-size: 0.875rem;
    width: 1.25rem;
    text-align: center;
}

.chapter-item .nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-item:hover {
    color: var(--copper);
    background: var(--copper-light);
    padding-left: 1.5rem;
    border-left-color: var(--copper);
}

.chapter-item.active {
    color: var(--copper);
    background: var(--copper-light);
    border-left-color: var(--copper);
    font-weight: 600;
    position: relative;
}

/* 当前阅读项的闪烁光点 */
.chapter-item.active::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--copper);
    border-radius: 50%;
    animation: pulse-glow 1.5s ease-in-out infinite;
    box-shadow: 0 0 8px var(--copper), 0 0 12px var(--copper);
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
        box-shadow: 0 0 8px var(--copper), 0 0 12px var(--copper);
    }
    50% {
        opacity: 0.6;
        transform: translateY(-50%) scale(0.8);
        box-shadow: 0 0 4px var(--copper), 0 0 8px var(--copper);
    }
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    left: 1rem;
    z-index: 1001;
    background: var(--bg-paper);
    box-shadow: var(--shadow-md);
}

.menu-toggle:hover {
    background: var(--copper-light);
    color: var(--copper);
}

.reading-progress {
    height: 2px;
    width: 100%;
    background: transparent;
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    z-index: 899;
}

.reading-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--copper), var(--copper-hover));
    transition: width 0.1s;
    box-shadow: 0 0 6px rgba(184, 115, 51, 0.4);
}

/* ========== 阅读内容 ========== */
.reader-content {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: var(--bg-main);
}

.book-page {
    max-width: 720px;
    margin: 0 auto;
    margin-right: calc(50% - 360px + 120px); /* 向左偏移120px，给右侧TOC留空间 */
    margin-left: calc(50% - 360px - 120px);
    background: var(--bg-paper);
    padding: 3rem 4rem;
    box-shadow: var(--shadow-md);
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    position: relative;
}

@media (max-width: 1400px) {
    .book-page {
        margin-right: calc(50% - 360px + 80px);
        margin-left: calc(50% - 360px - 80px);
    }
}

@media (max-width: 1200px) {
    .book-page {
        margin: 0 auto; /* 屏幕较小时恢复居中 */
    }
}

/* 正文内嵌导航按钮 */
.chapter-nav-top,
.chapter-nav-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.chapter-nav-bottom {
    border-bottom: none;
    border-top: 1px solid var(--border);
    margin-bottom: 0;
    margin-top: 2.5rem;
}

.chapter-nav-btn {
    position: relative;
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-nav-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--copper);
    transform: translateX(-50%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-nav-btn:hover:not(:disabled) {
    color: var(--copper);
    transform: translateY(-2px);
}

.chapter-nav-btn:hover:not(:disabled)::after {
    width: 80%;
}

.chapter-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chapter-info-inline {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-family: var(--font-serif);
    font-style: italic;
}

#content {
    font-family: var(--font-serif);
    font-size: 14px; /* Reduced for compactness */
    line-height: 1.7; /* Tighter */
    color: #2c2c2c;
    letter-spacing: 0.01em;
    text-align: justify;
    max-width: 850px;
    margin: 0 auto;
}

[data-theme="dark"] #content {
    color: #d0d0d0;
}

#content h1 {
    font-size: 1.625rem; /* Smaller H1 */
    text-align: center;
    margin: 0 0 2rem 0;
    color: var(--copper);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    scroll-margin-top: 100px; /* 为锚点跳转留出空间 */
    transition: background-color 0.3s ease; /* 锚点高亮过渡 */
}

#content h2 {
    font-size: 1.125rem; /* Smaller H2 */
    margin: 2rem 0 0.875rem;
    color: var(--copper);
    font-weight: 500;
    padding-top: 0.5rem;
    scroll-margin-top: 100px;
    transition: background-color 0.3s ease;
}

#content h3 {
    font-size: 1rem; /* Smaller H3 */
    margin: 1.5rem 0 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
    scroll-margin-top: 100px;
    transition: background-color 0.3s ease;
}

#content p {
    margin-bottom: 1.1em; /* Tighter paragraph spacing */
    text-indent: 2em;
    line-height: 1.75;
}

#content p:first-of-type {
    text-indent: 0;
}

#content p:first-of-type::first-letter {
    font-size: 2.5em; /* Smaller drop cap */
    float: left;
    line-height: 0.85;
    margin: 0.05em 0.08em 0 0;
    color: var(--copper);
    font-weight: 600;
}

#content blockquote {
    margin: 1.5rem 0;
    padding: 0.875rem 1.25rem;
    border-left: 3px solid var(--copper);
    background: var(--copper-light);
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 0.9em;
}

/* Code blocks - Enhanced */
#content pre {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: #f8f8f8;
    border-left: 4px solid var(--copper);
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 1em;
    display: block;
}

#content code {
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.875em;
    background: #f0f0f0;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: #c7254e;
    border: 1px solid #e0e0e0;
}

/* Code in dark mode */
[data-theme="dark"] #content pre {
    background: #1e1e1e;
    border-left-color: var(--copper);
}

[data-theme="dark"] #content code {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #e06c75;
}

/* Syntax highlighting compatibility */
#content .hljs {
    background: transparent;
    padding: 0;
}

/* Tables - Enhanced */
#content table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#content table th {
    background: var(--copper-light);
    color: var(--copper);
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--copper);
    border-right: 1px solid var(--border);
}

#content table th:last-child {
    border-right: none;
}

#content table td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(0,0,0,0.05);
    vertical-align: top;
}

#content table td:last-child {
    border-right: none;
}

#content table tr:last-child td {
    border-bottom: none;
}

#content table tr:hover {
    background: rgba(184, 115, 51, 0.05);
}

/* Table in dark mode */
[data-theme="dark"] #content table {
    border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] #content table th {
    background: rgba(184, 115, 51, 0.2);
    border-color: rgba(255,255,255,0.2);
}

[data-theme="dark"] #content table td {
    border-color: rgba(255,255,255,0.08);
}

/* Lists */
#content ul,
#content ol {
    margin: 1rem 0 1rem 2em;
    padding-left: 1em;
}

#content li {
    margin-bottom: 0.5rem;
    line-height: 1.65;
}

/* Links */
#content a {
    color: var(--copper);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
}

#content a:hover {
    border-bottom-color: var(--copper);
    color: var(--copper-hover);
}

/* External links icon */
#content a[href^="http"]::after {
    content: " ↗";
    font-size: 0.75em;
    vertical-align: super;
    opacity: 0.6;
}

#content a[href^="#"]::after {
    content: "";
}

/* Task lists (checkbox) */
#content input[type="checkbox"] {
    margin-right: 0.5em;
    cursor: pointer;
}

#content li.task-list-item {
    list-style: none;
    margin-left: -1.5em;
}

/* Footnotes */
#content .footnotes {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    font-size: 0.875em;
    color: var(--text-secondary);
}

#content .footnotes ol {
    padding-left: 1.5em;
}

#content sup {
    font-size: 0.75em;
    vertical-align: super;
}

#content sup a {
    color: var(--copper);
    text-decoration: none;
    padding: 0 0.2em;
}

#content sup a:hover {
    text-decoration: underline;
}

/* HR */
#content hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* Strong and Emphasis */
#content strong {
    font-weight: 600;
    color: var(--copper);
}

#content em {
    font-style: italic;
    color: var(--text-secondary);
}

/* ========== 设置抽屉 ========== */
.settings-drawer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    visibility: hidden;
    pointer-events: none;
}

.settings-drawer.open {
    visibility: visible;
    pointer-events: auto;
}

.settings-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s;
}

.settings-drawer.open .settings-overlay {
    background: rgba(0,0,0,0.4);
}

.settings-content {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 340px;
    background: var(--bg-paper);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.settings-drawer.open .settings-content {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.settings-header h3 {
    font-family: var(--font-serif);
    color: var(--copper);
    font-size: 1.125rem;
}

.close-settings {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-settings:hover {
    background: var(--copper-light);
    color: var(--copper);
}

.settings-body {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.setting-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
}

.theme-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--copper);
    background: var(--copper-light);
}

.lang-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
}

/* ========== 搜索结果面板 ========== */
.search-results-panel {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: var(--footer-height);
    background: var(--bg-paper);
    z-index: 800;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.search-results-panel.show {
    transform: translateY(0);
}

.search-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.search-panel-header h3 {
    font-family: var(--font-serif);
    color: var(--copper);
    font-size: 1.125rem;
}

.close-search {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-search:hover {
    background: var(--copper-light);
    color: var(--copper);
}

.search-results-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

/* 搜索结果分组容器 */
.search-result-group {
    margin-bottom: 1.5rem;
    background: var(--bg-sidebar);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(15px);
    animation: slideInResult 0.35s ease forwards;
}

.search-result-group:nth-child(1) { animation-delay: 0.05s; }
.search-result-group:nth-child(2) { animation-delay: 0.1s; }
.search-result-group:nth-child(3) { animation-delay: 0.15s; }
.search-result-group:nth-child(4) { animation-delay: 0.2s; }
.search-result-group:nth-child(5) { animation-delay: 0.25s; }

.result-group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--copper-light), transparent);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.result-group-header:hover {
    background: var(--copper-light);
}

.group-toggle {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.group-title {
    flex: 1;
    font-weight: 600;
    color: var(--copper);
    font-size: 0.9rem;
}

.group-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-paper);
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

.result-group-matches {
    padding: 0.5rem;
}

.search-match-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    line-height: 1.5;
}

.search-match-item:hover {
    background: var(--copper-light);
    transform: translateX(4px);
}

.match-line {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-paper);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.match-snippet {
    color: var(--text-secondary);
    word-break: break-all;
}

.match-snippet mark {
    background: rgba(184, 115, 51, 0.3);
    color: var(--copper);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 600;
}

.search-summary {
    padding: 1rem 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* 旧样式保留兼容 */
.search-result-item {
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: var(--bg-sidebar);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    opacity: 0;
    transform: translateY(20px);
    animation: slideInResult 0.4s ease forwards;
}

.search-result-item:nth-child(1) { animation-delay: 0.05s; }
.search-result-item:nth-child(2) { animation-delay: 0.1s; }
.search-result-item:nth-child(3) { animation-delay: 0.15s; }
.search-result-item:nth-child(4) { animation-delay: 0.2s; }
.search-result-item:nth-child(5) { animation-delay: 0.25s; }

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

.search-result-item:hover {
    background: var(--copper-light);
    border-left-color: var(--copper);
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
}

.result-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--copper);
    font-size: 1rem;
}

.result-snippet {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.result-snippet mark {
    background: var(--copper);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ========== 搜索关键词高亮 ========== */
.search-highlight {
    background: linear-gradient(120deg, #fff59d 0%, #fff176 100%);
    color: #000;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
    transition: all 0.3s ease;
}

[data-theme="dark"] .search-highlight {
    background: linear-gradient(120deg, #fbc02d 0%, #f9a825 100%);
    color: #000;
}

/* 第一个匹配项的脉冲动画 */
.search-highlight-pulse {
    animation: searchPulse 1.5s ease-in-out 2;
}

@keyframes searchPulse {
    0%, 100% {
        background: linear-gradient(120deg, #fff59d 0%, #fff176 100%);
        box-shadow: 0 1px 3px rgba(255, 193, 7, 0.3);
        transform: scale(1);
    }
    50% {
        background: linear-gradient(120deg, #ffc107 0%, #ffa000 100%);
        box-shadow: 0 3px 12px rgba(255, 152, 0, 0.6);
        transform: scale(1.05);
    }
}

[data-theme="dark"] @keyframes searchPulse {
    0%, 100% {
        background: linear-gradient(120deg, #fbc02d 0%, #f9a825 100%);
        box-shadow: 0 1px 3px rgba(251, 192, 45, 0.3);
        transform: scale(1);
    }
    50% {
        background: linear-gradient(120deg, #f9a825 0%, #f57f17 100%);
        box-shadow: 0 3px 12px rgba(249, 168, 37, 0.6);
        transform: scale(1.05);
    }
}

/* ========== 页内目录（TOC）========== */
/* ====== UNIFIED RIGHT PANEL (Tab Layout) ====== */
.right-panel {
    position: fixed;
    right: -380px;
    top: var(--header-height, 56px);
    bottom: var(--footer-height, 36px);
    width: 340px;
    z-index: 800;
    background: var(--bg-paper, #fff);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px 0 0 12px;
}
.right-panel.open { right: 0; }

.rp-tabs {
    display: flex;
    align-items: stretch;
    border-bottom: 2px solid var(--border);
    background: var(--bg-sidebar, #f8f6f3);
    flex-shrink: 0;
}
.rp-tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    position: relative;
    text-align: center;
    white-space: nowrap;
}
.rp-tab:hover { color: var(--text-primary); background: rgba(184,115,51,0.04); }
.rp-tab.active {
    color: var(--copper, #b87333);
    font-weight: 600;
}
.rp-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: var(--copper, #b87333);
    border-radius: 1px;
}
.rp-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    background: var(--copper, #b87333);
    border-radius: 10px;
    padding: 0 0.35rem;
    min-width: 1rem;
    text-align: center;
    line-height: 1.4;
    vertical-align: middle;
}
.rp-badge:empty { display: none; }
.rp-tab-close {
    width: 36px;
    flex: none;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: color 0.15s;
}
.rp-tab-close:hover { color: var(--text-primary); }

.rp-pane {
    flex: 1;
    overflow-y: auto;
    display: none;
}
.rp-pane.active { display: flex; flex-direction: column; }

.rp-toc-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.rp-empty { text-align: center; color: var(--text-muted); font-size: 0.75rem; padding: 2rem 1rem; }

.toc-item {
    display: block;
    padding: 0.45rem 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc-item:hover { background: rgba(184,115,51,0.08); color: var(--copper); }
.toc-item.active { background: rgba(184,115,51,0.12); color: var(--copper); border-left-color: var(--copper); font-weight: 600; }
.toc-item.level-1 { padding-left: 1rem; font-weight: 500; }
.toc-item.level-2 { padding-left: 1.5rem; font-size: 0.7rem; }
.toc-item.level-3 { padding-left: 2rem; font-size: 0.65rem; color: var(--text-muted); }

.rp-toc-body::-webkit-scrollbar,
.rp-pane::-webkit-scrollbar { width: 4px; }
.rp-toc-body::-webkit-scrollbar-thumb,
.rp-pane::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

@media (max-width: 768px) {
    .right-panel { width: 100%; right: -100%; border-radius: 0; }
}
[data-theme="dark"] .right-panel { box-shadow: -4px 0 20px rgba(0,0,0,0.3); }

/* ========== 全宽页脚 ========== */
.page-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    font-family: var(--font-serif);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    z-index: 1000;
}

/* ========== 欢迎页面 ========== */
.welcome-screen {
    text-align: center;
    padding: 4rem 2rem;
}

.welcome-screen h2 {
    font-family: var(--font-serif);
    font-size: 1.875rem;
    margin-bottom: 1.25rem;
    color: var(--copper);
    font-weight: 500;
}

.intro-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 2.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem;
    margin: 2.5rem 0;
}

.stat-item {
    text-align: center;
    padding: 1.75rem;
    background: var(--copper-light);
    border-radius: 12px;
    transition: transform 0.3s;
}

.stat-item:hover {
    transform: translateY(-4px);
}

.stat-val {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--copper);
    font-family: var(--font-serif);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* 互动中心6列统计网格 */
.stats-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 0.75rem;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--copper);
}

.stat-card.accent {
    background: linear-gradient(135deg, var(--copper) 0%, #d4a574 100%);
    color: white;
    border: none;
}

.stat-card.accent .stat-label {
    color: rgba(255,255,255,0.85);
}

.stat-card .stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.stat-card .stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    white-space: nowrap;
}

/* 次要统计行 */
.stats-row {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

@media (max-width: 768px) {
    .stats-grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-row {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* 互动中心多列统计 */
.stats-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.stats-grid-3 .stat-item {
    padding: 1.25rem;
}

.stats-grid-3 .stat-val {
    font-size: 1.5rem;
}

.stats-grid-3 .stat-label {
    font-size: 0.75rem;
}

/* 互动中心折叠区域 */
.collapsible-section {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-sidebar);
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.collapsible-header:hover {
    background: var(--copper-light);
}

.collapsible-header h4 {
    font-family: var(--font-serif);
    color: var(--copper);
    font-size: 0.9375rem;
    font-weight: 500;
}

.collapsible-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.collapsible-header.active .collapsible-toggle {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.collapsible-content.open {
    max-height: 50000px;
    overflow: visible;
}

.collapsible-body {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.page-stats-list {
    max-height: 300px;
    overflow-y: auto;
}

.page-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.page-stat-item:last-child {
    border-bottom: none;
}

.page-stat-title {
    color: var(--text-primary);
    flex: 1;
}

.page-stat-data {
    color: var(--text-muted);
    margin-left: 1rem;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        z-index: 2000;
        top: 0;
        height: 100vh;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle-mobile { display: block; }
    .menu-toggle { display: block; }
    .main-content { margin-left: 0; }
    .header-brand { width: auto; }
    .search-results-panel { left: 0; }
    .reading-progress { left: 0; }
    .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root {
        --header-height: 52px;
        --footer-height: 32px;
    }
    .unified-header {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
    .header-brand { min-width: 0; }
    .main-title { font-size: 0.95rem; letter-spacing: 0.05em; }
    .main-subtitle { display: none; }
    .header-nav { display: none; }
    .header-actions { gap: 0.35rem; }
    .search-box { width: 80px; }
    .search-box:focus-within { width: 160px; }
    .search-box input { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
    .header-icon-btn, .settings-toggle { padding: 0.35rem; }
    .header-icon-btn svg, .settings-toggle svg { width: 18px; height: 18px; }
    .user-badge { font-size: 0.65rem; padding: 0.2rem 0.5rem; }
    .menu-toggle {
        position: fixed;
        top: calc(var(--header-height) + 0.5rem);
        left: 0.5rem;
        font-size: 0.75rem;
        padding: 0.35rem 0.65rem;
        border-radius: 0 6px 6px 0;
        box-shadow: var(--shadow-sm);
        background: var(--bg-paper);
        z-index: 1001;
    }
    .book-page { padding: 1.5rem 1rem; }
    #content { font-size: 14px; line-height: 1.85; }
    .chapter-nav-btn { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .page-footer { height: var(--footer-height); }
    .page-footer p { font-size: 0.6rem; }
    .stats-grid-3 { grid-template-columns: 1fr; }
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-content {
    animation: fadeIn 0.5s ease;
}

/* ====== LOGIN MODAL ====== */
.login-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: var(--bg-paper, #fff); border-radius: 16px; padding: 2.5rem 2rem;
    width: min(400px, 90vw); box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-logo { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700; color: var(--copper, #b87333); margin-bottom: 0.25rem; }
.login-subtitle { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 1.5rem; }
.login-field { text-align: left; margin-bottom: 1rem; }
.login-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.05em; }
.login-field input {
    width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-main, #fafafa); color: var(--text-primary); font-size: 0.9rem;
    transition: border-color 0.2s; box-sizing: border-box;
}
.login-field input:focus { border-color: var(--copper, #b87333); outline: none; box-shadow: 0 0 0 3px rgba(184,115,51,0.12); }
.login-btn {
    width: 100%; padding: 0.7rem; border: none; border-radius: 10px; cursor: pointer;
    background: var(--copper, #b87333); color: #fff; font-size: 0.95rem; font-weight: 600;
    margin-top: 0.5rem; transition: transform 0.15s, box-shadow 0.15s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(184,115,51,0.35); }
.login-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.75rem; }

/* ====== USER BADGE ====== */
.user-badge {
    display: inline-flex; align-items: center; padding: 0.3rem 0.75rem;
    background: rgba(184,115,51,0.1); color: var(--copper, #b87333);
    border-radius: 20px; font-size: 0.75rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s;
}
.user-badge:hover { background: rgba(184,115,51,0.18); }

/* ====== COMMENT POPUP (text select) ====== */
.comment-popup {
    position: absolute; display: none; z-index: 1000;
    animation: fadeIn 0.15s ease;
}
.popup-comment-btn {
    padding: 0.35rem 0.75rem; border-radius: 20px; border: none; cursor: pointer;
    background: var(--copper, #b87333); color: #fff; font-size: 0.75rem; font-weight: 500;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2); white-space: nowrap;
    transition: transform 0.1s;
}
.popup-comment-btn:hover { transform: scale(1.05); }

/* ====== COMMENT COMPONENTS INSIDE RIGHT PANEL ====== */
.cs-quote { padding: 0.75rem 1.25rem; background: rgba(184,115,51,0.06); border-left: 3px solid var(--copper); font-size: 0.8rem; color: var(--text-secondary); font-style: italic; line-height: 1.5; }
.cs-input-area { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cs-input-area textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem;
    resize: none; font-size: 0.8rem; font-family: var(--font-sans); background: var(--bg-main);
    color: var(--text-primary); box-sizing: border-box;
}
.cs-input-area textarea:focus { border-color: var(--copper); outline: none; }
.cs-submit {
    margin-top: 0.5rem; padding: 0.4rem 1rem; border: none; border-radius: 20px;
    background: var(--copper); color: #fff; cursor: pointer; font-size: 0.75rem; font-weight: 500;
}
.cs-list { padding: 0.5rem 0.75rem; flex: 1; overflow-y: auto; }
.cs-empty { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 2rem 0; }
.cs-comment { margin-bottom: 0.75rem; }
.cs-comment-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.cs-user { font-weight: 600; font-size: 0.75rem; }
.cs-time { font-size: 0.65rem; color: var(--text-muted); }
.cs-quote-inline { font-size: 0.7rem; color: var(--copper); font-style: italic; margin-bottom: 0.2rem; padding: 0.2rem 0.4rem; background: rgba(184,115,51,0.05); border-radius: 4px; }
.cs-text { font-size: 0.8rem; line-height: 1.5; color: var(--text-primary); margin-bottom: 0.25rem; }

/* FAB removed — toggle is now in header */

/* ====== SHARED COMMENT COMPONENTS ====== */
.comment-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--copper), #d4956b); color: #fff;
    font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.comment-avatar.sm { width: 22px; height: 22px; font-size: 0.6rem; }
.comment-node { margin-bottom: 0.75rem; }
.comment-card { padding: 0.75rem; background: var(--bg-sidebar, #f8f6f3); border-radius: 10px; margin-bottom: 0.5rem; }
.comment-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.comment-user { font-weight: 600; font-size: 0.85rem; }
.comment-time { font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }
.comment-quote { font-size: 0.75rem; color: var(--copper); font-style: italic; padding: 0.3rem 0.6rem; background: rgba(184,115,51,0.05); border-radius: 6px; margin-bottom: 0.4rem; border-left: 2px solid var(--copper); }
.comment-body { font-size: 0.85rem; line-height: 1.6; color: var(--text-primary); }
.comment-actions { margin-top: 0.35rem; }
.reply-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 4px; }
.reply-btn:hover { color: var(--copper); background: rgba(184,115,51,0.08); }
.reply-btn.sm { font-size: 0.65rem; }
.reply-box { margin-top: 0.5rem; }
.reply-input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem; font-size: 0.8rem; resize: none; font-family: var(--font-sans); background: var(--bg-paper); color: var(--text-primary); box-sizing: border-box; }
.reply-input:focus { border-color: var(--copper); outline: none; }
.reply-submit { margin-top: 0.3rem; padding: 0.25rem 0.75rem; border: none; border-radius: 16px; background: var(--copper); color: #fff; cursor: pointer; font-size: 0.7rem; }
.delete-comment-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.7rem; padding: 0.1rem 0.3rem; border-radius: 4px; margin-left: auto; }
.delete-comment-btn:hover { color: #e74c3c; background: rgba(231,76,60,0.08); }

/* ====== iPhone / safe-area support ====== */
@supports (padding: env(safe-area-inset-top)) {
    .unified-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
    .page-footer {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--footer-height) + env(safe-area-inset-bottom));
    }
    .sidebar {
        top: calc(var(--header-height) + env(safe-area-inset-top));
        height: calc(100vh - var(--header-height) - var(--footer-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        padding-left: env(safe-area-inset-left);
    }
    .main-content {
        margin-top: calc(var(--header-height) + env(safe-area-inset-top));
        margin-bottom: calc(var(--footer-height) + env(safe-area-inset-bottom));
    }
    .right-panel {
        top: calc(var(--header-height) + env(safe-area-inset-top));
        bottom: calc(var(--footer-height) + env(safe-area-inset-bottom));
    }
    .menu-toggle {
        top: calc(var(--header-height) + env(safe-area-inset-top) + 0.5rem);
    }
}

/* ====== Small phone fine-tuning (iPhone 17 viewport ~402px) ====== */
@media (max-width: 430px) {
    .unified-header { padding: 0 0.5rem; gap: 0.35rem; }
    .main-title { font-size: 0.85rem; }
    .search-box { width: 60px; border-radius: 16px; padding: 0.3rem 0.5rem; }
    .search-box:focus-within { width: 140px; }
    .header-icon-btn, .settings-toggle { padding: 0.25rem; }
    .header-icon-btn svg, .settings-toggle svg { width: 16px; height: 16px; }
    .user-badge { font-size: 0.6rem; padding: 0.15rem 0.4rem; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .book-page { padding: 1.25rem 0.75rem; }
    #content { font-size: 13.5px; }
    #content h1 { font-size: 1.25rem; }
    #content h2 { font-size: 1rem; }
    #content p { text-indent: 1.5em; }
    .chapter-nav-top, .chapter-nav-bottom { flex-wrap: wrap; gap: 0.3rem; justify-content: center; }
    .chapter-info-inline { width: 100%; text-align: center; order: -1; font-size: 0.7rem; }
    .chapter-nav-btn { font-size: 0.7rem; padding: 0.25rem 0.5rem; }
    .welcome-screen { padding: 2rem 0.75rem; }
    .welcome-screen h2 { font-size: 1.25rem; }
    .stats-grid { gap: 0.75rem; }
    .stat-item { padding: 1rem; }
    .stat-val { font-size: 1.25rem; }
    .login-card { padding: 1.75rem 1.25rem; }
    .login-logo { font-size: 1.2rem; }
    .interaction-page h1 { font-size: 1.25rem !important; }
    .collapsible-header { padding: 0.75rem 1rem; }
    .collapsible-body { padding: 1rem; }
}
