/* site.css : modern frame for the latex2html pages (added by modernize.py).
   Loaded after doc.css, so it overrides the old latex2html styling.
   Every colour is a token; a theme only redefines the tokens.

   Themes (Display menu "Aa"): auto (follows the system), ivory, paper, sky,
   sage, lavender, sepia | dark: graphite, midnight, forest               */

/* ------------------------------------------------------------- themes */
:root, :root[data-theme="ivory"] {
    --bg: #fbf8f1;  --surface: #ffffff;  --sidebar: #f5f0e4;  --raised: #ffffff;
    --text: #22201c;  --muted: #6b655b;  --border: #e7dfcd;
    --accent: #8a1d1d;  --accent-2: #b8862b;  --link: #8a1d1d;
    --accent-soft: #f4e6e1;  --code-bg: #f5f1e6;  --mark: #fde68a;
    --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .06);
    color-scheme: light;
}
:root[data-theme="paper"] {
    --bg: #ffffff;  --surface: #ffffff;  --sidebar: #f8f9fb;  --raised: #ffffff;
    --text: #1c1f26;  --muted: #5f6673;  --border: #e5e7ee;
    --accent: #4f46e5;  --accent-2: #0ea5e9;  --link: #4338ca;
    --accent-soft: #eef0ff;  --code-bg: #f5f6fa;  --mark: #fef08a;
    --shadow: 0 1px 2px rgba(20, 25, 50, .06), 0 6px 20px rgba(20, 25, 50, .06);
}
:root[data-theme="sky"] {
    --bg: #f3f7fd;  --surface: #ffffff;  --sidebar: #e8f0fb;  --raised: #ffffff;
    --text: #12263f;  --muted: #4d6380;  --border: #d3e0f2;
    --accent: #1d5fbf;  --accent-2: #0d9488;  --link: #1d5fbf;
    --accent-soft: #dfeafb;  --code-bg: #eaf1fb;  --mark: #fde68a;
    --shadow: 0 1px 2px rgba(15, 40, 80, .07), 0 6px 20px rgba(15, 40, 80, .06);
}
:root[data-theme="sage"] {
    --bg: #f3f6f1;  --surface: #ffffff;  --sidebar: #e9efe6;  --raised: #ffffff;
    --text: #1d2a22;  --muted: #56685b;  --border: #d7e1d3;
    --accent: #2f6b4f;  --accent-2: #a16207;  --link: #2a6a4b;
    --accent-soft: #e0ece4;  --code-bg: #edf2ea;  --mark: #fde68a;
    --shadow: 0 1px 2px rgba(20, 50, 30, .07), 0 6px 20px rgba(20, 50, 30, .06);
}
:root[data-theme="lavender"] {
    --bg: #f7f5fb;  --surface: #ffffff;  --sidebar: #efebf7;  --raised: #ffffff;
    --text: #241d33;  --muted: #665d78;  --border: #e2dcef;
    --accent: #6d3fa8;  --accent-2: #c2477a;  --link: #6a3aa6;
    --accent-soft: #ede6f8;  --code-bg: #f1edf8;  --mark: #fbcfe8;
    --shadow: 0 1px 2px rgba(50, 30, 80, .07), 0 6px 20px rgba(50, 30, 80, .06);
}
:root[data-theme="sepia"] {
    --bg: #f4ecd8;  --surface: #fbf5e6;  --sidebar: #ece2c8;  --raised: #fbf5e6;
    --text: #3b2f22;  --muted: #75644f;  --border: #ddcfae;
    --accent: #8b5a2b;  --accent-2: #a0522d;  --link: #85501f;
    --accent-soft: #eadcbc;  --code-bg: #efe5cc;  --mark: #f6d365;
    --shadow: 0 1px 2px rgba(80, 50, 20, .08), 0 6px 20px rgba(80, 50, 20, .07);
}
:root[data-theme="graphite"] {
    --bg: #1d1f24;  --surface: #24272d;  --sidebar: #1a1c20;  --raised: #2b2e35;
    --text: #e7e7ea;  --muted: #a3a7b0;  --border: #353941;
    --accent: #ff8a70;  --accent-2: #f5c26b;  --link: #ffa38d;
    --accent-soft: #3a2b29;  --code-bg: #272a31;  --mark: #6b5310;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
}
:root[data-theme="midnight"] {
    --bg: #0f1626;  --surface: #151e31;  --sidebar: #0c1220;  --raised: #1b253b;
    --text: #e3e9f5;  --muted: #93a0bb;  --border: #26324b;
    --accent: #5cc8ff;  --accent-2: #a78bfa;  --link: #7fd4ff;
    --accent-soft: #16304a;  --code-bg: #131c2e;  --mark: #4c3d0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
}
:root[data-theme="forest"] {
    --bg: #141b17;  --surface: #19221d;  --sidebar: #111713;  --raised: #1f2a24;
    --text: #e2ebe5;  --muted: #98aa9e;  --border: #2a382f;
    --accent: #7fd1a2;  --accent-2: #e9c46a;  --link: #92dbb1;
    --accent-soft: #1f3529;  --code-bg: #18201b;  --mark: #4d4210;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
}
/* Auto (no saved choice): follow the operating system's dark mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #1d1f24;  --surface: #24272d;  --sidebar: #1a1c20;  --raised: #2b2e35;
        --text: #e7e7ea;  --muted: #a3a7b0;  --border: #353941;
        --accent: #ff8a70;  --accent-2: #f5c26b;  --link: #ffa38d;
        --accent-soft: #3a2b29;  --code-bg: #272a31;  --mark: #6b5310;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

/* -------------------------------------------------------------- fonts */
:root {
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, Arial, sans-serif;
    --font-head: var(--font);
    --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
    --topbar-h: 3.5rem;
    --sidebar-w: 18rem;
    --measure: 50rem;
    --page-max: 64rem;
    --radius: 10px;
}
:root[data-font="humanist"] {
    --font: Optima, Candara, "Noto Sans", "Segoe UI", "Gill Sans", "Trebuchet MS", sans-serif;
    --font-head: var(--font);
}
:root[data-font="serif"] {
    --font: "Iowan Old Style", Charter, "Bitstream Charter", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
    --font-head: var(--font);
}
:root[data-width="wide"] { --measure: 70rem; --page-max: 90rem; }

