* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.8;
    color: #333;
    background: #f5f5f5;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边导航 */
.sidebar {
    width: 280px;
    background: #2c3e50;
    color: #ecf0f1;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    z-index: 1000;
}

.nav-header {
    padding: 20px;
    background: #1a252f;
    border-bottom: 2px solid #34495e;
}

.nav-header h3 {
    font-size: 18px;
    margin-bottom: 5px;
    color: #3498db;
}

.subtitle {
    font-size: 12px;
    color: #95a5a6;
}

.nav-list {
    list-style: none;
    padding: 10px 0;
}

.nav-section {
    margin: 2px 0;
}

.nav-link {
    display: block;
    padding: 10px 15px;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: #34495e;
    color: #fff;
    border-left-color: #3498db;
}

.nav-link.active {
    background: #34495e;
    color: #fff;
    border-left-color: #3498db;
}

.page-num {
    display: inline-block;
    width: 40px;
    font-weight: bold;
    color: #3498db;
}

.chapter-range {
    display: block;
    font-size: 12px;
    color: #95a5a6;
    margin-top: 3px;
}

.short-title {
    display: block;
    font-size: 13px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 主内容区 */
.content {
    margin-left: 280px;
    flex: 1;
    padding: 40px 60px;
    background: #fff;
    min-height: 100vh;
}

/* 进度条 */
.progress-bar {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    height: 4px;
    background: #ecf0f1;
    z-index: 999;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    transition: width 0.3s ease;
}

/* 章节样式 */
article {
    max-width: 900px;
    margin: 0 auto;
    padding-top: 20px;
}

.chapter-section {
    margin-bottom: 60px;
    padding-bottom: 40px;
    border-bottom: 1px solid #ecf0f1;
}

.chapter-section:last-child {
    border-bottom: none;
}

.chapter-title {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-left: 15px;
    border-left: 4px solid #3498db;
    line-height: 1.4;
}

.chapter-content p {
    margin-bottom: 15px;
    text-align: justify;
    text-indent: 2em;
    font-size: 16px;
    line-height: 2;
}

/* 页码导航 */
.page-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 2px solid #ecf0f1;
}

.prev-btn, .next-btn {
    padding: 12px 25px;
    background: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-weight: bold;
}

.prev-btn:hover, .next-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.prev-btn.disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    pointer-events: none;
}

.page-info {
    color: #7f8c8d;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .content {
        margin-left: 200px;
        padding: 30px 20px;
    }
    
    .progress-bar {
        left: 200px;
    }
    
    .chapter-title {
        font-size: 20px;
    }
    
    .chapter-content p {
        font-size: 15px;
    }
}

@media (max-width: 600px) {
    .sidebar {
        display: none;
    }
    
    .content {
        margin-left: 0;
        padding: 20px 15px;
    }
    
    .progress-bar {
        left: 0;
    }
}

/* ========== 搜索功能样式 ========== */
/* 搜索框放在内容区顶部，紧贴进度条下方 */
.search-container {
    position: relative;
    padding: 14px 0 18px 0;
    background: #fff;
    border-bottom: 2px solid #e8e8e8;
    margin-bottom: 24px;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 12px 45px 12px 20px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

#search-input:focus {
    border-color: #3498db;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

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

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
    transition: color 0.2s;
}

.search-icon:hover {
    color: #3498db;
}

#search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
}

.search-results-header {
    padding: 12px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
    color: #666;
    border-radius: 12px 12px 0 0;
}

.search-results-header strong {
    color: #3498db;
}

.search-results-list {
    padding: 10px 0;
}

.search-result-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f9f9f9;
}

.result-header {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.result-page {
    background: #3498db;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

.result-number {
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    line-height: 1.4;
}

.result-summary {
    font-size: 13px;
    color: #7f8c8d;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.search-no-results p {
    margin-bottom: 8px;
}

.search-tip {
    font-size: 13px;
    color: #bbb;
}

mark {
    background: #ffeaa7;
    color: #d35400;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

/* 移动端搜索优化 */
@media (max-width: 768px) {
    .search-container {
        padding: 10px 15px;
    }
    
    #search-results {
        width: calc(100% - 30px);
        max-height: 400px;
    }
}

/* AI 插图卡片 */
.ai-illustration-card {
    margin: 30px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    background: #fff;
}

.ai-illustration-card img {
    width: 100%;
    height: auto;
    display: block;
}

.illustration-caption {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.illustration-caption h4 {
    font-size: 16px;
    margin-bottom: 5px;
}

.illustration-caption p {
    font-size: 13px;
    opacity: 0.9;
}
