:root {
    /* Colors - matching main website */
    --bg: #09090b;
    --bg-elevated: #18181b;
    --bg-card: #1c1c21;
    --bg-hover: #27272a;
    
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-glow: rgba(129, 140, 248, 0.15);
    
    --border: #27272a;
    --border-light: #3f3f46;
    
    --code-bg: #18181b;
    --code-border: #27272a;
    --success: #4ade80;
    
    --header-height: 72px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
}

/* ==========================================
   RESET & BASE
   ========================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a { 
    color: inherit; 
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { 
    color: var(--accent); 
}

/* ==========================================
   HEADER
   ========================================== */
.docs-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-inner--narrow {
    max-width: 900px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.125rem;
}

.brand:hover { 
    color: var(--text); 
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.version-pill {
    background: var(--accent-glow);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.version-banner {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(251, 146, 60, 0.35);
    color: #fb923c;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-form input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    width: min(280px, 40vw);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-form input::placeholder {
    color: var(--text-muted);
}

.version-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    cursor: pointer;
}

.home-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: all var(--transition-base);
}

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

/* Mobile menu toggle */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   SHELL / CONTAINER
   ========================================== */
.shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 3vw, 2rem) 4rem;
}

.shell--narrow {
    max-width: 900px;
}

.docs-shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 3vw, 2rem) 4rem;
}

/* ==========================================
   DOCS LAYOUT (3-column)
   ========================================== */
.docs-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 220px;
    gap: 2rem;
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-height) - 3rem);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.section-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0 0.25rem;
}

.section-tab {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all var(--transition-base);
}

.section-tab.active {
    color: var(--text);
    border-color: rgba(129, 140, 248, 0.4);
    background: var(--accent-glow);
}

.category-block {
    margin-bottom: 1.75rem;
}

.sidebar h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
    font-weight: 600;
}

.sidebar ul {
    list-style: none;
}

.sidebar li a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.sidebar li a:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.sidebar li a.active {
    color: var(--text);
    background: var(--accent-glow);
    border-color: rgba(129, 140, 248, 0.25);
}

/* ==========================================
   CARDS
   ========================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(129, 140, 248, 0.1);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.card .cta {
    color: var(--accent);
    font-weight: 600;
    margin-top: auto;
    padding-top: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: gap var(--transition-fast);
}

.card:hover .cta {
    gap: 0.5rem;
}

/* ==========================================
   ARTICLE
   ========================================== */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 3vw, 2.5rem);
}

.article-header {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.article-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.article-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 65ch;
    line-height: 1.6;
}

.meta {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ==========================================
   CONTENT (Article body)
   ========================================== */
.content {
    font-size: 0.95rem;
}

.content h2 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    scroll-margin-top: 100px;
    position: relative;
    padding-bottom: 0.5rem;
}

.content pre .copy-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.content pre .copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.content pre code {
    display: block;
}

.content pre .code-line {
    display: block;
    padding-left: 3.5rem;
    position: relative;
    white-space: pre;
}

.content pre .code-line::before {
    content: attr(data-line);
    position: absolute;
    left: 0;
    width: 3rem;
    text-align: right;
    color: var(--text-muted);
    opacity: 0.6;
}

.content pre .code-line:target {
    background: var(--accent-glow);
    border-radius: 4px;
}

.content h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    scroll-margin-top: 100px;
}

.content h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.content p {
    margin: 1rem 0;
    color: var(--text-secondary);
    line-height: 1.75;
}

.content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(129, 140, 248, 0.4);
    text-underline-offset: 2px;
}

.content a:hover {
    text-decoration-color: var(--accent);
}

.content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.85rem;
    line-height: 1.7;
}

.content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.content code {
    background: var(--bg-hover);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: #c4b5fd;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.9rem;
}

