:root {
    --api-red: #c91d31;
    --api-header-red: #c91d31;
    --api-ink: #20242b;
    --api-paper: #f7f4ee;
    --api-line: #ddd6ca;
    --api-code: #171a20;
    --api-surface: #fff;
    --api-muted: #625b52;
    --api-progress-track: #eee8de;
    --api-link: #871626;
    --api-link-hover: #fbf4f5;
    --api-link-active: #f8e9ec;
    --api-quote-ink: #5f554a;
    --api-quote-bg: #f7f1e8;
    --api-table-heading: #f2eee7;
    --api-table-stripe: #fcfaf7;
    --api-inline-code: #f5ecee;
    --api-shadow: rgba(39, 33, 24, .07);
}

html[data-sushiro-theme="dark"] {
    --api-red: #ff7f8d;
    --api-header-red: #b51f33;
    --api-ink: #edf0f4;
    --api-paper: #111318;
    --api-line: #393e48;
    --api-code: #090b0f;
    --api-surface: #1b1f26;
    --api-muted: #b0b5bd;
    --api-progress-track: #3b414b;
    --api-link: #ff8c99;
    --api-link-hover: #302126;
    --api-link-active: #44252c;
    --api-quote-ink: #d1c8bb;
    --api-quote-bg: #2d2925;
    --api-table-heading: #292e36;
    --api-table-stripe: #20242b;
    --api-inline-code: #33242a;
    --api-shadow: rgba(0, 0, 0, .26);
}

body {
    color: var(--api-ink);
    background: var(--api-paper);
}

.sushiro-api-page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 16px 64px;
}

.api-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 24px 28px;
    color: #fff;
    background: var(--api-header-red);
    border-radius: 4px 4px 24px 4px;
    box-shadow: 0 14px 36px rgba(105, 17, 28, .18);
}

.api-eyebrow {
    margin: 0 0 4px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .17em;
}

.api-page-summary {
    margin: 0;
    color: rgba(255, 255, 255, .86);
}

.api-page-summary code {
    color: inherit;
}

.api-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.api-content-layout {
    display: grid;
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.api-toc-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    overflow: hidden;
    background: var(--api-surface);
    border: 1px solid var(--api-line);
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--api-shadow);
}

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

.api-toc-content {
    display: flex;
    max-height: calc(100vh - 36px);
    flex-direction: column;
}

.api-reading-progress {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--api-line);
}

.api-reading-progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--api-muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.api-reading-progress-label output {
    color: var(--api-red);
}

.api-reading-progress-track {
    height: 5px;
    overflow: hidden;
    background: var(--api-progress-track);
    border-radius: 999px;
}

.api-reading-progress-bar {
    display: block;
    width: 0;
    height: 100%;
    background: var(--api-red);
    border-radius: inherit;
    transition: width .15s ease-out;
}

.api-toc {
    padding: 10px 8px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

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

.api-toc-item {
    margin: 1px 0;
}

.api-toc-link {
    display: block;
    padding: 7px 10px;
    overflow: hidden;
    color: var(--api-muted);
    border-left: 3px solid transparent;
    border-radius: 0 7px 7px 0;
    font-size: .86rem;
    line-height: 1.35;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}

.api-toc-level-h3 .api-toc-link {
    padding-left: 22px;
    font-size: .8rem;
}

.api-toc-link:hover,
.api-toc-link:focus-visible {
    color: var(--api-link);
    background: var(--api-link-hover);
    text-decoration: none;
}

.api-toc-link.is-active {
    color: var(--api-link);
    background: var(--api-link-active);
    border-left-color: var(--api-red);
    font-weight: 800;
}

.markdown-body,
.api-load-error {
    padding: clamp(22px, 4vw, 48px);
    background: var(--api-surface);
    border: 1px solid var(--api-line);
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--api-shadow);
}

.markdown-body {
    line-height: 1.72;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    scroll-margin-top: 18px;
    color: var(--api-ink);
    font-weight: 800;
}

.markdown-body h1 {
    margin: 0 0 24px;
    padding-bottom: 18px;
    border-bottom: 4px solid var(--api-red);
    font-size: clamp(2rem, 5vw, 3.4rem);
    letter-spacing: -.035em;
}

.markdown-body h2 {
    margin: 48px 0 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--api-line);
    font-size: 1.65rem;
}

.markdown-body h3 {
    margin: 34px 0 14px;
    font-size: 1.28rem;
}

.markdown-body h4 {
    margin: 28px 0 12px;
    font-size: 1.08rem;
}

.markdown-body a {
    color: var(--api-link);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.markdown-body blockquote {
    margin: 20px 0;
    padding: 14px 18px;
    color: var(--api-quote-ink);
    background: var(--api-quote-bg);
    border-left: 4px solid var(--api-red);
}

.markdown-body blockquote > :last-child {
    margin-bottom: 0;
}

.markdown-body table {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 18px 0 28px;
    overflow-x: auto;
    border-spacing: 0;
    border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 12px;
    vertical-align: top;
    border: 1px solid var(--api-line);
}

.markdown-body th {
    background: var(--api-table-heading);
    font-weight: 800;
}

.markdown-body tr:nth-child(even) td {
    background: var(--api-table-stripe);
}

.markdown-body pre {
    margin: 18px 0 26px;
    padding: 18px;
    overflow-x: auto;
    color: #f2f4f7;
    background: var(--api-code);
    border-radius: 10px;
}

.markdown-body pre code {
    padding: 0;
    color: inherit;
    background: transparent;
    white-space: pre;
}

.markdown-body code {
    padding: .12em .35em;
    color: var(--api-link);
    background: var(--api-inline-code);
    border-radius: 4px;
}

.markdown-body img {
    max-width: 100%;
}

.api-load-error h1 {
    margin-top: 0;
}

@media (max-width: 720px) {
    .api-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .api-header-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .markdown-body,
    .api-load-error {
        padding: 20px 16px;
    }
}

@media (max-width: 1050px) {
    .api-content-layout {
        display: block;
    }

    .api-toc-panel {
        top: 8px;
        z-index: 10;
        max-height: calc(100vh - 16px);
        margin-bottom: 16px;
        border-radius: 10px;
    }

    .api-toc-toggle {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        color: var(--api-ink);
        background: var(--api-surface);
        border: 0;
        font-weight: 800;
        cursor: pointer;
    }

    .api-toc-toggle-icon {
        color: var(--api-red);
        transition: transform .2s ease;
    }

    .api-toc-content {
        display: none;
        max-height: calc(100vh - 70px);
    }

    .api-toc-panel.is-open .api-toc-content {
        display: flex;
    }

    .api-toc-panel.is-open .api-toc-toggle-icon {
        transform: rotate(180deg);
    }

    .api-reading-progress {
        padding: 12px 16px;
    }

    .api-toc {
        padding: 8px;
    }

    .markdown-body h1,
    .markdown-body h2,
    .markdown-body h3,
    .markdown-body h4 {
        scroll-margin-top: 76px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .api-reading-progress-bar,
    .api-toc-toggle-icon {
        transition: none;
    }
}
