/* =========================================================================
   FmgLib Docs — design system
   Tokens first, then layout, then components. Dark is the default theme;
   the light theme only re-declares colour tokens.
   ========================================================================= */

:root {
    --accent: #6f7bff;
    --accent-2: #28c8ff;

    --bg: #0a0c11;
    --bg-soft: #0e1117;
    --surface: #12151d;
    --surface-2: #171b25;
    --surface-3: #1d2231;
    --border: #232838;
    --border-soft: #1a1f2b;

    --text: #e8ebf2;
    --text-muted: #9aa4ba;
    --text-faint: #6b7488;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);

    --tok-comment: #6a7392;
    --tok-kw: #c792ea;
    --tok-str: #b9dc8e;
    --tok-num: #f0956b;
    --tok-type: #ffcb6b;
    --tok-member: #82aaff;
    --tok-prop: #7fd6f0;
    --tok-attr: #f07178;

    /* Black in the source artwork; lightened on dark backgrounds so the mark keeps its shape. */
    --logo-ink: #eef2f8;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    --topbar-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;

    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #ffffff;
    --bg-soft: #f7f8fb;
    --surface: #ffffff;
    --surface-2: #f4f6fa;
    --surface-3: #eaeef5;
    --border: #e0e5ee;
    --border-soft: #edf0f5;

    --text: #10131a;
    --text-muted: #59616f;
    --text-faint: #838b99;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 8px 30px rgba(16, 24, 40, .10);
    --shadow-lg: 0 24px 70px rgba(16, 24, 40, .16);

    --logo-ink: #0b0d12;

    --tok-comment: #79808f;
    --tok-kw: #8250df;
    --tok-str: #1a7f37;
    --tok-num: #b8500f;
    --tok-type: #8a6100;
    --tok-member: #1f5fd0;
    --tok-prop: #0b6b7a;
    --tok-attr: #b02a37;

    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15.5px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
}

.muted { color: var(--text-muted); }
.dot { color: var(--text-faint); }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 200;
    background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

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

/* ---------------------------------------------------------------- topbar */

.topbar {
    position: sticky; top: 0; z-index: 60;
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
    height: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; border-radius: 7px; }
.brand-text { font-size: 15px; white-space: nowrap; }

.topbar-links { display: flex; gap: 4px; margin-left: 6px; }
.topbar-links a {
    color: var(--text-muted); font-size: 14px; padding: 6px 10px; border-radius: 8px;
}
.topbar-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    border: 1px solid transparent; background: transparent; color: var(--text-muted);
    cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.nav-toggle { display: none; }

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

.search-trigger {
    display: flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 10px 0 11px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 9px; color: var(--text-faint);
    font-family: inherit; font-size: 13.5px; cursor: pointer;
    transition: border-color .15s, color .15s;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text-muted); }
.search-trigger span { min-width: 90px; text-align: left; }
.search-trigger kbd { background: var(--surface-3); }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px; border-radius: 10px;
    font-size: 14.5px; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; cursor: pointer; transition: transform .12s, box-shadow .18s, background .18s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; }

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-primary:hover { box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 40%, transparent); }

.btn-ghost { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }

.pill {
    display: inline-block; padding: 5px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 600; letter-spacing: .02em;
    color: var(--accent-2);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ---------------------------------------------------------------- landing */

.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border-soft); }
.hero-glow {
    position: absolute; inset: -40% -10% auto -10%; height: 620px; pointer-events: none;
    background:
        radial-gradient(50% 50% at 22% 42%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 70%),
        radial-gradient(42% 44% at 78% 22%, color-mix(in srgb, var(--accent-2) 24%, transparent) 0%, transparent 70%);
    filter: blur(28px);
    opacity: .75;
}
[data-theme="light"] .hero-glow { opacity: .45; }

.hero-inner {
    position: relative;
    max-width: 1180px; margin: 0 auto; padding: 84px 24px 76px;
    display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center;
}

