.api-docs {
    --docs-ink: #1c2b24;
    --docs-muted: #5c6b64;
    --docs-line: #d9e4de;
    --docs-bg: #f4f8f6;
    --docs-card: #ffffff;
    --docs-code-bg: #12231c;
    --docs-code-ink: #d7efe4;
    --docs-accent: #2fa77a;
}

.api-docs-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.api-docs-toc {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    background: var(--docs-card);
    border: 1px solid var(--docs-line);
    border-radius: 14px;
    padding: 1rem 0.85rem;
}

.api-docs-toc h6 {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--docs-muted);
    margin: 0 0.4rem 0.75rem;
}

.api-docs-toc a {
    display: block;
    padding: 0.38rem 0.55rem;
    border-radius: 8px;
    color: var(--docs-ink);
    text-decoration: none;
    font-size: 0.9rem;
}

.api-docs-toc a:hover,
.api-docs-toc a.active {
    background: rgba(47, 167, 122, 0.12);
    color: var(--coren-primary-darker, #1f7352);
}

.api-docs-hero {
    background: linear-gradient(135deg, #1f7352 0%, #2fa77a 58%, #4ec89a 100%);
    color: #fff;
    border-radius: 16px;
    padding: 1.75rem 1.75rem 1.5rem;
    margin-bottom: 1.25rem;
}

.api-docs-hero h1,
.api-docs-hero h2 {
    color: #fff;
    margin-bottom: 0.5rem;
}

.api-docs-hero p {
    color: rgba(255, 255, 255, 0.92);
    margin-bottom: 0;
    max-width: 46rem;
}

.api-docs-section {
    background: var(--docs-card);
    border: 1px solid var(--docs-line);
    border-radius: 14px;
    padding: 1.4rem 1.5rem 1.5rem;
    margin-bottom: 1.15rem;
    scroll-margin-top: 1rem;
}

.api-docs-section h2 {
    font-size: 1.35rem;
    margin-bottom: 0.35rem;
}

.api-docs-section h3 {
    font-size: 1.05rem;
    margin-top: 1.25rem;
}

.api-docs-kicker {
    color: var(--docs-accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.api-docs-steps {
    counter-reset: docs-step;
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.api-docs-steps li {
    counter-increment: docs-step;
    position: relative;
    padding: 0.85rem 0.85rem 0.85rem 3.4rem;
    border: 1px solid var(--docs-line);
    border-radius: 12px;
    margin-bottom: 0.7rem;
    background: var(--docs-bg);
}

.api-docs-steps li::before {
    content: counter(docs-step);
    position: absolute;
    left: 0.75rem;
    top: 0.85rem;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: var(--docs-accent);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.api-docs-code {
    position: relative;
    background: var(--docs-code-bg);
    color: var(--docs-code-ink);
    border-radius: 12px;
    padding: 1rem 1rem 0.9rem;
    overflow: auto;
    font-size: 0.82rem;
    line-height: 1.55;
}

.api-docs-code pre {
    margin: 0;
    color: inherit;
    background: transparent;
    white-space: pre;
}

.api-docs-copy {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 8px;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
}

.api-docs-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.75rem 0 0.6rem;
}

.api-docs-tabs button {
    border: 1px solid var(--docs-line);
    background: #fff;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
}

.api-docs-tabs button.active {
    background: var(--docs-accent);
    border-color: var(--docs-accent);
    color: #fff;
}

.api-docs-table {
    width: 100%;
    font-size: 0.92rem;
}

.api-docs-table th,
.api-docs-table td {
    padding: 0.55rem 0.45rem;
    border-bottom: 1px solid var(--docs-line);
    vertical-align: top;
}

.api-docs-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    font-size: 0.74rem;
    font-weight: 600;
}

.api-docs-badge.post { background: #e7f7ef; color: #1f7352; }
.api-docs-badge.warn { background: #fff4d6; color: #8a6d12; }
.api-docs-badge.danger { background: #fde8e8; color: #9b1c1c; }

.api-docs-callout {
    border-left: 4px solid var(--docs-accent);
    background: rgba(47, 167, 122, 0.08);
    border-radius: 0 10px 10px 0;
    padding: 0.8rem 1rem;
    margin: 0.9rem 0;
}

.api-docs-callout.warning {
    border-left-color: #d39e00;
    background: #fff8e1;
}

.api-docs-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.api-docs-stat {
    border: 1px solid var(--docs-line);
    border-radius: 12px;
    padding: 0.9rem;
    background: var(--docs-bg);
}

.api-docs-stat small {
    display: block;
    color: var(--docs-muted);
    margin-bottom: 0.2rem;
}

.api-docs-try .form-label {
    font-weight: 600;
}

.api-docs-standalone {
    background: #eef5f1;
    min-height: 100vh;
}

.api-docs-standalone-bar {
    background: #fff;
    border-bottom: 1px solid var(--docs-line);
    padding: 0.9rem 1.25rem;
}

@media (max-width: 991px) {
    .api-docs-shell {
        grid-template-columns: 1fr;
    }
    .api-docs-toc {
        position: relative;
        top: 0;
        max-height: none;
    }
    .api-docs-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    .api-docs-toc,
    .api-docs-try,
    .api-docs-copy,
    .api-docs-nav,
    .sidebar-wrapper,
    .app-header,
    .app-hero-header {
        display: none !important;
    }
    .api-docs-shell {
        display: block;
    }
    .api-docs-section {
        break-inside: avoid;
    }
}
