:root {
    --font-main: "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", "Liberation Mono", "Courier New", monospace;

    /* Code highlighting */
    --hl-green: #c5e478;
    --hl-dark-green: #7fdbca;
    --hl-blue: #82aaff;
    --hl-purple: #c792ea;
    --hl-yellow: #ecc48d;
    --hl-orange: #f78c6c;
    --hl-grey: #919f9f;

    /* Abominations */
    --amber: #e6a817;
    --red: #f44747;
    --header-height: 3.25rem;
    --sidebar-width: 260px;

    --text: #c9d1d9;
    --text-bright: #ffffff;
    --text-dim: #c1c3c8;
    --text-invert: #17264f;

    /* --accent: #b3c7ff; */
    --accent: #f78c6c;

    --bg-page: #17181c;

    --bg-header: #23262f;
    --bg-sidebar: #23262f;
    --bg-code: #23262f;
    --bg-card: var(--bg-page);

    --bg-signature: var(--bg-code);
    --bg-inline: #353841;

    --border: #535763;
    --border-code: #30333c;
}

:root[data-theme="light"] {
    /* Code highlighting */
    --hl-green: #2d8a00;
    --hl-dark-green: #007a7a;
    --hl-blue: #0056b3;
    --hl-purple: #7b1fa2;
    --hl-yellow: #9b6d00;
    --hl-orange: #c43e00;
    --hl-grey: #455a64;

    /* Abominations */
    --amber: #e6a817;
    --red: #f44747;
    --header-height: 3.25rem;
    --sidebar-width: 260px;

    --text: #1e2033;
    --text-bright: #000000;
    --text-dim: #353841;
    --text-invert: #ffffff;

    --accent: #f5683d;

    --bg-page: #ffffff;

    --bg-sidebar: #f6f7f9;
    --bg-header: #f6f7f9;
    --bg-code: #f6f7f9;
    --bg-card: #f6f7f9;

    --bg-signature: var(--bg-code);
    --bg-inline: #edeef3;

    --border: #cfd0d5;
    --border-code: #cfd0d5;
}

html {
    scroll-padding-top: calc(var(--header-height) + 1rem);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-page);
    color: var(--text);
    font-family: var(--font-main);
    line-height: 1.65;
    tab-size: 4;
}

body::-webkit-scrollbar {
    width: 0.75em;
}

body::-webkit-scrollbar-track {
    background: var(--bg-header);
    border-left: 1px solid var(--border);
}

body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    border-left-width: 3px;
    background-clip: content-box;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
    flex-grow: 1;
}

/* Hero section styles */
.md-hero {
    padding: 2rem 0;
    background-size: cover;
    background-position: center;
    margin-bottom: 1rem;
    line-height: 1.1;
}
@media (max-width: 600px) {
    .md-hero {
        padding: 0;
    }
}
.md-hero h1 {
    color: var(--accent);
    margin: 0 0 0.5rem 0;
    font-size: 3rem;
}
.md-hero-desc {
    font-size: 3rem;
    margin: 0 0 1rem 0 !important;
    font-weight: bold;
    color: var(--text-bright);
}
.md-hero-actions {
    margin: 2rem 0 0 !important;
}
.md-hero-actions .md-hero-action {
    display: inline-block;
    margin-right: 0.5rem;
    background: var(--bg-inline);
    color: var(--text-bright);
    text-decoration: none;

    min-width: 5rem;
    border-radius: 1.25rem;
    padding: 0 1.25rem;
    font-size: 0.875rem;
    line-height: 2.375rem;
    font-weight: 600;
}
.md-hero-actions .md-hero-action.primary {
    background: var(--accent);
    color: var(--text-invert);
}

.md-footnotes {
    border-top: 1px solid var(--border);
    padding-top: 1em;
    margin-top: 1em;
}

.md-task_list_item::marker {
    content: none;
}
.md-task_list_item {
    margin-left: 0 !important;
}

