/* 阅读页样式 — 三栏响应式布局 */

/* ===== Layout ===== */
.reader-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* ===== Sidebar (left, 260px) ===== */
.reader-sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    padding: 20px 0;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.sidebar-nav {
    padding: 0 12px;
}

.sidebar-group {
    margin-bottom: 8px;
}

.sidebar-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 8px 12px 4px;
    cursor: pointer;
    user-select: none;
    letter-spacing: 0.02em;
}

.sidebar-chevron {
    transition: transform 0.2s;
}

.sidebar-group--collapsed .sidebar-chevron {
    transform: rotate(-90deg);
}

.sidebar-group--collapsed .sidebar-group-children {
    display: none;
}

.sidebar-link {
    display: block;
    padding: 6px 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-radius: 4px;
    line-height: 1.4;
}

.sidebar-link:hover {
    background: var(--bg-secondary);
    text-decoration: none;
}

.sidebar-link--active {
    color: var(--sidebar-active);
    font-weight: 600;
    background: var(--bg-secondary);
}

/* Hamburger button — hidden on desktop */
.sidebar-hamburger {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

/* ===== Content (center, flex) ===== */
.reader-content {
    flex: 1;
    min-width: 0;
    padding: 32px 48px;
    max-width: 860px;
}


/* Chapter content typography */
.chapter-content h1 { font-size: 1.8rem; margin: 24px 0 16px; }
.chapter-content h2 { font-size: 1.4rem; margin: 20px 0 12px; }
.chapter-content h3 { font-size: 1.2rem; margin: 16px 0 8px; }
.chapter-content p { margin-bottom: 12px; }
.chapter-content pre {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}
.chapter-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}
.chapter-content th,
.chapter-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.chapter-content th {
    background: var(--bg-secondary);
}
.chapter-content blockquote {
    border-left: 4px solid var(--border-color);
    padding: 8px 16px;
    margin: 0 0 16px;
    color: var(--text-secondary);
}
.chapter-content .tip {
    background: #e6f4ea;
    border-left: 4px solid #34a853;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}
.chapter-content .warning {
    background: #fef7e0;
    border-left: 4px solid #fbbc04;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

/* ===== Chapter actions (PDF export etc.) ===== */
.chapter-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.chapter-action-btn {
    display: inline-block;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--link-color);
    text-decoration: none;
    transition: background 0.2s;
}

.chapter-action-btn:hover {
    background: var(--border-color);
    text-decoration: none;
}

/* ===== Prev / Next navigation ===== */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.chapter-nav-link {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-nav-link:hover {
    background: var(--bg-secondary);
    text-decoration: none;
}

/* ===== TOC (right, 220px) ===== */
.reader-toc {
    width: 220px;
    flex-shrink: 0;
    padding: 20px 12px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.toc-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.toc-list {
    list-style: none;
}

.toc-item a {
    display: block;
    padding: 3px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    border-left: 2px solid transparent;
    padding-left: 8px;
}

.toc-item a:hover {
    color: var(--link-color);
    text-decoration: none;
}

.toc-item--h3 { padding-left: 12px; }
.toc-item--h4 { padding-left: 24px; }

.toc-item--active a {
    color: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

/* ===== Responsive: mobile < 1024px ===== */
@media (max-width: 1023px) {
    .reader-sidebar {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 280px;
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }

    .reader-sidebar.sidebar--open {
        display: block;
    }

    .sidebar-hamburger {
        display: flex;
    }

    .reader-toc {
        display: none;
    }

    .reader-content {
        padding: 24px 16px;
    }
}
