:root {
    --toc-width: 280px;
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
}

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

body {
    background-color: #f8f9fa;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* ===== Left TOC sidebar ===== */
.toc {
    width: var(--toc-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--primary-color);
    padding: 1.2rem 0.9rem;
}

.toc-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 0.6rem 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 0.8rem;
}

.toc ul {
    list-style: none;
}

.toc a {
    display: block;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-left: 2px solid transparent;
    font-size: 0.82rem;
    line-height: 1.0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.toc a:hover { color: #fff; }

.toc a.active {
    color: #fff;
    border-left-color: var(--secondary-color);
    background: rgba(52,152,219,0.15);
}

/* Level indentation = a tree */
.toc .h1 { margin-top: 1.8rem; margin-bottom: 0.2rem; }
.toc .h2 { margin-top: 0.2rem; margin-bottom: 0.2rem; }
.toc a.h1 { font-weight: 700; font-size: 1.6rem; }
.toc a.h2 { padding-left: 1.2rem; font-size: 1.5rem; }
.toc a.h3 { padding-left: 2.2rem; font-size: 1.4rem; color: rgba(255,255,255,0.7); }
.toc a.h4 { padding-left: 3.2rem; font-size: 1.2rem; color: rgba(255,255,255,0.6); }

/* Mobile toggle */
.toc-toggle {
    display: none;
    position: fixed;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 100;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ===== Content column ===== */
.content {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.container {
    width: auto;
    max-width: 100%;
    min-width: 0;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Reduce heading top-margin so jump targets land off-screen less */
.mdContent h1, .mdContent h2, .mdContent h3, .mdContent h4 {
    scroll-margin-top: 0.5rem;
}

@media (max-width: 820px) {
    .toc {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        z-index: 99;
    }
    body.nav-open .toc { transform: translateX(0); }
    .toc-toggle { display: block; }
    .content { padding: 3.5rem 1rem 1rem; }
}