/* ---- Announcement Banner ---- */
.announcement-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 110;
    background: var(--accent);
    color: var(--text-invert);
    text-align: center;
    padding: 0.4rem 2.5rem 0.4rem 1rem;
    font-size: 0.85rem;
    line-height: 1.4;
}
.announcement-banner a {
    color: var(--text-invert);
    font-weight: 600;
    text-decoration: underline;
}
.announcement-dismiss {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-invert);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0.25rem 0.5rem;
}
.announcement-dismiss:hover {
    opacity: 1;
}
/* When announcement is present, push header down */
.announcement-banner ~ .top-header {
    top: 1.8rem;
}
.announcement-banner ~ .top-header ~ .sidebar,
.announcement-banner ~ .top-header ~ .toc-sidebar {
    top: calc(var(--header-height) + 1.8rem);
}
.announcement-banner ~ .top-header ~ * .main-content {
    margin-top: calc(var(--header-height) + 1.8rem);
}

/* ---- Header ---- */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    width: 100vw;
}

.header-inner {
    width: 100%;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: 1fr minmax(0, 1fr) 1fr;
    align-items: center;
    gap: 1rem;
}

.header-burger {
    width: 2.85rem;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 0;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    height: 1.2rem;
    cursor: pointer;
    display: none;
}
.header-burger > div {
    width: 1.25em;
    height: 0.125rem;
    background-color: var(--text-dim);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.header-brand {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-bright);
    text-decoration: none;
    white-space: nowrap;
}

.header-brand:hover {
    color: var(--accent);
    text-decoration: none;
}

.header-module {
    color: var(--text-dim);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 1.1rem;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition:
        color 0.15s,
        border-color 0.15s;
}

.theme-toggle:hover {
    color: var(--text-bright);
    border-color: var(--accent);
}

/* ---- Search ---- */
.search-container {
    position: relative;
    width: 100%;
}
.search-input {
    width: 100%;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg-page);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.search-input::placeholder {
    color: var(--text-dim);
}
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

.search-results::-webkit-scrollbar {
    width: 0.5em;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    background-clip: content-box;
}

.search-results.visible {
    display: block;
}
.search-result {
    display: block;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.search-result:last-child {
    border-bottom: none;
}
.search-result:hover,
.search-result.selected {
    background: var(--bg-page);
}
.search-result-kind {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--hl-dark-green);
    margin-right: 0.5rem;
}
.search-result-title {
    font-size: 0.85rem;
    color: var(--text-bright);
}
.search-result-title mark {
    background: none;
    color: var(--accent);
    font-weight: 600;
}
.search-result-snippet {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-snippet mark {
    background: none;
    color: var(--accent);
}
.search-empty {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
}
@media (max-width: 700px) {
    .header-inner {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    }
    .header-module {
        display: none;
    }

    .search-results {
        width: 560px;
        max-width: 100vw;
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        top: calc(var(--header-height) + 4px);
    }
}

/* ---- Version Picker ---- */
.version-picker {
    position: relative;
    flex-shrink: 0;
}
.version-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-family: inherit;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    white-space: nowrap;
    transition:
        color 0.15s,
        border-color 0.15s;
}
.version-btn:hover {
    color: var(--text-bright);
    border-color: var(--accent);
}
.version-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 200;
    overflow: hidden;
}
.version-dropdown.visible {
    display: block;
}
.version-item {
    display: block;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s;
}
.version-item:hover {
    background: var(--bg-page);
}
.version-item.active {
    color: var(--accent);
    font-weight: 600;
}

/* ---- 404 ---- */
.not-found {
    text-align: center;
    padding: 4rem 1rem;
}
.not-found h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.not-found p {
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}
.not-found-link {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: var(--bg-page);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.not-found-link:hover {
    opacity: 0.9;
}

/* ---- Back to top ---- */
.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s,
        color 0.15s,
        border-color 0.15s;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}
.back-to-top:hover {
    color: var(--text-bright);
    border-color: var(--accent);
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    padding: 1rem 0;
}

/* .sidebar::-webkit-scrollbar {
    width: 0.5em;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    background-clip: content-box;
} */
::-webkit-scrollbar {
    width: 0.5em;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    background-clip: content-box;
}

.sidebar-group details > summary {
    list-style: none;
    cursor: pointer;
}

.sidebar-inner {
    padding: 0 0.75rem;
}

.sidebar-section {
    margin-bottom: 0.65rem;
}