.content table th {
    background: var(--code-bg);
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.content table th,
.content table td {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
}

.content table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.content blockquote {
    border-left: 3px solid var(--accent);
    background: var(--accent-glow);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.content blockquote p {
    color: var(--text-secondary);
    margin: 0;
}

.content ul, .content ol { 
    margin: 1rem 0 1rem 1.25rem;
    color: var(--text-secondary);
}

.content li { 
    margin: 0.5rem 0;
    padding-left: 0.25rem;
}

.content li::marker {
    color: var(--accent);
}

.content img {
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin: 1.5rem 0;
}

.content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* ==========================================
   TOC PANEL
   ========================================== */
.toc-panel {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    align-self: start;
    max-height: calc(100vh - var(--header-height) - 3rem);
    overflow-y: auto;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.toc-panel h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.toc-panel ul { 
    list-style: none;
}

.toc-panel li {
    margin-bottom: 0.5rem;
}

.toc-panel a {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    padding: 0.25rem 0;
    transition: color var(--transition-fast);
}

.toc-panel a:hover { 
    color: var(--accent); 
}

.toc-panel li[data-level="3"] {
    margin-left: 0.75rem;
}

.toc-panel li[data-level="3"] a {
    font-size: 0.75rem;
}

/* ==========================================
   NAV LINKS (Prev/Next)
   ========================================== */
.nav-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding-top: 2rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
}

.nav-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    transition: all var(--transition-base);
}

.nav-card:hover {
    border-color: rgba(129, 140, 248, 0.4);
    transform: translateY(-2px);
}

.nav-card span {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.nav-card strong {
    color: var(--text);
    font-weight: 600;
}

/* ==========================================
   SEARCH PAGE
   ========================================== */
.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 3vw, 2.5rem);
}

.search-card h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.search-box {
    margin-bottom: 2rem;
}

.search-input-wrap {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-input-wrap input {
    flex: 1;
    min-width: 200px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1.25rem;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font-sans);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input-wrap input::placeholder {
    color: var(--text-muted);
}

.search-input-wrap select {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    cursor: pointer;
}

.search-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    padding: 0.875rem 1.5rem;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-base), transform var(--transition-base);
}

.search-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.results-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.results-meta strong {
    color: var(--text);
}

/* Results list */
.results {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    transition: all var(--transition-base);
}

.result-item:hover {
    border-color: rgba(129, 140, 248, 0.4);
    transform: translateY(-2px);
}

.result-item h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-item h2 a {
    color: var(--accent);
}

.result-item h2 a:hover {
    text-decoration: underline;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.result-meta .category-tag {
    background: var(--accent-glow);
    border: 1px solid rgba(129, 140, 248, 0.25);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent);
}

.result-item p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Empty states */
.no-results,
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.no-results svg,
.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--border);
    margin-bottom: 1rem;
}

.empty-state svg {
    width: 56px;
    height: 56px;
    stroke: var(--accent);
    opacity: 0.6;
}

.no-results p {
    margin-bottom: 0.5rem;
}

/* ==========================================
   INDEX PAGE (Hero + Grid)
   ========================================== */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

/* ==========================================
   MOBILE SIDEBAR
   ========================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 89;
}

.sidebar-overlay.open {
    display: block;
}

.mobile-search {
    display: none;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.mobile-search input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-sans);
}

.mobile-version {
    margin-top: 0.75rem;
}

.mobile-version select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-sans);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1200px) {
    .docs-layout {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .toc-panel {
        display: none;
    }
}

@media (max-width: 900px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .header-actions .search-form,
    .header-actions .version-select,
    .header-actions .home-link {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        max-height: none;
        background: var(--bg);
        padding: 1.5rem;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-search {
        display: block;
    }

    .nav-links {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .shell {
        padding: 2.5rem 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .docs-shell,
    .shell--narrow {
        padding: 1.5rem 1rem 3rem;
    }

    .article-card,
    .search-card {
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    .article-header h1 {
        font-size: 1.5rem;
    }

    .search-card h1 {
        font-size: 1.5rem;
    }

    .content h2 {
        font-size: 1.25rem;
    }

    .content h3 {
        font-size: 1.05rem;
    }

    .content pre {
        padding: 1rem;
        font-size: 0.8rem;
        border-radius: var(--radius-sm);
    }

    .nav-card {
        padding: 0.875rem 1rem;
    }

    .search-input-wrap {
        flex-direction: column;
    }

    .search-input-wrap input,
    .search-input-wrap select {
        width: 100%;
    }

    .result-item {
        padding: 1rem;
    }

    .result-item h2 {
        font-size: 1rem;
    }
}