/* --------------------------------------------------------------- base */
html { scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body.l2h-modern {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1.02rem/1.7 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}
body.l2h-modern a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px;
                    text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
body.l2h-modern a:hover { color: var(--accent); text-decoration-color: currentColor; }
body.l2h-modern :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
body.l2h-modern ::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
#page-content a, #page-content tt, #page-content code { overflow-wrap: anywhere; }

body.l2h-modern h1, body.l2h-modern h2, body.l2h-modern h3,
body.l2h-modern h4, body.l2h-modern h5, body.l2h-modern h6 {
    font-family: var(--font-head);
    color: var(--text);
    text-shadow: none;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 2.2rem 0 .8rem;
    font-weight: 700;
}
body.l2h-modern h1, body.l2h-modern h2 {
    font-size: clamp(1.75rem, 1.25rem + 1.6vw, 2.4rem);
    margin-top: .4rem;
    padding-bottom: .55rem;
    background: linear-gradient(90deg, var(--accent), var(--accent-2)) left bottom / 3.5rem 3px no-repeat;
}
/* heading icons (added by modernize.py, chosen in heading_icons.py) */
.eyebrow {
    margin: .3rem 0 .35rem;
    font-size: .78rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted);
}
body.l2h-modern .page-title { display: flex; align-items: flex-start; gap: .85rem; }
body.l2h-modern .page-title .h-badge { margin-top: .1em; }   /* level with the first line */
body.l2h-modern .page-title.CENTER { justify-content: center; background-position: center bottom; }
/* centred text from LaTeX (\centering, title page author line): use the full width */
#page-content > p.CENTER, #page-content > div.CENTER { max-width: none; text-align: center; }
.h-badge {
    flex: none; display: grid; place-items: center;
    width: 2.6rem; height: 2.6rem; border-radius: .8rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent),
                inset 0 1px 0 rgba(255,255,255,.25);
}
.h-badge svg { width: 1.45rem; height: 1.45rem; }
body.l2h-modern .has-icon { display: flex; align-items: center; gap: .55rem; }
.h-icon {
    flex: none; display: grid; place-items: center;
    width: 1.8em; height: 1.8em; border-radius: .55em;
    color: var(--accent);
    background: var(--accent-soft);
}
.h-icon svg { width: 1.1em; height: 1.1em; }
@media (max-width: 480px) {
    .h-badge { width: 2.2rem; height: 2.2rem; border-radius: .65rem; }
    .h-badge svg { width: 1.2rem; height: 1.2rem; }
}
@media print { .h-badge, .h-icon { display: none; } }

