:root {
    /* GitBook / OpenAI inspired Light Theme */
    --primary: #10a37f; /* OpenAI Green-ish */
    --primary-hover: #0d8a6a;
    --text-main: #2d3748;
    --text-heading: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --bg-body: #ffffff;
    --bg-sidebar: #f7f9fb;
    --border: #e2e8f0;
    --hover-bg: #edf2f7;

    /* Code Blocks */
    --code-bg: #1a202c;
    --code-text: #e2e8f0;
    --inline-code-bg: #edf2f7;
    --inline-code-text: #2d3748;

    /* Components */
    --card-bg: #ffffff;
    --table-head-bg: #f7f9fb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Dimensions */
    --sidebar-w: 280px;
    --header-h: 60px;
}

[data-theme="dark"] {
    /* Dark Theme */
    --primary: #10a37f;
    --primary-hover: #1abc9c;
    --text-main: #e2e8f0;
    --text-heading: #f7fafc;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --bg-body: #0f1117; /* Deep dark blue-black */
    --bg-sidebar: #0b0d11;
    --border: #2d3748;
    --hover-bg: #1a202c;

    /* Code Blocks */
    --code-bg: #0b0d11;
    --code-text: #e2e8f0;
    --inline-code-bg: #1a202c;
    --inline-code-text: #e2e8f0;

    /* Components */
    --card-bg: #151921;
    --table-head-bg: #151921;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    background: var(--bg-body);
    line-height: 1.6;
    font-size: 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* --- Layout --- */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
    z-index: 50;
}

.brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 32px; height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 18px;
}
.brand-name {
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}

.nav-scroll { overflow-y: auto; flex: 1; padding: 24px 16px; }

.nav-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    margin: 24px 0 8px 12px;
}
.nav-group-title:first-child { margin-top: 0; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: 0.1s;
    cursor: pointer;
    font-weight: 500;
}

.nav-link:hover { background: var(--hover-bg); color: var(--text-main); }
.nav-link.active {
    background: var(--bg-body);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .nav-link.active {
    background: #1f2937;
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}
.theme-toggle-btn:hover {
    background: var(--hover-bg);
    color: var(--primary);
    border-color: var(--primary);
}
.cloud-icon { fill: currentColor; }

/* Main Content */
.main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    position: relative;
    background: var(--bg-body);
}

.content-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 64px 40px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Pages */
.doc-page { display: none; animation: fadeIn 0.3s ease; }
.doc-page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Typography */
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 24px; line-height: 1.1; color: var(--text-heading); }
h2 { font-size: 1.75rem; font-weight: 700; margin: 48px 0 16px 0; letter-spacing: -0.02em; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--text-heading); }
h3 { font-size: 1.25rem; font-weight: 600; margin: 32px 0 16px 0; color: var(--text-heading); }
p { margin-bottom: 16px; color: var(--text-secondary); font-size: 1.05rem; }
.lead { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 40px; font-weight: 300; line-height: 1.6; }

.badge-pill {
    display: inline-block;
    background: var(--hover-bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 99px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

/* Endpoints */
.endpoint-block {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.endpoint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.method {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.method.post { background: rgba(16, 163, 127, 0.1); color: #10a37f; }
.method.get { background: rgba(37, 99, 235, 0.1); color: #2563eb; }
.path { color: var(--text-main); font-weight: 500; }
.url { color: var(--text-secondary); word-break: break-all; }

/* Features Grid (for limits etc) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 24px 0;
}
.feature-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: 0.2s;
}
.feature-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.feature-icon { font-size: 1.5rem; margin-bottom: 12px; }
.feature-card h4 { margin-bottom: 8px; font-weight: 600; color: var(--text-heading); }
.feature-card p { font-size: 0.9rem; margin: 0; }

.stat-value { display: block; font-size: 2rem; font-weight: 800; color: var(--text-heading); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Code Blocks */
.code-block {
    background: var(--code-bg);
    border-radius: 8px;
    margin: 24px 0;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 500;
}
pre { padding: 20px; overflow-x: auto; margin: 0; }
code { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--code-text); line-height: 1.5; }

.inline-code {
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    border: 1px solid var(--border);
}
.error-code { color: #ef4444; background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

.copy-btn, .copy-btn-mini {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #e2e8f0;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: 0.2s;
}
.copy-btn:hover { background: rgba(255,255,255,0.1); }
.copy-btn-mini { border-color: var(--border); color: var(--text-muted); padding: 4px; display: flex; }
.copy-btn-mini:hover { color: var(--primary); border-color: var(--primary); }

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 24px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th {
    background: var(--table-head-bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover-bg); }

/* Tags */
.tag {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
}
.tag.vision { background: rgba(67, 56, 202, 0.1); color: #6366f1; }
.tag.code { background: rgba(194, 65, 12, 0.1); color: #f97316; }
.tag.fast { background: rgba(21, 128, 61, 0.1); color: #22c55e; }
.tag.reasoning { background: rgba(124, 58, 237, 0.1); color: #8b5cf6; }

/* Callout */
.callout {
    padding: 16px;
    border-radius: 8px;
    margin: 24px 0;
    font-size: 0.95rem;
}
.callout.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #b45309;
}
[data-theme="dark"] .callout.warning { color: #fbbf24; }

/* Navigation Footer */
.page-nav {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.nav-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}
.nav-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.nav-card.hidden { visibility: hidden; pointer-events: none; }
.nav-card-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.nav-card-title { font-size: 1rem; color: var(--primary); font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* Mobile */
.mobile-header {
    display: none;
    height: var(--header-h);
    background: var(--bg-body);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0; z-index: 60;
}
.mobile-left { display: flex; align-items: center; gap: 12px; }
.menu-btn { background: none; border: none; cursor: pointer; color: var(--text-main); display: flex; }
.mobile-brand { font-weight: 700; color: var(--text-heading); font-size: 1.1rem; }
.mobile-theme-btn { width: auto; border: none; padding: 4px; color: var(--text-secondary); }

.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45;
    display: none; opacity: 0; transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .app-container { height: auto; display: block; padding-top: var(--header-h); }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh;
        transform: translateX(-100%); width: 80%; max-width: 300px;
        box-shadow: 10px 0 20px rgba(0,0,0,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .overlay.open { display: block; opacity: 1; }
    .content-wrapper { padding: 32px 20px; }
    .page-nav { grid-template-columns: 1fr; }
    h1 { font-size: 2rem; }
    .endpoint { flex-direction: column; align-items: flex-start; gap: 8px; }
    .features-grid { grid-template-columns: 1fr; }
}
