/*
   Cream-themed Editorial Design System
   Inspired by the clean, serif typography layout.
*/

@import url("https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
    /* Color Palette */
    --bg-color: #faf7f2;
    --sidebar-bg: #f5f1ea;
    --text-primary: #2b2b2b;
    --text-secondary: #6b665e;
    --text-muted: #8e887e;
    --border-color: #e6dfd5;
    --border-light: #ece7de;
    --accent-color: #4a5c4e; /* Dark Sage Green for subtle accents */
    --accent-hover: #3c4b3f;
    --code-bg: #f0ebe0;

    /* Font Stacks */
    --font-serif: "Lora", Georgia, serif;
    --font-sans:
        "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, sans-serif;
    --font-mono: "JetBrains Mono", monospace;

    /* Layout Variables */
    --sidebar-width: 320px;
    --header-height: 70px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Sidebar Styling */
aside.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Custom scrollbars for sidebar */
aside.sidebar::-webkit-scrollbar {
    width: 6px;
}
aside.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
aside.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
aside.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Brand Logo */
.brand {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding-left: 0.5rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    color: var(--text-primary);
}

/* Search Box */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background-color: var(--border-light);
    border: 1px solid transparent;
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

.search-input:focus {
    background-color: #fff;
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Floating Search Results */
.search-results {
    position: absolute;
    top: 105%;
    left: 0;
    width: 100%;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    display: block;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--sidebar-bg);
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.search-result-snippet {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Navigation Links */
.sidebar-menu {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.menu-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.menu-group-title::after {
    content: "▼";
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.menu-group.collapsed .menu-group-title::after {
    transform: rotate(-90deg);
}

.menu-items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.menu-group.collapsed .menu-items {
    display: none;
}

.menu-items a {
    display: block;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.menu-items a:hover {
    color: var(--text-primary);
    background-color: var(--border-light);
    padding-left: 0.75rem;
}

.menu-items li.active a {
    color: var(--text-primary);
    font-weight: 600;
    background-color: var(--border-light);
    padding-left: 0.75rem;
}

/* Visited History Section */
.history-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.history-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.history-list a {
    display: block;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
}

.history-list a:hover {
    color: var(--text-primary);
    background-color: var(--border-light);
}

.history-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.5rem;
    line-height: 1.4;
    font-style: italic;
}

/* Footer links inside sidebar */
.sidebar-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.8rem;
}

.footer-nav a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: var(--text-primary);
}

.global-views {
    color: var(--text-muted);
}

/* Main Content Container */
main.content-area {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Top Navigation Header */
header.top-header {
    height: var(--header-height);
    padding: 0 4rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: rgba(250, 247, 242, 0.9);
    backdrop-filter: blur(8px);
    z-index: 90;
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-login {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.btn-login:hover {
    opacity: 0.8;
}

.btn-signup {
    background-color: var(--text-primary);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    transition: background-color 0.2s ease;
}

.btn-signup:hover {
    background-color: var(--accent-color);
}

/* Mobile Hamburger Menu */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 110;
}

.mobile-nav-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

/* Article Layout */
article.lecture-content {
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 4rem 6rem 4rem;
    flex-grow: 1;
}

/* Category indicator */
.category-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* H1 Main Page Title */
.lecture-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.2rem;
    color: var(--text-primary);
    text-wrap: balance;
}

/* Meta Line */
.lecture-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 3.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.lecture-meta .separator {
    color: var(--border-color);
}

.download-link {
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.download-link:hover {
    color: var(--accent-color);
}

/* Markdown Content Styling */
.markdown-body {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--text-primary);
}

/* Headings */
.markdown-body h2 {
    font-family: var(--font-serif);
    font-size: 1.7rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    text-wrap: balance;
}

.markdown-body h3 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    text-wrap: balance;
}

.markdown-body p {
    margin-bottom: 1.5rem;
    text-wrap: pretty;
}

.markdown-body strong {
    font-weight: 700;
}

/* Horizontal Rules */
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 3rem 0;
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
    text-wrap: pretty;
}

/* Blockquotes */
.markdown-body blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Inline Code */
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background-color: var(--border-light);
    padding: 0.15em 0.35em;
    border-radius: 4px;
    color: var(--text-primary);
}

.markdown-body a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.markdown-body a:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

/* Code Blocks */
.markdown-body pre {
    margin: 1.8rem 0;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    background-color: var(--code-bg) !important;
}

.markdown-body pre code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: var(--text-primary);
}