body.l2h-modern h3 { font-size: 1.4rem; color: var(--accent); }
body.l2h-modern h4 { font-size: 1.15rem; }
body.l2h-modern h5, body.l2h-modern h6 { font-size: 1rem; }
body.l2h-modern td, body.l2h-modern caption { font-size: inherit; font-family: inherit; color: inherit; }
body.l2h-modern hr { border: 0; border-top: 1px solid var(--border); background: none; padding: 0; margin: 2rem 0; }
body.l2h-modern li { margin: .35rem 0; }
body.l2h-modern li::marker { color: var(--accent); }
#page-content > p, #page-content > ul, #page-content > ol, #page-content > dl { max-width: var(--measure); }
mark.hit { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 .1em; }

/* ------------------------------------------------------- code blocks */
body.l2h-modern pre, body.l2h-modern code, body.l2h-modern tt, body.l2h-modern kbd {
    font-family: var(--mono);
    font-size: .88rem;
    color: inherit;
}
body.l2h-modern :not(pre) > tt, body.l2h-modern :not(pre) > code,
body.l2h-modern span.texttt {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .05em .35em;
    font-family: var(--mono);
    font-size: .88em;
}
body.l2h-modern pre {
    position: relative;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: .9rem 1.1rem;
    overflow-x: auto;
    line-height: 1.55;
    tab-size: 4;
    max-width: var(--measure);
}
.copy-btn {
    position: absolute;
    top: .45rem;
    right: .45rem;
    font: 600 .72rem var(--font);
    letter-spacing: .02em;
    padding: .25rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--raised);
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s;
}
pre:hover .copy-btn, .copy-btn:focus-visible, .copy-btn.done { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: .9; } }
.copy-btn.done { color: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------------------- callouts */
.callout {
    --c: #2f6fdf;
    position: relative;
    max-width: var(--measure);
    margin: 1.25rem 0;
    padding: .85rem 1.1rem .85rem 3rem;
    border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border));
    border-left: 4px solid var(--c);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--c) 8%, var(--surface));
}
.callout::before {
    content: "i";
    position: absolute;
    left: .9rem;
    top: .95rem;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font: 700 .8rem/1 var(--font);
    color: #fff;
    background: var(--c);
}
.callout p { margin: .4rem 0 0; }
.callout .callout-title {
    display: block;
    font-weight: 700;
    color: color-mix(in srgb, var(--c) 75%, var(--text));
    margin-bottom: .15rem;
}
.callout-tip { --c: #1f9d63; }
.callout-tip::before { content: "\2713"; }
.callout-warning { --c: #d48806; }
.callout-warning::before { content: "!"; }
.callout-important { --c: #d0453c; }
.callout-important::before { content: "\2605"; }

/* ------------------------------------------------------------ top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1rem;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(1.5) blur(10px);
    -webkit-backdrop-filter: saturate(1.5) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar::before {             /* thin accent line */
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.brand {
    font: 700 1.02rem/1.2 var(--font-head);
    letter-spacing: -.01em;
    white-space: nowrap;
    text-decoration: none !important;
    color: var(--text) !important;
}
.crumbs {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .45rem;
    overflow: hidden;
    white-space: nowrap;
    font-size: .85rem;
    color: var(--muted);
    padding-left: .6rem;
    border-left: 1px solid var(--border);
}
.crumbs a { color: var(--muted) !important; text-decoration: none !important; }
.crumbs a:hover { color: var(--accent) !important; }
.crumbs > :last-child { overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 500; }
.crumbs .sep { opacity: .45; }
.icon-btn {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .5rem;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text) !important;
    font: 600 .9rem var(--font);
    cursor: pointer;
    text-decoration: none !important;
    transition: background .15s, border-color .15s;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--border); }
.icon-btn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8;
                stroke-linecap: round; stroke-linejoin: round; }
