/* =========================================
   1. VARIABLES & BASE SETUP
   ========================================= */
:root {
    --primary: #ed2b34; 
    --primary-hover: #c81e25;
    --primary-btn: #dc2626;
    --primary-btn-hover: #b91c1c;
    --surface: rgba(35, 39, 50, 0.75);
    --surface-alt: rgba(25, 28, 37, 0.85);
    --text: #F8FAFC;
    --text-muted: #9BA3AF;
    --border: rgba(255, 255, 255, 0.1);
}

html {
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; padding: 0; background-color: #161922;
    background-image: radial-gradient(ellipse at top, #363C4F 0%, #161922 80%);
    background-attachment: fixed; color: var(--text); min-height: 100vh;
}

body.no-scroll {
    overflow: hidden;
}

/* =========================================
   2. LAYOUT CONTAINERS
   ========================================= */
.container { max-width: 1400px; margin: 2rem auto; padding: 0 2rem; }

/* =========================================
   3. TYPOGRAPHY, BUTTONS & FORMS
   ========================================= */
.btn {
    background: var(--primary-btn); color: white; border: 1px solid transparent; padding: 0.65rem 1rem;
    border-radius: 6px; cursor: pointer; font-size: 0.95rem; width: 100%; box-sizing: border-box;
    transition: all 0.2s; font-weight: 600; text-align: center; text-decoration: none; display: inline-block;
}
.btn:hover:not(:disabled) { background: var(--primary-btn-hover); }
.btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; border-color: transparent; }

.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); font-size: 0.95rem; font-weight: 600; }
.btn-outline:hover:not(:disabled) { background: rgba(237, 43, 52, 0.1); }
.btn-outline:disabled { border-color: var(--border); color: var(--text-muted); }

/* Accessibility & Keyboard Navigation Focus Indicator */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.75rem; border-radius: 4px; border: 1px solid var(--border);
    background: rgba(0,0,0,0.2); color: var(--text); font-family: inherit; box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group select option { background: #1E212B; color: var(--text); }
select { color-scheme: dark; cursor: pointer; outline: none; }
textarea { resize: vertical; }
input[type="checkbox"] { accent-color: var(--primary); width: 1.25rem; height: 1.25rem; cursor: pointer; margin: 0; }

.form-row { display: flex; gap: 1rem; }
.form-row > .form-group { flex: 1; }

.nobr { white-space: nowrap; }

/* Fix for browser autofill on dark background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0px 1000px rgba(0,0,0,0.2) inset;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: var(--text);
    color-scheme: dark;
}

/* =========================================
   4. HEADER, FOOTER & MODALS
   ========================================= */
header, .portal-header {
    background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    width: 100%;
}
.header-content {
    max-width: none; width: 100%; margin: 0; padding: 0.85rem 2rem; min-height: 68px;
    display: flex; justify-content: space-between; align-items: center; box-sizing: border-box;
}
.logo-container {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
    color: inherit;
}
.logo-container:hover, .logo-container:focus, .logo-container:active {
    text-decoration: none !important;
    color: inherit;
}
.logo-container img {
    height: 38px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}
.logo-container span {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-muted);
    border-left: 1px solid var(--border);
    padding-left: 12px;
    line-height: 1;
    text-decoration: none !important;
    display: inline-block;
}
header a {
    text-decoration: none;
}
header h1 { margin: 0; font-size: 1.5rem; color: var(--text); }
header h1 span { color: var(--primary); }

.header-controls { display: flex; align-items: center; gap: 1.5rem; }

.portal-nav-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}
.portal-nav-link:hover {
    color: var(--text);
}
.portal-nav-link svg {
    opacity: 0.7;
    transition: opacity 0.2s;
}
.portal-nav-link:hover svg {
    opacity: 1;
}

/* Circular Header Button */
.cart-icon-btn {
    position: relative;
    background: transparent;
    color: var(--text);
    border: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    text-decoration: none;
}
.cart-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.cart-icon-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-menu-btn {
    display: none;
    position: relative;
    background: transparent;
    color: var(--text);
    border: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}