/* Override Prism Tomorrow theme colors to blend with our cream styling */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #8a8273;
    font-style: italic;
}

.token.punctuation {
    color: #5c554a;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #b55a30;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #3b6b4c;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #70583b;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #2b558c;
    font-weight: bold;
}

.token.function,
.token.class-name {
    color: #8c2b75;
}

.token.regex,
.token.important,
.token.variable {
    color: #825d10;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.markdown-body th {
    font-family: var(--font-sans);
    background-color: var(--sidebar-bg);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    padding: 0.75rem 1rem;
}

.markdown-body td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    vertical-align: top;
}

.markdown-body tr:hover {
    background-color: rgba(245, 241, 234, 0.5);
}

/* Prev / Next Pagination Controls */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    padding-top: 2rem;
    gap: 2rem;
}

.pag-btn {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text-secondary);
    max-width: 45%;
}

.pag-btn.next {
    text-align: right;
    align-items: flex-end;
}

.pag-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.pag-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.pag-btn:hover .pag-title {
    color: var(--accent-color);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
    header.top-header {
        padding: 0 2rem;
    }
    article.lecture-content {
        padding: 2rem 2rem 5rem 2rem;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    aside.sidebar {
        width: 100%;
        height: auto;
        position: relative;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        transition:
            max-height 0.35s ease,
            padding 0.35s ease;
    }

    aside.sidebar.mobile-active {
        max-height: 100vh;
        padding: 1.5rem;
        overflow-y: auto;
    }

    header.top-header {
        height: 60px;
        padding: 0 1.5rem;
        justify-content: space-between;
        position: relative;
        background-color: var(--sidebar-bg);
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-weight: 700;
        font-size: 1rem;
    }

    .mobile-nav-toggle {
        display: block;
    }

    .auth-buttons {
        display: none; /* Hide on mobile to keep clean or move to sidebar */
    }

    main.content-area {
        margin-left: 0;
        width: 100%;
    }

    article.lecture-content {
        padding: 1.5rem 1.5rem 4rem 1.5rem;
    }

    .lecture-title {
        font-size: 2rem;
    }

    .lecture-meta {
        flex-wrap: wrap;
        margin-bottom: 2rem;
    }

    .pagination-container {
        flex-direction: column;
        gap: 1.5rem;
        margin-top: 3rem;
    }

    .pag-btn {
        max-width: 100%;
        width: 100%;
    }

    .pag-btn.next {
        text-align: left;
        align-items: flex-start;
    }
}

/* Print Styling - Highly optimized for book export */
@media print {
    aside.sidebar,
    header.top-header,
    .pagination-container,
    .mobile-nav-toggle {
        display: none !important;
    }

    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    main.content-area {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    article.lecture-content {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    .lecture-meta {
        margin-bottom: 2rem !important;
        border-bottom: 1px solid #ccc !important;
    }

    .lecture-meta .download-link {
        display: none !important;
    }

    .markdown-body {
        font-size: 11pt !important;
    }

    .markdown-body pre {
        background-color: #f8f8f8 !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }

    .markdown-body table {
        page-break-inside: avoid;
    }

    .markdown-body tr {
        page-break-inside: avoid;
    }

    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }
}

/* Copy Code Button styling */
.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.3rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
    z-index: 10;
}

div:hover > .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    color: var(--text-primary);
    background-color: var(--border-light);
    border-color: var(--text-muted);
}

.copy-code-btn.copied {
    color: #fff;
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

@media print {
    .copy-code-btn {
        display: none !important;
    }
}

/* TOC Card Container */
.toc-container {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0 2.5rem 0;
    max-width: 500px;
}
.toc-container h2 {
    font-family: var(--font-sans) !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0 !important;
    margin-bottom: 1rem !important;
    color: var(--text-secondary) !important;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.toc-container ol {
    margin-bottom: 0 !important;
    padding-left: 1.2rem !important;
}
.toc-container li {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    margin-bottom: 0.4rem !important;
}
.toc-container li a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}
.toc-container li a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════
   ENHANCED DESIGN SYSTEM
   ═══════════════════════════════════════════════ */

/* --- Reading Progress Bar --- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 200;
    pointer-events: none;
}

.reading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #10b981);
    width: 0%;
    transition: width 0.1s linear;
}

/* --- Article Typography Refinements --- */
.markdown-body {
    font-size: 1.1rem;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.markdown-body h1 {
    font-size: 2.75rem;
    letter-spacing: -0.03em;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.markdown-body h2 {
    position: relative;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.markdown-body h2::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 48px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
    opacity: 0.6;
}

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

.markdown-body p {
    margin-bottom: 1.6rem;
}

.markdown-body p + ul,
.markdown-body p + ol {
    margin-top: -0.5rem;
}

/* --- Key Insight Box --- */
.markdown-body .insight-box {
    background: linear-gradient(
        135deg,
        rgba(74, 92, 78, 0.06),
        rgba(74, 92, 78, 0.02)
    );
    border: 1px solid rgba(74, 92, 78, 0.15);
    border-left: 4px solid var(--accent-color);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    font-size: 1rem;
}

.markdown-body .insight-box strong:first-child {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

/* --- Better Blockquotes --- */
.markdown-body blockquote {
    border-left: 3px solid var(--accent-color);
    background: linear-gradient(90deg, rgba(74, 92, 78, 0.04), transparent);
    padding: 1rem 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 2rem 0;
    font-style: normal;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

/* --- Enhanced Code Blocks --- */
.markdown-body pre {
    position: relative;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--code-bg);
    padding: 1.25rem;
    margin: 2rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.markdown-body pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    right: 1rem;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    background: var(--sidebar-bg);
    border-radius: 0 0 6px 6px;
    border: 1px solid var(--border-color);
    border-top: none;
}

.markdown-body pre code {
    font-size: 0.875rem;
    line-height: 1.7;
}

/* --- Better Inline Code --- */
.markdown-body :not(pre) > code {
    background: rgba(74, 92, 78, 0.08);
    color: var(--accent-color);
    padding: 0.15em 0.45em;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9em;
}

/* --- Tables --- */
.markdown-body table {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.markdown-body th {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    padding: 0.85rem 1rem;
}

.markdown-body td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.markdown-body tr:last-child td {
    border-bottom: none;
}

/* --- Images --- */
.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* --- Horizontal Rules --- */
.markdown-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--border-color),
        transparent
    );
    margin: 3rem 0;
}

/* --- Pagination --- */
.pagination-container {
    margin-top: 5rem;
    padding-top: 2rem;
}

.pag-btn {
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.pag-btn:hover {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

.pag-title {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

/* --- Lists --- */
.markdown-body ul {
    list-style: none;
    padding-left: 0;
}

.markdown-body ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.6rem;
}

.markdown-body ul li::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0.65em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.5;
}

.markdown-body ol {
    padding-left: 1.5rem;
}

.markdown-body ol li {
    margin-bottom: 0.6rem;
}

.markdown-body ol li::marker {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9em;
}

/* --- Sidebar Polish --- */
.sidebar-menu .menu-group-title {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.sidebar-menu .menu-group-title:hover {
    background: var(--border-light);
}

.menu-items a {
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    margin: 0 0.25rem;
}

.menu-items li.active a {
    background: rgba(74, 92, 78, 0.08);
    color: var(--accent-color);
    font-weight: 600;
}

/* --- Copy Button --- */
.copy-code-btn {
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    top: 0.6rem;
    right: 0.6rem;
}

/* --- TOC Card --- */
.toc-container {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.toc-container li a {
    transition: all 0.15s ease;
    padding: 0.15rem 0;
    display: inline-block;
}

/* --- Smooth scroll --- */
html {
    scroll-behavior: smooth;
}

/* --- Print optimizations --- */
@media print {
    .markdown-body h2::after {
        display: none;
    }

    .markdown-body blockquote {
        background: none;
        border-left: 3px solid #ccc;
    }
}
