@font-face {
    font-family: 'Archivo';
    src: url('fonts/archivo.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-stretch: 62.5% 125%;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: 'Archivo';
    src: url('fonts/archivo-italic.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-stretch: 62.5% 125%;
    font-style: italic;
    font-display: block;
}
@font-face {
    font-family: 'Noto Sans';
    src: url('fonts/noto-sans.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-stretch: 62.5% 100%;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: 'Noto Sans';
    src: url('fonts/noto-sans-italic.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-stretch: 62.5% 100%;
    font-style: italic;
    font-display: block;
}
@font-face {
    font-family: 'Iosevka Extended';
    src: url('fonts/iosevka-extended.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: 'Iosevka Extended';
    src: url('fonts/iosevka-extended-italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: block;
}
@font-face {
    font-family: 'Iosevka Extended';
    src: url('fonts/iosevka-extended-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: 'Iosevka Extended';
    src: url('fonts/iosevka-extended-bold-italic.woff2') format('woff2');
    font-weight: 700;
    font-style: italic;
    font-display: block;
}

@font-face {
    font-family: 'Noto Sans Fallback';
    src: local('Arial'), local('Helvetica');
    size-adjust: 100.06%;
    ascent-override: 107%;
    descent-override: 29%;
    line-gap-override: 0%;
}
@font-face {
    font-family: 'Iosevka Fallback';
    src: local('Menlo'), local('Consolas'), local('Courier New');
    size-adjust: 108%;
    ascent-override: 95%;
    descent-override: 22%;
    line-gap-override: 0%;
}

:root {
    color-scheme: dark light;
    --sans: 'Noto Sans', 'Noto Sans Fallback', system-ui, sans-serif;
    --display: 'Archivo', 'Noto Sans', 'Noto Sans Fallback', system-ui, sans-serif;
    --mono: 'Iosevka Extended', 'Iosevka Fallback', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --bg: #0b1020;
    --bg-elev: #111830;
    --bg-alt: #16203f;
    --text: #e8eefc;
    --muted: #98a7cc;
    --accent: #79b8ff;
    --accent-soft: rgba(121, 184, 255, 0.12);
    --border: #243257;
    --border-soft: #1a2442;
    --kind-trait: #b488ff;
    --kind-effect: #f78c6c;
    --kind-struct: #82aaff;
    --kind-fn: #82d8a0;
    --kind-macro: #ffcb6b;
    --kind-type: #6bd4ff;
    --kind-predicate: #4fd1c5;
    --kind-aspect: #d896a5;
    --kw: #c792ea;
    --string: #c3e88d;
    --num: #ffcb6b;
    --comment: #6b7aa8;
    --nav-height: 2.75rem;
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
}
:root[data-font-size="sm"] { font-size: 13px; }
:root[data-font-size="md"] { font-size: 15px; }
:root[data-font-size="lg"] { font-size: 17px; }

@media (prefers-color-scheme: light) {
    :root {
        --bg: #fafbff;
        --bg-elev: #ffffff;
        --bg-alt: #f4f6fb;
        --text: #1a1f36;
        --muted: #5a6784;
        --accent: #0969da;
        --accent-soft: rgba(9, 105, 218, 0.1);
        --border: #d0d7e2;
        --border-soft: #e4e9f0;
        --kind-trait: #6f42c1;
        --kind-effect: #b55200;
        --kind-struct: #0550ae;
        --kind-fn: #116329;
        --kind-macro: #9a6700;
        --kind-type: #0969da;
        --kind-predicate: #0a7e7a;
        --kind-aspect: #a84b6e;
        --kw: #8250df;
        --string: #0a7f40;
        --num: #9a6700;
        --comment: #6e7a90;
    }
}

/* Explicit user-chosen theme via theme.js. `data-theme="auto"` keeps the
   media-query rules above. Light/dark force the palette regardless of
   system preference. */
:root[data-theme="light"] {
    --bg: #fafbff;
    --bg-elev: #ffffff;
    --bg-alt: #f4f6fb;
    --text: #1a1f36;
    --muted: #5a6784;
    --accent: #0969da;
    --accent-soft: rgba(9, 105, 218, 0.1);
    --border: #d0d7e2;
    --border-soft: #e4e9f0;
    --kind-trait: #6f42c1;
    --kind-effect: #b55200;
    --kind-struct: #0550ae;
    --kind-fn: #116329;
    --kind-macro: #9a6700;
    --kind-type: #0969da;
    --kind-predicate: #0a7e7a;
    --kind-aspect: #a84b6e;
    --kw: #8250df;
    --string: #0a7f40;
    --num: #9a6700;
    --comment: #6e7a90;
}
:root[data-theme="dark"] {
    --bg: #0b1020;
    --bg-elev: #111830;
    --bg-alt: #16203f;
    --text: #e8eefc;
    --muted: #98a7cc;
    --accent: #79b8ff;
    --accent-soft: rgba(121, 184, 255, 0.12);
    --border: #243257;
    --border-soft: #1a2442;
    --kind-trait: #b488ff;
    --kind-effect: #f78c6c;
    --kind-struct: #82aaff;
    --kind-fn: #82d8a0;
    --kind-macro: #ffcb6b;
    --kind-type: #6bd4ff;
    --kind-predicate: #4fd1c5;
    --kind-aspect: #d896a5;
    --kw: #c792ea;
    --string: #c3e88d;
    --num: #ffcb6b;
    --comment: #6b7aa8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-feature-settings: "calt" 1, "liga" 1, "dlig" 1;
    font-variant-ligatures: common-ligatures contextual discretionary-ligatures;
}

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

/* ---------- Link theming ---------- */

/* Intra-package API references (rendered as `<a><code>…</code></a>` by
   resolve_intra_links) get coloured by item kind, using the same palette
   as the sidebar + item headings. The href shape is
   `.../api/<kind>/<module>/<name>/index.html`. */
.docblock a[href*="/api/trait/"]         { color: var(--kind-trait); }
.docblock a[href*="/api/effect/"]        { color: var(--kind-effect); }
.docblock a[href*="/api/record/"],
.docblock a[href*="/api/struct/"]        { color: var(--kind-struct); }
.docblock a[href*="/api/function/"],
.docblock a[href*="/api/init/"]          { color: var(--kind-fn); }
.docblock a[href*="/api/macro/"],
.docblock a[href*="/api/derive/"]        { color: var(--kind-macro); }
.docblock a[href*="/api/type/"],
.docblock a[href*="/api/alias/"],
.docblock a[href*="/api/union/"],
.docblock a[href*="/api/enum/"]          { color: var(--kind-type); }
.docblock a[href*="/api/predicate/"]     { color: var(--kind-predicate); }
.docblock a[href*="/api/aspect/"]        { color: var(--kind-aspect); }

/* Intra-package links carry a `<code>` inside. Let them inherit the
   link colour (from the kind-specific rules above) so the `<code>`
   doesn't show its default mono-on-grey chip styling inside the link. */
.docblock a > code {
    color: inherit;
    background: transparent;
    padding: 0;
}

/* External links get a trailing ↗ indicator. */
.docblock a[href^="http://"]::after,
.docblock a[href^="https://"]::after {
    content: " ↗";
    font-size: 0.85em;
    opacity: 0.6;
}

/* Anchor-only links (`#section`) get a subtle underline on hover. */
.docblock a[href^="#"]:hover {
    text-decoration: underline dotted;
}

/* Opt-in glossary marker: `<a class="gloss" href=...>term</a>` gets a
   dotted underline, distinct from both plain links (solid-on-hover) and
   intra-package refs (dotted border-bottom). Intended for pointers into
   a Silo Glossary chapter — informative but not primary navigation. */
a.gloss,
a.gloss:hover,
a.gloss:visited,
.docblock abbr[title] {
    text-decoration: underline dotted;
    text-underline-offset: 0.2em;
    color: inherit;
}

/* Inline <kbd> from `:kbd[...]`. */
.docblock kbd {
    font-family: var(--mono);
    font-size: 0.85em;
    padding: 0.1em 0.4em;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 0.25rem;
    background: var(--bg-alt);
    color: var(--text);
    vertical-align: 0.05em;
    line-height: 1;
}

/* `:abbr[...]` — dotted underline (shared rule above) plus CSS popover
   on :hover / :focus that works on both desktop and mobile (tap
   focuses the element, popover shows). No JS. */
.docblock abbr[title] {
    cursor: help;
    position: relative;
    outline: none;
}
.docblock abbr[title]:hover::after,
.docblock abbr[title]:focus::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 0.25em);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 10;
    padding: 0.3em 0.6em;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0.3em;
    font-size: 0.85em;
    font-weight: normal;
    font-style: normal;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

code, pre, kbd { font-family: var(--mono); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--display);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

/* ---------- Top-level layout ---------- */

.rustdoc {
    display: grid;
    grid-template-columns: var(--sidebar-width, 240px) minmax(0, 1fr);
    min-height: calc(100vh - var(--nav-height));
}

/* Chapter pages render with a third column for the "On this page"
   TOC. `.chapter-toc` is a sibling of `<main>` so it becomes a proper
   grid column — not a `float` inside the content. */
.rustdoc.with-toc {
    grid-template-columns: var(--sidebar-width, 240px) minmax(0, 1fr) var(--toc-width, 13rem);
}

.chapter-toc {
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--nav-height) - 2rem);
    overflow-y: auto;
    margin: 1.5rem 1rem 1rem 0;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border-soft);
    font-size: 0.85rem;
    color: var(--muted);
}
.chapter-toc-label {
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 0.35rem 0;
}
.chapter-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.chapter-toc li { margin: 0; }
.chapter-toc li.toc-h3 { padding-left: 0.9rem; }
.chapter-toc a {
    display: block;
    padding: 0.2rem 0.5rem;
    color: var(--muted);
    border-left: 2px solid transparent;
    margin-left: -0.78rem;
    line-height: 1.35;
}
.chapter-toc a:hover { color: var(--accent); text-decoration: none; }
.chapter-toc a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-soft);
}

/* Heading anchors: each H2-H6 inside a chapter carries an `id` slug
   and a hover-reveal `#` self-link. The `scroll-margin-top` keeps the
   heading clear of the sticky top nav when the user hits `#slug`. */
.docblock h2.chapter-heading,
.docblock h3.chapter-heading,
.docblock h4.chapter-heading,
.docblock h5.chapter-heading,
.docblock h6.chapter-heading {
    scroll-margin-top: calc(var(--nav-height) + 1rem);
    position: relative;
}
/* Chapter headings rely on the shared `.doc-anchor` § glyph injected
   by doc-anchors.js; no `.anchor-self` block needed. */

/* ---------- Top navigation bar ---------- */

/* The drawer checkbox is invisible; it exists only to toggle the mobile
   nav via the `:checked ~` CSS sibling selector. */
.nav-drawer-toggle {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--nav-height);
    padding: 0 0.75rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}
