:root {
    --bg-primary: #F2F0EB;
    --bg-secondary: #E8E6E1;
    --bg-tertiary: #DEDBD3;
    --text-primary: #0A0A0A;
    --text-secondary: #3A3A3A;
    --text-muted: #6B6B6B;
    --accent: #0A0A0A;
    --border: #C4C2BB;
    --shadow: rgba(10, 10, 10, 0.08);
    --font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 16px;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr 220px;
    gap: 0;
    margin-top: 60px;
    min-height: calc(100vh - 60px - 50px);
}

.sidebar {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px - 50px);
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px 0;
}

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

.nav-list > li > a {
    display: block;
    padding: 10px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
}

.nav-list > li > a:hover {
    background-color: var(--bg-tertiary);
}

.nav-list > li > a.active {
    background-color: var(--accent);
    color: var(--bg-primary);
}

.has-mega {
    position: relative;
}

.mega-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mega-menu {
    display: none;
    list-style: none;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    margin: 0 10px;
    padding: 8px 0;
    border-radius: 4px;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    z-index: 50;
    box-shadow: 0 4px 12px var(--shadow);
}

.has-mega.active .mega-menu {
    display: block;
}

.mega-menu li a {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background-color 0.15s ease;
}

.mega-menu li a:hover {
    background-color: var(--bg-secondary);
}

.main-content {
    padding: 30px 40px;
    max-width: 100%;
    overflow-x: hidden;
}

.content-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
}

.markdown-content {
    max-width: 800px;
}

.markdown-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--text-primary);
    letter-spacing: -0.02em;
}

.markdown-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.markdown-content ul {
    list-style: circle;
    margin-bottom: 24px;
    padding-left: 24px;
}

.markdown-content li {
    padding: 6px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.markdown-content li a {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: #DC2626;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s ease;
}

.markdown-content li a:hover {
    text-decoration-color: #DC2626;
}

.markdown-content .section-divider {
    height: 1px;
    background-color: var(--border);
    margin: 24px 0;
}

.toc-sidebar {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px - 50px);
    overflow-y: auto;
    border-left: 1px solid var(--border);
    padding: 20px;
}

.toc-container {
    position: relative;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.toc {
    list-style: none;
}

.toc li {
    margin-bottom: 8px;
}

.toc li a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    display: block;
    padding: 4px 0;
    transition: color 0.15s ease;
}

.toc li a:hover {
    color: var(--text-primary);
}

.toc li a.active {
    color: var(--text-primary);
    font-weight: 500;
}

.toc .toc-h2 {
    padding-left: 12px;
}

.footer {
    height: 50px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 220px 1fr;
    }

    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 60px;
        left: -280px;
        width: 280px;
        height: calc(100vh - 60px);
        z-index: 99;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }

    .overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.4);
        z-index: 98;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .overlay.active {
        opacity: 1;
        visibility: visible;
    }

    body.body-lock {
        overflow: hidden;
    }

    .main-content {
        padding: 20px;
    }

    .markdown-content h1 {
        font-size: 1.5rem;
    }

    .markdown-content h2 {
        font-size: 1.1rem;
    }

    .mega-menu {
        position: static;
        display: none;
        background-color: var(--bg-primary);
        border: none;
        margin: 0;
        padding: 0 0 0 16px;
    }

    .has-mega.active .mega-menu {
        display: block;
    }
}

.markdown-content .star {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-content .arrow {
    color: var(--text-muted);
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}
