/* 小说阅读器 - 简洁阅读风格 */

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

:root {
    --bg: #f8f5f0;
    --surface: #fffef9;
    --text: #2c2416;
    --text-muted: #8c8273;
    --accent: #8b4513;
    --accent-hover: #a0522d;
    --border: #e6ddd0;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 8px;
    --max-w: 800px;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Serif SC", serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.back-link {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95rem;
}

.back-link:hover {
    text-decoration: underline;
}

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* 首页 */
.project-grid {
    display: grid;
    gap: 16px;
}

.project-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.project-card h2 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.project-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    background: #f0ebe0;
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

.badge-platform {
    background: #e8f0e0;
    color: #4a7c2e;
}

.badge-resolved {
    background: #e0f0e8;
    color: #2e7c4a;
}

.target-words {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* 小说信息 */
.novel-info {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

/* ARC 区域 */
.arcs-section {
    margin-bottom: 30px;
}

.arcs-section h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.arc-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.arc-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    flex: 1;
    min-width: 200px;
}

.arc-item strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
}

.arc-range {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.arc-theme {
    display: block;
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: 4px;
}

/* 章节列表 */
.chapter-list h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.1s;
}

.chapter-item:hover {
    background: var(--surface);
}

.chapter-num {
    font-weight: 600;
    color: var(--accent);
    min-width: 80px;
    font-size: 0.95rem;
}

.chapter-title {
    flex: 1;
}

.chapter-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 章节内容 */
.chapter-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
}

.chapter-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.chapter-header .chapter-title {
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.chapter-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.chapter-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.15s;
    text-decoration: none;
}

.btn-copy {
    background: var(--accent);
    color: #fff;
}

.btn-copy:hover {
    background: var(--accent-hover);
}

.btn-copy-plain {
    background: #4a7c2e;
    color: #fff;
}

.btn-copy-plain:hover {
    background: #5a9c3e;
}

.chapter-body {
    font-size: 1.15rem;
    line-height: 2;
    text-align: justify;
}

.chapter-body p {
    text-indent: 2em;
    margin-bottom: 12px;
}

/* Toast */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

.hidden {
    display: none;
}

/* 伏笔 */
.foreshadows-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.foreshadows-section h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.foreshadow-item {
    padding: 8px 0;
    font-size: 0.9rem;
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}

/* 导航 */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 10px;
}

.nav-btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
    transition: background 0.15s;
}

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

.nav-btn.disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-btn.disabled:hover {
    background: var(--surface);
}

.nav-prev { flex: 1; text-align: left; }
.nav-next { flex: 1; text-align: right; }
.nav-toc  { min-width: 80px; }

/* 状态标签 */
.status {
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 1px 8px;
    border-radius: 10px;
}

.status-published {
    background: #e0f0e8;
    color: #2e7c4a;
}

.status-draft {
    background: #f0ebe0;
    color: #8b6914;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .hint {
    font-size: 0.85rem;
    margin-top: 8px;
}

/* ===== 导航标签栏 ===== */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    display: inline-block;
    padding: 10px 18px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.tab-item:hover {
    color: var(--accent);
}

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ===== 统计概览 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== 通用内容卡片 ===== */
.content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* ===== 作品简介 ===== */
.synopsis-section h2 {
    margin-bottom: 20px;
    color: var(--accent);
}
.synopsis-text {
    font-size: 1.05rem;
    line-height: 2;
    color: #3d3226;
}
.synopsis-text p {
    text-indent: 2em;
    margin-bottom: 14px;
}

/* ===== MD 渲染内容 ===== */
.md-content {
    line-height: 1.9;
    font-size: 1rem;
}

.md-content .md-h1,
.md-content .md-h2,
.md-content .md-h3,
.md-content .md-h4 {
    margin-top: 28px;
    margin-bottom: 12px;
}

.md-content .md-h1 { font-size: 1.4rem; color: var(--accent); }
.md-content .md-h2 { font-size: 1.25rem; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-content .md-h3 { font-size: 1.1rem; color: #5a3e1b; }
.md-content .md-h4 { font-size: 1rem; color: #6b5040; }

.md-content .content-divider {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 24px 0;
}

.md-content .md-ul {
    padding-left: 24px;
    margin: 8px 0;
}

.md-content .md-ul li {
    margin-bottom: 4px;
}

.md-content p {
    margin-bottom: 10px;
    text-indent: 0;
}

/* ===== 可折叠区块 ===== */
.collapsible {
    margin-bottom: 16px;
}

.collapsible-summary {
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent);
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    list-style: none;
    user-select: none;
}

.collapsible-summary::-webkit-details-marker {
    display: none;
}

.collapsible-summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.2s;
}

details[open] > .collapsible-summary::before {
    transform: rotate(90deg);
}

/* ===== 角色卡片 ===== */
.character-card {
    margin-bottom: 30px;
}

.character-name {
    font-size: 1.3rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.character-meta {
    margin-bottom: 16px;
}

.character-raw {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.9;
    background: none;
    padding: 0;
    margin: 0;
    border: none;
    color: var(--text);
}

/* ===== 伏笔卡片 ===== */
.foreshadow-card {
    margin-bottom: 12px;
    padding: 16px 20px;
}

.foreshadow-header {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.foreshadow-content {
    font-size: 0.95rem;
    line-height: 1.8;
}

/* ===== 时间线 ===== */
.timeline-list {
    position: relative;
    padding-left: 16px;
}

.timeline-list::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-chapter-marker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
    position: relative;
}

.chapter-dot {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    left: -21px;
    z-index: 1;
}

.chapter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    margin-left: 8px;
}

.timeline-event {
    margin-bottom: 8px;
    margin-left: 8px;
    padding: 12px 16px;
}

.timeline-event p {
    margin: 0;
    font-size: 0.95rem;
}

/* ===== 分区标题 ===== */
.section-title {
    font-size: 1.1rem;
    color: var(--accent);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* 响应式 */
@media (max-width: 600px) {
    .chapter-content {
        padding: 20px;
    }

    .chapter-body p {
        text-indent: 1.5em;
    }

    .chapter-actions {
        flex-direction: column;
    }

    .arc-item {
        min-width: 100%;
    }
}
