:root {
    --brand: #4caf3d;
    --brand-dark: #3c9130;
    --brand-tint: #eaf7e6;
    --ink: #16213b;
    --body-text: #3c4257;
    --muted: #6b7280;
    --border: #e7e9ee;
    --bg: #ffffff;
    --bg-subtle: #f8f9fb;
    --code-bg: #0f1629;
    --code-text: #e3e8f0;
    --callout-text: #2b4a22;
    --inline-code-text: #b33a6b;
    --font-display: "Space Grotesk", sans-serif;
    --font-body: "Inter", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

[data-theme="dark"] {
    --brand: #5fcb4c;
    --brand-dark: #7cdb6b;
    --brand-tint: rgba(95, 203, 76, 0.14);
    --ink: #edeff5;
    --body-text: #c3c8d6;
    --muted: #8a93a6;
    --border: #262b3d;
    --bg: #0e1220;
    --bg-subtle: #161b2c;
    --code-bg: #0a0d18;
    --code-text: #e3e8f0;
    --callout-text: #b7e6ac;
    --inline-code-text: #f0a8c6;
}

[data-theme="dark"] #nav-menu .nav-tag.tag-info {
    background: rgba(37, 99, 235, 0.18);
    color: #7ca8ff;
}

[data-theme="dark"] #nav-menu .nav-tag.tag-muted {
    background: rgba(255, 255, 255, 0.08);
    color: #9aa1b0;
}

[data-theme="dark"] #nav-menu .nav-tag.tag-warning {
    background: rgba(180, 83, 9, 0.2);
    color: #f2b15c;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--body-text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.15s ease, color 0.15s ease;
}

a {
    color: var(--brand-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.skip-link {
    position: absolute;
    top: -60px;
    left: 12px;
    z-index: 100;
    background: var(--brand-dark);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 12px;
}

#doc-content:focus {
    outline: none;
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
    padding: 0 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    white-space: nowrap;
    min-width: 0;
    /* flex items default to min-width:auto — this is what actually lets it shrink */
    overflow: hidden;
}

.topbar .brand img {
    height: 33px;
    flex-shrink: 0;
}

.topbar .brand .divider {
    color: var(--border);
    font-weight: 400;
    flex-shrink: 0;
}

.topbar .brand .doc-label {
    color: var(--muted);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink);
    outline: none;
}

.topbar-search input:focus {
    border-color: var(--brand);
    background: var(--bg);
}

.topbar-search svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.45;
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(22, 33, 59, 0.12);
    z-index: 50;
}

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

.search-results .sr-group {
    border-bottom: 1px solid var(--border);
}

.search-results .sr-group:last-child {
    border-bottom: none;
}

.search-results .sr-page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 10px 14px 4px;
}

.search-results .sr-hit {
    display: block;
    padding: 8px 14px;
    cursor: pointer;
}

.search-results .sr-hit:hover {
    background: var(--bg-subtle);
}

.search-results .sr-heading {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
}

.search-results .sr-snippet {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.5;
}

.search-results .sr-snippet mark {
    background: var(--brand-tint);
    color: var(--brand-dark);
    border-radius: 3px;
    padding: 0 1px;
}

.search-results .sr-empty {
    padding: 16px 14px;
    font-size: 13px;
    color: var(--muted);
}

.menu-toggle {
    display: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 6px;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--ink);
    margin: 4px 0;
    border-radius: 1px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--body-text);
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

.mobile-search-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--body-text);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
}

.mobile-search-toggle:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

/* ---------- Shell ---------- */
.shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr) 220px;
    max-width: 1440px;
    margin: 0 auto;
}

/* ---------- Sidebar nav ---------- */
.sidebar {
    border-right: 1px solid var(--border);
    padding: 24px 12px 40px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

#nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

#nav-menu .menu-item {
    margin-bottom: 2px;
}

#nav-menu>.menu-item>a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
    color: var(--body-text);
    cursor: pointer;
}

#nav-menu>.menu-item>a:hover {
    background: var(--bg-subtle);
    text-decoration: none;
}