.hero-copy h1 {
    margin: 18px 0 0;
    font-size: clamp(34px, 4.4vw, 52px);
    line-height: 1.08; letter-spacing: -.035em; font-weight: 700;
}
.grad {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede { margin: 18px 0 0; font-size: 17px; color: var(--text-muted); max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.hero-code .code-card { box-shadow: var(--shadow-lg); }
.code-file { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }

.hero-install {
    display: inline-flex; align-items: center; gap: 10px;
    margin-top: 22px; padding: 9px 9px 9px 14px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
    font-family: var(--font-mono); font-size: 13px; color: var(--text-muted);
    max-width: 100%; overflow-x: auto;
}
.hero-install code { white-space: nowrap; }
.copy-inline {
    flex: none;
    padding: 4px 10px; border-radius: 7px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-family: var(--font-sans); font-size: 12px; cursor: pointer;
    transition: color .15s, border-color .15s;
}
.copy-inline:hover { color: var(--text); border-color: var(--accent); }
.copy-inline.is-copied { color: #3fbf8f; border-color: #3fbf8f; }

/* "What's in the docs" — the README's table of contents, as cards. */
.toc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.toc-card {
    padding: 20px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--border);
}
.toc-card h3 {
    margin: 0 0 12px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint);
}
.toc-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.toc-card a { font-size: 14px; color: var(--text); }
.toc-card a:hover { color: var(--accent); text-decoration: none; }

.section { max-width: 1180px; margin: 0 auto; padding: 76px 24px; }
.section-alt { border-top: 1px solid var(--border-soft); background: var(--bg-soft); max-width: none; }
.section-alt > * { max-width: 1180px; margin-inline: auto; }

.section-head { margin-bottom: 34px; }
.section-head h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.section-head p { margin: 8px 0 0; color: var(--text-muted); max-width: 62ch; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.feature { padding: 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.feature h3 { margin: 0 0 8px; font-size: 16px; letter-spacing: -.01em; }
.feature p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ---------------------------------------------------------------- docs shell */

.docs-shell {
    max-width: 1680px; margin: 0 auto;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr) 236px;
    align-items: start;
    gap: 0;
}

.sidebar {
    position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto; overscroll-behavior: contain;
    border-right: 1px solid var(--border-soft);
    padding: 0 14px 60px 20px;
    background: var(--bg);
}
.sidebar::-webkit-scrollbar, .toc-sticky::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .toc-sticky::-webkit-scrollbar-thumb {
    background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg);
}

/* Sticky so the library name, switchers and filter stay reachable in a long nav. */
.sidebar-head {
    position: sticky; top: 0; z-index: 2;
    display: grid; gap: 12px;
    padding: 20px 0 14px; margin-bottom: 10px;
    background-color: inherit;
    border-bottom: 1px solid var(--border-soft);
}
.sidebar-lib { display: flex; align-items: center; gap: 9px; }
.sidebar-lib img { border-radius: 5px; }
.sidebar-lib a { color: var(--text); font-weight: 650; font-size: 15px; letter-spacing: -.01em; }

/* A page listed outside any group sits flush with the group headings. */
.nav-link-top { margin-top: 4px; font-weight: 550; }

.sidebar-selects { display: flex; gap: 8px; }
.mini-select {
    flex: 1; min-width: 0;
    height: 30px; padding: 0 26px 0 9px;
    border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%238b93a5' d='m8 11-4-4.5h8z'/%3E%3C/svg%3E") no-repeat right 7px center/11px;
    color: var(--text); font-family: inherit; font-size: 12.5px;
    appearance: none; cursor: pointer;
}
.mini-select:hover { border-color: var(--accent); }

.sidebar-filter { position: relative; display: flex; align-items: center; }
.sidebar-filter svg { position: absolute; left: 10px; color: var(--text-faint); }
.sidebar-filter input {
    width: 100%; height: 32px; padding: 0 10px 0 30px;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font-family: inherit; font-size: 13px;
}
.sidebar-filter input::placeholder { color: var(--text-faint); }
.sidebar-filter input:focus { outline: none; border-color: var(--accent); }

.sidebar-nav { display: grid; gap: 1px; padding-top: 6px; }

.nav-group > summary {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 8px; border-radius: 7px; cursor: pointer;
    font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-faint); list-style: none;
    margin-top: 12px;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--text-muted); }
