:root {
    --bg: #ffffff;
    --text: #1d1d1f;
    --muted: #86868b;
    --link: #0066cc;
    --border: #d2d2d7;
    --nav-bg: rgba(255, 255, 255, 0.72);
    --surface: #f5f5f7;
    --surface-border: #e5e5ea;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-pill: 9999px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur: 0.4s;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #000000;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #333336;
    --nav-bg: rgba(0, 0, 0, 0.72);
    --surface: #111111;
    --surface-border: #222222;
    color-scheme: dark;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.015em;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
    border-radius: 4px;
}

h1, h2, h3 {
    letter-spacing: -0.02em;
}

nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(134, 134, 139, 0.15);
    transition: background-color var(--dur) var(--ease);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    transition: opacity 0.2s var(--ease);
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s var(--ease);
}

.nav-links a:hover {
    color: var(--muted);
}

.nav-links a.active {
    color: var(--text);
    font-weight: 600;
}

.nav-github {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-btn {
    display: none;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.menu-btn:hover {
    color: var(--muted);
    background: var(--surface);
}

.theme-switch-mini {
    display: flex;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    padding: 3px;
    border-radius: var(--radius-pill);
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.theme-switch-mini button {
    position: relative;
    z-index: 2;
    padding: 0.15rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    line-height: 1;
    font-weight: 500;
    font-family: inherit;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: transparent;
    transition: color 0.3s var(--ease);
}

.theme-switch-mini button.active {
    color: var(--text);
}

.theme-switch-mini::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--bg);
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: transform 0.3s var(--ease), background-color var(--dur) var(--ease);
}

[data-theme="light"] .theme-switch-mini::before {
    transform: translateX(100%);
}

.docs-layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 0 3rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
    align-items: start;
}

.docs-sidebar {
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding-bottom: 1rem;
    padding-right: 0.6rem;
}

.search {
    position: relative;
    margin-bottom: 1.5rem;
}

.search input {
    width: 100%;
    padding: 0.55rem 2.3rem 0.55rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s var(--ease), background-color var(--dur) var(--ease);
}

.search input::placeholder {
    color: var(--muted);
}

.search input:focus {
    outline: none;
    border-color: var(--border);
}

.search-key {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--surface-border);
    border-radius: 5px;
    padding: 0.2rem 0.45rem;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.search:focus-within .search-key,
.search input:not(:placeholder-shown) ~ .search-key {
    opacity: 0;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    z-index: 60;
    max-height: 340px;
    overflow-y: auto;
    display: none;
}

.search-results.open {
    display: block;
}

[data-theme="dark"] .search-results {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.search-result {
    display: block;
    padding: 0.6rem 0.9rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--surface-border);
    font-size: 0.85rem;
    transition: background-color 0.15s var(--ease);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: var(--surface);
}

.sr-title {
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.sr-section {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 400;
    white-space: nowrap;
}

.sr-snippet {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
    line-height: 1.45;
}

.search-empty {
    padding: 0.75rem 0.9rem;
    color: var(--muted);
    font-size: 0.82rem;
}

mark {
    background: rgba(0, 102, 204, 0.16);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.nav-section {
    margin: 1.5rem 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.nav-section:first-of-type {
    margin-top: 0;
}

.nav-item {
    display: block;
    padding: 0.32rem 0.6rem;
    margin: 1px 0;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface);
}

.nav-item.active {
    color: var(--text);
    font-weight: 500;
    background: var(--surface);
}

.nav-item.sub {
    padding-left: 1.5rem;
    font-size: 0.84rem;
}

.docs-main {
    min-width: 0;
}

.docs-main.has-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px;
    gap: 2.5rem;
    align-items: start;
}

article {
    max-width: 760px;
    min-width: 0;
}

.page-section {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 0 0 1.25rem;
}

article h1 {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 1.25rem;
    text-wrap: balance;
}

article h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 2.5rem 0 0.9rem;
    scroll-margin-top: 76px;
}

article h3 {
    font-size: 1.12rem;
    font-weight: 600;
    margin: 1.9rem 0 0.7rem;
    scroll-margin-top: 76px;
}

article h4, article h5, article h6 {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    scroll-margin-top: 76px;
}

article p {
    margin: 0 0 1rem;
    line-height: 1.65;
    font-size: 0.95rem;
}

article ul, article ol {
    margin: 0 0 1rem;
    padding-left: 1.4rem;
}

article li {
    margin: 0.3rem 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

article li > ul, article li > ol {
    margin: 0.25rem 0 0.25rem;
}

article a {
    color: var(--link);
    text-decoration: none;
}

article a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

article code {
    font-family: var(--mono);
    font-size: 0.8em;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 5px;
    padding: 0.1em 0.35em;
    white-space: nowrap;
}

article pre {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    overflow-x: auto;
    margin: 0 0 1.25rem;
}

article pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre;
}

.table-wrap {
    overflow-x: auto;
    margin: 0 0 1.25rem;
}

article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

article th {
    text-align: left;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

article td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--surface-border);
    vertical-align: top;
    line-height: 1.55;
}

article th:first-child,
article td:first-child {
    padding-left: 0;
}

article th:last-child,
article td:last-child {
    padding-right: 0;
}

article blockquote {
    border-left: 3px solid var(--link);
    background: var(--surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0.7rem 1rem;
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

article blockquote p {
    margin: 0;
}

article hr {
    border: none;
    border-top: 1px solid var(--surface-border);
    margin: 2rem 0;
}

article img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.toc {
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    font-size: 0.8rem;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.toc a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    padding: 0.28rem 0 0.28rem 0.75rem;
    border-left: 1px solid var(--surface-border);
    line-height: 1.4;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.toc a:hover {
    color: var(--text);
}

.toc a.active {
    color: var(--text);
    border-left-color: var(--link);
}

.toc a.l3 {
    padding-left: 1.5rem;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 760px;
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--surface-border);
}

.pager a {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.pager a:hover {
    border-color: var(--border);
    background: var(--surface);
}

.pager .label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.pager .chevron {
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.2s var(--ease);
}

.pager a.prev:hover .chevron {
    transform: translateX(-3px);
}

.pager a.next:hover .chevron {
    transform: translateX(3px);
}

.pager .title {
    display: block;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.pager .next {
    text-align: right;
    align-items: flex-end;
}

.docs-footer-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.docs-footer {
    padding: 2rem 0 0;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
    transition: border-color var(--dur) var(--ease);
}

.docs-footer .footer-logo {
    font-weight: 600;
    color: var(--text);
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1100px) {
    .docs-main.has-toc {
        grid-template-columns: minmax(0, 1fr);
    }

    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .docs-layout {
        grid-template-columns: 1fr;
        padding: 1.75rem 1.25rem 3rem;
    }

    .menu-btn {
        display: inline-flex;
        align-items: center;
    }

    .search-key {
        display: none;
    }

    .search input {
        font-size: 1rem;
        padding-right: 0.9rem;
    }

    .nav-content {
        padding: 1rem 1.25rem;
    }

    .nav-links {
        gap: 1.25rem;
    }

    .nav-links a:not(.active) {
        display: none;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 292px;
        max-height: none;
        background: var(--bg);
        border-right: 1px solid var(--surface-border);
        padding: 1.5rem 1.25rem;
        z-index: 200;
        transform: translateX(-105%);
        transition: transform 0.3s var(--ease), background-color var(--dur) var(--ease);
    }

    body.sidebar-open .docs-sidebar {
        transform: none;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 150;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .pager {
        grid-template-columns: 1fr;
    }

    .docs-footer-wrap {
        padding: 0 1.25rem 2rem;
    }
}