.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.header-back-link {
    color: var(--text-muted); text-decoration: none; font-size: 0.95rem; font-weight: 500;
    transition: color 0.2s, background-color 0.2s; display: inline-flex; align-items: center; gap: 0.4rem;
}
.header-back-link:hover { color: var(--text); }

/* Site Footer */
.site-footer {
    width: 100%;
    margin-top: 0;
    padding: 3.5rem 2rem 2.5rem 2rem;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 0.9rem;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
}
.footer-container { max-width: 1400px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; align-items: center; }
.footer-col p { margin: 0 0 0.5rem 0; line-height: 1.6; }
.footer-col h4 { margin: 0 0 1rem 0; color: var(--text); font-size: 1rem; }
.footer-col a { color: inherit; text-decoration: none; transition: color 0.2s; display: inline-block; padding: 0.25rem 0; min-height: 24px; box-sizing: border-box; }
.footer-col a:hover { color: var(--primary); }
.footer-middle { display: flex; justify-content: center; opacity: 0.6; transition: opacity 0.2s; }
.footer-middle:hover { opacity: 1; }
.footer-container > .footer-col:last-of-type { text-align: justify; }
.footer-bottom {
    max-width: 1400px; margin: 2rem auto 0 auto; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.05);
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; font-size: 0.85rem;
}
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: inherit; text-decoration: none; transition: color 0.2s; display: inline-block; padding: 0.25rem 0; min-height: 24px; box-sizing: border-box; }
.footer-links a:hover { color: var(--primary); }

/* Cookie Banner */
.cookie-banner {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: rgba(20, 22, 28, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border); padding: 1.5rem 2rem; box-sizing: border-box;
    display: flex; justify-content: space-between; align-items: center; gap: 2rem;
    z-index: 9999; transform: translateY(100%); transition: transform 0.4s ease-in-out; box-shadow: 0 -4px 25px rgba(0,0,0,0.5);
}
.cookie-banner.show { transform: translateY(0); }
.cookie-banner p { margin: 0; font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.cookie-banner a { color: var(--text); text-decoration: underline; }
.cookie-banner a:hover { color: var(--primary); }
.cookie-banner .btn { width: auto; padding: 0.6rem 2rem; margin: 0; white-space: nowrap; font-size: 1rem; }

/* =========================================
   5. DOCUMENTATION / WIKI LAYOUT (GitHub Docs Style)
   ========================================= */
html {
    scroll-behavior: smooth;
}

/* Sticky Sub-Navigation Bar (Sidebar Toggle & Breadcrumbs) */
.doc-subnav-sticky {
    position: sticky;
    top: 68px;
    z-index: 90;
    background: rgba(20, 23, 31, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    height: 44px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.doc-subnav-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    scrollbar-width: none;
}
.doc-subnav-container::-webkit-scrollbar {
    display: none;
}

.subnav-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.subnav-toggle-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}
body.sidebar-collapsed .subnav-toggle-btn {
    background: rgba(237, 43, 52, 0.15);
    border-color: rgba(237, 43, 52, 0.4);
    color: var(--text);
}

.subnav-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex-shrink: 0;
}

/* GitHub Docs Style Breadcrumbs inside Sticky Subnav */
.doc-breadcrumb {
    display: flex;
    align-items: center;
    min-width: 0;
}
.breadcrumb-list {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 0.45rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.82rem;
}
.breadcrumb-item {
    display: inline-flex;
    align-items: center;
}
.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s ease;
}
.breadcrumb-item a:hover {
    color: var(--primary);
}
.breadcrumb-item a svg {
    opacity: 0.7;
}
.breadcrumb-category {
    color: var(--text-muted);
}
.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.2);
    user-select: none;
}
.breadcrumb-item.current span {
    color: var(--text);
    font-weight: 600;
}

