/* API documentation page */

body.api-app {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--comp-bg, #f0f3f8);
    color: var(--comp-text, #1a2233);
    min-height: 100dvh;
    padding: 0;
}

.api-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100dvh - var(--comp-header-h, 58px));
}

.api-sidebar {
    position: sticky;
    top: var(--comp-header-h, 58px);
    align-self: start;
    height: calc(100dvh - var(--comp-header-h, 58px));
    overflow-y: auto;
    padding: 16px 12px 24px;
    border-right: 1px solid var(--comp-border, #e4e9f2);
    background: #fff;
}

.api-sidebar__title {
    margin: 0 0 10px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--comp-muted, #6b7a90);
}

.api-toc {
    list-style: none;
    margin: 0;
    padding: 0;
}

.api-toc a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--comp-text, #1a2233);
    text-decoration: none;
    border-left: 3px solid transparent;
    line-height: 1.35;
}

.api-toc a:hover {
    background: #f8fafc;
}

.api-toc a.active {
    color: var(--comp-accent, #6d5ef7);
    background: var(--comp-accent-soft, #f0edff);
    border-left-color: var(--comp-accent, #6d5ef7);
}

.api-sidebar__downloads {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--comp-border, #e4e9f2);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-sidebar__downloads a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--comp-text, #1a2233);
    background: #f8fafc;
    border: 1px solid var(--comp-border, #e4e9f2);
}

.api-sidebar__downloads a:hover {
    background: var(--comp-accent-soft, #f0edff);
    border-color: #c4b5fd;
    color: var(--comp-accent, #6d5ef7);
}

.api-sidebar__colab img {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    height: auto;
}

.api-main {
    min-width: 0;
    padding: 0 0 48px;
}

.api-hero {
    padding: 28px 32px 24px;
    background: #fff;
    border-bottom: 1px solid var(--comp-border, #e4e9f2);
}

.api-hero__badge {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--comp-accent, #6d5ef7);
}

.api-hero__title {
    margin: 0 0 10px;
    font-size: clamp(1.4rem, 2.5vw, 1.85rem);
    font-weight: 800;
    line-height: 1.2;
}

.api-hero__lead {
    margin: 0 0 16px;
    max-width: 52rem;
    font-size: 0.98rem;
    line-height: 1.55;
    color: var(--comp-muted, #6b7a90);
}

.api-hero__lead code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #f1f5f9;
    font-size: 0.9em;
}

.api-hero__colab {
    display: inline-block;
    margin-bottom: 14px;
}

.api-hero__colab img {
    display: block;
    height: 32px;
    width: auto;
}

.api-section a {
    color: var(--comp-accent, #6d5ef7);
    font-weight: 600;
    text-decoration: none;
}

.api-section a:hover {
    text-decoration: underline;
}

.api-md-colab {
    display: inline-block;
    margin: 0.35rem 0 0.6rem;
    line-height: 0;
}

.api-md-colab img {
    display: block;
    height: 32px;
    width: auto;
}

.api-md-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0.5rem 0;
    border-radius: 8px;
}

.api-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.api-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--comp-border, #e4e9f2);
    background: #f8fafc;
    color: var(--comp-muted, #6b7a90);
}

.api-status-pill--ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.api-status-pill--warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

.api-status-pill--off {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.api-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.api-quick-card {
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid var(--comp-border, #e4e9f2);
    font-size: 13px;
}

.api-quick-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.api-quick-card a {
    color: var(--comp-accent, #6d5ef7);
    text-decoration: none;
    font-weight: 600;
}

.api-auth-card {
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--comp-accent-soft, #f0edff);
    border: 1px solid #ddd6fe;
    font-size: 14px;
    line-height: 1.55;
}

.api-auth-card h2 {
    margin: 0 0 8px;
    font-size: 15px;
}

.api-auth-card ol {
    margin: 8px 0 0 1.2rem;
    padding: 0;
}

.api-auth-card li {
    margin-bottom: 6px;
}

.api-auth-card code {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.api-auth-card a {
    color: var(--comp-accent, #6d5ef7);
    font-weight: 600;
}

.api-content {
    padding: 24px 32px 0;
    max-width: 820px;
}

.api-loading,
.api-error {
    padding: 48px 32px;
    text-align: center;
    color: var(--comp-muted, #6b7a90);
}

.api-error {
    color: #b91c1c;
}

.api-error a {
    color: var(--comp-accent, #6d5ef7);
}

.api-section {
    background: #fff;
    border: 1px solid var(--comp-border, #e4e9f2);
    border-radius: 14px;
    padding: 24px 26px;
    margin-bottom: 16px;
    scroll-margin-top: calc(var(--comp-header-h, 58px) + 16px);
    box-shadow: var(--comp-shadow, 0 8px 30px rgba(26, 34, 51, 0.04));
}

.api-section--intro {
    border-color: #c4b5fd;
}

.api-section h2 {
    margin: 0 0 14px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.api-section .api-md-heading {
    margin: 1.15rem 0 0.45rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--comp-text, #1a2233);
    line-height: 1.35;
}

.api-section h3.api-md-heading {
    font-size: 0.98rem;
}

.api-section h4.api-md-heading {
    font-size: 0.92rem;
    color: var(--comp-muted, #6b7a90);
}

.api-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--comp-accent, #6d5ef7);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.api-section p {
    margin: 0.55rem 0;
    color: #334155;
    line-height: 1.6;
}

.api-section ul,
.api-section ol {
    margin: 0.55rem 0;
    padding-left: 1.35rem;
}

.api-section blockquote {
    margin: 0.8rem 0;
    padding: 12px 14px;
    background: #f8fafc;
    border-left: 3px solid var(--comp-accent, #6d5ef7);
    border-radius: 0 10px 10px 0;
    font-size: 14px;
    color: #475569;
}

.api-methods-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 0.8rem 0;
}

.api-methods-table th,
.api-methods-table td {
    border: 1px solid var(--comp-border, #e4e9f2);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.api-methods-table th {
    background: #f8fafc;
    font-weight: 600;
}

.api-methods-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.api-code-wrap {
    position: relative;
    margin: 14px 0 0;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid var(--comp-border, #e4e9f2);
}

.api-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f1f5f9;
    font-size: 12px;
    color: var(--comp-muted, #6b7a90);
    border-bottom: 1px solid var(--comp-border, #e4e9f2);
}

.api-code-header span {
    font-weight: 600;
}

.api-copy-btn {
    border: 1px solid var(--comp-border, #e4e9f2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--comp-text, #1a2233);
    background: #fff;
}

.api-copy-btn:hover {
    background: var(--comp-accent-soft, #f0edff);
}

.api-copy-btn.copied {
    background: #22a06b;
    color: #fff;
}

.api-code-wrap pre,
.api-md-pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-family: 'Consolas', 'SF Mono', monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #334155;
    background: #f8fafc;
}

.api-md-pre {
    margin: 0.8rem 0;
    border-radius: 10px;
    border: 1px solid var(--comp-border, #e4e9f2);
}

.api-sh .api-sh-comment {
    color: #64748b;
    font-style: italic;
}

.api-sh .api-sh-string {
    color: #0f766e;
}

.api-sh .api-sh-keyword {
    color: #7c3aed;
    font-weight: 600;
}

.api-sh .api-sh-builtin {
    color: #2563eb;
}

.api-sh .api-sh-func {
    color: #0369a1;
}

.api-sh .api-sh-number {
    color: #c2410c;
}

.api-sh .api-sh-name {
    color: #334155;
}

.api-cta {
    margin-top: 8px;
    padding: 20px 22px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6d5ef7 0%, #4f46e5 100%);
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.api-cta p {
    margin: 0;
    font-size: 15px;
}

.api-cta a {
    padding: 10px 18px;
    border-radius: 10px;
    background: #fff;
    color: #4f46e5;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}

#apiSidebarBackdrop {
    z-index: 270;
}

.api-toc-toggle {
    display: none;
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 90;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--comp-accent, #6d5ef7);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
    cursor: pointer;
}

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

    .api-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100dvh;
        z-index: 280;
        transition: left 0.22s ease;
        box-shadow: 8px 0 32px rgba(26, 34, 51, 0.12);
    }

    .api-sidebar.open {
        left: 0;
    }

    .api-toc-toggle {
        display: block;
    }

    .api-hero,
    .api-content {
        padding-left: 20px;
        padding-right: 20px;
    }

    .api-section {
        padding: 18px 16px;
    }
}
