:root {
    --primary: #f5a623;
    --primary-rgb: 245, 166, 35;
    --background: #000000;
    --surface: #0a0a0a;
    --surface-light: #111111;
    --border: #222222;
    --text: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --nav-height: 64px;
    --sidebar-width: 260px;
    --toc-width: 240px;
    --radius: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
}

.nav-center {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
}

.search-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.search-trigger:hover {
    border-color: var(--text-muted);
}

.search-shortcut {
    margin-left: auto;
    padding: 0.125rem 0.375rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

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

.nav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius);
    margin-left: 0.75rem;
}

.nav-mobile-toggle svg {
    width: 20px;
    height: 20px;
}

.nav-mobile-toggle:hover {
    background: var(--surface-light);
    color: var(--text);
}

/* Main Layout */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
    max-width: 1920px;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 6rem;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    height: calc(100vh - var(--nav-height) - 2rem);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 2rem 1rem 4rem 1rem;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, and Opera */
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-group {
    margin-bottom: 1rem;
}

.sidebar-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: var(--transition);
    margin-bottom: 0.25rem;
}

.sidebar-item:hover {
    background: var(--surface-light);
    color: var(--text);
}

.sidebar-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    font-weight: 500;
}

.sidebar-item-new {
    background: var(--primary);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    margin-left: auto;
}

/* Content Area */
.content-area {
    padding: 3rem;
    max-width: 900px;
    margin: 0 auto;
}

.section-hidden {
    display: none;
}

.docs-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.docs-pagination-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.docs-pagination-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.docs-pagination-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.docs-pagination-buttons {
    display: flex;
    gap: 0.75rem;
}

.docs-pagination-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.docs-pagination-button:hover:not(.disabled) {
    border-color: var(--text-muted);
    color: var(--text);
}

.docs-pagination-button.disabled {
    opacity: 0.4;
    cursor: default;
}

.section {
    margin-bottom: 5rem;
    scroll-margin-top: 100px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* Info Box / TL;DR */
.info-box {
    background: rgba(59, 130, 246, 0.1);
    border-left: 2px solid #3b82f6;
    padding: 1.25rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 2rem 0;
    display: flex;
    gap: 1rem;
}

.info-box-icon {
    color: #3b82f6;
    flex-shrink: 0;
}

.info-box-content {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Feature Cards */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.feature-card {
    background: var(--surface-light);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
    transition: var(--transition);
}

.feature-card:hover {
    border-color: var(--text-muted);
}

.feature-card-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.feature-card-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.feature-card-arrow {
    margin-top: 1rem;
    align-self: flex-end;
    color: var(--text-muted);
}

/* TOC Sidebar */
.toc-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    height: calc(100vh - var(--nav-height) - 2rem);
    padding: 2rem 1rem 4rem 1rem;
    border-left: 1px solid var(--border);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

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

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

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

.toc-link.active {
    color: var(--text);
    border-left: 2px solid var(--primary);
    padding-left: 0.75rem;
}

/* Code Blocks */
.code-block-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 2rem 0;
    overflow: hidden;
}

.code-header {
    background: var(--surface-light);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.code-lang {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.copy-button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
}

.copy-button:hover {
    color: var(--text);
    background: var(--surface);
}

pre {
    margin: 0;
    padding: 1.5rem;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}

/* Parameter Tables */
.params-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.params-table th {
    background: var(--surface-light);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.params-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.params-table tr:last-child td {
    border-bottom: none;
}

.params-table code {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* Sidebar Collapsible */
.sidebar-group-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-in-out;
}

.sidebar-group.collapsed .sidebar-group-content {
    max-height: 0;
    opacity: 0;
}

.sidebar-group .chevron {
    transition: transform 0.3s ease;
}

.sidebar-group.collapsed .chevron {
    transform: rotate(-90deg);
}

/* Search Dialog */
.search-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-dialog.active {
    display: flex;
}

.search-dialog-content {
    width: 100%;
    max-width: 640px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: dialogAppear 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dialogAppear {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-dialog-header {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.search-dialog-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.125rem;
    outline: none;
}

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

.search-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem;
}

.search-placeholder {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-category-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 1rem 1rem 0.5rem 1rem;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
}

.search-result:hover {
    background: var(--surface-light);
    color: var(--text);
}

.search-result-icon {
    width: 32px;
    height: 32px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-result:hover .search-result-icon {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.3);
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    background: var(--surface-light);
    border-radius: 4px;
    border: 1px solid var(--border);
}

mark {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 1200px) {
    .app-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
        padding-bottom: 5rem;
    }

    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        padding-bottom: 4rem;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        bottom: 0;
        width: min(80%, 320px);
        max-width: 100%;
        background: var(--surface);
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.2s ease-out;
        z-index: 1500;
        padding: 1.5rem 1rem 2.5rem 1rem;
        height: auto;
    }

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

    .nav-center {
        display: flex;
        justify-content: flex-end;
        max-width: none;
        margin: 0 0.25rem 0 auto;
    }

    .nav-mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    .nav-links a {
        display: none;
    }

    .search-trigger {
        width: auto;
        padding: 0.35rem 0.45rem;
        background: transparent;
        border: none;
        border-radius: 999px;
    }

    .search-trigger span {
        display: none;
    }

    .content-area {
        padding: 1.25rem 1rem 2.5rem;
    }

    .docs-pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-top: 2.5rem;
        padding-top: 1.5rem;
    }

    .docs-pagination-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .docs-pagination-button {
        flex: 1;
        justify-content: center;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .section {
        margin-bottom: 3rem;
    }

    .params-table th,
    .params-table td {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    pre {
        padding: 1rem;
        font-size: 0.8rem;
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
        word-break: break-word;
    }

    .search-dialog {
        padding: 0;
    }

    .search-dialog-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}