#nav-menu>.menu-item.active>a {
    background: var(--brand-tint);
    color: var(--brand-dark);
    font-weight: 600;
}

#nav-menu .menu-item img {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

#nav-menu .nav-tag {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 600;
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
}

#nav-menu .nav-tag.tag-brand {
    background: var(--brand);
    color: #fff;
}

#nav-menu .nav-tag.tag-info {
    background: #e8f1ff;
    color: #2563eb;
}

#nav-menu .nav-tag.tag-muted {
    background: #f1f2f4;
    color: #6b7280;
}

#nav-menu .nav-tag.tag-warning {
    background: #fff4e5;
    color: #b45309;
}

#nav-menu .dropdown-toggle {
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    margin-left: auto;
}

#nav-menu .menu-item.active>a .dropdown-toggle {
    transform: rotate(-135deg);
}

.sub-menu {
    list-style: none;
    margin: 0;
    padding: 0 0 0 14px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
    border-left: 1px solid var(--border);
    margin-left: 12px;
}

.menu-item.active>.sub-menu {
    max-height: 800px;
}

.sub-menu-item a {
    display: block;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--muted);
    border-radius: 6px;
}

.sub-menu-item a:hover {
    color: var(--ink);
    background: var(--bg-subtle);
    text-decoration: none;
}

.sub-menu-item.active>a {
    color: var(--brand-dark);
    font-weight: 600;
}

.sub-menu .sub-menu {
    padding-left: 12px;
}

.nav-empty-state {
    font-size: 13px;
    color: var(--muted);
    padding: 8px 10px;
}

/* ---------- Content ---------- */
.content-col {
    padding: 40px 48px 120px;
    min-width: 0;
}

.breadcrumb {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
}

#doc-content {
    max-width: 720px;
}

#doc-content h1 {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 24px;
    line-height: 1.2;
}

#doc-content h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    margin: 40px 0 14px;
    padding-top: 8px;
    scroll-margin-top: 76px;
}

#doc-content h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    margin: 28px 0 10px;
    scroll-margin-top: 76px;
}

#doc-content .heading-anchor {
    opacity: 0;
    margin-left: 8px;
    color: var(--brand);
    font-family: var(--font-body);
    font-weight: 400;
    text-decoration: none;
    font-size: 0.85em;
}

#doc-content h2:hover .heading-anchor,
#doc-content h3:hover .heading-anchor {
    opacity: 1;
}

#doc-content p {
    font-size: 15px;
    line-height: 1.7;
    margin: 0 0 16px;
}

#doc-content ol,
#doc-content ul {
    font-size: 15px;
    line-height: 1.75;
    padding-left: 22px;
    margin: 0 0 20px;
}

#doc-content li {
    margin-bottom: 6px;
}

#doc-content li>ol,
#doc-content li>ul {
    margin-top: 6px;
}

#doc-content li p {
    margin: 0;
}

#doc-content strong {
    color: var(--ink);
    font-weight: 600;
}

#doc-content blockquote {
    margin: 0 0 20px;
    padding: 14px 16px;
    background: var(--brand-tint);
    border-left: 3px solid var(--brand);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: var(--callout-text);
}

#doc-content blockquote p {
    margin: 0;
}

#doc-content blockquote p+p {
    margin-top: 8px;
}

#doc-content img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 8px 0;
}

#doc-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

.pager-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.pager-link {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    max-width: 48%;
}

.pager-link:hover {
    border-color: var(--brand);
    text-decoration: none;
}

.pager-next {
    text-align: right;
    margin-left: auto;
}

.pager-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pager-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 24px;
}

#doc-content table {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
    margin: 0;
    font-size: 13.5px;
}

#doc-content th {
    text-align: left;
    background: var(--bg-subtle);
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
}

#doc-content td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

#doc-content code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--inline-code-text);
}

.code-block-wrap {
    position: relative;
    margin: 0 0 22px;
}

#doc-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 16px 18px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

#doc-content pre code {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    font-family: var(--font-mono);
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    font-family: var(--font-body);
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
}

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

