
/* ── Page layout: sidebar + content ──────────────────────────────────────── */

#page-layout {
    display: flex;
    height: calc(100vh - 54px);
    overflow: hidden;
}

@media (min-width: 992px) {
    #page-layout { height: calc(100vh - 56px); }
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

#sidebar {
    width: 350px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid #dee2e6;
    background: #fff;
    display: flex;
    flex-direction: column;
}

#sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

#sidebar-rtd {
    padding: 10px 20px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.82em;
    flex-shrink: 0;
}

#sidebar-rtd a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

#sidebar-rtd a:hover { text-decoration: underline; }

@media (max-width: 767px) {
    #sidebar { display: none; }
}

#sidebar-resizer {
    width: 4px;
    flex-shrink: 0;
    align-self: stretch;
    cursor: ew-resize;
    background-color: transparent;
    transition: background-color 0.12s;
}

#sidebar-resizer:hover,
#sidebar-resizer.resizing {
    background-color: #dee2e6;
}

#branch-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    box-sizing: border-box;
    width: 100%;
}

#branch-selector label {
    font-size: 0.85em;
    color: #6c757d;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
    margin-bottom: 0;
    align-self: center;
}

#branch-selector select {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    color: #4a4a4a;
    background: #fff;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    margin: 0;
    vertical-align: middle;
}

#branch-selector select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

.sidebar-header {
    padding: 14px 20px 10px;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6c757d;
    border-bottom: 1px solid #f0f0f0;
}

/* Section captions (from .. toctree:: :caption:) */
.sidebar-caption {
    padding: 12px 20px 4px;
    font-size: 0.68em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #adb5bd;
}

/* Top-level nav list */
.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.sidebar-list > li > a {
    display: flex;
    align-items: center;
    padding: 6px 20px;
    font-size: 0.88em;
    font-weight: 700;
    color: #4a4a4a;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    line-height: 1.4;
}

.sidebar-list > li > a:hover {
    color: #007bff;
    background: #f0f7ff;
    border-left-color: #b8d9ff;
    text-decoration: none;
}

.sidebar-list > li.active > a {
    color: #007bff;
    font-weight: 600;
    background: #e8f2ff;
    border-left-color: #007bff;
}

/* Section headings sub-list (h2s of the active page) */
.sidebar-sublist {
    list-style: none;
    margin: 0;
    padding: 2px 0 6px;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    margin-left: 17px; /* align with text above */
}

.sidebar-sublist li a {
    display: block;
    padding: 4px 16px 4px 14px;
    font-size: 0.8em;
    color: #6c757d;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.1s;
}

.sidebar-sublist li a:hover {
    color: #007bff;
    text-decoration: none;
}

.sidebar-sublist li.active a {
    color: #007bff;
    font-weight: 600;
}

.sidebar-loading {
    padding: 12px 20px;
    color: #adb5bd;
    font-size: 0.85em;
    font-style: italic;
}

/* ── Main content ─────────────────────────────────────────────────────────── */

#rst-wrapper {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    display: flex;
    justify-content: flex-start;
    padding: 32px 40px 64px;
    box-sizing: border-box;
}

#rst-content {
    width: 100%;
    max-width: 820px;
    line-height: 1.75;
    color: #4a4a4a;
}

/* ── Loading / error states ───────────────────────────────────────────────── */

.rst-loading {
    color: #6c757d;
    font-style: italic;
    padding: 24px 0;
}

.rst-error {
    background: #fff3f3;
    border-left: 4px solid #dc3545;
    padding: 12px 16px;
    border-radius: 4px;
    margin: 16px 0;
}

/* ── Headings ─────────────────────────────────────────────────────────────── */

#rst-content h1 { font-size: 2em;    font-weight: 800; border-bottom: 2px solid #dee2e6; padding-bottom: 8px;  margin: 8px 0 18px; }
#rst-content h2 { font-size: 1.45em; font-weight: 800; border-bottom: 1px solid #dee2e6; padding-bottom: 5px;  margin: 28px 0 12px; }
#rst-content h3 { font-size: 1.2em;  font-weight: 700; margin: 22px 0 10px; }
#rst-content h4 { font-size: 1.05em; font-weight: 700; margin: 18px 0 8px; }
#rst-content h5,
#rst-content h6 { font-size: 1em;    margin: 14px 0 6px; font-weight: 600; }

#rst-content h1, #rst-content h2, #rst-content h3,
#rst-content h4, #rst-content h5, #rst-content h6 {
    scroll-margin-top: 100px;
}

/* ── Paragraphs & inline ──────────────────────────────────────────────────── */

#rst-content p    { margin: 0 0 1em; }
#rst-content a    { color: #007bff; }
#rst-content a:hover { text-decoration: underline; }
#rst-content code {
    background: #f4f4f4;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.875em;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ── Code blocks ──────────────────────────────────────────────────────────── */

#rst-content pre {
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin: 0 0 1.2em;
    line-height: 1.5;
}

#rst-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875em;
}

/* ── Lists ────────────────────────────────────────────────────────────────── */

#rst-content ul,
#rst-content ol {
    padding-left: 1.8em;
    margin: 0 0 1em;
}
#rst-content li { margin-bottom: 4px; }

/* ── Admonitions ──────────────────────────────────────────────────────────── */

#rst-content .admonition {
    border-radius: 4px;
    padding: 12px 16px;
    margin: 1em 0;
    border-left: 4px solid #aaa;
    background: #f8f9fa;
}
#rst-content .admonition p { margin: 0; }
#rst-content .admonition p + p { margin-top: 6px; }

#rst-content .admonition-title {
    font-weight: 700;
    margin: 0 0 6px;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.06em;
}

#rst-content .admonition.note      { border-color: #17a2b8; background: #e8f7fb; }
#rst-content .admonition.note      .admonition-title { color: #0c6674; }
#rst-content .admonition.warning   { border-color: #ffc107; background: #fff8e1; }
#rst-content .admonition.warning   .admonition-title { color: #856404; }
#rst-content .admonition.tip       { border-color: #28a745; background: #eafaf1; }
#rst-content .admonition.tip       .admonition-title { color: #155724; }
#rst-content .admonition.important { border-color: #fd7e14; background: #fff3e0; }
#rst-content .admonition.important .admonition-title { color: #7d3c00; }
#rst-content .admonition.caution   { border-color: #e83e8c; background: #fce4f0; }
#rst-content .admonition.caution   .admonition-title { color: #7a0e3e; }
#rst-content .admonition.deprecated,
#rst-content .admonition.versionchanged,
#rst-content .admonition.versionadded { border-color: #6c757d; background: #f0f0f0; }

/* ── Toctree ──────────────────────────────────────────────────────────────── */

#rst-content .toctree {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px 20px;
    margin: 1em 0;
}
#rst-content .toctree ul  { margin: 0; padding-left: 1.2em; }
#rst-content .toctree li  { margin-bottom: 6px; }
#rst-content .toctree a   { font-weight: 500; }

/* ── Figures ──────────────────────────────────────────────────────────────── */

#rst-content .rst-figure { text-align: center; margin: 1.5em 0; }
#rst-content .rst-figure img { max-width: 100%; border-radius: 4px; }

/* ── Rubric / math ────────────────────────────────────────────────────────── */

#rst-content .rubric { font-weight: 700; border-bottom: 1px solid #dee2e6; margin: 1.5em 0 0.5em; }
#rst-content .math pre { background: #f4f4f4; color: #4a4a4a; font-style: italic; }