.doc-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    min-height: calc(100vh - 112px);
    box-sizing: border-box;
    position: relative;
}

/* Left Navigation Sidebar - Pinned at 112px */
.doc-sidebar {
    background: rgba(20, 23, 31, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    border-top: none;
    border-left: none;
    border-bottom: none;
    border-radius: 0;
    padding: 1.35rem 1rem 3rem 1.25rem;
    align-self: start;
    position: sticky;
    top: 112px;
    width: 306px;
    min-width: 306px;
    max-width: 306px;
    height: calc(100vh - 112px);
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: margin-left 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

body.sidebar-collapsed .doc-sidebar {
    margin-left: -306px;
    opacity: 0;
    pointer-events: none;
}

/* Sleek Minimalist Scrollbar for Sidebar */
.doc-sidebar::-webkit-scrollbar {
    width: 4px;
}
.doc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.doc-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    transition: background 0.2s ease;
}
.doc-sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
}
.doc-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Sidebar Header & Collapse Toggle */
.doc-sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.doc-sidebar-header .doc-search-box {
    flex: 1;
    min-width: 0;
}
.sidebar-collapse-btn {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.sidebar-collapse-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Sidebar Search Box */
.doc-search-box {
    position: relative;
    width: 100%;
}
.doc-search-box input {
    width: 100%;
    padding: 0.6rem 2rem 0.6rem 2.1rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.2s;
}
.doc-search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.45);
}
.doc-search-box > svg,
.doc-search-box .doc-search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.doc-search-clear {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.doc-search-clear:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}
.doc-nav-empty {
    padding: 1rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

/* Segmented Hardware Standard Filter */
.doc-filter-segmented {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-sizing: border-box;
}

.filter-segment-btn {
    flex: 1 1 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.48rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    line-height: 1.2;
}

.filter-segment-btn[data-tag="all"] {
    flex: 0 0 auto;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
}

.filter-segment-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.filter-segment-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(237, 43, 52, 0.3);
}

/* Sidebar Sections */
.doc-nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.doc-nav-title {
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--primary);
    margin: 0.35rem 0 0.15rem 0.5rem;
}
.doc-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.doc-nav-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.48rem 0.65rem 0.48rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1.35;
    border-left: 3px solid transparent;
    border-radius: 6px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.doc-nav-item a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}
.doc-nav-item a.active {
    color: #ffffff;
    background: rgba(237, 43, 52, 0.16);
    border-left-color: var(--primary);
}

/* Center Main Content Wrapper (Centers the article & holds footer) */
.doc-main-wrapper {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding: 0;
}

/* Main Content Area */
.doc-content {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2.25rem 2rem 4rem 2rem;
    box-sizing: border-box;
    box-shadow: none;
    position: relative;
    min-width: 0;
    max-width: 880px;
    width: 100%;
    overflow-x: clip;
    margin: 0 auto;
}

/* Right Column: In this article (Table of Contents) & Symmetry Spacer */
.doc-toc-aside {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    flex-shrink: 0;
    align-self: start;
    position: sticky;
    top: 112px;
    height: calc(100vh - 112px);
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2.25rem 1.25rem 3rem 1rem;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}
.doc-toc-aside::-webkit-scrollbar {
    width: 3px;
}
.doc-toc-aside::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
}

/* Spacer for pages without TOC (Prevents horizontal layout shifts) */
.doc-toc-empty {
    border-left: 1px solid transparent;
    background: transparent;
    visibility: hidden;
    pointer-events: none;
}