.nav-chevron { transition: transform .16s; flex: none; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
.nav-group-body { display: grid; gap: 1px; padding-left: 4px; }

.nav-link {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 7px;
    color: var(--text-muted); font-size: 13.8px; line-height: 1.45;
    border-left: 2px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link.is-current {
    color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent);
    font-weight: 600;
}
.nav-badge {
    margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 1px 6px; border-radius: 999px; color: var(--accent-2);
    background: color-mix(in srgb, var(--accent-2) 14%, transparent);
}
.nav-link[hidden], .nav-group[hidden] { display: none; }

/* ---------------------------------------------------------------- article */

.article-col { min-width: 0; padding: 28px 44px 90px; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; font-size: 12.5px; color: var(--text-faint); margin-bottom: 18px; }
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs a:hover { color: var(--accent); }

.version-notice {
    margin-bottom: 22px; padding: 11px 15px; border-radius: 10px; font-size: 13.5px;
    background: color-mix(in srgb, #e0a83c 12%, transparent);
    border: 1px solid color-mix(in srgb, #e0a83c 35%, transparent);
    color: var(--text);
}

.article { max-width: 860px; }
.article-head h1 { margin: 0; font-size: clamp(28px, 3.4vw, 38px); line-height: 1.15; letter-spacing: -.03em; }
.article-lede { margin: 12px 0 0; font-size: 17px; color: var(--text-muted); }
.article-head { padding-bottom: 26px; margin-bottom: 8px; border-bottom: 1px solid var(--border-soft); }

/* ---------------------------------------------------------------- prose */

.prose { max-width: 860px; }
.prose > *:first-child { margin-top: 24px; }

.prose h2, .prose h3, .prose h4, .prose h5 {
    position: relative; letter-spacing: -.02em; line-height: 1.3; scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.prose h2 { margin: 46px 0 14px; font-size: 25px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.prose h3 { margin: 34px 0 10px; font-size: 19.5px; }
.prose h4 { margin: 26px 0 8px; font-size: 16.5px; }
.prose h5 { margin: 22px 0 8px; font-size: 15px; color: var(--text-muted); }

.heading-anchor {
    position: absolute; left: -20px; top: 0;
    color: var(--text-faint); opacity: 0; text-decoration: none; font-weight: 400;
    transition: opacity .14s;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }

.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 5px 0; }
.prose li > ul, .prose li > ol { margin: 6px 0; }
.prose strong { font-weight: 650; color: var(--text); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }

.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose a.external-link::after { content: "↗"; font-size: .82em; margin-left: 2px; opacity: .7; }

.prose code {
    font-family: var(--font-mono); font-size: .875em;
    padding: .14em .4em; border-radius: 5px;
    background: var(--surface-3); color: var(--text);
    border: 1px solid var(--border-soft);
    word-break: break-word;
}
.prose a code { color: var(--accent); }

.prose blockquote {
    margin: 20px 0; padding: 2px 18px;
    border-left: 3px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
}
.prose blockquote p { margin: 12px 0; }

.prose img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); }

/* GitHub-style alerts */
.markdown-alert {
    margin: 20px 0; padding: 14px 18px; border-radius: 10px;
    border: 1px solid var(--border); border-left-width: 3px;
    background: var(--surface);
}
.markdown-alert p { margin: 6px 0; }
.markdown-alert-title { font-weight: 650; display: flex; align-items: center; gap: 7px; margin-top: 0 !important; }
.markdown-alert-note { border-left-color: #4a90e2; }
.markdown-alert-note .markdown-alert-title { color: #4a90e2; }
.markdown-alert-tip { border-left-color: #3fbf8f; }
.markdown-alert-tip .markdown-alert-title { color: #3fbf8f; }
.markdown-alert-important { border-left-color: #a86ff0; }
.markdown-alert-important .markdown-alert-title { color: #a86ff0; }
.markdown-alert-warning { border-left-color: #e0a83c; }
.markdown-alert-warning .markdown-alert-title { color: #e0a83c; }
.markdown-alert-caution { border-left-color: #e35d6a; }
.markdown-alert-caution .markdown-alert-title { color: #e35d6a; }

/* tables */
.table-wrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: 10px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose thead { background: var(--surface-2); }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-soft); }
.prose th { font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.prose td code { white-space: nowrap; }

/* task lists */
.prose .task-list-item { list-style: none; margin-left: -20px; }
.prose input[type="checkbox"] { margin-right: 8px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- code cards */

.code-card {
    margin: 20px 0; border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg-soft);
}
[data-theme="light"] .code-card { background: #fbfcfe; }

.code-card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 12px; border-bottom: 1px solid var(--border-soft);
    background: var(--surface-2);
}
.code-lang { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }

.code-copy {
    margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px; border-radius: 7px; border: 1px solid transparent;
    background: transparent; color: var(--text-faint);
    font-family: inherit; font-size: 12px; cursor: pointer;
    transition: color .15s, background .15s;
}
.code-copy:hover { color: var(--text); background: var(--surface-3); }
.code-copy.is-copied { color: #3fbf8f; }

.code-card-body {
    margin: 0; padding: 16px 18px; overflow-x: auto;
    font-family: var(--font-mono); font-size: 13.2px; line-height: 1.62;
    tab-size: 4;
}
.code-card-body code { font-family: inherit; background: none; border: none; padding: 0; font-size: inherit; }
.code-card-body::-webkit-scrollbar { height: 9px; }
.code-card-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }

.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-type { color: var(--tok-type); }
.tok-member { color: var(--tok-member); }
.tok-prop { color: var(--tok-prop); }
.tok-attr { color: var(--tok-attr); }
.tok-pre { color: var(--tok-comment); }
.tok-tag { color: var(--tok-kw); }
.tok-tag2 { color: var(--tok-kw); }
.tok-prompt { color: var(--text-faint); }

/* ---------------------------------------------------------------- article footer */

.article-foot { max-width: 860px; margin-top: 52px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager-link {
    display: grid; gap: 3px; padding: 14px 18px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
    color: var(--text); transition: border-color .16s, transform .16s;
}
.pager-link:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.pager-next { text-align: right; }
.pager-label { font-size: 12px; color: var(--text-faint); }
.pager-title { font-weight: 600; font-size: 14.5px; }

.article-meta {
    margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border-soft);
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    font-size: 12.5px; color: var(--text-faint);
}
.article-meta a { color: var(--text-muted); }
.article-meta a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- right rail */

.toc-col { min-width: 0; }
.toc-sticky {
    position: sticky; top: var(--topbar-h);
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 30px 20px 40px 4px;
    display: grid; gap: 22px; align-content: start;
}
.toc-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); margin-bottom: 10px; }
.toc { display: grid; gap: 1px; border-left: 1px solid var(--border-soft); }
.toc-link {
    padding: 4px 0 4px 12px; margin-left: -1px;
    border-left: 2px solid transparent;
    color: var(--text-muted); font-size: 13px; line-height: 1.45;
}
.toc-link:hover { color: var(--text); text-decoration: none; }
.toc-h3 { padding-left: 24px; font-size: 12.5px; }
.toc-link.is-active { color: var(--accent); border-left-color: var(--accent); }

.toc-aside { display: grid; gap: 8px; }
.toc-cta {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 9px; font-size: 13px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.toc-cta:hover { border-color: var(--accent); text-decoration: none; }
.toc-cta-quiet { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }

/* ---------------------------------------------------------------- search */

.search-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(4, 6, 10, .62);
    backdrop-filter: blur(3px);
    display: flex; justify-content: center; align-items: flex-start;
    padding: 12vh 20px 20px;
}
.search-overlay[hidden] { display: none; }

.search-modal {
    width: min(660px, 100%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
    animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.985); } }

.search-field { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.search-field svg { color: var(--text-faint); flex: none; }
.search-field input {
    flex: 1; min-width: 0; border: none; background: none; outline: none;
    color: var(--text); font-family: inherit; font-size: 16px;
}
.search-field input::placeholder { color: var(--text-faint); }
.search-field-lg { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }

.search-scope { display: flex; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-muted); }
.search-scope label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.search-scope input { accent-color: var(--accent); }

.search-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.search-empty, .search-none { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 13.5px; margin: 0; }

.search-hit { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.search-hit:hover, .search-hit.is-active { background: var(--surface-2); text-decoration: none; }
.search-hit.is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.search-hit-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.search-hit-snippet { font-size: 12.8px; color: var(--text-muted); line-height: 1.5; }
.search-hit mark, .search-item mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.search-tag {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    padding: 2px 7px; border-radius: 999px;
    color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 13%, transparent);
}
.search-tag-quiet { color: var(--text-faint); background: var(--surface-3); }

/* full search page */
.page-narrow { max-width: 880px; margin: 0 auto; padding: 48px 24px 90px; }
.center-block { text-align: center; }
.page-title { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.03em; margin: 0 0 20px; }
.status-code { font-size: 74px; font-weight: 800; letter-spacing: -.05em; background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.center-block .hero-actions { justify-content: center; }

.search-page-form { display: grid; gap: 12px; margin-bottom: 28px; }
.search-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.search-filters .mini-select { flex: 0 0 auto; min-width: 160px; height: 36px; }
.search-count { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

.search-list { display: grid; gap: 10px; }
.search-item {
    display: grid; gap: 5px; padding: 16px 18px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
    transition: border-color .16s, transform .16s;
}
.search-item:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.search-item-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.search-item p { margin: 0; font-size: 13.5px; color: var(--text-muted); }
.search-url { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }

.empty-state { padding: 48px 20px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; }

/* ---------------------------------------------------------------- footer */

.site-footer { border-top: 1px solid var(--border-soft); background: var(--bg-soft); margin-top: auto; }
.footer-inner {
    max-width: 1180px; margin: 0 auto; padding: 52px 24px 34px;
    display: grid; grid-template-columns: 1.2fr 2fr; gap: 40px;
}
.footer-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; margin-bottom: 8px; }
.footer-brand img { border-radius: 6px; }
.footer-rev { margin-top: 12px !important; font-size: 12.5px; color: var(--text-faint) !important; }
.footer-rev code { font-family: var(--font-mono); font-size: 11.5px; }
.footer-inner p { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 42ch; }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.footer-cols h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.footer-cols a { display: block; color: var(--text-muted); font-size: 13.5px; padding: 3px 0; }
.footer-cols a:hover { color: var(--accent); }
.footer-bottom {
    max-width: 1180px; margin: 0 auto; padding: 16px 24px 28px;
    border-top: 1px solid var(--border-soft); color: var(--text-faint); font-size: 12.5px;
}

.has-sidebar .site-footer { display: none; }

/* ---------------------------------------------------------------- responsive */

.sidebar-scrim { display: none; }

@media (max-width: 1280px) {
    .docs-shell { grid-template-columns: 270px minmax(0, 1fr); }
    .toc-col { display: none; }
    .article-col { padding: 28px 32px 90px; }
}

@media (max-width: 1080px) {
    .hero-inner { grid-template-columns: 1fr; gap: 40px; padding-top: 60px; }
    .footer-inner { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .topbar-links { display: none; }
    .search-trigger span { display: none; }
    .search-trigger kbd { display: none; }

    .docs-shell { grid-template-columns: minmax(0, 1fr); }
    .article-col { padding: 22px 20px 80px; }

    .sidebar {
        position: fixed; top: var(--topbar-h); left: 0; z-index: 55;
        width: 300px; max-width: 86vw;
        background: var(--surface); border-right: none;
        transform: translateX(-102%); transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-scrim {
        display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 54;
        background: rgba(4, 6, 10, .5);
    }
    body.sidebar-open { overflow: hidden; }

    .pager { grid-template-columns: 1fr; }
    .footer-cols { grid-template-columns: 1fr 1fr; }
    .search-overlay { padding: 6vh 12px 12px; }
}

@media (max-width: 560px) {
    .brand-text { display: none; }
    .topbar-inner { gap: 10px; padding: 0 12px; }
    .article-col { padding: 18px 16px 70px; }
    .code-card-body { font-size: 12.4px; padding: 14px; }
    .prose h2 { font-size: 22px; }
    .heading-anchor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