.aa { font: 700 .95rem/1 var(--font-head); letter-spacing: -.02em; }

/* search */
.search { position: relative; margin-left: auto; }
.search-box {
    display: flex;
    align-items: center;
    gap: .4rem;
    width: clamp(14rem, 24vw, 22rem);
    height: 2.3rem;
    padding: 0 .55rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-sizing: border-box;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico svg { width: 1rem; height: 1rem; fill: none; stroke: var(--muted); stroke-width: 2; display: block; }
#doc-search {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0 !important;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: .9rem;
}
.search-key {
    font: 600 .72rem var(--mono);
    padding: .05rem .4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
}
.search-box:focus-within .search-key { display: none; }
.search-open, .search-close { display: none; }
.search-results {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    width: min(36rem, 92vw);
    max-height: min(70vh, 34rem);
    overflow-y: auto;
    padding: .4rem;
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    box-sizing: border-box;
}
.search-results a {
    display: block;
    padding: .6rem .75rem;
    border-radius: 8px;
    text-decoration: none !important;
    color: var(--text) !important;
}
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--accent-soft); }
.search-results .r-sec { font-size: .74rem; color: var(--muted); }
.search-results .r-title { font-weight: 650; color: var(--accent); }
.search-results .r-snip { font-size: .84rem; color: var(--muted); line-height: 1.45;
                          display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results .r-none { padding: .9rem; color: var(--muted); font-size: .9rem; }

/* display menu */
.display { position: relative; }
.display-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    width: 19.5rem;
    padding: .9rem;
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    box-sizing: border-box;
    font-size: .85rem;
}
.dm-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
            color: var(--muted); margin: .9rem 0 .45rem; }
.dm-label:first-child { margin-top: 0; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: .45rem .3rem; }
.swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .2rem 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: 500 .68rem var(--font);
    cursor: pointer;
}
.swatch i {
    position: relative;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
    transition: transform .15s;
}
.swatch i b {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: .8rem;
    height: .8rem;
    border-radius: 50%;
    border: 2px solid var(--raised);
}
.swatch:hover i { transform: scale(1.08); }
.swatch[aria-pressed="true"] { color: var(--text); font-weight: 700; }
.swatch[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--accent); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button {
    flex: 1;
    padding: .45rem .3rem;
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: 500 .82rem var(--font);
    cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--accent-soft); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--surface); font-weight: 650; }
.seg .f-serif { font-family: "Iowan Old Style", Charter, Palatino, Georgia, serif; }
.seg .f-humanist { font-family: Optima, Candara, "Noto Sans", "Segoe UI", sans-serif; }
.seg .zoom-val { flex: 1.3; color: var(--muted); }

/* --------------------------------------------------------- page layout */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar-h));
    transition: grid-template-columns .2s ease;
}
:root[data-nav="closed"] .layout { grid-template-columns: 0 minmax(0, 1fr); }
:root[data-nav="closed"] .sidebar { visibility: hidden; }
.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 0 .7rem 2rem;
    box-sizing: border-box;
    font-size: .88rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.side-head { position: sticky; top: 0; z-index: 1; padding: .9rem 0 .6rem; background: var(--sidebar); }
#page-content {
    max-width: var(--page-max);
    width: 100%;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 3.5vw, 3rem) 2.5rem;
    box-sizing: border-box;
}

/* contents tree */
.toc-filter {
    width: 100%;
    box-sizing: border-box;
    padding: .5rem .7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.toc-filter:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: .75rem; border-left: 1px solid var(--border); margin-left: .55rem; }