.site-nav .hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    cursor: pointer;
    color: var(--muted);
    user-select: none;
    -webkit-user-select: none;
}
.site-nav .hamburger:hover { color: var(--accent); background: var(--accent-soft); }
.site-nav .brand {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}
.site-nav .brand-name {
    font-family: var(--display);
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.site-nav .brand-name:hover { color: var(--accent); text-decoration: none; }
.site-nav .brand-version {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.site-nav .top-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: 0.5rem;
}
.site-nav .top-tab {
    display: inline-flex;
    align-items: center;
    height: 1.75rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    color: var(--muted);
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.85rem;
}
.site-nav .top-tab:hover {
    color: var(--accent);
    background: var(--accent-soft);
    text-decoration: none;
}
.site-nav .top-tab.active {
    color: var(--accent);
    background: var(--accent-soft);
}
.site-nav .top-search {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 28rem;
    margin-left: auto;
    position: relative;
}
.site-nav .top-search .search-input-wrap {
    display: flex;
    align-items: center;
    padding: 0 0.5rem 0 0.7rem;
    height: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
}
.site-nav .top-search .search-icon { display: inline-flex; margin-right: 0.35rem; }
.site-nav .top-search input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text);
    font: inherit;
}
.site-nav .top-search input[type="search"]:focus { outline: none; }
.site-nav .top-tools {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.25rem;
}

/* ---------- Mobile drawer ---------- */

/* Backdrop is a sibling label that covers the viewport when the
   checkbox is on. Tap-to-close. */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 25;
    cursor: pointer;
}

/* Draggable handle between sidebar and main. Visual affordance is the
   2px border-right on .sidebar; the handle is an overlay strip. */
.sidebar-resizer {
    position: fixed;
    left: calc(var(--sidebar-width, 240px) - 3px);
    top: var(--nav-height);
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 20;
    background: transparent;
}
.sidebar-resizer:hover,
body.sidebar-resizing .sidebar-resizer {
    background: var(--accent-soft);
}
body.sidebar-resizing { user-select: none; cursor: ew-resize; }
@media (max-width: 800px) {
    .sidebar-resizer { display: none; }
}

.sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg-elev);
    position: sticky;
    top: var(--nav-height);
    align-self: start;
    height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    padding: 1rem 0.75rem 2rem 0.75rem;
    font-size: 0.9rem;
}

/* Theme + font-size toggles share geometry so they line up pixel-for-
   pixel inside the top nav. Both are pill-shaped strips with uniform
   button height; the active button is filled. */
.theme-toggle,
.font-size-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    vertical-align: middle;
    height: 1.75rem;
    box-sizing: border-box;
}
.theme-toggle button,
.theme-toggle button.icon-btn,
.font-size-toggle button,
.font-size-toggle button.icon-btn {
    background: none;
    border: none;
    border-radius: 0;
    color: var(--muted);
    padding: 0 0.5rem;
    height: 100%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.theme-toggle button:hover,
.theme-toggle button.icon-btn:hover,
.font-size-toggle button:hover,
.font-size-toggle button.icon-btn:hover {
    color: var(--accent);
    border-color: transparent;
}
.theme-toggle button[aria-pressed="true"],
.font-size-toggle button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}

.font-size-toggle button {
    font-family: var(--display);
    font-weight: 600;
    line-height: 1;
    /* The "A" labels are UI, not content. Disable text selection and
       keep the pointer cursor on the inner span. */
    user-select: none;
    -webkit-user-select: none;
    /* Fixed width per size so the three buttons don't resize the strip
       as the user flips between them. */
    min-width: 1.4rem;
}
.font-size-toggle button .fs-label {
    cursor: inherit;
    user-select: none;
    -webkit-user-select: none;
}
.font-size-toggle button:hover,
.font-size-toggle button.icon-btn:hover {
    color: var(--accent);
    border-color: transparent;
}
.font-size-toggle button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}
.font-size-toggle .fs-sm { font-size: 11px; }
.font-size-toggle .fs-md { font-size: 13px; }
.font-size-toggle .fs-lg { font-size: 15px; }

.search-results {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
    font-size: 0.85rem;
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elev);
    position: absolute;
    left: 0;
    right: 0;
    z-index: 10;
}
.search-results[hidden] { display: none; }
.search-results li { margin: 0; padding: 0; }
.search-results a {
    display: flex;
    flex-direction: column;
    padding: 0.3rem 0.5rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
}
.search-results a:hover { background: var(--accent-soft); text-decoration: none; }
.search-results a:last-child { border-bottom: none; }
.search-name { font-weight: 600; color: var(--text); }
.search-meta { font-size: 0.7rem; color: var(--muted); }

.sidebar-elems { padding: 0 0.25rem; }
.sidebar-elems h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0.75rem 0 0.25rem 0;
    padding: 0 0.25rem;
}
.sidebar-elems h3 a { color: inherit; }
.sidebar-elems h3 a:hover { color: var(--accent); text-decoration: none; }
.sidebar-elems .block { list-style: none; padding: 0; margin: 0 0 0.25rem 0; }
.sidebar-elems .block li { margin: 0.15rem 0; }
.sidebar-elems .block li.depth-1 > a {
    padding-left: 1.25rem;
    font-size: 0.78rem;
    color: var(--muted);
}
.sidebar-elems .block li.depth-1 > a:hover { color: var(--accent); }
.sidebar-elems .block li a {
    display: block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    color: var(--text);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-elems .block li a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar-elems .block li a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* Part-kind headings inside the Handbook sidebar chapter list.
   Small uppercase eyebrows separating Front Matter / Chapters /
   Appendices when a book populates more than one part. */
.sidebar-elems .chapter-list li.chapter-section-heading {
    padding: 0.65rem 0.55rem 0.2rem 0.55rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-muted);
    font-weight: 600;
}
.sidebar-elems .chapter-list li.chapter-section-heading:first-child {
    padding-top: 0.25rem;
}

.sidebar-elems .modnav {
    padding: 0.5rem 0.25rem 0 0.25rem;
    border-top: 1px solid var(--border-soft);
    margin-top: 1rem;
}
.sidebar-elems .modnav h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 0.25rem 0;
    padding: 0 0.25rem;
}
.sidebar-elems .modnav a { color: var(--text); }

/* ---------- Main content region ---------- */

main {
    min-width: 0;
    padding: 1rem 1.5rem 3rem 1.5rem;
}

.width-limiter { max-width: 960px; }

.skip-link {
    position: absolute;
    left: 1rem;
    top: 1rem;
    transform: translateY(-200%);
    background: var(--bg-alt);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
}
.skip-link:focus { transform: translateY(0); }

.main-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.75rem;
    margin-bottom: 0.6rem;
}
.rustdoc-breadcrumbs {
    flex-basis: 100%;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.1rem;
}
.rustdoc-breadcrumbs a { color: var(--muted); }
.rustdoc-breadcrumbs a:hover { color: var(--accent); }

.main-heading h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    word-break: break-word;
}
.main-heading h1 .kind-label {
    color: var(--muted);
    font-weight: 500;
    margin-right: 0.4rem;
}
.main-heading h1 .kind-label .kind-icon {
    display: inline-flex;
    color: var(--accent);
    margin-right: 0.35rem;
}
.main-heading h1 > span.record,
.main-heading h1 > span.union,
.main-heading h1 > span.enum { color: var(--kind-struct); }
.main-heading h1 > span.trait { color: var(--kind-trait); }
.main-heading h1 > span.effect { color: var(--kind-effect); }
.main-heading h1 > span.function,
.main-heading h1 > span.init { color: var(--kind-fn); }
.main-heading h1 > span.macro,
.main-heading h1 > span.derive { color: var(--kind-macro); }
.main-heading h1 > span.type,
.main-heading h1 > span.alias,
.main-heading h1 > span.newtype { color: var(--kind-type); }
.main-heading h1 > span.predicate { color: var(--kind-predicate); }
.main-heading h1 > span.aspect { color: var(--kind-aspect); }
.main-heading h1 > span.module,
.main-heading h1 > span.package,
.main-heading h1 > span.crate { color: var(--accent); }
.sidebar-kind .kind-icon {
    display: inline-flex;
    align-items: center;
    color: var(--accent);
    margin-right: 0.35rem;
}
.row-kind-icon {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    margin-right: 0.3rem;
    vertical-align: -0.2em;
}
dl.item-table > dt a:hover .row-kind-icon { color: var(--accent); }

