:root {
    --primary-color: #007AFF;
    --bg-color: #FFFFFF;
    --text-color: #333333;
    --secondary-bg: #F2F2F7;
    --border-color: #E5E5EA;
    --header-height: 60px;
    --footer-height: 70px;
    --content-padding: 20px;
}

.dark-mode {
    --primary-color: #0A84FF;
    --bg-color: #1C1C1E;
    --text-color: #E5E5EA;
    --secondary-bg: #2C2C2E;
    --border-color: #38383A;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 var(--content-padding);
}

header {
    height: var(--header-height);
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.left-header, .right-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    font-weight: 700;
    font-size: 22px;
    color: var(--primary-color);
    text-decoration: none;
}

.btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn:hover {
    background-color: var(--secondary-bg);
}

.theme-toggle {
    width: 40px;
    height: 24px;
    background-color: var(--secondary-bg);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background-color 0.3s;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: var(--primary-color);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.dark-mode .theme-toggle::after {
    transform: translateX(16px);
}

main {
    flex: 1;
    padding: 30px 0;
}

.chapter-title {
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 600;
}

.content {
    font-size: 18px;
    text-align: justify;
}

.content p {
    margin-bottom: 20px;
}

.font-controls {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    justify-content: center;
}

.font-btn {
    padding: 8px 16px;
    background-color: var(--secondary-bg);
    border: none;
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
}

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

footer {
    height: var(--footer-height);
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-btn {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    text-decoration: none;
}

.nav-btn:disabled {
    background-color: var(--secondary-bg);
    color: var(--text-color);
    opacity: 0.7;
    cursor: not-allowed;
}

.chapter-nav {
    display: flex;
    gap: 15px;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    z-index: 200;
    overflow-y: auto;
    padding: 20px;
    transition: left 0.3s ease;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 199;
    display: none;
}

.sidebar-overlay.open {
    display: block;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 600;
}

.chapter-list {
    list-style: none;
}

.chapter-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.chapter-item a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
}

.chapter-item.active a {
    color: var(--primary-color);
    font-weight: 600;
}

.font-small {
    font-size: 16px;
}

.font-medium {
    font-size: 18px;
}

.font-large {
    font-size: 20px;
}

@media (max-width: 768px) {
    :root {
        --content-padding: 15px;
    }
    
    .chapter-title {
        font-size: 22px;
    }
    
    .content {
        font-size: 16px;
    }
    
    .nav-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .sidebar {
        width: 85%;
        left: -85%;
    }
}