.doc-toc-sticky {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.doc-toc-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-muted);
    padding-left: 0.75rem;
    margin-bottom: 0.25rem;
}
.doc-toc-header svg {
    opacity: 0.7;
}
.doc-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}
.doc-toc-list .toc-item a {
    display: block;
    padding: 0.35rem 0.6rem 0.35rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    line-height: 1.4;
    border-left: 2px solid transparent;
    margin-left: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-toc-list .toc-item.toc-h3 a {
    padding-left: 1.35rem;
    font-size: 0.78rem;
    color: rgba(148, 163, 184, 0.8);
}
.doc-toc-list .toc-item a:hover {
    color: var(--text);
    border-left-color: rgba(255, 255, 255, 0.3);
}
.doc-toc-list .toc-item a.active {
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
    background: rgba(237, 43, 52, 0.04);
}

/* GitHub Docs Style "Next Steps" / Related Articles Section */
.doc-next-steps {
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.doc-next-steps-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
    margin-bottom: 1.25rem;
}
.doc-next-steps-title svg {
    color: var(--primary);
}
.doc-next-steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}
.doc-next-step-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    gap: 1rem;
}
.doc-next-step-card:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(35, 39, 50, 0.95);
    transform: translateY(-1px);
    text-decoration: none;
}
.doc-next-step-card:hover .next-step-title {
    color: var(--primary);
}
.next-step-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.next-step-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}
.next-step-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    transition: color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.next-step-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}
.doc-next-step-card:hover .next-step-arrow {
    color: var(--primary);
    transform: translateX(3px);
}

/* Download File Cards inside Documentation */
.doc-download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    margin: 1.35rem 0 1.75rem 0;
}
.doc-content a.doc-download-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.15rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    gap: 0.85rem;
}
.doc-content a.doc-download-card:hover {
    border-color: rgba(237, 43, 52, 0.45);
    background: rgba(35, 39, 50, 0.95);
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.doc-download-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.doc-download-meta {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}
.doc-download-name {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    transition: color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-content a.doc-download-card:hover .doc-download-name {
    color: var(--primary);
}
.doc-download-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.doc-content a.doc-download-card:hover .doc-download-icon {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

/* Content Typography & Heading Scroll Margins */
.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5,
.doc-content h6 {
    scroll-margin-top: 130px;
}

/* Content Typography */
.doc-content h1 {
    font-size: 2.3rem;
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: #ffffff;
    font-weight: 700;
    line-height: 1.2;
}
.doc-content h2 {
    font-size: 1.5rem;
    margin-top: 2.75rem;
    margin-bottom: 1rem;
    color: #ffffff;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.6rem;
    font-weight: 600;
}
.doc-content h3 {
    font-size: 1.18rem;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    color: #ffffff;
    font-weight: 600;
}
.doc-content p {
    line-height: 1.75;
    color: #CBD5E1;
    margin-bottom: 1.25rem;
    font-size: 1.02rem;
    max-width: 860px;
}
.doc-content ul, .doc-content ol {
    max-width: 860px;
    line-height: 1.7;
}
.doc-content a:not(.doc-next-step-card):not(.doc-download-card):not(.heading-anchor) {
    color: #f1f5f9;
    text-decoration: underline;
    text-decoration-color: rgba(237, 43, 52, 0.55);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.doc-content a:not(.doc-next-step-card):not(.doc-download-card):not(.heading-anchor):hover {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: var(--primary);
}
body[data-page="home"] .doc-content div > ul a {
    color: #e2e8f0;
    text-decoration: none;
}
body[data-page="home"] .doc-content div > ul a:hover {
    color: var(--primary);
    text-decoration: none;
}

.doc-content ul, .doc-content ol {
    line-height: 1.75;
    color: #CBD5E1;
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}
.doc-content li {
    margin-bottom: 0.5rem;
}

/* Code & Syntax */
.doc-content code {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.88em;
    color: #f87171;
}

.doc-content pre {
    background: #0b0d13;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
    position: relative;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.doc-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: #f1f5f9;
    font-size: 0.92rem;
    line-height: 1.6;
    display: block;
    min-width: 0;
}

/* Code Copy Button */
.doc-code-copy-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 5;
    opacity: 0.6;
    backdrop-filter: blur(4px);
    user-select: none;
}

.doc-content pre:hover .doc-code-copy-btn {
    opacity: 1;
}

.doc-code-copy-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.25);
}

.doc-code-copy-btn.copied {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.4);
    background: rgba(52, 211, 153, 0.1);
    opacity: 1;
}

