:root {
    --sidebar-width: 280px;
    --header-height: 56px;
    --bg: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-code: #0f172a;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #0e7490;
    --primary-dark: #0c6378;
    --primary-light: #ecfeff;
    --accent: #14b8a6;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #ffffff;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    --radius: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
}

/* ── Layout ── */
.docs-layout {
    display: flex;
    min-height: 100vh;
}

.docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.docs-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}

.docs-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 50;
}

.docs-content {
    max-width: 860px;
    padding: 2rem 2.5rem 4rem;
}

.docs-content--wide {
    max-width: none;
    padding: 0;
}

/* ── Sidebar branding ── */
.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand a {
    text-decoration: none;
    color: #fff;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
}

.sidebar-tagline {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.35rem;
    padding-left: 2.45rem;
}

.sidebar-version {
    display: inline-block;
    margin-top: 0.5rem;
    margin-left: 2.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    background: rgba(20, 184, 166, 0.2);
    color: #5eead4;
    border-radius: 999px;
}

/* ── Sidebar search ── */
.sidebar-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}

.sidebar-search input::placeholder { color: #64748b; }
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-search-wrap {
    position: relative;
}

.sidebar-search-wrap svg {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: #64748b;
    pointer-events: none;
}

/* ── Sidebar nav ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0 1.5rem;
}

.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 1.25rem 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: all 0.12s;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--sidebar-active);
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--accent);
    font-weight: 500;
}

.nav-link svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.nav-link.active svg { opacity: 1; }

/* ── Header ── */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    color: var(--text);
}

.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

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

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.header-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.header-btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.header-btn--primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

/* ── Home / Overview ── */
.hero {
    padding: 2.5rem 0 2rem;
}

.hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 0.75rem;
    line-height: 1.2;
}

.hero-lead {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 0 2rem;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.badge--green {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.quickstart-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.quickstart-box h3 {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
    background: var(--bg);
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.card h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 600;
}

.card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* ── Markdown content ── */
.md-content h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.md-content h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 2.5rem 0 0.75rem;
    letter-spacing: -0.01em;
}

.md-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.75rem 0 0.5rem;
}

.md-content p { margin: 0 0 1rem; }

.md-content ul, .md-content ol {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.md-content li { margin-bottom: 0.35rem; }

.md-content a {
    color: var(--primary);
    text-decoration: none;
}

.md-content a:hover { text-decoration: underline; }

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

.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.875rem;
}

.md-content th, .md-content td {
    border: 1px solid var(--border);
    padding: 0.6rem 0.85rem;
    text-align: left;
}

.md-content th {
    background: var(--bg-subtle);
    font-weight: 600;
}

.md-content blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--accent);
    background: var(--primary-light);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text);
}

.md-content blockquote p:last-child { margin-bottom: 0; }

/* ── Code blocks ── */
.code-block {
    position: relative;
    margin: 1rem 0 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid #1e293b;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.85rem;
    background: #1e293b;
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: var(--font-mono);
}

.code-copy-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #cbd5e1;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.12s;
}

.code-copy-btn:hover { background: rgba(255, 255, 255, 0.15); }

.md-content pre,
.code-block pre {
    margin: 0;
    padding: 1rem 1.15rem;
    background: var(--bg-code);
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.55;
}

.md-content pre code,
.code-block code {
    font-family: var(--font-mono);
    color: #e2e8f0;
    background: none;
    padding: 0;
}

.md-content :not(pre) > code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: #be185d;
}

/* ── Swagger UI ── */
.swagger-wrap {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height));
}

.swagger-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}

.swagger-toolbar p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.swagger-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.swagger-ui-container {
    flex: 1;
    min-height: 600px;
}

.swagger-ui-container .swagger-ui {
    font-family: var(--font);
}

.swagger-ui-container .swagger-ui .topbar {
    display: none;
}

.swagger-error {
    margin: 2rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    background: #fef2f2;
    color: #991b1b;
}

.swagger-error p {
    margin: 0.5rem 0 0;
}

/* ── Loading ── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Search results ── */
.search-results {
    padding: 0.5rem 0;
}

.search-result {
    display: block;
    padding: 0.5rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85rem;
}

.search-result:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.search-result mark {
    background: rgba(20, 184, 166, 0.3);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
}

.search-empty {
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    color: #64748b;
}

/* ── Footer ── */
.docs-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Mobile ── */
@media (max-width: 900px) {
    .docs-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

    .docs-main { margin-left: 0; }

    .menu-toggle { display: block; }

    .docs-content { padding: 1.5rem 1.25rem 3rem; }

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

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

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