/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --text-color: #333;
    --bg-color: #fff;
    --sidebar-bg: #f8f9fa;
    --border-color: #e0e0e0;
    --code-bg: #f4f4f4;
    --link-color: #3498db;
    --link-hover: #2980b9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* Container layout */
.container {
    display: flex;
    min-height: 100vh;
}

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

.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-header h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    position: relative;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--primary-color);
    margin: 4px 0;
    transition: 0.3s;
}

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

.nav-list li {
    margin-bottom: 8px;
}

.nav-list a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-list a:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--link-color);
}

.nav-list .active a {
    background-color: var(--secondary-color);
    color: white;
}

/* Main content */
.content {
    flex: 1;
    margin-left: 300px;
    padding: 40px;
    max-width: 900px;
    width: 100%;
}

article {
    margin-bottom: 40px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

h1 { font-size: 2.2em; border-bottom: 2px solid var(--border-color); padding-bottom: 0.3em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }
h4 { font-size: 1.3em; }
h5 { font-size: 1.1em; }
h6 { font-size: 1em; }

p {
    margin-bottom: 1em;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

li {
    margin-bottom: 0.5em;
}

/* Code blocks */
pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 1em;
}

code {
    background-color: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.9em;
}

pre code {
    background-color: transparent;
    padding: 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

th, td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

th {
    background-color: var(--sidebar-bg);
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 20px;
    margin: 1em 0;
    color: #666;
}

/* Page navigation */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.nav-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--sidebar-bg);
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(52, 152, 219, 0.1);
    text-decoration: none;
}

.nav-link.prev {
    margin-right: auto;
}

.nav-link.next {
    margin-left: auto;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .content {
        margin-left: 0;
        padding: 20px;
    }
    
    .page-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
    }
    
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }
    h3 { font-size: 1.3em; }
}

/* Dark mode preparation */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ecf0f1;
        --secondary-color: #3498db;
        --text-color: #ecf0f1;
        --bg-color: #1a1a1a;
        --sidebar-bg: #2c3e50;
        --border-color: #34495e;
        --code-bg: #2c3e50;
    }
}

/* Math display */
.MathJax_Display {
    overflow-x: auto;
    overflow-y: hidden;
}