/* CSS重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --success-color: #27ae60;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #e1e1e1;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;
    --border-color: #404040;
    --accent-color: #4a9eff;
    --accent-hover: #357abd;
    --success-color: #2ecc71;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ======================================*/

/* 清除浮动样式 */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* 专栏折叠显示控制 */
.column-item-hidden {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: var(--transition);
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* 防止水平滚动 */
}

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

.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    position: relative; /* 为搜索框绝对定位提供参考 */
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
    margin: 0;
}

/* 搜索框样式 - 完全复制CSDN设计 */
.search-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px; /* 搜索框和按钮之间的间距 */
}

.search-wrapper {
    display: flex;
    align-items: center;
    background-color: #f5f6f7;
    border-radius: 16px;
    border: 1px solid #e8e8ed;
    height: 40px;
    min-width: 400px; /* 增大搜索框宽度 */
    position: relative;
}

[data-theme="dark"] .search-wrapper {
    background-color: #2d2d2d;
    border-color: #404040;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: #999;
    font-size: 14px;
    pointer-events: none;
    z-index: 2;
}

[data-theme="dark"] .search-icon {
    color: #b3b3b3;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0 16px 0 32px; /* 去掉右边距，因为按钮在外面 */
    height: 100%;
    font-size: 14px;
    font-family: "PingFang SC", "SF Pro Display", "Microsoft YaHei", Roboto, Noto, Arial, sans-serif;
    color: #2c2c2c;
    outline: none;
}

.search-input::placeholder {
    color: #999;
}

[data-theme="dark"] .search-input {
    color: #e1e1e1;
}

[data-theme="dark"] .search-input::placeholder {
    color: #b3b3b3;
}

.search-btn {
    background-color: #ff6900;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.search-btn:hover {
    background-color: #e55a00;
}

.ai-search-btn {
    background-color: #8a2be2;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.ai-search-btn:hover {
    background-color: #7a25cc;
}

.search-buttons {
    display: flex;
    align-items: center;
    gap: 6px; /* 两个按钮之间的间距 */
}

/* 搜索高亮样式 */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

[data-theme="dark"] .search-highlight {
    background-color: #ffc107;
    color: #000;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.main-content {
    display: grid;
    grid-template-columns: 280px 280px 1fr 300px;
    grid-template-areas: "sidebar recommendations reader rightsidebar";
    flex: 1;
    min-height: 0;
    height: calc(100vh - 80px); /* 恢复高度限制，确保左侧sidebar滚动正常 */
    max-height: calc(100vh - 80px);
}

.sidebar {
    grid-area: sidebar;
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
    overflow-x: hidden; /* 防止水平滚动 */
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-tertiary);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    display: none;
}

.close-btn:hover {
    color: var(--text-primary);
}

.chapter-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* 防止水平滚动 */
    padding: 0.5rem 0;
}

.chapter-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
    box-sizing: border-box;
}

.chapter-item:hover {
    background-color: var(--bg-tertiary);
}

.chapter-item.active {
    background-color: var(--accent-color);
    color: white;
}

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.reader {
    grid-area: reader;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden; /* 确保内容不会溢出 */
}

.reader-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 2rem;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 2rem;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-screen h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.welcome-screen p {
    margin-bottom: 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.feature-list {
    list-style: none;
    text-align: left;
}

.feature-list li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.reading-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
}





.chapter-info {
    text-align: center;
    flex: 1;
    margin: 0 1rem;
}