.code-tabs {
    margin: 0 0 22px;
    border-radius: 10px;
    overflow: hidden;
}

.code-tabs-bar {
    display: flex;
    background: var(--code-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
}

.code-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    white-space: nowrap;
}

.code-tab-btn:hover {
    color: #fff;
}

.code-tab-btn.active {
    color: #fff;
    border-bottom-color: var(--brand);
    background: rgba(255, 255, 255, 0.04);
}

.code-tab-panel {
    display: none;
}

.code-tab-panel.active {
    display: block;
}

.code-tab-panel .code-block-wrap {
    margin: 0;
}

.code-tab-panel .code-block-wrap pre {
    border-radius: 0;
}

#doc-content .code-tab-panel .code-block-wrap pre {
    border-radius: 0 0 10px 10px;
}

/* ---------- On this page ---------- */
.toc-col {
    padding: 40px 20px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.toc-col .toc-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
}

.toc-list li a {
    display: block;
    font-size: 13px;
    color: var(--muted);
    padding: 5px 0 5px 14px;
    border-left: 2px solid transparent;
    margin-left: -1px;
}

.toc-list li.toc-h3 a {
    padding-left: 26px;
    font-size: 12.5px;
}

.toc-list li a:hover {
    color: var(--ink);
    text-decoration: none;
}

.toc-list li a.active {
    color: var(--brand-dark);
    font-weight: 600;
    border-left-color: var(--brand);
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
    padding: 64px 48px 40px;
}

.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 56px;
}

.footer-logo {
    height: 26px;
    margin-bottom: 18px;
}

.footer-brand p {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--muted);
    margin: 0 0 14px;
    max-width: 340px;
}

.footer-apps {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.footer-apps img {
    height: 38px;
    width: auto;
}

.footer-col h4 {
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink);
    margin: 0 0 20px;
}

.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-col ul li {
    margin-bottom: 13px;
}

.footer-col ul li a {
    color: var(--muted);
    font-size: 13.5px;
}

.footer-col ul li a:hover {
    color: var(--brand-dark);
    text-decoration: none;
}

.footer-col-copy {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--muted);
    margin: 0 0 18px;
}

.footer-cta {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
}

.footer-cta:hover {
    background: var(--brand-dark);
    color: #fff;
    text-decoration: none;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.footer-copyright {
    font-size: 13px;
    color: var(--muted);
}

.footer-social {
    display: flex;
    align-items: center;
    gap: 14px;
}

.footer-social-label {
    font-size: 13px;
    color: var(--muted);
    margin-right: 4px;
}

.footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
}

.footer-social a:hover {
    border-color: var(--brand);
}

.footer-social img {
    width: 15px;
    height: 15px;
}

@media (max-width: 900px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        row-gap: 40px;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .site-footer {
        padding: 48px 20px 32px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 36px;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .shell {
        grid-template-columns: 264px minmax(0, 1fr);
    }

    .toc-col {
        display: none;
    }
}

@media (max-width: 860px) {
    .menu-toggle {
        display: block;
    }

    .topbar-search {
        display: none;
    }

    .mobile-search-toggle {
        display: flex;
    }

    .topbar-search.open {
        display: flex;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        max-width: none;
        padding: 10px 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        z-index: 45;
    }

    .topbar-search.open .search-results {
        left: 16px;
        right: 16px;
    }

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

    .sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        width: 82%;
        max-width: 320px;
        background: var(--bg);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 39;
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.08);
    }

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

    .content-col {
        padding: 28px 20px 80px;
    }

    #doc-content h1 {
        font-size: 26px;
    }
}

@media (max-width: 400px) {

    .topbar .brand .doc-label,
    .topbar .brand .divider {
        display: none;
    }
}

.topbar .brand .logo-light {
    display: none;
}

.topbar .brand .logo-dark {
    display: inline-block;
}

[data-theme="dark"] .topbar .brand .logo-light {
    display: inline-block;
}

[data-theme="dark"] .topbar .brand .logo-dark {
    display: none;
}