.method-icon,
.impl-icon {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    margin-right: 0.35rem;
}
.method-name { font-weight: 600; }
.method-name.fn { color: var(--kind-fn); }
.method-name.macro { color: var(--kind-macro); }
.method-name.dispose { color: #e06c75; }
.method-name.implicit {
    font-family: var(--display);
    font-style: italic;
    font-weight: 500;
    opacity: 0.9;
    margin-left: 0.4em;
}
.main-heading h1 .trait { color: var(--kind-trait); }
.main-heading h1 .effect { color: var(--kind-effect); }
.main-heading h1 .record, .main-heading h1 .struct { color: var(--kind-struct); }
.main-heading h1 .fn, .main-heading h1 .function { color: var(--kind-fn); }
.main-heading h1 .macro { color: var(--kind-macro); }
.main-heading h1 .type { color: var(--kind-type); }

.sub-heading {
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: auto;
    display: inline-flex;
    gap: 0.5rem;
    align-items: baseline;
}

/* Generic icon-only button: bordered, muted, accent on hover. */
button.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
button.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Collapse/expand-all toggle in the sub-heading row. */
button.expand-all {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    padding: 0.1rem 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
button.expand-all:hover {
    border-color: var(--accent);
    color: var(--accent);
}
button.expand-all .icon-collapse,
button.expand-all .icon-expand {
    display: inline-flex;
    align-items: center;
}
button.expand-all[data-state="open"] .icon-expand { display: none; }
button.expand-all[data-state="closed"] .icon-collapse { display: none; }

.sub-heading a.src {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.sub-heading a.src:hover { color: var(--accent); }

/* ---------- Item decl signature block ---------- */

pre.silo.item-decl {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0 0 0.75rem 0;
}
pre.silo.item-decl code { padding: 0; background: none; }

.kw { color: var(--kw); font-weight: 600; }
.modes { color: var(--muted); }

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

.docblock {
    margin: 0 0 0.75rem 0;
    line-height: 1.55;
}
.docblock p { margin: 0.5em 0; }
.docblock p:first-child { margin-top: 0; }
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
    margin: 1.2em 0 0.4em 0;
    font-weight: 600;
}
.docblock h2 { font-size: 1.2rem; }
.docblock h3 { font-size: 1.05rem; }
.docblock h4 { font-size: 0.95rem; }
.docblock code {
    background: var(--bg-alt);
    padding: 0.08em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}
.docblock pre {
    background: var(--bg-alt);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    margin: 1rem auto;
    max-width: 100%;
}
.docblock pre code { background: none; padding: 0; font-size: 0.9em; }

/* Syntax-highlighted spans inside prose code blocks. markdawn emits
   custom element tags (`a-k` keyword, `a-v` variable, `a-t` type, etc.)
   rather than class names, so we style them directly. */
.docblock pre code a-k,
.docblock pre code a-kw,
.docblock pre code a-keyword { color: var(--kw); font-weight: 600; }
.docblock pre code a-t,
.docblock pre code a-ty,
.docblock pre code a-type { color: var(--kind-struct); }
.docblock pre code a-v,
.docblock pre code a-var,
.docblock pre code a-variable { color: var(--text); }
.docblock pre code a-s,
.docblock pre code a-string { color: var(--string); }
.docblock pre code a-n,
.docblock pre code a-num,
.docblock pre code a-number { color: var(--num); }
.docblock pre code a-c,
.docblock pre code a-comment { color: var(--comment); font-style: italic; }
.docblock pre code a-m,
.docblock pre code a-modifier { color: var(--kind-effect); }
.docblock pre code a-o,
.docblock pre code a-op,
.docblock pre code a-operator { color: var(--kw); }
.docblock ul, .docblock ol { padding-left: 1.5em; margin: 0.5em 0; }
.docblock table {
    border-collapse: collapse;
    margin: 1rem auto;
    max-width: 100%;
}
.docblock figure { margin: 1rem auto; text-align: center; }
.docblock img { max-width: 100%; display: block; margin: 0.5rem auto; }
.docblock th, .docblock td { border: 1px solid var(--border); padding: 0.3rem 0.6rem; }
.docblock th { background: var(--bg-alt); }
.docblock .math-display {
    display: block;
    text-align: center;
    margin: 1rem 0;
    overflow-x: auto;
}
.docblock .math-display > svg { display: inline-block; max-width: 100%; height: auto; }
.docblock .math-inline > svg { vertical-align: -0.15em; }
.docblock .pikchr {
    display: block;
    text-align: center;
    margin: 1rem 0;
}
.docblock .pikchr > svg { max-width: 100%; height: auto; }

.docblock blockquote {
    border-left: 3px solid var(--border);
    padding-left: 0.75rem;
    color: var(--muted);
    margin: 0.75rem 0;
}
.docblock .markdown-alert {
    border-left: 3px solid;
    padding: 0.6rem 0.9rem;
    background: var(--bg-elev);
    border-radius: 0 4px 4px 0;
    margin: 0.9rem 0;
}
.docblock .markdown-alert-title {
    font-family: var(--sans);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.35rem 0;
}
.docblock .markdown-alert-icon {
    display: inline-flex;
    align-items: center;
}
.docblock .markdown-alert > :not(.markdown-alert-title) {
    color: var(--text);
}
.docblock .markdown-alert > p:last-child { margin-bottom: 0; }
.docblock .markdown-alert-note {
    border-color: var(--kind-trait, #3b82f6);
    color: var(--kind-trait, #3b82f6);
}
.docblock .markdown-alert-tip {
    border-color: var(--kind-fn, #16a34a);
    color: var(--kind-fn, #16a34a);
}
.docblock .markdown-alert-important {
    border-color: var(--kind-macro, #a855f7);
    color: var(--kind-macro, #a855f7);
}
.docblock .markdown-alert-warning {
    border-color: #d6a100;
    color: #d6a100;
}
.docblock .markdown-alert-caution {
    border-color: #c0392b;
    color: #c0392b;
}

/* ---------- Named blocks: tabs, details, figure ---------- */

/* Tabs: hidden-radio pattern. `:checked` + nth-of-type / nth-child select
   the active label and panel. No JS. Supports up to 10 tabs per tabset;
   add more rules below if you ever need a wider set. */
.docblock .tabs {
    margin: 1.25rem 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--bg-elev);
}
.docblock .tabs > input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.docblock .tabs > .tab-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}
.docblock .tabs > .tab-labels > label {
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    user-select: none;
    transition: color 80ms, border-color 80ms, background 80ms;
}
.docblock .tabs > .tab-labels > label:hover {
    color: var(--text);
    background: var(--bg-elev);
}
.docblock .tabs > .tab-panels {
    padding: 0.75rem 1rem;
}
.docblock .tabs > .tab-panels > .tab-panel {
    display: none;
}
.docblock .tabs > .tab-panels > .tab-panel > :first-child { margin-top: 0; }
.docblock .tabs > .tab-panels > .tab-panel > :last-child { margin-bottom: 0; }

/* One pair of rules per position up to 10 tabs. */
.docblock .tabs > input:nth-of-type(1):checked ~ .tab-panels > .tab-panel:nth-child(1) { display: block; }
.docblock .tabs > input:nth-of-type(1):checked ~ .tab-labels > label:nth-child(1) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(2):checked ~ .tab-panels > .tab-panel:nth-child(2) { display: block; }
.docblock .tabs > input:nth-of-type(2):checked ~ .tab-labels > label:nth-child(2) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(3):checked ~ .tab-panels > .tab-panel:nth-child(3) { display: block; }
.docblock .tabs > input:nth-of-type(3):checked ~ .tab-labels > label:nth-child(3) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(4):checked ~ .tab-panels > .tab-panel:nth-child(4) { display: block; }
.docblock .tabs > input:nth-of-type(4):checked ~ .tab-labels > label:nth-child(4) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(5):checked ~ .tab-panels > .tab-panel:nth-child(5) { display: block; }
.docblock .tabs > input:nth-of-type(5):checked ~ .tab-labels > label:nth-child(5) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(6):checked ~ .tab-panels > .tab-panel:nth-child(6) { display: block; }
.docblock .tabs > input:nth-of-type(6):checked ~ .tab-labels > label:nth-child(6) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(7):checked ~ .tab-panels > .tab-panel:nth-child(7) { display: block; }
.docblock .tabs > input:nth-of-type(7):checked ~ .tab-labels > label:nth-child(7) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(8):checked ~ .tab-panels > .tab-panel:nth-child(8) { display: block; }
.docblock .tabs > input:nth-of-type(8):checked ~ .tab-labels > label:nth-child(8) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(9):checked ~ .tab-panels > .tab-panel:nth-child(9) { display: block; }
.docblock .tabs > input:nth-of-type(9):checked ~ .tab-labels > label:nth-child(9) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }
.docblock .tabs > input:nth-of-type(10):checked ~ .tab-panels > .tab-panel:nth-child(10) { display: block; }
.docblock .tabs > input:nth-of-type(10):checked ~ .tab-labels > label:nth-child(10) { color: var(--text); border-bottom-color: var(--accent); background: var(--bg-elev); }

/* Details / summary. Native <details> gets a little polish.
   Override the default-empty summary via `--details-empty-summary` on
   `:root` (or any ancestor) to re-word or localise; the default value
   is "Details". Authors that want explicit text still write
   `:details My summary text`. */
.docblock details {
    margin: 1rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-elev);
}
.docblock details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.docblock details > summary:empty::before {
    content: var(--details-empty-summary, "Details");
    color: var(--muted);
    font-style: italic;
}
.docblock details[open] > summary {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.375rem;
}
.docblock details > :not(summary):first-of-type { margin-top: 0; }
.docblock details > :last-child { margin-bottom: 0; }

/* Figure / figcaption. */
.docblock figure {
    margin: 1.25rem 0;
    text-align: center;
}
.docblock figure img { max-width: 100%; height: auto; }
.docblock figure figcaption {
    margin-top: 0.5rem;
    font-size: 0.9em;
    color: var(--muted);
    font-style: italic;
}

/* Generic fenced-block fallback for unknown :<name> values. */
.docblock .fenced-block {
    margin: 1rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 0.375rem;
}

.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 {
    scroll-margin-top: 1rem;
}
.docblock a.doc-anchor {
    margin-left: 0.3em;
    opacity: 0;
    color: var(--muted);
    font-weight: 400;
    text-decoration: none;
    transition: opacity 80ms;
}
.docblock h1:hover a.doc-anchor,
.docblock h2:hover a.doc-anchor,
.docblock h3:hover a.doc-anchor,
.docblock h4:hover a.doc-anchor,
.docblock h5:hover a.doc-anchor,
.docblock h6:hover a.doc-anchor,
.docblock *:target > a.doc-anchor { opacity: 1; }

/* ---------- Collapse toggles ---------- */

details.toggle { margin: 0; }
details.toggle > summary {
    cursor: pointer;
    list-style: none;
    outline: none;
}
details.toggle > summary::-webkit-details-marker { display: none; }
details.toggle > summary.hideme { display: none; }

details.toggle.top-doc { margin: 0 0 1rem 0; }
details.toggle.top-doc > summary.top-doc-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--display);
    font-weight: 600;
    color: var(--muted);
    padding: 0.2rem 0;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    user-select: none;
}
details.toggle.top-doc > summary.top-doc-summary:hover { color: var(--accent); }

.details-chevron {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    margin-right: 0.3rem;
    transition: transform 120ms ease;
}
details.toggle[open] > summary .details-chevron { transform: rotate(90deg); }

/* ---------- Section headers with § anchors ---------- */

h2.section-header {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border);
    scroll-margin-top: 1rem;
}
h3.section-header, h4.section-header {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.9rem 0 0.4rem 0;
    scroll-margin-top: 1rem;
}

/* Meta-group: `<h2 class="section-header">` (e.g. "Data Types") followed by
   a responsive multi-column grid of sub-kind groups (Records, Unions, …).
   Single-member meta-groups drop the column layout via `.single`. */
.kind-groups {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    margin: 0 0 1rem 0;
}
.kind-groups.single { display: block; }
@media (max-width: 700px) {
    .kind-groups { grid-template-columns: 1fr; }
}
.kind-group { min-width: 0; }
.kind-group-title {
    font-family: var(--display);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 0.5rem 0 0.3rem 0;
}
.kind-group dl.item-table {
    margin: 0 0 0.25rem 0;
    gap: 0.2rem 0.75rem;
}

/* Handbook table of contents rendered as nested ULs. */
ul.handbook-toc {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem 0;
}
ul.handbook-toc ul.handbook-toc {
    margin: 0.15rem 0 0.35rem 0;
    padding-left: 1.25rem;
    border-left: 1px solid var(--border-soft);
}
ul.handbook-toc > li.toc-part-heading {
    list-style: none;
    padding: 1rem 0 0.2rem 0;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 0.3rem;
}
ul.handbook-toc > li.toc-part-heading:first-child { padding-top: 0; }
ul.handbook-toc > li.toc-item {
    margin: 0.45rem 0;
    font-size: 0.95rem;
    line-height: 1.5;
}
ul.handbook-toc > li.toc-item > a {
    font-family: var(--display);
    font-weight: 500;
}
ul.handbook-toc > li.toc-item > .row-kind-icon {
    margin-right: 0.3rem;
    color: var(--muted);
}
ul.handbook-toc > li.toc-item:hover > .row-kind-icon { color: var(--accent); }

/* Predicate page: Pattern + Conditions */
.predicate-pattern {
    margin: 0.5rem 0 0.75rem 0;
    color: var(--muted);
}
.predicate-pattern .type-view {
    color: var(--text);
    font-family: var(--mono);
}
.predicate-pattern .pattern-binding {
    color: var(--kind-fn);
    font-weight: 600;
}
ul.predicate-conditions {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem 0;
}
ul.predicate-conditions > li {
    font-family: var(--mono);
    font-size: 0.95rem;
    padding: 0.3rem 0.6rem;
    border-left: 2px solid var(--border);
    margin-bottom: 0.2rem;
}

a.anchor {
    margin-left: 0.3em;
    color: var(--muted);
    font-weight: 400;
    opacity: 0;
    transition: opacity 80ms;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    position: relative;
}
a.anchor:hover { color: var(--accent); }
a.anchor.anchor-copied { opacity: 1; color: var(--accent); }
a.anchor.anchor-copied::after {
    content: "Link copied";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.4rem;
    font-size: 0.7rem;
    font-family: var(--sans);
    background: var(--accent);
    color: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    animation: anchor-copied-flash 1200ms ease-out;
}
@keyframes anchor-copied-flash {
    0% { opacity: 0; }
    10%, 80% { opacity: 1; }
    100% { opacity: 0; }
}
h2.section-header:hover a.anchor,
h3.section-header:hover a.anchor,
h4.section-header:hover a.anchor,
section:target a.anchor,
section:hover > h3.code-header a.anchor,
section:hover > h4.code-header a.anchor { opacity: 1; }

/* ---------- Summary tables ---------- */

dl.item-table {
    display: grid;
    grid-template-columns: minmax(120px, max-content) 1fr;
    gap: 0.35rem 1.25rem;
    margin: 0 0 1rem 0;
    padding: 0;
}
dl.item-table > dt {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}
dl.item-table > dt a {
    font-family: var(--display);
    font-weight: 500;
    letter-spacing: -0.005em;
}
dl.item-table > dd {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}
dl.item-table > dd > p { margin: 0; }
dl.item-table > dd > p:not(:last-child) { margin-bottom: 0.2rem; }
dl.item-table a.trait { color: var(--kind-trait); }
dl.item-table a.effect { color: var(--kind-effect); }
dl.item-table a.record, dl.item-table a.struct, dl.item-table a.union, dl.item-table a.enum { color: var(--kind-struct); }
dl.item-table a.function, dl.item-table a.fn, dl.item-table a.init { color: var(--kind-fn); }
dl.item-table a.macro, dl.item-table a.derive { color: var(--kind-macro); }
dl.item-table a.type, dl.item-table a.alias, dl.item-table a.newtype { color: var(--kind-type); }
dl.item-table a.predicate { color: var(--kind-predicate); }
dl.item-table a.aspect { color: var(--kind-aspect); }

/* ---------- Item detail entries (inline on module page) ---------- */

section.item {
    margin: 0 0 1.5rem 0;
    scroll-margin-top: 1rem;
}
section.item:target {
    outline: 2px solid var(--accent);
    outline-offset: 6px;
    border-radius: 4px;
}

h3.code-header, h4.code-header {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0 0 0.4rem 0;
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
    scroll-margin-top: 1rem;
}
h3.code-header { font-size: 1rem; }

.rightside {
    float: right;
    margin-left: 0.6rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
}
.rightside a {
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.rightside a:hover { color: var(--accent); }

/* ---------- Methods / impls ---------- */

.methods, .impl-items { display: block; }

section.method {
    padding: 0.4rem 0;
    border-top: 1px solid var(--border-soft);
}
section.method:first-child { border-top: none; }

details.method-toggle { }
details.method-toggle > summary {
    display: flex;
    align-items: flex-start;
    gap: 0.1rem;
}
details.method-toggle > summary > section.method { flex: 1; min-width: 0; padding-bottom: 0; }
details.method-toggle > summary > .details-chevron { margin-top: 0.55rem; }
details.method-toggle > .docblock { padding: 0.25rem 0 0.75rem 1rem; }

section.impl {
    margin: 1rem 0 0 0;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-elev);
}
section.impl > h3.code-header {
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-soft);
}