.sidebar-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-bright);
    padding: 0 0.5rem;
    padding-left: 1.5em;
    margin: 0.65rem 0 0.15rem;
    cursor: pointer;
    position: relative;
}
.sidebar-section[open] > .sidebar-heading::after {
    display: inline-block;
    left: 0.25em;
    top: 45%;
    position: absolute;
    content: "";
    width: 0.6em;
    height: 0.1em;
    background-color: var(--text-dim);
    align-self: center;
}
.sidebar-section:not([open]) > .sidebar-heading::after {
    display: inline-block;
    left: 0.25em;
    top: 45%;
    position: absolute;
    content: "";
    width: 0.6em;
    height: 0.1em;
    background-color: var(--text-dim);
    align-self: center;
}
.sidebar-section:not([open]) > .sidebar-heading::before {
    display: inline-block;
    left: 0.5em;
    top: calc(45% - 0.25em);
    position: absolute;
    content: "";
    width: 0.1em;
    height: 0.6em;
    background-color: var(--text-dim);
    align-self: center;
}
.sidebar-heading::marker {
    display: none;
    content: "";
}

.sidebar ul {
    list-style: none;
}

.sidebar-link {
    display: block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    text-decoration: none;
    color: var(--text-bright);
}

.sidebar-link.active {
    background: var(--accent);
    color: var(--text-invert);
    font-weight: 600;
}

.md-list_item {
    margin-left: 1rem;
}

.sidebar-nav li li {
    margin-left: 0.75rem !important;
}

.sidebar-group {
    margin-bottom: 0.15rem;
}

/* ---- Main content ---- */
body:has(#sidebar) .main-content {
    margin-left: var(--sidebar-width);
}
.main-content {
    margin-top: var(--header-height);
    padding: 2rem 1rem;
    min-height: calc(100vh - var(--header-height));

    display: flex;
    flex-direction: column;
}

.module-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.module-title-row h1 {
    margin: 0;
}
.json-link {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: rgba(86, 156, 214, 0.15);
    color: var(--accent);
    text-decoration: none;
    border: 1px solid rgba(86, 156, 214, 0.3);
    white-space: nowrap;
}
.json-link:hover {
    background: rgba(86, 156, 214, 0.25);
}

/* ---- Sidebar toggle (mobile) ---- */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--border);
    color: #fff;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding-left: 0.5rem;
        padding-right: 0.5rem;

        padding-top: 1rem;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-burger {
        display: flex;
    }
    .header-inner {
        padding-right: 0.75rem;
    }
    .header-burger + .header-inner {
        padding-left: 0.25rem;
    }
    .container {
        padding: 0 0.5rem;
    }
}

