#rdmc-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 10001;
    background: linear-gradient(90deg, #2980b9, #6cb2f7);
    transition: width 0.1s ease-out;
}

#rdmc-back-to-top {
    position: fixed;
    bottom: 72px;
    right: 18px;
    z-index: 10000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #fff;
    color: #404040;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

#rdmc-back-to-top.rdmc-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#rdmc-back-to-top:hover {
    transform: scale(1.1);
}

html[data-theme="dark"] #rdmc-back-to-top {
    background: #2d2d2d;
    color: #d6d8da;
    border-color: rgba(255, 255, 255, 0.2);
}

.rst-content .headerlink {
    opacity: 0;
    margin-left: 6px;
    text-decoration: none;
    transition: opacity 0.15s ease-in-out;
}

.rst-content h1:hover .headerlink,
.rst-content h2:hover .headerlink,
.rst-content h3:hover .headerlink,
.rst-content h4:hover .headerlink,
.rst-content h5:hover .headerlink,
.rst-content h6:hover .headerlink,
.rst-content dt:hover .headerlink,
.rst-content p.caption:hover .headerlink {
    opacity: 1;
}

.rdmc-anchor-tooltip {
    position: absolute;
    background: #27ae60;
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10002;
    pointer-events: none;
}

.rst-content img.zoomable {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    padding: 4px;
    background: #fff;
    margin-bottom: 12px;
}

html[data-theme="dark"] .rst-content img.zoomable {
    border-color: rgba(255, 255, 255, 0.15);
    background: #22262a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.rdmc-feedback {
    margin: 48px 0 8px;
    padding: 18px 22px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    background: #f8f9fa;
    text-align: center;
}

html[data-theme="dark"] .rdmc-feedback {
    background: #22262a;
    border-color: #3c4248;
}

.rdmc-feedback__question {
    font-weight: 600;
    margin-bottom: 10px;
}

.rdmc-feedback button {
    margin: 0 8px;
    padding: 8px 20px;
    font-size: 15px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #fff;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
}

.rdmc-feedback button:hover {
    transform: scale(1.08);
}

html[data-theme="dark"] .rdmc-feedback button {
    background: #2d2d2d;
    color: #d6d8da;
    border-color: rgba(255, 255, 255, 0.2);
}

.rdmc-feedback__thanks {
    color: #27ae60;
    font-weight: 600;
}

#rdmc-sidebar-links {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 6px 0 10px;
}

#rdmc-sidebar-logo {
    display: block;
    text-align: center;
    margin-bottom: 6px;
}

#rdmc-sidebar-links a {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff !important;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 14px;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s;
}

#rdmc-sidebar-links a:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.rdmc-steps {
    counter-reset: rdmc-step;
    margin: 20px 0 28px;
    padding: 0;
    list-style: none !important;
}

.rdmc-steps > li {
    counter-increment: rdmc-step;
    position: relative;
    list-style: none !important;
    margin: 0 0 14px 0 !important;
    padding: 14px 18px 14px 64px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .rdmc-steps > li {
    background: #22262a;
    border-color: #3c4248;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.rdmc-steps > li::before {
    content: counter(rdmc-step);
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2980b9;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

html[data-theme="dark"] .rdmc-steps > li::before {
    background: #6cb2f7;
    color: #1a1c1e;
}

.rdmc-steps > li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 31px;
    bottom: -15px;
    width: 2px;
    height: 15px;
    background: rgba(41, 128, 185, 0.4);
}

.rdmc-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10001;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    transition: background 0.15s;
}

.rdmc-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.35);
}

#rdmc-lightbox-prev { left: 18px; }
#rdmc-lightbox-next { right: 18px; }

#rdmc-lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 14px;
    border-radius: 14px;
}

.rst-content .mermaid {
    cursor: zoom-in;
}

#rdmc-mermaid-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10001;
    overflow: auto;
    cursor: zoom-out;
}

/* Reading time badge */
.rdmc-reading-time {
    display: inline-block;
    margin: 8px 0 16px;
    padding: 4px 12px;
    font-size: 12px;
    color: #555;
    background: rgba(41, 128, 185, 0.08);
    border: 1px solid rgba(41, 128, 185, 0.25);
    border-radius: 14px;
}
html[data-theme="dark"] .rdmc-reading-time {
    color: #c9ccd0;
    background: rgba(108, 178, 247, 0.12);
    border-color: rgba(108, 178, 247, 0.3);
}