.chapter-info h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.progress-info {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.text-content {
    flex: 1;
    line-height: 1.8;
    font-size: 16px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 2rem;
    overflow-y: auto; /* 添加垂直滚动 */
    max-height: calc(100vh - 120px); /* 调整高度限制，因为去掉了导航栏 */
}

.reading-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.font-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn {
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.control-btn:hover {
    background-color: var(--border-color);
}

.font-size-display {
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    margin-left: 2rem;
    overflow: hidden;
}

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

/* 响应式设计 */
@media (max-width: 1399px) {
    .main-content {
        grid-template-columns: 280px 280px 1fr !important;
        grid-template-areas: "sidebar recommendations reader" !important;
    }
    
    .right-sidebar {
        display: none !important;
    }
}

@media (max-width: 1199px) {
    .main-content {
        grid-template-columns: 280px 1fr !important;
        grid-template-areas: "sidebar reader" !important;
    }
    
    .recommendations-panel {
        display: none !important;
    }
    
    .right-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .controls {
        order: 2;
        width: 100%;
        justify-content: center;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        grid-template-areas: "reader";
        height: calc(100vh - 120px); /* 移动端header高度可能更大 */
        max-height: calc(100vh - 120px);
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        height: 100vh;
        z-index: 200;
        box-shadow: var(--shadow);
        overflow-y: auto; /* 移动端保留滚动，因为高度有限 */
        grid-area: none;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .recommendations-panel {
        display: none;
    }
    
    .right-sidebar {
        display: none;
    }
    
    .close-btn {
        display: block;
    }
    
    .reader-content {
        padding: 0 1rem;
    }
    
    
    .reading-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .progress-bar {
        margin-left: 0;
        width: 100%;
    }
    
    .text-content {
        max-height: calc(100vh - 180px); /* 移动端调整高度限制，去掉了导航栏 */
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.5rem;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .reader-content {
        padding: 0 0.5rem;
    }
    
    .text-content {
        font-size: 14px;
        max-height: calc(100vh - 200px); /* 移动端调整高度限制，去掉了导航栏 */
    }
    
    .welcome-screen {
        padding: 1rem;
    }
    
    .welcome-icon {
        font-size: 3rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 选中文本样式 */
::selection {
    background-color: var(--accent-color);
    color: white;
}

/* 过渡动画 */
.sidebar {
    transition: left 0.3s ease;
}

.text-content {
    transition: font-size 0.2s ease;
}

/* 推荐面板样式 */
.recommendations-panel {
    grid-area: recommendations;
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden; /* 防止水平滚动 */
    padding: 0;
}

/* CSDN栏目样式 - 完全复制原设计 */
.aside-box {
    background-color: rgb(255, 255, 255);
    margin: 0;
    border-radius: 6px;
    max-width: 100%;
    width: 100%;
    font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.75);
    line-height: 1.6;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .aside-box {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.aside-title {
    background-color: rgb(9, 9, 59);
    color: rgb(255, 255, 255);
    font-family: "PingFang SC", "Microsoft YaHei", SimHei, Arial, SimSun;
    font-size: 14px;
    margin: 0;
    padding: 12px 16px;
    border: 0;
    border-radius: 6px 6px 0 0;
    display: block;
    width: 100%;
    line-height: 1.4;
    box-sizing: border-box;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.aside-content {
    padding: 16px;
}

.aside-content a {
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 4px 0;
    display: block;
}

.aside-content a:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: rgb(59, 130, 246);
    transform: translateX(2px);
}

[data-theme="dark"] .aside-content a:hover {
    background-color: rgba(99, 179, 237, 0.2);
    color: rgb(99, 179, 237);
}

/* TA的精选样式 */
.his-selection-box {
    list-style: none;
    margin: 0;
    padding: 0;
}

.his-selection-item {
    margin: 0;
    padding: 0 0 16px 0;
    font-size: 14px;
    line-height: 22.75px;
}

.his-selection-item .title {
    display: block;
    color: rgb(85, 86, 102);
    font-size: 14px;
    line-height: 22px;
    margin: 0 0 2px 0;
    text-decoration: none;
    font-family: inherit;
    font-weight: 500;
}

[data-theme="dark"] .his-selection-item .title {
    color: var(--accent-color);
}

.his-selection-item .title:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .his-selection-item .title:hover {
    color: var(--accent-color);
}

.his-selection-item .tag {
    background-color: rgb(252, 85, 49);
    color: rgb(255, 255, 255);
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 6px;
    display: inline;
    line-height: 22px;
}

.his-selection-item .tag.active {
    background-color: rgb(255, 238, 234);
    color: rgb(252, 85, 49);
}

.his-selection-item .text {
    font-size: 14px;
    line-height: 22px;
}

.his-selection-item .read-count {
    color: rgb(153, 154, 170);
    font-size: 12px;
    font-weight: 400;
    margin: 0 8px 0 0;
    padding: 0;
}

[data-theme="dark"] .his-selection-item .read-count {
    color: var(--text-muted);
}

.his-selection-move {
    margin: 16px 0 0 0;
    padding: 0;
}

.his-selection-move .more {
    color: rgb(153, 154, 170);
    font-size: 12px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .his-selection-move .more {
    color: var(--text-muted);
}

.his-selection-move .more:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .his-selection-move .more:hover {
    color: var(--accent-color);
}

.his-selection-move .more img {
    width: 12px;
    height: 12px;
}

/* 大家在看样式 */
.hotArticle-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hotArticle-list li {
    margin: 8px 0 0 0;
    padding: 0;
    font-size: 14px;
    line-height: 22.75px;
}

.hotArticle-list li:first-child {
    margin: 0;
}

.hotArticle-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: rgb(85, 86, 102);
    font-size: 14px;
    line-height: 22.75px;
    text-decoration: none;
    padding: 4px 0;
}

[data-theme="dark"] .hotArticle-list li a {
    color: var(--text-secondary);
}

.hotArticle-list li a:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .hotArticle-list li a:hover {
    color: var(--accent-color);
}

.hotArticle-list .read {
    color: rgb(153, 154, 170);
    font-size: 12px;
    margin-left: 4px;
}

[data-theme="dark"] .hotArticle-list .read {
    color: var(--text-muted);
}

.hotArticle-list img {
    width: 12px;
    height: 12px;
    margin-left: 4px;
}

/* 右侧栏目样式 */
.right-sidebar {
    grid-area: rightsidebar;
    width: 300px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: visible; /* 让所有内容完全显示 */
    padding: 8px;
    gap: 8px;
    height: auto; /* 自动高度 */
    min-height: 0; /* 移除最小高度限制 */
    align-self: start; /* 从顶部开始排列，不受grid容器高度限制 */
}

/* 目录栏目样式 */
.groupfile {
    background-color: rgb(255, 255, 255);
    margin: 0 0 8px;
    border-radius: 2px;
    width: 300px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px;
    height: auto; /* 自动高度 */
    overflow: visible; /* 让内容完全显示 */
}

[data-theme="dark"] .groupfile {
    background-color: var(--bg-tertiary);
}

.groupfile-div {
    padding: 0;
}

.group_item {
    /* 移除高度限制，让内容完整显示 */
}

.pos-box {
    position: relative;
}

.scroll-box {
    /* 移除overflow: hidden，让内容完整显示 */
}

.toc-box {
    padding: 16px;
}

.toc-box ol {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 22px;
}

.toc-box li {
    margin: 0 0 8px 0;
    padding: 0;
}

.toc-box li.active > a {
    color: rgb(9, 9, 59);
    font-weight: 500;
}

[data-theme="dark"] .toc-box li.active > a {
    color: var(--accent-color);
}

.toc-box a {
    color: rgb(85, 86, 102);
    text-decoration: none;
    font-size: 14px;
    line-height: 22px;
    display: block;
}

[data-theme="dark"] .toc-box a {
    color: var(--text-secondary);
}

.toc-box a:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .toc-box a:hover {
    color: var(--accent-color);
}

.toc-box .sub-box ol {
    margin-left: 16px;
}

.flexible-btn-new {
    text-align: center;
    padding: 8px 16px;
    margin: 0;
    background-color: rgb(248, 248, 248);
    border-top: 1px solid rgb(238, 238, 238);
    cursor: pointer;
    font-size: 12px;
    color: rgb(153, 154, 170);
}

[data-theme="dark"] .flexible-btn-new {
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

.flexible-btn-new:hover {
    background-color: rgb(238, 238, 238);
}

[data-theme="dark"] .flexible-btn-new:hover {
    background-color: var(--border-color);
}

.flexible-btn-new .text {
    margin-right: 4px;
}

.flexible-btn-new img {
    width: 12px;
    height: 12px;
    vertical-align: middle;
}

.flexible-btn-new-close {
    display: none;
}

/* 上一篇栏目样式 */
.article-previous {
    background-color: rgb(255, 255, 255);
    margin: 0 0 8px;
    padding: 12px 16px;
    border-radius: 2px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px;
    font-size: 14px;
    line-height: 22px;
}

[data-theme="dark"] .article-previous {
    background-color: var(--bg-tertiary);
}

.article-previous dl {
    margin: 0;
    padding: 0;
}

.article-previous dt {
    color: rgb(153, 154, 170);
    font-size: 14px;
    margin: 0 0 4px 0;
    font-weight: normal;
}

[data-theme="dark"] .article-previous dt {
    color: var(--text-muted);
}

.article-previous dd {
    margin: 0;
    padding: 0;
}

.article-previous a {
    color: rgb(26, 26, 26);
    text-decoration: none;
    font-size: 14px;
    line-height: 22px;
    display: block;
}

[data-theme="dark"] .article-previous a {
    color: var(--text-primary);
}

.article-previous a:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .article-previous a:hover {
    color: var(--accent-color);
}

/* 分类专栏样式 */
.kind_person {
    background-color: rgb(255, 255, 255);
    margin: 0 0 8px;
    border-radius: 2px;
    width: 300px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px;
    height: auto; /* 自动高度 */
    overflow: visible; /* 让内容完全显示 */
}

[data-theme="dark"] .kind_person {
    background-color: var(--bg-tertiary);
}

.kindof_item {
    padding: 0;
}

#aside-content-column {
    /* 移除高度限制，让内容完整显示 */
}

#aside-content-column ul {
    list-style: none;
    margin: 0;
    padding: 16px;
}

#aside-content-column li {
    margin: 0 0 12px 0;
    padding: 0;
    display: flex;
    align-items: center; /* 确保整行居中对齐 */
    justify-content: space-between;
    min-height: 44px; /* 给足够高度确保对齐 */
}

.special-column-name {
    display: flex;
    flex-direction: row; /* 确保水平排列 */
    align-items: center; /* 图标、文字垂直居中 */
    color: rgb(85, 86, 102);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4; /* 调整行高避免偏移 */
    flex: 1;
    gap: 12px; /* 图标和文字之间的间距 */
    height: 44px; /* 固定高度确保对齐 */
}

[data-theme="dark"] .special-column-name {
    color: var(--text-secondary);
}

.special-column-name:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .special-column-name:hover {
    color: var(--accent-color);
}

.special-column-bar {
    display: none; /* 隐藏竖线 */
}

.special-column-bar-second {
    background-color: rgb(255, 165, 0);
}

.special-column-name img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0; /* 防止图片被压缩 */
    object-fit: cover; /* 确保图片显示正确 */
    display: block;
     /* 图标自身居中 */
}

.right-sidebar .special-column-name {
    display: flex !important; /* 强制使用flex布局 */
    flex-direction: row !important; /* 强制水平排列 */
    align-items: center !important; /* 强制垂直居中 */
    overflow: visible !important; /* 覆盖右侧边栏的hidden设置 */
    white-space: normal !important; /* 确保文字正常换行 */
    gap: 12px !important; /* 强制设置间距 */
}


.special-column-name span {
    flex: 1;
    line-height: 1.4;
    color: inherit;
    margin: 0;
    padding: 0;
}

[data-theme="dark"] .special-column-name span {
    color: var(--text-secondary);
}

.special-column-num {
    color: rgb(153, 154, 170);
    font-size: 12px;
    flex-shrink: 0;
    line-height: 1.4;
}

.text-center {
    text-align: center;
    padding: 8px 16px;
    margin: 0;
    background-color: rgb(248, 248, 248);
    border-top: 1px solid rgb(238, 238, 238);
}

[data-theme="dark"] .text-center {
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.text-center .flexible-btn-new {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    color: rgb(153, 154, 170);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

[data-theme="dark"] .text-center .flexible-btn-new {
    color: var(--text-muted);
}

.text-center .flexible-btn-new:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .text-center .flexible-btn-new:hover {
    color: var(--accent-color);
}

.text-center .flexible-btn-new-close {
    display: none;
}

/* 相关专栏样式 */
.related-columns {
    background-color: rgb(255, 255, 255);
    margin: 0 0 8px;
    border-radius: 2px;
    width: 300px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px;
    height: auto; /* 自动高度 */
    overflow: visible; /* 让内容完全显示 */
}

[data-theme="dark"] .related-columns {
    background-color: var(--bg-tertiary);
}

.related-content {
    padding: 16px;
}

.related-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.related-list li {
    margin: 0 0 12px 0;
    padding: 0;
    display: flex;
    align-items: center; /* 确保整行居中对齐 */
    justify-content: space-between;
    min-height: 40px; /* 给足够高度确保对齐 */
}

.related-column-name {
    display: flex;
    flex-direction: row; /* 确保水平排列 */
    align-items: center; /* 图标、文字垂直居中 */
    color: rgb(85, 86, 102);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4; /* 调整行高避免偏移 */
    flex: 1;
    gap: 12px; /* 图标和文字之间的间距 */
    height: 44px; /* 统一高度确保对齐 */
    overflow: visible !important; /* 覆盖右侧边栏的hidden设置 */
}

.right-sidebar .related-column-name {
    overflow: visible !important; /* 覆盖右侧边栏的hidden设置 */
    white-space: normal !important; /* 确保文字正常换行 */
}

[data-theme="dark"] .related-column-name {
    color: var(--text-secondary);
}

.related-column-name:hover {
    color: rgb(9, 9, 59);
}

[data-theme="dark"] .related-column-name:hover {
    color: var(--accent-color);
}

.related-column-bar {
    display: none; /* 隐藏竖线 */
}

.related-column-bar-orange {
    background-color: rgb(255, 165, 0);
}

.related-column-name img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0; /* 防止图片被压缩 */
    object-fit: cover; /* 确保图片显示正确 */
    display: block;
    align-self: center; /* 图标自身居中 */
}

.related-column-name span {
    flex: 1;
    line-height: 1.4;
    display: flex;
    align-items: center; /* 文字内容垂直居中 */
    height: 32px; /* 与图标同高 */
}

.related-column-num {
    color: rgb(153, 154, 170);
    font-size: 12px;
    margin-left: 8px;
    display: flex;
    align-items: center; /* 篇数也要居中 */
    height: 32px; /* 与图标同高 */
}

[data-theme="dark"] .related-column-num {
    color: var(--text-muted);
}

/* 设置弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-modal:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.setting-group {
    margin-bottom: 1.5rem;
}

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

.range-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-input {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.range-input::-moz-range-track {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    border: none;
}

.range-container span {
    min-width: 50px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.color-options {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.color-btn.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.color-btn.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-color);
    font-weight: bold;
    font-size: 16px;
}

.setting-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* 可调节边距样式 */
.adjustable-margins {
    transition: padding 0.3s ease;
}

/* 侧栏文本控制 - 防止水平溢出（优雅版本） */
.sidebar *, .right-sidebar * {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.sidebar a, .right-sidebar a {
    white-space: normal !important;
    overflow: hidden !important;
    word-wrap: break-word !important;
    line-height: 1.5 !important;
}

.sidebar ul, .right-sidebar ul,
.sidebar ol, .right-sidebar ol,
.sidebar li, .right-sidebar li {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
}


/* 文件选择按钮修复 - 确保可点击性 */
.header .btn {
    position: relative;
    z-index: 101;
    pointer-events: auto;
    user-select: none;
}

.header .controls {
    position: relative;
    z-index: 101;
}

/* 确保隐藏的文件输入框不影响布局 */
#fileInput {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
}

/* 按钮状态确保 */
.btn:not(:disabled) {
    pointer-events: auto;
}

.btn:active {
    transform: translateY(0px);
}

/* 全屏布局优化 */
html, body {
    height: 100% !important;
    overflow: hidden !important; /* 禁用页面滚动 */
    margin: 0 !important;
    padding: 0 !important;
}

.app-container {
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh !important;
}

.main-content {
    height: calc(100vh - 80px) !important;
    max-height: calc(100vh - 80px) !important;
}

/* 右边栏全屏优化 */
.right-sidebar {
    height: 100% !important;
    padding: 0 !important;
    overflow: hidden !important;
    gap: 0 !important;
}

/* 禁用右边栏滚动，但保持点击功能 */
.right-sidebar, .right-sidebar * {
    overflow: hidden !important;
}

/* 确保右边栏内容适应高度 */
.right-sidebar > * {
    flex-shrink: 0;
}

    .reading-controls,
    .modal {
        display: none;
    }
    
    .text-content {
        border: none;
        background: none;
        padding: 0;
        font-size: 12pt;
        line-height: 1.6;
    }
}


/* 文件选择按钮修复 - 确保可点击性 */
.header .btn {
    position: relative;
    z-index: 101;
    pointer-events: auto;
    user-select: none;
}

.header .controls {
    position: relative;
    z-index: 101;
}

/* 确保隐藏的文件输入框不影响布局 */
#fileInput {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
}

/* 按钮状态确保 */
.btn:not(:disabled) {
    pointer-events: auto;
}

.btn:active {
    transform: translateY(0px);
}
/* 全屏化样式调整 */

/* 1. 设置html和body为100%高度，禁用页面滚动 */
html, body {
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important; /* 禁用页面级别滚动 */
}

/* 2. 应用容器填满整个视口 */
.app-container {
    height: 100vh !important;
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 3. 主内容区域调整为全屏布局 */
.main-content {
    display: grid !important;
    grid-template-columns: 280px 280px 1fr 300px !important;
    grid-template-areas: "sidebar recommendations reader rightsidebar" !important;
    flex: 1 !important;
    height: calc(100vh - 80px) !important; /* 减去header高度 */
    max-height: calc(100vh - 80px) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 4. 右边栏全屏高度设置，禁用滚动 */
.right-sidebar {
    grid-area: rightsidebar !important;
    width: 300px !important;
    background-color: var(--bg-secondary) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important; /* 完全禁用滚动 */
    padding: 0 !important; /* 移除内边距，上下边缘顶到屏幕 */
    gap: 0 !important;
    height: 100% !important; /* 填满整个可用高度 */
    min-height: 100% !important;
    max-height: 100% !important;
    align-self: stretch !important; /* 拉伸到容器全高 */
    position: relative !important; /* 确保定位正确 */
}

/* 5. 禁用右边栏鼠标滚动事件 */
.right-sidebar, .right-sidebar * {
    overflow: hidden !important;
    pointer-events: auto !important; /* 保持点击功能 */
    -webkit-overflow-scrolling: none !important;
}

/* 6. 右边栏内容区域调整 */
.right-sidebar .aside-box {
    margin: 0 !important;
    padding: 8px !important;
    flex-shrink: 0 !important; /* 防止压缩 */
    overflow: hidden !important;
}

/* 7. 确保其他栏目也填满屏幕高度 */
.sidebar, .recommendations-panel {
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: auto !important; /* 保持这两个栏目的滚动功能 */
}

/* 8. 阅读区域调整 */
.reader {
    grid-area: reader !important;
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    overflow: hidden !important;
    height: 100% !important;
    max-height: 100% !important;
}

/* 9. 移除相关专栏的所有CSS样式（清理残留样式） */
.related-columns,
.related-content,
.related-list,
.related-column-name,
.related-column-bar,
.related-column-bar-orange,
.related-column-num {
    display: none !important;
}

/* 10. 确保header固定高度 */
.header {
    height: 80px !important;
    min-height: 80px !important;
    max-height: 80px !important;
    flex-shrink: 0 !important;
}

/* 11. 响应式设计更新 - 保持原有断点但调整布局 */
@media (max-width: 1399px) {
    .main-content {
        grid-template-columns: 280px 280px 1fr !important;
        grid-template-areas: "sidebar recommendations reader" !important;
    }
    
    .right-sidebar {
        display: none !important;
    }
}

@media (max-width: 1199px) {
    .main-content {
        grid-template-columns: 280px 1fr !important;
        grid-template-areas: "sidebar reader" !important;
    }
    
    .recommendations-panel,
    .right-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr !important;
        grid-template-areas: "reader" !important;
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
    }
    
    .sidebar,
    .recommendations-panel,
    .right-sidebar {
        display: none !important;
    }
    
    .sidebar.open {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        z-index: 200 !important;
    }
    
    /* 搜索框响应式 - 平板尺寸调整 */
    .search-container {
        gap: 6px; /* 减小间距 */
    }
    
    .search-wrapper {
        min-width: 300px; /* 平板尺寸下保持合适宽度 */
    }
    
    .search-buttons {
        gap: 4px; /* 减小按钮间距 */
    }
    
    .search-btn, .ai-search-btn {
        padding: 6px 12px; /* 稍微减小按钮内边距 */
        font-size: 13px;
    }
}

/* 移动端响应式 - 更小的屏幕 */
@media (max-width: 640px) {
    .header {
        padding: 0.75rem 1rem;
        flex-direction: column; /* 垂直布局 */
        align-items: stretch;
        gap: 8px;
        position: relative; /* 确保header是相对定位容器 */
    }
    
    .controls {
        order: 2; /* 控制按钮在第二行 */
        width: 100%;
        justify-content: center;
    }
    
    .search-container {
        position: static !important; /* 使用static定位完全脱离绝对定位 */
        transform: none !important;
        flex-direction: column; /* 垂直布局 */
        gap: 8px;
        width: 100% !important;
        order: 3; /* 让搜索框在第三行显示 */
        margin: 8px 0 !important;
        display: flex !important; /* 强制显示 */
        left: auto !important; /* 重置left值 */
        top: auto !important; /* 重置top值 */
        right: auto !important; /* 重置right值 */
        bottom: auto !important; /* 重置bottom值 */
    }
    
    .search-wrapper {
        min-width: 100%; /* 占满宽度 */
        width: 100%;
    }
    
    .search-buttons {
        display: flex;
        width: 100%;
        gap: 4px;
    }
    
    .search-btn, .ai-search-btn {
        flex: 1; /* 按钮平分宽度 */
        justify-content: center;
        height: 36px; /* 稍微调小移动端按钮高度 */
        font-size: 12px;
    }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem;
    }
    
    .controls {
        gap: 0.25rem;
    }
    
    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* ========================================
   重构后的章节导航样式 - 固定在正文底部
   ======================================== */

/* 章节文本容器 - 包含实际章节内容 */
.chapter-text {
    flex: 1;
    line-height: 1.8;
    font-size: inherit;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-bottom: 2rem;
    min-height: 200px; /* 确保有足够空间显示内容 */
}

/* 更新后的text-content样式 - 现在是容器，包含章节文本和导航 */
.text-content {
    /* 保持原有的基本样式 */
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.8;
    font-size: 16px;
    color: var(--text-primary);
    overflow-y: auto;
    max-height: calc(100vh - 120px);
    padding: 1rem;
    position: relative;
}