/* Interactive Tabs Component */
.doc-tabs {
    margin: 1.75rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.doc-tabs-header {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 0 0.5rem;
    scrollbar-width: none;
}

.doc-tabs-header::-webkit-scrollbar {
    display: none;
}

.doc-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.75rem 1.15rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.doc-tab-btn:hover {
    color: var(--text);
}

.doc-tab-btn.active {
    color: #ffffff;
    border-bottom-color: var(--primary);
    background: rgba(255, 255, 255, 0.03);
}

.doc-tab-panel {
    display: none;
    padding: 1.5rem;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.doc-tab-panel.active {
    display: block;
}

.doc-tab-panel > :first-child {
    margin-top: 0;
}

.doc-tab-panel > :last-child {
    margin-bottom: 0;
}

/* Callouts / Alert Boxes */
.callout {
    border-radius: 8px;
    padding: 1.15rem 1.35rem;
    margin: 1.75rem 0;
    border-left: 4px solid;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    line-height: 1.6;
}
.callout-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}
.callout p {
    margin: 0;
    font-size: 0.95rem;
}
.callout-note {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    color: #e0f2fe;
}
.callout-note .callout-title { color: #38bdf8; }
.callout-tip {
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.08);
    color: #d1fae5;
}
.callout-tip .callout-title { color: #34d399; }
.callout-warning {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    color: #fef3c7;
}
.callout-warning .callout-title { color: #fbbf24; }
.callout-important {
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.08);
    color: #ede9fe;
}
.callout-important .callout-title { color: #a78bfa; }
.callout-caution {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.08);
    color: #fee2e2;
}
.callout-caution .callout-title { color: #f87171; }

/* Heading Permalink Anchor Icons */
.doc-content .heading-anchor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.45rem;
    color: var(--text-muted);
    opacity: 0;
    font-weight: 400;
    font-size: 0.85em;
    text-decoration: none !important;
    transition: opacity 0.15s ease, color 0.15s ease;
    vertical-align: middle;
    user-select: none;
}
.doc-content h2:hover .heading-anchor,
.doc-content h3:hover .heading-anchor,
.doc-content .heading-anchor:focus-visible {
    opacity: 0.65;
}
.doc-content .heading-anchor:hover {
    opacity: 1 !important;
    color: var(--primary) !important;
}
.doc-content .heading-anchor.copied {
    opacity: 1 !important;
    color: #34d399 !important;
}

/* Figures & Images + Lightbox */
.doc-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: zoom-in;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}
.doc-content img.img-transparent-bg,
.doc-lightbox-img.img-transparent-bg {
    background: rgba(15, 18, 26, 0.45);
    padding: 0.75rem;
}
.doc-content img:hover {
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.doc-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 12, 18, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    cursor: zoom-out;
}
.doc-lightbox-overlay.open {
    opacity: 1;
    visibility: visible;
}
.doc-lightbox-img {
    max-width: min(94vw, 1400px);
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    transform: scale(0.97);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    object-fit: contain;
}
.doc-lightbox-overlay.open .doc-lightbox-img {
    transform: scale(1);
}

/* Tables */
.doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.92rem;
}
.doc-content th, .doc-content td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    text-align: left;
}
.doc-content th {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    font-weight: 600;
}
.doc-content tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.15);
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 998;
}
.sidebar-overlay.open {
    display: block;
}

/* =========================================
   6. RESPONSIVE MEDIA QUERIES
   ========================================= */