/* Collapsible code blocks */
.rdmc-code-collapsible {
    position: relative;
}
.rdmc-code-collapsible.rdmc-collapsed .highlight,
.rdmc-code-collapsible.rdmc-collapsed pre.literal-block {
    max-height: 320px;
    overflow: hidden;
}
.rdmc-code-collapsible.rdmc-collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 34px;
    height: 60px;
    background: linear-gradient(transparent, #f8f8f8);
    pointer-events: none;
}
html[data-theme="dark"] .rdmc-code-collapsible.rdmc-collapsed::after {
    background: linear-gradient(transparent, #1e2124);
}
.rdmc-code-toggle {
    display: block;
    margin: 6px auto 14px;
    padding: 4px 14px;
    font-size: 12px;
    border-radius: 14px;
    border: 1px solid rgba(41, 128, 185, 0.4);
    background: transparent;
    color: #2980b9;
    cursor: pointer;
}
html[data-theme="dark"] .rdmc-code-toggle {
    color: #6cb2f7;
    border-color: rgba(108, 178, 247, 0.5);
}

/* TOC scroll-spy */
.rdmc-toc-active {
    font-weight: 700 !important;
    color: #2980b9 !important;
}
html[data-theme="dark"] .rdmc-toc-active {
    color: #6cb2f7 !important;
}

/* Copy toast */
.rdmc-copy-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #27ae60;
    color: #fff;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10002;
}
.rdmc-copy-toast.rdmc-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Search highlight (dark mode) */
html[data-theme="dark"] .highlighted {
    background: #b58900 !important;
    color: #1a1c1e !important;
    padding: 0 2px;
    border-radius: 3px;
}

/* Print stylesheet */
@media print {
    #rdmc-progress-bar,
    #rdmc-back-to-top,
    #rdmc-theme-toggle,
    #rdmc-translate-toggle,
    #rdmc-chat-toggle,
    #rdmc-chat-panel,
    .wy-nav-side,
    .wy-side-nav-search,
    .rst-footer-buttons,
    .rdmc-feedback {
        display: none !important;
    }
    body {
        transform: none !important;
        text-align: left !important;
    }
    .wy-nav-content {
        margin-left: 0 !important;
    }
    .rst-content {
        max-width: 100% !important;
    }
    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #555;
    }
    a[href^="#"]::after,
    a.headerlink::after {
        content: "";
    }
    details, .sd-dropdown {
        display: block !important;
    }
    .rdmc-code-collapsible.rdmc-collapsed .highlight,
    .rdmc-code-collapsible.rdmc-collapsed pre.literal-block {
        max-height: none !important;
        overflow: visible !important;
    }
}



/* Dark-mode code theme overrides */
html[data-theme="dark"] .highlight,
html[data-theme="dark"] pre {
    background: #1e2124 !important;
    color: #d6d8da;
}
html[data-theme="dark"] .highlight .hll {
    background: #3a3f45;
}
html[data-theme="dark"] .highlight .c,
html[data-theme="dark"] .highlight .cm,
html[data-theme="dark"] .highlight .c1 {
    color: #8b949e;
    font-style: italic;
}
html[data-theme="dark"] .highlight .k,
html[data-theme="dark"] .highlight .kc,
html[data-theme="dark"] .highlight .kd,
html[data-theme="dark"] .highlight .kn {
    color: #ff7b72;
}
html[data-theme="dark"] .highlight .s,
html[data-theme="dark"] .highlight .s1,
html[data-theme="dark"] .highlight .s2,
html[data-theme="dark"] .highlight .sb {
    color: #a5d6ff;
}
html[data-theme="dark"] .highlight .n,
html[data-theme="dark"] .highlight .na {
    color: #d6d8da;
}
html[data-theme="dark"] .highlight .mi,
html[data-theme="dark"] .highlight .mf {
    color: #79c0ff;
}
html[data-theme="dark"] .highlight .o,
html[data-theme="dark"] .highlight .ow {
    color: #ff7b72;
}
html[data-theme="dark"] .highlight .nf,
html[data-theme="dark"] .highlight .fm {
    color: #d2a8ff;
}
html[data-theme="dark"] .highlight .nb {
    color: #79c0ff;
}
#rdmc-mermaid-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10001;
    overflow: auto;
    cursor: zoom-out;
}
#rdmc-mermaid-overlay svg {
    display: block;
    margin: auto;
    max-width: 92vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out;
    transform-origin: center center;
}

.rdmc-related-pages {
    margin-top: 32px;
    padding: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.rdmc-related-pages h3 {
    margin-top: 0;
}
html[data-theme="dark"] .rdmc-related-pages {
    border-top-color: #3c4248;
}
