@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');
/* =========================================
           VARIABLES & THEMES
           ========================================= */
        :root, [data-theme="dark"] {
            --bg-color: #0a0a0a;
            --surface-color: #111111;
            --surface-hover: #1a1a1a;
            --text-main: #e0e0e0;
            --text-dim: #888888;
            --border-color: #222222;
            --accent-color: #ffffff;
            --highlight: #1a1a1a;
            --nav-height: 70px;
            --toc-bar-height: 56px;
            --sidebar-width: 260px;
            --progress-h: 3px;
            --ease: cubic-bezier(0.4, 0, 0.2, 1);
            --code-bg: #161b22;
            --task-red: #ff4444;
            --link-color: #7ab3ff;
            --table-stripe: rgba(255,255,255,0.03);
            --ad-bg: #161616;
            --loader-accent: #ffffff;
        }
        [data-theme="amoled"] {
            --bg-color: #000;
            --surface-color: #000;
            --surface-hover: #0a0a0a;
            --text-main: #d4d4d4;
            --text-dim: #666;
            --border-color: #111;
            --accent-color: #fff;
            --highlight: #050505;
            --code-bg: #0a0a0a;
            --ad-bg: #080808;
        }
        [data-theme="coffee"] {
            --bg-color: #2b211e;
            --surface-color: #221a17;
            --surface-hover: #382b26;
            --text-main: #e8dccb;
            --text-dim: #a6958a;
            --border-color: #3d2f29;
            --accent-color: #e0a96d;
            --highlight: #362924;
            --code-bg: #1a1210;
            --link-color: #e0a96d;
            --ad-bg: #1e1512;
            --loader-accent: #e0a96d;
        }

        /* =========================================
           BASE
           ========================================= */
        *, *::before, *::after { box-sizing: border-box; }

        body {
            margin: 0;
            font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
            background: var(--bg-color);
            color: var(--text-main);
            line-height: 1.7;
            transition: background 0.3s, color 0.3s;
            overflow-x: hidden;
        }
        /* Bidi on all text containers */
        p, li, td, th, blockquote, figcaption,
        h1, h2, h3, h4, h5, h6, dt, dd,
        .toc-list a, .fs-file, .fs-folder { unicode-bidi: plaintext; }

        /* =========================================
           PAGE LOADER (content switch)
           ========================================= */
        #page-loader {
            position: fixed; inset: 0; z-index: 9999;
            background: var(--bg-color);
            display: flex; align-items: center; justify-content: center;
            opacity: 0; pointer-events: none;
            transition: opacity 0.2s ease;
        }
        #page-loader.active { opacity: 1; pointer-events: all; }
        .loader-ring {
            width: 44px; height: 44px;
            border: 3px solid var(--border-color);
            border-top-color: var(--loader-accent);
            border-radius: 50%;
            animation: spin 0.7s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        #article {
            transition: opacity 0.18s ease, transform 0.18s ease;
            will-change: opacity, transform;
        }
        #article.loading { opacity: 0; transform: translateY(8px); pointer-events: none; }

        /* =========================================
           LIGHTBOX
           ========================================= */
        #lightbox {
            position: fixed; inset: 0; z-index: 10000;
            background: rgba(0,0,0,0.93);
            backdrop-filter: blur(8px);
            display: flex; align-items: center; justify-content: center;
            opacity: 0; pointer-events: none;
            transition: opacity 0.25s ease;
            cursor: zoom-out;
        }
        #lightbox.open { opacity: 1; pointer-events: all; }
        #lightbox-img {
            max-width: min(90vw, 1280px);
            max-height: 88vh;
            border-radius: 10px;
            box-shadow: 0 30px 80px rgba(0,0,0,0.8);
            transform: scale(0.94);
            transition: transform 0.25s var(--ease);
            cursor: default;
            object-fit: contain;
            display: block;
        }
        #lightbox.open #lightbox-img { transform: scale(1); }
        #lightbox-caption {
            position: absolute; bottom: 20px; left: 50%;
            transform: translateX(-50%);
            font-family: 'JetBrains Mono', monospace;
            font-size: 0.78rem; color: rgba(255,255,255,0.55);
            text-align: center; max-width: 80vw; pointer-events: none;
        }
        #lightbox-close {
            position: absolute; top: 18px; right: 18px;
            width: 38px; height: 38px; border-radius: 50%;
            background: rgba(255,255,255,0.1); border: none;
            color: #fff; font-size: 1rem; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: background 0.2s;
        }
        #lightbox-close:hover { background: rgba(255,255,255,0.22); }
        /* Zoomable cursor on content images */
        #article img:not(.emoji):not(.no-zoom) { cursor: zoom-in; }

        /* =========================================
           IMAGES
           ========================================= */
        #article img:not(.emoji) {
            margin-left: auto;
            margin-right: auto;
        }

        img { max-width: 100%; height: auto; border-radius: 8px; display: block; }
        img.emoji {
            height: 1.2em; width: 1.2em;
            margin: 0 .05em 0 .1em; vertical-align: -0.1em;
            border-radius: 0; display: inline;
        }
        figure.doc-figure {
            margin: 2rem 0; border: 1px solid var(--border-color);
            border-radius: 8px; overflow: hidden;
            background: var(--surface-color);
        }
        figure.doc-figure img { border-radius: 0; border-bottom: 1px solid var(--border-color); }
        figure.doc-figure figcaption {
            padding: 0.7rem 1rem; font-size: 0.82rem;
            color: var(--text-dim); text-align: center;
            font-family: 'JetBrains Mono', monospace;
        }
        .img-plain { margin: 1.5rem 0; }
        #lightbox img {
            margin: 0;
        }
        /* Auto-caption figures (from JS) */
        figure.auto-captioned { margin: 2rem 0; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--surface-color); }
        figure.auto-captioned img { border-radius: 0; border-bottom: 1px solid var(--border-color); }
        figure.auto-captioned figcaption { padding: 0.7rem 1rem; font-size: 0.82rem; color: var(--text-dim); text-align: center; font-family: 'JetBrains Mono', monospace; }

        /* =========================================
           TYPOGRAPHY — H1–H5
           ========================================= */
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Rajdhani', 'IBM Plex Sans Arabic', sans-serif;
            overflow-wrap: break-word; word-break: break-word; hyphens: auto;
            scroll-margin-top: calc(var(--nav-height) + var(--progress-h) + 20px);
        }
        h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); margin-top: 0; margin-bottom: 1rem; }
        h2 {
            font-size: clamp(1.3rem, 3vw, 1.9rem); margin-top: 3rem;
            border-inline-start: 3px solid var(--accent-color);
            padding-inline-start: 15px; position: relative;
        }
        h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); margin-top: 2rem; }
        h4 { font-size: clamp(1rem, 2vw, 1.2rem); margin-top: 1.5rem; color: var(--text-dim); }
        h5 { font-size: 0.95rem; margin-top: 1rem; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }

        /* GitHub-style anchor links */
        .anchor-link {
            color: var(--text-dim); text-decoration: none;
            font-size: 0.82em; margin-inline-end: 0.4em;
            opacity: 0; transition: opacity 0.15s;
            font-family: 'JetBrains Mono', monospace;
            user-select: none;
        }
        h2:hover .anchor-link, h3:hover .anchor-link,
        h4:hover .anchor-link, h5:hover .anchor-link { opacity: 1; }

        /* =========================================
           INLINE
           ========================================= */
        strong, b { font-weight: 700; }
        em, i { font-style: italic; }
        u { text-decoration: underline; text-underline-offset: 3px; }
        s, del { text-decoration: line-through; opacity: 0.7; }
        mark { background: rgba(255,220,50,0.22); color: var(--text-main); padding: 0 3px; border-radius: 3px; }
        :not(pre) > code {
            font-family: 'JetBrains Mono', monospace; font-size: 0.85em;
            background: var(--code-bg); border: 1px solid var(--border-color);
            padding: 2px 6px; border-radius: 4px;
            direction: ltr !important; unicode-bidi: embed;
        }
        kbd {
            font-family: 'JetBrains Mono', monospace; font-size: 0.8em;
            background: var(--surface-color); border: 1px solid var(--border-color);
            border-bottom-width: 3px; padding: 2px 7px; border-radius: 5px;
        }
        abbr[title] { text-decoration: underline dotted; cursor: help; }
        sub { vertical-align: sub; font-size: 0.8em; }
        sup { vertical-align: super; font-size: 0.8em; }

        /* =========================================
           LINKS
           ========================================= */
        .container a:not([class]) {
            color: var(--link-color, #7ab3ff); text-decoration: none;
            border-bottom: 1px solid transparent;
            transition: border-color 0.2s, opacity 0.2s;
        }
        .container a:not([class]):hover { border-bottom-color: var(--link-color, #7ab3ff); opacity: 0.85; }
        .container a:not([class]):visited { opacity: 0.75; }

        /* =========================================
           LISTS
           ========================================= */
        .container ul:not(.toc-list):not(.task-list),
        .container ol { padding-inline-start: 1.8rem; margin: 1rem 0; }
        .container ul:not(.toc-list):not(.task-list) li,
        .container ol li { margin-bottom: 0.4rem; unicode-bidi: plaintext; }
        .container ul:not(.toc-list):not(.task-list) { list-style: disc; }
        .container ol { list-style: decimal; }
        .container ul ul { list-style: circle; }
        .container ul ul ul { list-style: square; }
        /* Task list */
        .task-list { list-style: none !important; padding-inline-start: 0.5rem !important; }
        .task-list li { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.5rem; unicode-bidi: plaintext; }
        .task-list li::before { display: none; }
        .task-check { flex-shrink: 0; font-size: 1rem; margin-top: 0.15em; }
        .task-check.undone { color: var(--task-red); font-weight: bold; }

        /* =========================================
           BLOCKQUOTE
           ========================================= */
        blockquote {
            margin: 1.5rem 0; padding: 1rem 1.2rem;
            border-inline-start: 4px solid var(--accent-color);
            background: var(--highlight);
            border-radius: 0 8px 8px 0;
            color: var(--text-main); font-style: italic;
        }
        [dir="rtl"] blockquote { border-radius: 8px 0 0 8px; }
        blockquote p { margin: 0; }
        blockquote cite { display: block; margin-top: 0.5rem; font-style: normal; font-size: 0.85rem; color: var(--text-dim); }
        blockquote cite::before { content: "— "; }

        /* =========================================
           CODE — always LTR
           ========================================= */
        pre {
            direction: ltr !important; unicode-bidi: embed; text-align: left !important;
            background: var(--code-bg) !important; border: 1px solid var(--border-color);
            border-radius: 8px; padding: 0; margin: 1.5rem 0; overflow: hidden;
        }
        .code-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 7px 14px; background: rgba(255,255,255,0.05);
            border-bottom: 1px solid var(--border-color); direction: ltr;
        }
        .code-lang {
            font-family: 'JetBrains Mono', monospace; font-size: 0.73rem;
            color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
        }
        .copy-btn {
            font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
            background: transparent; border: 1px solid var(--border-color);
            color: var(--text-dim); padding: 3px 10px; border-radius: 4px;
            cursor: pointer; transition: all 0.2s;
        }
        .copy-btn:hover { color: var(--accent-color); border-color: var(--accent-color); }
        pre code.hljs {
            display: block; padding: 1.2rem 1.4rem; overflow-x: auto;
            background: transparent !important;
            direction: ltr !important; text-align: left !important;
            font-family: 'JetBrains Mono', monospace; font-size: 0.875rem; line-height: 1.6;
        }

        /* =========================================
           TABLES — responsive scroll
           ========================================= */
        .table-wrapper {
            overflow-x: auto; -webkit-overflow-scrolling: touch;
            margin: 1.5rem 0; border: 1px solid var(--border-color); border-radius: 8px;
        }
        table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 500px; }
        thead tr { background: var(--surface-color); }
        th {
            padding: 10px 16px; text-align: start;
            font-family: 'JetBrains Mono', monospace; font-size: 0.78rem;
            letter-spacing: 0.5px; color: var(--text-dim);
            border-bottom: 1px solid var(--border-color); white-space: nowrap;
        }
        td { padding: 10px 16px; border-bottom: 1px solid var(--border-color); unicode-bidi: plaintext; }
        tbody tr:last-child td { border-bottom: none; }
        tbody tr:nth-child(even) { background: var(--table-stripe); }
        tbody tr:hover { background: var(--highlight); }

        /* =========================================
           ADS
           ========================================= */
        .ad-text {
            background: var(--ad-bg); border: 1px dashed var(--border-color);
            border-radius: 6px; padding: 0.7rem 1rem; font-size: 0.78rem;
            color: var(--text-dim); font-family: 'JetBrains Mono', monospace;
            display: flex; align-items: center; gap: 0.6rem; margin: 1.5rem 0;
        }
        .ad-label {
            font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px;
            border: 1px solid var(--border-color); padding: 2px 5px; border-radius: 3px;
            flex-shrink: 0; opacity: 0.6;
        }
        .ad-image-wrap {
            margin: 1.5rem 0; position: relative; border-radius: 8px;
            overflow: hidden; border: 1px dashed var(--border-color);
        }
        .ad-image-wrap img { border-radius: 0; }
        .ad-label-overlay {
            position: absolute; top: 8px; inset-inline-start: 8px;
            font-size: 0.65rem; font-family: 'JetBrains Mono', monospace;
            text-transform: uppercase; letter-spacing: 1px;
            background: rgba(0,0,0,0.7); color: #888; padding: 2px 6px; border-radius: 3px;
        }

        /* =========================================
           FOOTNOTES / CITATIONS
           ========================================= */
        .cite-ref { font-size: 0.78em; vertical-align: super; color: var(--link-color, #7ab3ff); cursor: pointer; font-family: 'JetBrains Mono', monospace; }
        .footnotes { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); font-size: 0.85rem; color: var(--text-dim); }
        .footnotes ol { padding-inline-start: 1.5rem; }
        .footnotes li { margin-bottom: 0.4rem; unicode-bidi: plaintext; }

        /* =========================================
           NEXT / PREV NAV
           ========================================= */
        .page-nav { display: flex; gap: 1rem; margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color); }
        .page-nav-btn {
            flex: 1; display: flex; flex-direction: column; gap: 4px;
            padding: 1rem 1.2rem; background: var(--surface-color);
            border: 1px solid var(--border-color); border-radius: 10px;
            text-decoration: none; color: var(--text-main);
            transition: border-color 0.2s, background 0.2s;
        }
        .page-nav-btn:hover { background: var(--highlight); border-color: var(--accent-color); }
        .page-nav-btn.next { text-align: end; }
        .page-nav-label {
            font-family: 'JetBrains Mono', monospace; font-size: 0.7rem;
            color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
            display: flex; align-items: center; gap: 6px;
        }
        .page-nav-btn.next .page-nav-label { justify-content: flex-end; }
        .page-nav-title { font-family: 'Rajdhani', sans-serif; font-size: 1rem; font-weight: 600; overflow-wrap: break-word; word-break: break-word; }
        @media (max-width: 600px) { .page-nav { flex-direction: column; } }

        /* =========================================
           PROGRESS LINE — desktop only
           ========================================= */
        #progress-line {
            position: fixed; top: var(--nav-height); left: 0;
            height: var(--progress-h); width: 0%;
            background: var(--accent-color); z-index: 999;
            pointer-events: none;
            transition: top 0.4s var(--ease);
            will-change: width;
        }
        /* When nav hidden, line slides to very top */
        html.nav-hidden #progress-line { top: 0; }
        @media (max-width: 900px) { #progress-line { display: none; } }

        /* =========================================
           NAVBAR
           ========================================= */
        .navbar {
            position: fixed; top: 0; width: 100%; height: var(--nav-height);
            background: var(--surface-color); border-bottom: 1px solid var(--border-color);
            z-index: 1000; display: flex; align-items: center;
            justify-content: space-between; padding: 0 1.2rem;
            transition: transform 0.4s var(--ease);
        }
        .navbar.nav-hidden { transform: translateY(-100%); }
        .nav-left, .nav-controls { display: flex; align-items: center; gap: 1rem; min-width: 0; }
        .brand {
            font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 1.6rem;
            letter-spacing: 2px; color: var(--accent-color); margin-inline-end: 1rem; white-space: nowrap;
        }
        .icon-btn {
            background: var(--highlight); border: 1px solid var(--border-color);
            color: var(--text-main); width: 40px; height: 40px; border-radius: 8px;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            transition: all 0.2s; flex-shrink: 0;
        }
        .icon-btn:hover { background: var(--surface-hover); }
        .dropdown { position: relative; }
        .dropdown-btn {
            font-family: 'JetBrains Mono', monospace; font-size: 0.85rem;
            background: transparent; border: 1px solid var(--border-color);
            padding: 8px 12px; border-radius: 6px; color: var(--text-main);
            cursor: pointer; display: flex; align-items: center; gap: 8px;
            transition: background 0.2s; white-space: nowrap;
        }
        .dropdown-btn:hover { background: var(--highlight); }
        .dropdown-menu {
            position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
            background: var(--surface-color); border: 1px solid var(--border-color);
            border-radius: 8px; min-width: 140px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            opacity: 0; visibility: hidden; transform: translateY(-10px);
            transition: all 0.2s; z-index: 1001; overflow: hidden;
        }
        .dropdown.active .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
        .dropdown-item {
            padding: 10px 16px; cursor: pointer;
            font-size: 0.85rem; font-family: 'JetBrains Mono', monospace;
            display: flex; align-items: center; gap: 10px;
            color: var(--text-main); transition: background 0.2s;
        }
        .dropdown-item:hover { background: var(--surface-hover); color: var(--accent-color); }

        /* =========================================
           THREE-COLUMN LAYOUT
           ========================================= */
        .layout-wrapper {
            display: flex; padding-top: var(--nav-height);
            min-height: 100vh; max-width: 1600px; margin: 0 auto;
        }
        .sidebar {
            width: var(--sidebar-width); flex-shrink: 0;
            background: var(--bg-color);
            position: sticky; top: var(--nav-height);
            height: calc(100vh - var(--nav-height)); overflow-y: auto;
            transition: width 0.4s var(--ease), padding 0.4s var(--ease), transform 0.4s var(--ease);
            scrollbar-width: thin; scrollbar-color: var(--border-color) transparent;
        }
        .sidebar-left { border-inline-end: 1px solid var(--border-color); }
        .sidebar-right { border-inline-start: 1px solid var(--border-color); }
        .sidebar.collapsed { width: 0; border: none; overflow: hidden; }
        .sidebar-inner { width: var(--sidebar-width); padding: 1.5rem; }
        .sidebar.collapsed .sidebar-inner { opacity: 0; pointer-events: none; }
        .main-content { flex: 1; min-width: 0; }
        .container { padding: 2rem 3rem 5rem; max-width: 800px; margin: 0 auto; }

        /* =========================================
           SIDEBAR TITLE
           ========================================= */
        .sidebar-title {
            font-family: 'Rajdhani', sans-serif; font-size: 0.9rem;
            color: var(--text-dim); letter-spacing: 1px;
            margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;
        }

        /* =========================================
           FILE TREE (dynamic — window.Pages)
           ========================================= */
        #fs-tree ul { list-style: none; padding: 0; margin: 0; }
        .fs-folder {
            color: var(--text-dim); font-size: 0.88rem;
            display: flex; align-items: center; gap: 8px;
            padding: 5px 8px; border-radius: 4px;
            cursor: pointer; transition: all 0.2s; user-select: none;
        }
        .fs-folder:hover { background: var(--highlight); color: var(--text-main); }
        .folder-icon { flex-shrink: 0; font-size: 0.6rem; display: inline-block; transition: transform 0.2s; }
        .fs-file {
            color: var(--text-dim); text-decoration: none; font-size: 0.88rem;
            display: flex; align-items: center; gap: 8px;
            padding: 5px 8px; border-radius: 4px; transition: all 0.2s;
        }
        .fs-file:hover { background: var(--highlight); color: var(--text-main); }
        .fs-file.active { color: var(--accent-color); background: var(--highlight); font-weight: 600; }
        /* Static fallback tree */
        .file-tree { list-style: none; padding: 0; margin: 0; }
        .file-tree ul { list-style: none; padding-inline-start: 1.2rem; margin: 0; border-inline-start: 1px solid var(--border-color); margin-inline-start: 0.6rem; }
        .file-tree a { color: var(--text-dim); text-decoration: none; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; }
        .file-tree a:hover { background: var(--highlight); color: var(--text-main); }

        /* =========================================
           TOC LIST
           ========================================= */
        .toc-list { list-style: none; padding: 0; margin: 0; }
        .toc-list li { margin-bottom: 4px; }
        .toc-list a {
            color: var(--text-dim); text-decoration: none; font-size: 0.85rem;
            transition: color 0.2s; display: block;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 0;
        }
        .toc-list a:hover, .toc-list a.toc-active { color: var(--accent-color); }
        .toc-list a.toc-active { font-weight: 600; }
        /* TOC indent by heading level */
        .toc-level-1 { padding-inline-start: 0; }
        .toc-level-2 { padding-inline-start: 1rem; }
        .toc-level-3 { padding-inline-start: 2rem; }
        .toc-level-4 { padding-inline-start: 2.8rem; }
        .toc-level-5 { padding-inline-start: 3.4rem; }

        /* =========================================
           MOBILE TOC BAR
           ========================================= */
        .mobile-toc-bar {
            position: fixed; top: var(--nav-height); left: 0; width: 100%;
            height: var(--toc-bar-height);
            background: var(--surface-color); border-bottom: 1px solid var(--border-color);
            z-index: 990; display: none; align-items: center;
            justify-content: space-between; padding: 0 1.2rem;
            /* Smooth: only top, not display */
            transition: top 0.4s var(--ease);
        }
        /* Sticky at top when nav is hidden — driven via JS class on <html> */
        html.nav-hidden .mobile-toc-bar { top: 0; }

        .toc-current-section {
            font-family: 'Rajdhani', sans-serif; font-weight: 600; font-size: 1rem;
            color: var(--text-main); display: flex; align-items: center; gap: 10px;
            max-width: calc(100% - 60px); cursor: pointer; padding: 5px 10px;
            border-radius: 6px; background: var(--highlight); user-select: none; overflow: hidden;
        }
        .toc-current-section i { flex-shrink: 0; }
        #toc-current-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

        .mobile-toc-modal {
            position: absolute; top: calc(100% + 5px); inset-inline-start: 1.2rem;
            background: var(--surface-color); border: 1px solid var(--border-color);
            border-radius: 8px; width: min(300px, calc(100vw - 2.4rem));
            max-height: 60vh; overflow-y: auto;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5); padding: 1rem;
            display: none; flex-direction: column; gap: 10px;
        }
        .mobile-toc-modal.open { display: flex; }
        .mobile-toc-modal .toc-list a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

        /* Circular progress */
        .circular-progress {
            width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
            background: conic-gradient(var(--accent-color) var(--progress-deg, 0deg), var(--border-color) 0deg);
            display: flex; align-items: center; justify-content: center;
        }
        .circular-progress-inner {
            width: 32px; height: 32px; background: var(--surface-color); border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-family: 'JetBrains Mono', monospace; font-size: 0.58rem; font-weight: 700;
        }

        /* =========================================
           MISC
           ========================================= */
        hr { border: none; border-top: 1px solid var(--border-color); margin: 2rem 0; }
        dl { margin: 1rem 0; }
        dt { font-weight: 700; color: var(--accent-color); margin-top: 0.8rem; unicode-bidi: plaintext; }
        dd { margin-inline-start: 1.5rem; color: var(--text-dim); unicode-bidi: plaintext; }
        footer {
            border-top: 1px solid var(--border-color); padding: 2rem 1.2rem;
            text-align: center; font-family: 'JetBrains Mono', monospace;
            font-size: 0.75rem; color: var(--text-dim); background: var(--surface-color);
        }

        /* =========================================
           RESPONSIVE
           ========================================= */
        @media (max-width: 900px) {
            .mobile-toc-bar { display: flex; }
            .layout-wrapper { padding-top: calc(var(--nav-height) + var(--toc-bar-height)); }
            .container { padding: 1.5rem 1.2rem 5rem; }
            h1, h2, h3, h4, h5 { scroll-margin-top: calc(var(--nav-height) + var(--toc-bar-height) + 20px); }
            html.nav-hidden h1, html.nav-hidden h2,
            html.nav-hidden h3, html.nav-hidden h4,
            html.nav-hidden h5 { scroll-margin-top: calc(var(--toc-bar-height) + 20px); }
            .sidebar-right, #btn-toggle-right { display: none !important; }
            .sidebar-left {
                position: fixed; top: 0; inset-inline-start: 0; height: 100vh;
                z-index: 2000; box-shadow: 5px 0 30px rgba(0,0,0,0.8);
                transform: translateX(-100%); width: var(--sidebar-width) !important;
                background: var(--surface-color);
            }
            [dir="rtl"] .sidebar-left { transform: translateX(100%); box-shadow: -5px 0 30px rgba(0,0,0,0.8); }
            .sidebar-left.mobile-open { transform: translateX(0); }
            [dir="rtl"] .sidebar-left.mobile-open { transform: translateX(0); }
            .sidebar-left .sidebar-inner { opacity: 1; pointer-events: auto; padding-top: 2rem; }
            .mobile-overlay {
                visibility: hidden; opacity: 0; position: fixed; inset: 0;
                background: rgba(0,0,0,0.6); z-index: 1999; backdrop-filter: blur(2px);
                transition: opacity 0.4s var(--ease), visibility 0.4s;
            }
            .mobile-overlay.active { visibility: visible; opacity: 1; }
        }
        @media (max-width: 600px) { .container { padding: 1rem 1rem 4rem; } }