@media (max-width: 768px) {
    /* Global Layout & Padding */
    .container { padding: 0 1rem; margin: 1.5rem auto; }
    
    /* Header - Scaled cleanly for mobile without colliding */
    .header-content { padding: 0.75rem 1rem; gap: 0.75rem; min-height: 60px; }
    .logo-container { gap: 8px; flex-shrink: 1; min-width: 0; min-height: auto; }
    .logo-container img { height: 26px; width: auto; } /* Mobile logo: 26px (Desktop remains 38px) */
    .logo-container span { font-size: 1.15rem; padding-left: 8px; white-space: nowrap; }
    .portal-nav-link { display: none; }
    .header-controls { flex-shrink: 0; margin-left: auto; gap: 0.75rem; }
    .cart-icon-btn { width: 38px; height: 38px; }
    .cart-icon-btn svg { width: 20px; height: 20px; }
    .mobile-menu-btn { display: inline-flex; width: 38px; height: 38px; }
    .mobile-menu-btn svg { width: 20px; height: 20px; }
    .header-back-link {
        font-size: 0.85rem; padding: 0.4rem 0.75rem; background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border); border-radius: 6px; white-space: nowrap; flex-shrink: 0;
    }

    /* Footer */
    .site-footer { margin-top: 0; padding: 2.5rem 1rem 1.5rem 1rem; }
    .footer-container { grid-template-columns: 1fr; text-align: center; gap: 1.5rem; }
    .footer-container > .footer-col:last-of-type { text-align: center; }
    .footer-bottom { flex-direction: column; text-align: center; gap: 1rem; }
    .footer-links { justify-content: center; gap: 1rem; }
    
    /* Cookie Banner */
    .cookie-banner { flex-direction: column; text-align: center; padding: 1.25rem 1rem; gap: 1rem; }
    .cookie-banner .btn { width: 100%; }

    /* Docs layout on mobile */
    .doc-container {
        flex-direction: column;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        width: 100%;
    }
    .doc-sidebar {
        position: fixed;
        top: 0;
        left: -320px;
        width: 300px;
        min-width: 300px;
        max-width: 300px;
        height: 100vh;
        max-height: 100vh;
        z-index: 999;
        border-radius: 0;
        border-top: none;
        border-left: none;
        border-bottom: none;
        border-right: 1px solid var(--border);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        padding-top: 2rem;
    }
    .doc-sidebar.open {
        left: 0;
    }
    .doc-main-wrapper {
        padding: 0;
    }
    .doc-content {
        padding: 1.75rem 1.25rem 3.5rem 1.25rem;
    }
    .doc-toc-aside {
        display: none !important;
    }
    .sidebar-expand-btn {
        display: none !important;
    }
}

@media (max-width: 1200px) {
    .doc-toc-aside {
        display: none !important;
    }
    .doc-main-wrapper {
        padding: 0;
    }
}

/* Scroll to Top Button (Minimalist & Clean) */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(19, 23, 31, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 850;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    outline: none;
}

.scroll-top-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(30, 36, 49, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.scroll-top-btn:active {
    transform: translateY(0);
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .scroll-top-btn {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 480px) {
    .header-content { padding: 0.75rem 0.85rem; gap: 0.5rem; }
    .logo-container img { height: 21px; } /* Proportional height for smartphones */
    .logo-container span { font-size: 0.95rem; padding-left: 6px; }
    .cart-icon-btn { width: 36px; height: 36px; }
    .cart-icon-btn svg { width: 19px; height: 19px; }
    .mobile-menu-btn { width: 36px; height: 36px; }
    .mobile-menu-btn svg { width: 19px; height: 19px; }
    .header-back-link { font-size: 0.8rem; padding: 0.35rem 0.6rem; }
    .doc-content { padding: 1.25rem; }
    .doc-content h1 { font-size: 1.6rem; }
    .doc-content h2 { font-size: 1.25rem; }
}

@media (max-width: 360px) {
    .logo-container img { height: 18px; }
    .logo-container span { display: none; } /* On extremely small screens (<=360px), hide sublabel */
    .cart-icon-btn { width: 34px; height: 34px; }
    .cart-icon-btn svg { width: 18px; height: 18px; }
    .mobile-menu-btn { width: 34px; height: 34px; }
    .mobile-menu-btn svg { width: 18px; height: 18px; }
    .header-back-link { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
}