h1 {
    color: var(--text-bright);
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

h2 {
    color: var(--text-bright);
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}
h2:first-of-type {
    margin-top: 0.75rem;
}

h3 {
    color: var(--text-bright);
    font-size: 1.1rem;
    margin: 0;
}
h4 {
    color: var(--text-bright);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.article-content {
    width: 100%;
}
.article-content h3.md-heading {
    margin: 0.75em 0 0.25em;
}
.article-content .md-quote:not(:last-child),
.article-content .md-paragraph:not(:last-child),
.article-content .md-list:not(:last-child),
.article-content .md-list:not(:last-child) {
    margin-bottom: 1.25em;
}
.article-content .md-quote:not(:first-child),
.article-content .md-paragraph:not(:first-child),
.article-content .md-list:not(:first-child),
.article-content .md-list:not(:first-child) {
    margin-top: 1.25em;
}
.md-list {
    margin-left: 2em;
}

.meta {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.doc-entry {
    background: var(--bg-card);
    /* border-radius: 8px; */
    overflow: hidden;
}
.doc-entry:not(:first-child) {
    margin-top: 2rem;
}
.doc-entry:not(:last-child) {
    margin-bottom: 1rem;
}
details.doc-entry {
    margin-bottom: 2rem;
}

.doc-entry > summary {
    list-style: none;
    cursor: pointer;
}

.doc-entry > summary::-webkit-details-marker {
    display: none;
}

.doc-entry > summary::marker {
    display: none;
    content: "";
}

.doc-entry .type-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-left: auto;
    user-select: none;
}

.doc-entry .type-toggle::after {
    content: "\25B6";
    font-size: 0.65rem;
    transition: transform 0.15s;
}

.doc-entry[open] .type-toggle::after {
    transform: rotate(90deg);
}

.doc-entry .doc-entry {
    border-radius: 0;
}

.entry-header {
    display: flex;
    align-items: center;
    margin: 0 0 0.25rem;
    gap: 0.75rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-yields {
    background: rgba(230, 168, 23, 0.18);
    color: var(--amber);
}

.badge-exported {
    background: rgba(86, 156, 214, 0.18);
    color: var(--accent);
}

.badge-internal {
    background: rgba(220, 50, 47, 0.18);
    color: var(--red);
}

.signature {
    background: var(--bg-signature);
    padding: 0.9rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.75;
    white-space: pre;
    overflow-x: auto;
    /* border-top: 1px solid var(--border-code);
    border-bottom: 1px solid var(--border-code); */
}
.signature + .signature {
    border-top: none;
}

.signature.signature-small {
    padding: 0.4rem 1.25rem;
}

.signature::-webkit-scrollbar {
    height: 0.75em;
}

.signature::-webkit-scrollbar-track {
    background: transparent;
}

.signature::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    background-clip: content-box;
}

.syn-type {
    /*DONE*/
    color: var(--hl-green);
}

.syn-fn {
    /*DONE*/
    color: var(--hl-blue);
}

.syn-kw {
    /*DONE*/
    color: var(--hl-purple);
}

.syn-str {
    /*DONE*/
    color: var(--hl-yellow);
}

.syn-num {
    /*DONE*/
    color: var(--hl-orange);
}

.syn-comment {
    /*DONE*/
    color: var(--hl-grey);
}

.syn-param {
    /*DONE*/
    color: var(--hl-dark-green);
}

.syn-self {
    color: var(--hl-blue);
    font-style: italic;
}

.syn-builtin {
    /*DONE*/
    color: var(--hl-green);
}

.syn-punct {
    color: var(--text);
}

.syn-variadic {
    color: var(--text);
}

.entry-content {
    margin: 0.5rem 0 0.25rem;
}

.entry-content p {
    margin-bottom: 0.75rem;
}

.entry-content p:last-child {
    margin-bottom: 0;
}

code {
    background: var(--bg-inline);
    padding: 0.12rem 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--hl-yellow);
}
.md-color_dot {
    width: 0.8em;
    height: 0.8em;
    display: inline-block;
    border-radius: 50%;
    background-color: var(--color);
    vertical-align: baseline;
    margin-left: 0.35em;
    border: 1px solid var(--border);
}

.md-tab_panel {
    padding-top: 0.5em;
}
.md-tab_panel:not([active]) {
    display: none;
}
.md-tab_group_header {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.md-tab_group_button {
    padding: 0.25em 1em;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    margin-bottom: -1px;
}
.md-tab_group_button[active] {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.md-paragraph + .md-paragraph {
    margin-top: 0.75em;
}

pre.md-code_block {
    background: var(--bg-code);
    border: 1px solid var(--border-code);
    margin: 0.75rem 0;
    line-height: 1.55;
    position: relative;
}

pre.md-code_block code {
    background: transparent;
    padding: 1rem 1.25rem;
    font-size: 0.88rem;
    color: var(--text);
    display: block;
    overflow-x: auto;
    position: relative;
}
pre.md-code_block::before {
    z-index: 1;
    position: absolute;
    display: block;
    content: "";
    left: 0;
    top: 0;
    height: 100%;
    width: 1.25rem;
    background: linear-gradient(270deg, transparent, var(--bg-code));
}
pre.md-code_block::after {
    z-index: 1;
    position: absolute;
    display: block;
    content: "";
    right: 0;
    top: 0;
    height: 100%;
    width: 1.25rem;
    background: linear-gradient(90deg, transparent, var(--bg-code));
}

pre.md-code_block:first-child {
    margin-top: 0;
}

pre.md-code_block:last-child {
    margin-bottom: 0;
}

.md-admonition {
    border-radius: 6px;
    padding: 0.85rem 1.15rem;
    margin: 0.75rem 0;
}

.md-admonition-title {
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.4rem;
    font-size: 0.88rem;
    letter-spacing: 0.03em;
}

.md-admonition p {
    margin-bottom: 0;
}

.md-admonition[data-label="caution"] {
    background: rgba(230, 168, 23, 0.12);
    border-left: 4px solid var(--amber);
}

.md-admonition[data-label="caution"] .md-admonition-title {
    color: var(--amber);
}

.md-admonition[data-label="info"],
.md-admonition[data-label="note"] {
    background: rgba(86, 156, 214, 0.12);
    border-left: 4px solid var(--accent);
}

.md-admonition[data-label="info"] .md-admonition-title,
.md-admonition[data-label="note"] .md-admonition-title {
    color: var(--accent);
}

.md-admonition[data-label="tip"] {
    background: rgba(78, 201, 176, 0.12);
    border-left: 4px solid var(--hl-dark-green);
}

.md-admonition[data-label="tip"] .md-admonition-title {
    color: var(--hl-dark-green);
}

.md-admonition[data-label="danger"],
.md-admonition[data-label="warning"] {
    background: rgba(244, 71, 71, 0.12);
    border-left: 4px solid var(--red);
}

.md-admonition[data-label="danger"] .md-admonition-title,
.md-admonition[data-label="warning"] .md-admonition-title {
    color: var(--red);
}

table.params {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}

table.params th {
    text-align: left;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border);
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.params td {
    border-bottom: 1px solid rgba(61, 61, 92, 0.5);
    padding: 0.45rem 0.6rem;
    vertical-align: top;
}

table.params td code {
    font-size: 0.85em;
}

table.params tr:last-child td {
    border-bottom: none;
}

.return-line {
    margin: 0.5rem 0;
    font-size: 0.92rem;
}

.return-line strong {
    color: var(--text-bright);
}

.const-group-title {
    color: var(--text-bright);
    font-weight: 600;
    margin: 0.75rem 0 0.25rem;
}

.const-list {
    list-style: none;
    padding: 0;
    margin-bottom: 0.75rem;
}

.const-list li {
    margin: 0.2rem 0;
    font-size: 0.92rem;
}

.const-list li code {
    margin-right: 0.25rem;
}

.const-desc {
    color: var(--text-dim);
    font-size: 0.88rem;
}

.field-item {
    margin: 0.4rem 0;
    font-size: 0.92rem;
}

.field-item .field-doc {
    color: var(--text-dim);
    margin-left: 0.5rem;
    font-size: 0.88rem;
}

.md-quote {
    border-left: 4px solid var(--border);
    padding-left: 1em;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
}

.md-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-bright);
    border-bottom: 2px solid var(--border);
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

.md-table td {
    border-bottom: 1px solid rgba(61, 61, 92, 0.5);
    padding: 0.4rem 0.75rem;
    vertical-align: top;
}

.md-table tr:last-child td {
    border-bottom: none;
}

.md-table code {
    font-size: 0.85em;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

hr.section-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.module-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.module-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    text-decoration: none;
}

.module-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.module-name code {
    background: transparent;
    padding: 0;
    color: var(--text-bright);
    font-size: 1rem;
}

.module-desc {
    color: var(--text-dim);
    font-size: 0.88rem;
    line-height: 1.45;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.module-stats {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.module-stats span + span::before {
    content: "\b7\a0";
}

/* ---- Light theme overrides ---- */
/* Admonition tints are hardcoded rgba - bump opacity so they show on light bg */
:root[data-theme="light"] .md-admonition[data-label="caution"] {
    background: rgba(184, 114, 14, 0.13);
}

:root[data-theme="light"] .md-admonition[data-label="info"],
:root[data-theme="light"] .md-admonition[data-label="note"] {
    background: rgba(0, 87, 174, 0.1);
}

:root[data-theme="light"] .md-admonition[data-label="tip"] {
    background: rgba(38, 127, 153, 0.1);
}

:root[data-theme="light"] .md-admonition[data-label="danger"],
:root[data-theme="light"] .md-admonition[data-label="warning"] {
    background: rgba(201, 48, 48, 0.1);
}

/* Table row separators are hardcoded - keep them visible but light */
:root[data-theme="light"] table.params td,
:root[data-theme="light"] .md-table td {
    border-bottom-color: rgba(100, 100, 160, 0.25);
}

.summary-row {
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    padding: 0.5rem;
    display: block;
}

.summary-row:not(.summary-row + .summary-row) {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    margin-top: 0.5rem;
}

.summary-row + .summary-row {
    border-top: none;
}

.summary-row:not(:has(+ .summary-row)) {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.sig-link,
.type-link {
    text-underline-offset: 0.2em;
    text-decoration: underline;
}

.params-head {
    margin: 1rem 0 0.75rem;
    color: var(--text-bright);
}
.param-entry {
    border: 1px solid var(--border);
    padding: 0.45em 1em;
}
.param-entry + .param-entry {
    border-top: none;
}
.param-entry .signature {
    background: transparent;
    padding: 0;
}

.api-category {
    margin: 1rem 0;
}
.summary-class-name {
    font-weight: bold;
    color: var(--text-bright);
    margin: 1rem 0 0.75rem;
}
.summary-class-name a {
    color: inherit;
}

/* ---- ToC right sidebar ---- */
.toc-sidebar {
    position: fixed;
    top: calc(var(--header-height));
    right: 0;
    width: var(--sidebar-width);
    height: 100%;
    overflow-y: auto;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    padding: 0.6rem 0.75rem;
    z-index: 85;
}
.toc-sidebar .sidebar-link {
    padding: 0 0.5em;
}
.toc-sidebar .sidebar-link.level-3 {
    padding: 0 0.5em 0 1.5em;
    font-size: 0.8em;
    line-height: 1.1;
    margin-top: -0.3em;
    margin-bottom: 0.3em;
}
.toc-sidebar .sidebar-link.level-4 {
    padding: 0 0.5em 0 2.5em;
    font-size: 0.8em;
    line-height: 1.1;
    margin-top: -0.3em;
    margin-bottom: 0.3em;
}
.toc-sidebar .sidebar-link.active {
    background-color: unset;
    color: var(--accent);
}

.toc-sidebar .sidebar-heading {
    margin-bottom: 0.5rem;
}

.sidebar-nav .toc-indent {
    padding-left: 0.75rem;
}

.sidebar-nav .toc-indent .sidebar-link {
    font-size: 0.85em;
    opacity: 0.8;
}

.toc-sidebar::-webkit-scrollbar {
    width: 0.5em;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 100em;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Widen content area to avoid overlap when toc sidebar is present */
body:has(#toc-sidebar) .main-content {
    margin-right: calc(210px + 2.5rem);
}

@media (max-width: 1200px) {
    .toc-sidebar {
        display: none;
    }

    body:has(#toc-sidebar) .main-content {
        margin-right: 0;
    }
}

/* ── Breadcrumbs ──────────────────────────────────────────────────────── */

.breadcrumbs {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--text-dim);
    margin: 0 0.1rem;
}

.breadcrumb-current {
    color: var(--text);
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

.section-page-list {
    margin: 1.5rem 0 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg-card);
}

.section-page-list h2 {
    margin-top: 0;
}

.section-page-list-items {
    margin: 0.75rem 0 0 1.25rem;
}

.section-page-list-items li + li {
    margin-top: 0.35rem;
}

/* ── Prev/Next article navigation ─────────────────────────────────────── */

.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.article-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text);
    max-width: 50%;
    transition: border-color 0.15s;
    flex-basis: 50%;
}

.article-nav-link:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.article-nav-next {
    text-align: right;
    margin-left: auto;
}

.article-nav-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.article-nav-title {
    color: var(--accent);
    font-weight: 500;
}

/* ── Heading anchor links ─────────────────────────────────────────────── */

.heading-anchor {
    color: var(--text-dim);
    text-decoration: none;
    margin-left: 0.35em;
    opacity: 0;
    transition: opacity 0.15s;
    font-weight: 400;
}

h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent);
}

/* ── Code copy button ─────────────────────────────────────────────────── */

.code-copy-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background: var(--bg-inline);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.type-hover-card {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1200;
    max-width: min(50vw, 40rem);
    max-height: min(32rem, calc(100vh - 1.5rem));
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition:
        opacity 0.12s ease,
        transform 0.12s ease;
}

.type-hover-card.visible {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
}

.type-hover-card__code {
    overflow-y: auto;
    margin: 0;
    padding: 0.5rem 0.75rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
    line-height: 1.55;
    font-size: 0.84rem;
    color: var(--text);
    background: var(--bg-code);
    border: 1px solid var(--border-code);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.type-hover-card__doc {
    overflow-y: auto;
    padding: 0.65rem 0.8rem 0.8rem;
    font-size: 0.84rem;
    background: var(--bg-page);
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.type-hover-card__doc > :first-child {
    margin-top: 0;
}

.type-hover-card__doc > :last-child {
    margin-bottom: 0;
}

.type-hover-card__doc pre.md-code_block {
    margin: 0.6rem 0 0;
}

.type-hover-card__signature-inline {
    font-family: var(--font-mono);
    margin-top: 0.75rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-code);
    border: 1px solid var(--border-code);
    font-size: 0.84rem;
    line-height: 1.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