#implementors-list > section.impl { background: var(--bg-elev); }

/* ---------- Field lists (records / unions) ---------- */

dl.fields, dl.variants {
    display: grid;
    grid-template-columns: minmax(100px, max-content) 1fr;
    gap: 0.3rem 1rem;
    margin: 0.25rem 0 0.75rem 1rem;
}
dl.fields > dt, dl.variants > dt {
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--text);
}
dl.fields > dd, dl.variants > dd {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.5;
}

/* ---------- Elevated conversions (From / Into / TryFrom / TryInto) ---------- */

.conversions {
    margin: 0.8rem 0 1.2rem 0;
    padding: 0.6rem 0.9rem;
    border-left: 2px solid var(--border-soft, #d0d7e2);
    background: var(--bg-soft, #f4f6fb);
    border-radius: 0 3px 3px 0;
}
.conversions h3.conversions-direction {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 0 0 0.3rem 0;
    border: none;
}
.conversions ul.conversions-list {
    list-style: none;
    margin: 0 0 0.6rem 0;
    padding: 0;
}
.conversions ul.conversions-list > li {
    margin: 0.25rem 0;
    font-size: 0.92rem;
}
.conv-err {
    color: var(--muted);
    font-size: 0.88rem;
}

/* ---------- Signature styling (inline in code-header) ---------- */

.sig-paren { color: var(--muted); }
.sig-arrow { color: var(--kw); font-weight: 600; font-size: 1.1em; }

/* Stack-effect arrow (U+2192). */
.arrow {
    color: var(--kw);
    font-weight: 700;
}
.sig-effect { color: var(--kind-effect); }
.sig-effect a { color: inherit; }
.sig-constraints { color: var(--num); }
.sig-existentials { color: var(--muted); font-size: 0.82rem; margin-top: 0.25rem; display: block; }

.type-view { color: var(--kind-struct); }
.type-view a { color: inherit; }

.badge {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.05rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.7rem;
    text-transform: lowercase;
    vertical-align: middle;
}

.reexport-note {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.5rem 0 0.75rem 0;
}

/* "Implements: Trait · Trait" chip row under the h1 on type pages. */
.implements-row {
    font-size: 0.85rem;
    margin: -0.2rem 0 0.75rem 0;
    padding: 0.2rem 0 0.4rem 0;
    color: var(--muted);
    border-bottom: 1px dashed var(--border-soft);
}
.implements-row .label {
    font-weight: 600;
    font-family: var(--display);
    letter-spacing: 0.01em;
    color: var(--muted);
    margin-right: 0.2rem;
}
.implements-row a.trait-chip {
    font-family: var(--mono);
    color: var(--kind-trait);
}
.implements-row a.trait-chip:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Effect parent-chain breadcrumb. */
.effect-chain {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.2rem 0 0.75rem 0;
    padding: 0.2rem 0 0.4rem 0;
    border-bottom: 1px dashed var(--border-soft);
}
.effect-chain .label {
    font-weight: 600;
    font-family: var(--display);
    color: var(--muted);
    margin-right: 0.3rem;
}
.effect-chain .effect-chip a, .effect-chain .effect-chip .effect {
    color: var(--kind-effect);
    font-family: var(--mono);
}
.effect-chain .effect-chip.current .effect { font-weight: 700; }
.effect-chain .chain-arrow { color: var(--muted); padding: 0 0.15rem; }

/* Crate-root stats strip under the main heading. */
.crate-stats {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.2rem 0 0.75rem 0;
    padding: 0.2rem 0 0.4rem 0;
    border-bottom: 1px dashed var(--border-soft);
}

/* Mode badges beside item names — visibility/locality info. */
.mode-badges {
    display: inline-flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Per-mode colours make the discipline scannable. */
.badge.mode-pub    { color: #4a9eff; border-color: rgba(74, 158, 255, 0.5); }
.badge.mode-sealed { color: #b488ff; border-color: rgba(180, 136, 255, 0.5); }
.badge.mode-pkg    { color: #82d8a0; border-color: rgba(130, 216, 160, 0.5); }
.badge.mode-mod    { color: var(--muted); border-color: var(--border); }
.badge.mode-local  { color: #6bd4ff; border-color: rgba(107, 212, 255, 0.5); }
.badge.mode-unique { color: #f78c6c; border-color: rgba(247, 140, 108, 0.55); }
.badge.mode-linear { color: #ff4d6d; border-color: rgba(255, 77, 109, 0.55); }

@media (prefers-color-scheme: light) {
    .badge.mode-pub    { color: #0550ae; border-color: rgba(5, 80, 174, 0.45); }
    .badge.mode-sealed { color: #6f42c1; border-color: rgba(111, 66, 193, 0.45); }
    .badge.mode-pkg    { color: #116329; border-color: rgba(17, 99, 41, 0.45); }
    .badge.mode-local  { color: #0969da; border-color: rgba(9, 105, 218, 0.45); }
    .badge.mode-unique { color: #b55200; border-color: rgba(181, 82, 0, 0.45); }
    .badge.mode-linear { color: #d01a3f; border-color: rgba(208, 26, 63, 0.45); }
}

/* Performs line on functions with declared effects. */
.meta-line.performs {
    margin: 0.25rem 0 0.75rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}
.meta-line.performs .kind-label {
    font-family: var(--display);
    font-weight: 600;
    color: var(--text);
    margin-right: 0.3rem;
}

/* Silo-specific type-discipline callout. Appears on types whose locality
   mode is `unique` (affine) or `linear`. */
.type-discipline {
    margin: 0 0 1rem 0;
    padding: 0.55rem 0.8rem;
    border-left: 3px solid var(--kind-effect);
    background: var(--bg-alt);
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
    color: var(--text);
}
.type-discipline.unique { border-left-color: var(--kind-effect); }
.type-discipline.unique strong { color: var(--kind-effect); }
.type-discipline.linear { border-left-color: var(--kind-trait); }
.type-discipline.linear strong { color: var(--kind-trait); }

/* Item-table row tags. */
.discipline-tag, .variadic-tag {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.02rem 0.35rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    border-radius: 3px;
    background: var(--bg-alt);
    color: var(--muted);
    border: 1px solid var(--border-soft);
}
.discipline-tag.unique { color: var(--kind-effect); border-color: var(--kind-effect); }
.discipline-tag.linear { color: var(--kind-trait); border-color: var(--kind-trait); }
.discipline-tag.local { color: var(--muted); border-color: var(--border); }

.effect-tags { display: inline-flex; gap: 0.25rem; margin-left: 0.3rem; }
.effect-tag {
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0 0.35rem;
    border-radius: 3px;
    color: var(--kind-effect);
    border: 1px solid var(--kind-effect);
    background: transparent;
    line-height: 1.4;
    white-space: nowrap;
}

/* ---------- Implementors list ---------- */

#implementors-list { display: block; }

/* ---------- Source page ---------- */

pre.source-listing {
    font-family: var(--mono);
    font-size: 0.85rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0;
    overflow-x: auto;
    line-height: 1.45;
    margin: 1rem 0 0 0;
}
.src-line { display: block; padding: 0 0.5rem; }
.src-line:target {
    background: var(--accent-soft);
    border-left: 2px solid var(--accent);
    padding-left: calc(0.5rem - 2px);
}
.src-lineno {
    display: inline-block;
    width: 3.25em;
    padding-right: 1em;
    color: var(--muted);
    user-select: none;
    text-align: right;
}
.src-code { white-space: pre; }

.tok-keyword { color: var(--kw); }
.tok-type { color: var(--kind-struct); }
.tok-variable { color: var(--text); }
.tok-variable\.member { color: var(--accent); }
.tok-string, .tok-string\.special\.symbol, .tok-character { color: var(--string); }
.tok-number { color: var(--num); }
.tok-comment { color: var(--comment); font-style: italic; }
.tok-keyword\.modifier { color: var(--kind-effect); }
.tok-keyword\.operator { color: var(--kw); }
/* Markdown / .simd captures from arborium's tree-sitter-markdown. */
.tok-text\.title { color: var(--kind-struct); font-weight: 700; }
.tok-text\.literal { color: var(--string); }
.tok-text\.emphasis { font-style: italic; color: var(--text); }
.tok-text\.strong { font-weight: 700; color: var(--text); }
.tok-text\.reference { color: var(--accent); }
.tok-text\.uri { color: var(--accent); text-decoration: underline; }
.tok-text\.quote { color: var(--muted); font-style: italic; }
.tok-punctuation\.special { color: var(--kw); }
.tok-punctuation\.delimiter { color: var(--muted); }
.tok-punctuation\.bracket { color: var(--muted); }

/* ---------- Book index hero + chapter list ---------- */

.book-index { padding: 2.5rem 1.5rem 3rem 1.5rem; }
.book-hero {
    padding: 2rem 0 2.5rem 0;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 1.5rem;
}
.book-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.book-hero h1 {
    margin: 0 0 0.5rem 0;
    font-family: var(--display);
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.book-hero-sub {
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    color: var(--muted);
}
.book-hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    background: var(--accent);
    color: var(--bg-elev);
    border-radius: 999px;
    font-family: var(--display);
    font-weight: 600;
    font-size: 0.9rem;
}
.book-hero-cta:hover { background: var(--accent); filter: brightness(1.1); text-decoration: none; }

.book-index-list {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
    display: grid;
    gap: 0.75rem;
    counter-reset: book-chapter;
}
.book-index-item {
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--bg-elev);
    transition: border-color 0.12s, background 0.12s;
}
.book-index-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.book-index-link {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: var(--text);
}
.book-index-link:hover { text-decoration: none; color: var(--text); }
.book-index-number {
    flex: 0 0 auto;
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--muted);
    min-width: 2rem;
    text-align: right;
}
.book-index-item:hover .book-index-number { color: var(--accent); }
.book-index-body { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.book-index-title {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
}
.book-index-item:hover .book-index-title { color: var(--accent); }
.book-index-summary {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.55;
}
.book-empty { color: var(--muted); font-style: italic; padding: 1.5rem 0; }

.book-locale-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.book-locale-list li {
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    transition: background 0.12s, border-color 0.12s;
}
.book-locale-list li:hover { border-color: var(--accent); background: var(--accent-soft); }
.book-locale-list li.current { background: var(--accent-soft); border-color: var(--accent); }
.book-locale-list li a {
    display: block;
    padding: 0.4rem 1rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
}
.book-locale-list li a:hover { text-decoration: none; color: var(--accent); }
.book-locale-list li.current a { color: var(--accent); }

/* "Read the guide →" callout on the crate root, shown when the
   package ships book chapters. */
.guide-callout {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 1.25rem 0;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-elev);
    color: var(--text);
}
.guide-callout a { color: var(--accent); font-family: var(--display); font-weight: 600; }

/* ---------- Prev/next chapter footer ---------- */

.chapter-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 2.5rem 0 1rem 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-soft);
}
.chapter-nav > a,
.chapter-nav > span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-elev);
    color: var(--text);
    text-decoration: none;
    min-height: 3rem;
    transition: border-color 0.12s;
}
.chapter-nav > a:hover { border-color: var(--accent); text-decoration: none; }
.chapter-nav > .chapter-nav-next { text-align: right; align-items: flex-end; }
.chapter-nav .chapter-nav-label {
    font-family: var(--display);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.chapter-nav .chapter-nav-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}
.chapter-nav > .empty { background: transparent; border-color: transparent; }

/* ---------- Global code / signature reflow ---------- */

pre { overflow-x: auto; max-width: 100%; }

/* Sidebar-hosted copy of the theme + font-size toggles. Hidden by
   default; shown only inside the mobile drawer. The primary toggles
   live in the top nav on desktop (`.site-nav .top-tools`). */
.sidebar-tools { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    /* Three-column layout doesn't fit under ~1100px — collapse back to
       two columns and drop the rail. Heading anchors remain clickable;
       only the rail is hidden. */
    .rustdoc.with-toc {
        grid-template-columns: var(--sidebar-width, 240px) minmax(0, 1fr);
    }
    .chapter-toc { display: none; }
}

@media (max-width: 800px) {
    .rustdoc { grid-template-columns: 1fr; }

    /* Hamburger-driven off-canvas drawer. The sidebar slides in from
       the left when `#nav-drawer-toggle:checked` is set. */
    .site-nav .hamburger { display: inline-flex; }
    .sidebar {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: min(85vw, 320px);
        height: calc(100vh - var(--nav-height));
        max-height: none;
        border-right: 1px solid var(--border);
        border-bottom: none;
        padding: 1rem 1rem 2rem 1rem;
        transform: translateX(-100%);
        transition: transform 0.2s ease-out;
        z-index: 28;
    }
    .nav-drawer-toggle:checked ~ .rustdoc .sidebar { transform: translateX(0); }
    .nav-drawer-toggle:checked ~ .drawer-backdrop { display: block; }

    .sidebar-resizer { display: none; }
    main { padding: 1rem 1.25rem 3rem 1.25rem; }

    /* Compress the top nav when horizontal space is tight. */
    .site-nav { padding: 0 0.5rem; gap: 0.4rem; }
    .site-nav .top-tabs { margin-left: 0; }
    .site-nav .top-tools { display: none; }
    .site-nav .brand-version { display: none; }
    .site-nav .top-search { max-width: none; }

    /* Theme + text-size toggles live at the top of the drawer on
       mobile, where they reliably fit instead of competing for space
       with the hamburger + search. */
    .sidebar-tools {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
        padding: 0.25rem 0.25rem 0.75rem 0.25rem;
        margin-bottom: 0.75rem;
        border-bottom: 1px solid var(--border-soft);
    }

    .main-heading h1 {
        font-size: 1.25rem;
        word-break: break-word;
    }
    .rustdoc-breadcrumbs { font-size: 0.75rem; word-break: break-all; }
    dl.item-table {
        grid-template-columns: 1fr;
        gap: 0.1rem 0;
    }
    dl.item-table > dt { white-space: normal; }
    dl.item-table > dd { margin: 0 0 0.4rem 0; }
    .kind-groups { grid-template-columns: 1fr; }
    .sub-heading { flex-wrap: wrap; }
    h3.code-header, h4.code-header { font-size: 0.9rem; }
    details.method-toggle > summary { flex-wrap: wrap; }

    /* Signatures: scroll within the container, don't blow out the page. */
    .sig-view, pre.silo.item-decl { overflow-x: auto; max-width: 100%; }

    /* Prev/next footer stacks so thumbs don't fight for width. */
    .chapter-nav { grid-template-columns: 1fr; }
    .chapter-nav .chapter-nav-next { text-align: left; align-items: flex-start; }
    .chapter-nav .empty { display: none; }
}

@media (max-width: 480px) {
    main { padding: 0.75rem 1rem 2rem 1rem; }
    .book-index { padding: 1.25rem 1rem 2rem 1rem; }
    .book-hero h1 { font-size: 1.75rem; }
}
