:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f2f5;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #6a6a6a;
    --border-color: #e0e0e0;
    --accent-color: #f7931a;
    --accent-hover: #e88308;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8b8;
    --text-tertiary: #888888;
    --border-color: #333333;
    --shadow-light: rgba(255, 255, 255, 0.03);
    --shadow-medium: rgba(255, 255, 255, 0.05);
    --shadow-heavy: rgba(255, 255, 255, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

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

.sidebar {
    width: 320px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

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

.sidebar-header {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.book-title-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: opacity 0.2s ease;
}

.book-title-link:hover {
    opacity: 0.7;
}

.book-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.book-subtitle {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.toc {
    padding: 0 1.5rem;
}

.toc-section {
    margin-bottom: 2rem;
}

.toc-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
}

.toc-section .divider {
    color: var(--text-tertiary);
    font-weight: 400;
    margin: 0 0.5rem;
}

.toc-section ul {
    list-style: none;
}

.toc-section li {
    margin-bottom: 0.5rem;
}

.toc-section a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.toc-section a:hover:not(.disabled) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.toc-section a.active {
    background-color: var(--accent-color);
    color: #ffffff;
    font-weight: 500;
}

.toc-section a.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.theme-toggle {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s ease;
    z-index: 101;
}

.theme-toggle:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    transform: rotate(180deg);
}

.theme-icon {
    display: block;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    z-index: 102;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: var(--bg-tertiary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 99;
}

.content {
    flex: 1;
    margin-left: 320px;
    padding: 4rem 6rem;
    max-width: 900px;
}

.intro-section {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.main-title {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.main-subtitle {
    font-size: 1.8rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 3rem;
}

.intro-text {
    margin-top: 4rem;
}

.lead {
    font-size: 1.5rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-style: italic;
}

.intro-content p {
    font-size: 1.15rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.start-reading {
    margin-top: 3rem;
}

.btn-primary {
    display: inline-block;
    padding: 1rem 2.5rem;
    background-color: var(--accent-color);
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--shadow-medium);
}

.overview-section {
    margin-top: 8rem;
    padding: 4rem 0;
}

.overview-section h2 {
    font-size: 2.5rem;
    margin-bottom: 3rem;
    font-weight: 700;
}

.overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.overview-card {
    padding: 2rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.overview-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-medium);
}

.overview-card h3 {
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overview-card h4 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.overview-card p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.chapter-content {
    padding-top: 2rem;
}

.chapter {
    max-width: 680px;
}

.chapter-header {
    margin-bottom: 3rem;
}

.chapter-label {
    font-size: 0.9rem;
    color: var(--accent-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.chapter-title {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.reading-progress {
    height: 3px;
    background-color: var(--accent-color);
    position: fixed;
    top: 0;
    left: 320px;
    right: 0;
    transform-origin: left;
    transform: scaleX(0);
    z-index: 99;
    transition: transform 0.1s ease;
}

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

.chapter-section {
    margin-bottom: 4rem;
}

.section-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 2rem;
    margin-top: 3rem;
    color: var(--text-primary);
}

.chapter-body p {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.emphasis {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    font-weight: 500;
}

.standout {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1.9;
    margin: 2rem 0;
}

.standout-large {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.4rem;
    line-height: 1.8;
    margin: 2.5rem 0;
    letter-spacing: -0.01em;
}

.insight-list {
    list-style: none;
    margin: 2rem 0;
    padding-left: 0;
}

.insight-list li {
    padding-left: 2rem;
    position: relative;
    margin-bottom: 0.75rem;
}

.insight-list li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: 600;
}

.reflection-box {
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--accent-color);
    padding: 2rem;
    margin: 2.5rem 0;
    border-radius: 0 8px 8px 0;
}

.reflection-box p {
    margin-bottom: 1rem;
}

.reflection-box p:last-child {
    margin-bottom: 0;
}

.insight-box {
    background-color: var(--bg-tertiary);
    padding: 2rem;
    margin: 2.5rem 0;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.insight-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

.contrast-box {
    padding: 2rem;
    margin: 2.5rem 0;
    border-top: 2px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

.contrast-box p {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.contrast-box p:last-child {
    margin-bottom: 0;
}

.closing-thought {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 3rem 0;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-style: italic;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: 2px solid var(--border-color);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover:not(.disabled) {
    background-color: var(--bg-tertiary);
    transform: translateX(4px);
}

.nav-link.prev:hover:not(.disabled) {
    transform: translateX(-4px);
}

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

.nav-arrow {
    font-size: 1.2rem;
}

@media (max-width: 1200px) {
    .content {
        padding: 4rem;
    }
    
    .main-title {
        font-size: 3rem;
    }
}

@media (max-width: 968px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar {
        width: min(320px, 86vw);
        transform: translateX(-100%);
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 20px 40px var(--shadow-heavy);
    }

    .sidebar-overlay {
        display: block;
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }
    
    .sidebar-toggle {
        display: flex;
        top: calc(1.25rem + env(safe-area-inset-top));
        left: calc(1.25rem + env(safe-area-inset-left));
    }
    
    .content {
        margin-left: 0;
        padding: 3rem 2rem;
        padding-left: calc(2rem + env(safe-area-inset-left));
        padding-right: calc(2rem + env(safe-area-inset-right));
    }
    
    .reading-progress {
        left: 0;
    }
    
    .theme-toggle {
        left: auto;
        right: calc(1.25rem + env(safe-area-inset-right));
        bottom: calc(2rem + env(safe-area-inset-bottom));
    }
    
    .main-title {
        font-size: 2.5rem;
    }
    
    .main-subtitle {
        font-size: 1.4rem;
    }
    
    .chapter-title {
        font-size: 2rem;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 2rem 1.25rem;
        padding-left: calc(1.25rem + env(safe-area-inset-left));
        padding-right: calc(1.25rem + env(safe-area-inset-right));
    }

    .toc-section a {
        padding: 0.65rem 1rem;
    }

    .chapter-body {
        font-size: 1.05rem;
        line-height: 1.95;
    }

    .emphasis {
        font-size: 1.15rem;
    }

    .standout {
        font-size: 1.1rem;
    }

    .standout-large {
        font-size: 1.25rem;
    }

    .reflection-box,
    .insight-box,
    .contrast-box,
    .overview-card {
        padding: 1.5rem;
    }
    
    .main-title {
        font-size: 2rem;
    }
    
    .main-subtitle {
        font-size: 1.2rem;
    }
    
    .chapter-title {
        font-size: 1.6rem;
    }
    
    .chapter-nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-link {
        width: 100%;
        justify-content: center;
    }
}

@media print {
    .sidebar,
    .sidebar-toggle,
    .theme-toggle,
    .chapter-nav,
    .reading-progress {
        display: none;
    }
    
    .content {
        margin-left: 0;
        max-width: 100%;
    }
}
