:root {
    --bg-body: #f8f7e3;
    --bg-sidebar: #f8f7e3;
    --bg-content: #f8f7e3;
    --text-main: #111111;
    --text-soft: #333333;
    --border-light: #dddddd;
    --border-strong: #aaaaaa;
    --link-color: #1a0dab;
    --link-visited: #4b0082;
    --pre-bg: #f4f4f4;
    --sidebar-width: 280px;
}

body.dark {
    --bg-body: #212529;
    --bg-sidebar: #212529;
    --bg-content: #212529;
    --text-main: #e0e0e0;
    --text-soft: #c0c0c0;
    --border-light: #3e3e42;
    --border-strong: #6a6a6a;
    --link-color: #8ab4f8;
    --link-visited: #c792ea;
    --pre-bg: #2d2d2d;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Courier New', Courier, monospace;
    font-size: 15pt;
    display: flex;
    transition: background-color 0.2s, color 0.2s;
}

.control-panel {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 12px;
}

.ctrl-btn {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 4px var(--shadow);
    transition: 0.1s;
}

.ctrl-btn:hover {
    background: var(--border-light);
}

.btn-icon {
    width: 24px;
    height: 24px;
    display: block;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    padding: 30px 16px 30px 24px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    box-sizing: border-box;
    transition: margin-left 0.25s ease, background-color 0.2s;
    box-shadow: inset -2px 0 6px var(--shadow);
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar h2 {
    text-align: left;
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin: 0;
    padding: 0;
}

.toc-list a {
    display: block;
    padding: 6px 8px;
    text-decoration: none;
    color: var(--text-soft);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: 0.1s;
}

.toc-list a:hover {
    color: var(--text-main);
    border-left-color: var(--border-strong);
    background-color: var(--shadow);
}

.main-content {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 40px 60px 40px;
}

p {
    margin-top: 0;
    margin-bottom: 0;
    vertical-align: top;
    color: var(--text-main);
}

pre {
    margin-top: 0;
    margin-bottom: 0;
    vertical-align: top;
    background-color: var(--pre-bg);
    border: 1px solid var(--border-light);
    padding: 12px 16px;
    border-radius: 2px;
    overflow-x: auto;
}

h1 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

h2 {
    color: var(--text-main);
    padding-bottom: 4px;
    margin-top: 36px;
}

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

a:visited {
    color: var(--link-visited);
}

hr {
    border: 0.5px solid var(--border-light);
    margin: 24px 0;
}

table {
    border-collapse: collapse;
}

td, th {
    color: var(--text-main);
}

@media (max-width: 760px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 16px;
    }
    .sidebar.collapsed {
        margin-left: 0;
        display: none;
    }
    .main-content {
        padding: 20px 16px;
    }
    .control-panel {
        top: 8px;
        right: 12px;
    }
    
}