.toc li { margin: 0; }
.toc a {
    display: block;
    padding: .3rem .55rem;
    border-radius: 7px;
    color: var(--text) !important;
    opacity: .88;
    text-decoration: none !important;
    line-height: 1.38;
}
.toc .toc-l0 > li > a, .toc .toc-l0 > li > details > summary > a { font-weight: 650; opacity: 1; }
.toc a:hover { background: var(--accent-soft); opacity: 1; }
.toc a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent) !important;
    font-weight: 700;
    opacity: 1;
    box-shadow: inset 3px 0 0 var(--accent);
}
.toc summary { display: flex; align-items: flex-start; cursor: pointer; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before {
    content: "\203A";
    flex: 0 0 1rem;
    padding-top: .28rem;
    text-align: center;
    color: var(--muted);
    transition: transform .15s;
}
.toc details[open] > summary::before { transform: rotate(90deg); }
.toc summary > a { flex: 1; }
.toc li:not(:has(details)) > a { margin-left: 1rem; }
.toc .hide { display: none; }

/* latex2html "Subsections" list -> cards */
body.l2h-modern ul.ChildLinks {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: .7rem;
}
body.l2h-modern ul.ChildLinks ul { display: none; }
body.l2h-modern ul.ChildLinks > li { margin: 0; }
body.l2h-modern ul.ChildLinks > li > a {
    display: block;
    height: 100%;
    box-sizing: border-box;
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text) !important;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
body.l2h-modern ul.ChildLinks > li > a::after { content: " \2192"; color: var(--accent); }
body.l2h-modern ul.ChildLinks > li > a:hover { border-color: var(--accent); transform: translateY(-1px); }

/* previous / next cards */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 3.5rem 0 1rem; }
.pager a {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .9rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none !important;
    box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.pager a:hover { border-color: var(--accent); transform: translateY(-1px); }
.pager span { font-size: .78rem; color: var(--muted); letter-spacing: .02em; }
.pager b { color: var(--accent); font-weight: 650; }
.pager .next { text-align: right; grid-column: 2; }
.site-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: .84rem;
}
.site-foot a { color: var(--muted) !important; text-decoration: none !important; }
.site-foot a:hover { color: var(--accent) !important; }

/* figures: theme-aware frame (layout is in doc.css / fix_images.py) */
body.l2h-modern IMG.fig { border-color: var(--border); border-radius: 8px; box-shadow: var(--shadow); }
body.l2h-modern .fig-arrow { color: var(--accent); }
body.l2h-modern figure.l2h-figure figcaption { color: var(--muted); }
body.l2h-modern figure.l2h-figure figcaption strong { color: var(--text); }

/* --------------------------------------------------- tablets & phones */
.scrim { display: none; }
@media (max-width: 1100px) {
    .crumbs { display: none; }
    .search { margin-left: auto; }
}
@media (max-width: 960px) {
    .layout, :root[data-nav="closed"] .layout { grid-template-columns: minmax(0, 1fr); }
    :root[data-nav="closed"] .sidebar { visibility: visible; }
    .sidebar {
        position: fixed;
        z-index: 60;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(86vw, 20rem);
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(2px);
    }
    .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .search { margin-left: 0; position: static; }
    .search-open { display: inline-grid; }
    .search-box { display: none; }
    .search.open .search-box {
        display: flex;
        position: absolute;
        inset: .55rem .75rem auto .75rem;
        width: auto;
        z-index: 2;
        box-shadow: var(--shadow);
    }
    .search.open .search-close { display: inline-grid; min-width: 1.8rem; height: 1.8rem; }
    .search.open .search-key { display: none; }
    .search-results { left: .75rem; right: .75rem; width: auto; top: calc(var(--topbar-h) + .2rem); }
}
@media (max-width: 480px) {
    .pager { grid-template-columns: 1fr; }
    .pager .next { grid-column: 1; }
    .display-menu { position: fixed; left: .75rem; right: .75rem; top: calc(var(--topbar-h) + .3rem); width: auto; }
    .callout { padding-left: 2.7rem; }
}

/* ------------------------------------------------------------ motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* ------------------------------------------------------------- print */
@media print {
    .topbar, .sidebar, .pager, .site-foot, .copy-btn, .scrim { display: none !important; }
    .layout { display: block; }
    #page-content { max-width: none; padding: 0; }
    body.l2h-modern { background: #fff; color: #000; }
    .callout { break-inside: avoid; }
}
