/* NagiSeries documentation site. Pages are generated by site/build.py. */

:root {
    --bg: #fbfcfc;
    --surface: #ffffff;
    --side: #f2f6f7;
    --text: #1b2327;
    --muted: #5a6870;
    --line: #dde5e8;
    --line-strong: #c6d2d7;
    --accent: #1d6a89;
    --accent-hover: #134f68;
    --accent-soft: #e1f0f5;
    --on-accent: #ffffff;
    --code-bg: #eff3f4;
    --code-text: #24323a;
    --pre-bg: #15212a;
    --pre-text: #e3ebef;
    --mark: #ffe2a8;
    --brand-bg: #15252e;
    --brand-wave: #7dbad6;
    --shadow: 0 1px 2px rgba(16, 32, 40, .06), 0 8px 24px rgba(16, 32, 40, .06);
    --side-w: 300px;
    --topbar-h: 56px;
    --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "BIZ UDGothic", "Osaka-Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1316;
        --surface: #121a1f;
        --side: #0b1013;
        --text: #e4ebee;
        --muted: #92a3ab;
        --line: #22313a;
        --line-strong: #31444f;
        --accent: #7dbad6;
        --accent-hover: #a5d3e8;
        --accent-soft: #15283271;
        --on-accent: #0b1216;
        --code-bg: #1a252c;
        --code-text: #d7e2e7;
        --pre-bg: #0a1014;
        --pre-text: #dce6ea;
        --mark: #6b5420;
        --brand-bg: #1c3340;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0e1316; --surface: #121a1f; --side: #0b1013; --text: #e4ebee; --muted: #92a3ab;
    --line: #22313a; --line-strong: #31444f; --accent: #7dbad6; --accent-hover: #a5d3e8;
    --accent-soft: #15283271; --on-accent: #0b1216; --code-bg: #1a252c; --code-text: #d7e2e7; --pre-bg: #0a1014;
    --pre-text: #dce6ea; --mark: #6b5420; --brand-bg: #1c3340;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.85;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
}
html.menu-open { overflow: hidden; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg { display: block; }

.skip {
    position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---- brand ---- */
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .02em;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-size: 18px; }

/* ---- layout: a fixed left column on wide screens ---- */
.topbar { display: none; }
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; gap: 14px;
    padding: 20px 14px 16px 20px;
    background: var(--side);
    border-right: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin;
}
.sidebar > .brand { padding: 2px 6px; }

.main { min-width: 0; padding: 40px clamp(20px, 5vw, 64px) 40px; }
.doc, .pager, .foot { max-width: 820px; margin-left: auto; margin-right: auto; }

/* ---- navigation ---- */
.nav-list, .nav-toc, .nav-toc ol { list-style: none; margin: 0; padding: 0; }
.nav-list { display: grid; gap: 2px; }
.nav-link {
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    padding: 7px 10px; border-radius: 8px;
    color: var(--text); text-decoration: none; line-height: 1.4;
}
.nav-link:hover { background: var(--accent-soft); color: var(--text); }
.nav-name { font-weight: 650; }
.nav-sub { font-size: 12px; color: var(--muted); }
.nav-item.is-current > .nav-link { background: var(--accent-soft); }
.nav-item.is-current > .nav-link .nav-name { color: var(--accent); }

.nav-toc { margin: 4px 0 10px 10px; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.nav-toc a {
    display: block; padding: 4px 8px; border-radius: 6px;
    color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.5;
}
.nav-toc ol a { padding-left: 20px; font-size: 13px; }
.nav-toc a:hover { color: var(--text); background: var(--accent-soft); }
.nav-toc a.is-active { color: var(--accent); font-weight: 650; background: var(--accent-soft); }
.nav-toc code { font-size: .92em; background: none; padding: 0; }

.side-foot {
    margin: auto 0 0; padding: 12px 10px 0; border-top: 1px solid var(--line);
    display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px;
}
.side-foot a { color: var(--muted); text-decoration: none; }
.side-foot a:hover { color: var(--accent); }

/* ---- the same page in the other language ---- */
.side-lang {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    padding: 5px 12px 5px 9px; border: 1px solid var(--line-strong); border-radius: 999px;
    color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.3;
}
.side-lang:hover { color: var(--accent); border-color: var(--accent); }
.side-lang svg, .topbar-lang svg { width: 17px; height: 17px; flex: none; }
.topbar-tools { display: inline-flex; align-items: center; gap: 2px; }
.topbar-lang { text-decoration: none; }

/* ---- search ---- */
.search { position: relative; }
.search-field {
    display: flex; align-items: center; gap: 8px;
    padding: 0 10px; height: 40px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
    color: var(--muted);
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field svg { width: 18px; height: 18px; flex: none; }
.search-field input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
    color: var(--text); font: inherit; font-size: 15px;
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-key {
    font-family: var(--mono); font-size: 12px; line-height: 1; padding: 3px 6px;
    border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted);
}
.search-field:focus-within .search-key { display: none; }
.menu .search-key { display: none; }
.search-results {
    margin-top: 8px; padding: 4px; max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.search-results a {
    display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.5;
}
.search-results a:hover, .search-results a.is-selected { background: var(--accent-soft); }
.search-results .r-page { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.search-results .r-title { display: block; font-weight: 650; font-size: 14.5px; }
.search-results .r-text { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 10px; font-size: 13.5px; color: var(--muted); }

/* ---- document ---- */
/* Breadcrumb: one soft pill, house icon > this page (same look as NagiLog). */
.breadcrumb { display: flex; margin: 0 0 14px; font-size: 12.5px; line-height: 1.4; }
.doc .breadcrumb ol { display: flex; align-items: center; min-width: 0; max-width: 100%; margin: 0; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 82%, transparent); box-shadow: var(--shadow); }
.breadcrumb li { display: flex; align-items: center; flex: none; min-width: 0; }
.breadcrumb li:last-child { flex: 0 1 auto; }
.crumb { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 11px; border-radius: 999px; color: var(--muted); font-weight: 600; text-decoration: none; transition: background-color .15s ease, color .15s ease; }
.crumb > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.crumb { color: var(--accent); }
a.crumb:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
a.crumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.breadcrumb li:first-child .crumb { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.breadcrumb [aria-current] .crumb { color: var(--text); }
.crumb-home { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.crumb-sep { width: 14px; height: 14px; flex: none; margin: 0 1px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: .6; }
@media (max-width: 600px) { .breadcrumb { font-size: 12px; } .crumb { padding: 5px 9px; gap: 5px; } }
.doc-title { margin: 0 0 18px; font-size: clamp(26px, 4vw, 34px); line-height: 1.35; letter-spacing: .01em; }
.doc-title.has-logo { display: flex; align-items: center; gap: 14px; }
.doc-logo { flex: none; width: 56px; height: 56px; border-radius: 13px; }
@media (max-width: 600px) { .doc-logo { width: 44px; height: 44px; border-radius: 10px; } }
.lead { font-size: 16.5px; color: var(--text); }
.lead > p:first-child { margin-top: 0; }

/* This page's chapters: numbered cards on wide screens, a plain list on narrow ones. */
.toc-inline {
    margin: 28px 0 8px; padding: 16px 18px 18px;
    background: var(--side); border: 1px solid var(--line); border-radius: 14px;
}
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.toc-title { margin: 0; font-weight: 700; font-size: 15px; }
.toc-list, .toc-list ol { list-style: none; margin: 0; padding: 0; }
.toc-list { counter-reset: toc; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.toc-list > li {
    counter-increment: toc; margin: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.toc-list a { display: block; color: var(--text); text-decoration: none; line-height: 1.5; }
.toc-list > li > a { display: flex; align-items: baseline; gap: 8px; height: 100%; padding: 9px 12px; font-size: 14.5px; font-weight: 600; border-radius: 10px; }
.toc-list > li > a:hover { background: var(--accent-soft); color: var(--text); }
.toc-list > li > a::before {
    content: counter(toc, decimal-leading-zero); flex: none;
    font: 700 11.5px/1.9 var(--mono); color: var(--accent);
    padding: 0 6px; border-radius: 6px; background: var(--accent-soft);
}
.toc-list ol { display: none; }
.toc-list code { font-family: var(--mono); font-size: .9em; }

.fold-all {
    flex: none; padding: 4px 12px; font: inherit; font-size: 13px; line-height: 1.6;
    color: var(--accent); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
}
.fold-all:hover { border-color: var(--accent); }

/* Reading progress: a thin line on the top edge (the rail has its own on wide screens). */
.read-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 40; pointer-events: none; }
.read-progress span, .rail-progress span { display: block; height: 100%; width: 0; background: var(--accent); }

.doc-body h2, .doc-body h3, .doc-body h4 {
    position: relative; line-height: 1.45; scroll-margin-top: 16px;
}
.doc-body h2 {
    margin: 56px 0 16px; padding-top: 24px; font-size: 24px;
    border-top: 1px solid var(--line);
}
.doc-body > h2:first-child { margin-top: 32px; }
.doc-body h3 { margin: 36px 0 12px; font-size: 19px; }
.doc-body h4 { margin: 28px 0 8px; font-size: 16.5px; }
.doc-body hr { display: none; }
.anchor {
    margin-left: 8px; color: var(--line-strong); text-decoration: none; font-weight: 400;
    opacity: 0; transition: opacity .15s;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); }

.doc p { margin: 14px 0; }
.doc ul, .doc ol { margin: 12px 0; padding-left: 1.5em; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0; }
.doc li::marker { color: var(--muted); }
.doc strong { font-weight: 700; }
.doc blockquote {
    margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--accent);
    background: var(--accent-soft); border-radius: 0 8px 8px 0;
}

.doc code {
    font-family: var(--mono); font-size: .88em;
    background: var(--code-bg); color: var(--code-text);
    padding: .12em .4em; border-radius: 5px; overflow-wrap: anywhere;
}
.doc pre {
    position: relative; margin: 16px 0; padding: 16px 18px;
    background: var(--pre-bg); color: var(--pre-text);
    border-radius: 10px; overflow-x: auto; line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}
.doc pre code {
    background: none; color: inherit; padding: 0; font-size: 13.5px;
    white-space: pre; overflow-wrap: normal;
}
/* The code and its Copy button. The button is fixed to the frame's top right
   corner, half above it, so it does not scroll with a long line. */
.doc .code-block { position: relative; margin: 30px 0 16px; }
.doc .code-block > pre { margin: 0; }
.copy {
    position: absolute; top: 0; right: 12px; z-index: 1; transform: translateY(-50%);
    padding: 4px 13px; font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.5;
    color: var(--pre-text); background: var(--pre-bg);
    border: 1px solid color-mix(in srgb, var(--pre-text) 30%, var(--pre-bg)); border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18); cursor: pointer;
}
.copy:hover { border-color: var(--brand-wave); }
.copy:active { transform: translateY(-50%) scale(.96); }

/* A short note at the bottom of the screen ("Copied!"). */
.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60;
    max-width: calc(100vw - 32px); padding: 10px 18px;
    background: var(--pre-bg); color: var(--pre-text); border-radius: 999px;
    font-size: 14.5px; font-weight: 600; line-height: 1.4; text-align: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
    opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-failed { background: #8a2b2b; color: #fff; }

.table-wrap {
    margin: 16px 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line); border-radius: 10px;
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.7; }
.table-wrap th, .table-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.table-wrap th { background: var(--side); font-weight: 650; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child { font-weight: 600; min-width: 7em; }

.figure { margin: 20px 0; }
.doc img { max-width: 100%; height: auto; border-radius: 8px; }
.zoom { display: inline-block; cursor: zoom-in; border-radius: 10px; line-height: 0; }
.figure .zoom img, .shots img { border: 1px solid var(--line); box-shadow: var(--shadow); }
.shots { display: block; margin: 20px 0; }
.shots tbody { display: block; }
.shots tr { display: flex; flex-wrap: wrap; gap: 16px; }
.shots td { flex: 1 1 200px; padding: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.shots td[align="center"] { text-align: center; }
.shots br { display: block; content: ""; margin-top: 6px; }
.shots .zoom { margin-bottom: 4px; }

/* ---- top page ---- */
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
    border-radius: 999px; border: 1px solid var(--line-strong);
    color: var(--text); text-decoration: none; font-weight: 600; font-size: 14.5px; line-height: 1.4;
    background: var(--surface);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-download { padding: 11px 22px; font-size: 15.5px; box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.doc .hero-links { margin: 16px 0 20px; }

/* ---- a page's banner, the gallery to try, lists shown as cards ---- */
.doc-hero {
    margin: 0 0 22px; border-radius: 16px; overflow: hidden; line-height: 0;
    background: var(--brand-bg); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.doc-hero img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 0; }

.try {
    margin: 22px 0 6px; padding: 16px 18px 14px;
    border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
}
.try-title { margin: 0 0 10px; font-weight: 700; color: var(--accent); }
.doc .try-gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.doc .try-gallery li { margin: 0; }
.try-gallery a { display: block; border-radius: 12px; overflow: hidden; line-height: 0; background: var(--brand-bg); border: 1px solid var(--line); transition: transform .18s ease, box-shadow .18s ease; }
.try-gallery a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.try-gallery img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 0; }
.try-note { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }

.doc .feature-list {
    list-style: none; padding: 0; margin: 18px 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px;
}
.doc .feature-list li {
    margin: 0; padding: 14px 16px 15px;
    border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px;
    background: var(--surface); line-height: 1.7; font-size: 15px;
}
.feature-name { display: block; margin-bottom: 3px; color: var(--accent); font-size: 15.5px; }
@media (prefers-reduced-motion: reduce) { .try-gallery a { transition: none; } .try-gallery a:hover { transform: none; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 20px 0; }
.card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    overflow: hidden; box-shadow: var(--shadow);
}
.card-img { display: block; aspect-ratio: 1200 / 630; overflow: hidden; background: var(--brand-bg); line-height: 0; }
.card-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 14px 16px 16px; }
.card h3 { margin: 0 !important; font-size: 19px !important; }
.card .card-kind { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.card ul { margin: 0 0 14px; padding-left: 1.2em; font-size: 14.5px; line-height: 1.7; }
.card-links { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.card-links .btn { padding: 6px 12px; font-size: 13.5px; }

.flow { display: grid; gap: 10px; margin: 16px 0; padding: 0; list-style: none; counter-reset: flow; }
.flow li {
    counter-increment: flow; position: relative; margin: 0;
    padding: 12px 14px 12px 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.flow li::before {
    content: counter(flow); position: absolute; left: 14px; top: 13px;
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; line-height: 1;
}

/* ---- pager / footer ---- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a {
    display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px;
    text-decoration: none; color: var(--accent); font-weight: 650; background: var(--surface);
}
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.pager-next { text-align: right; grid-column: 2; }
.foot {
    margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line);
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
    font-size: 13px; color: var(--muted);
}
.foot p { margin: 0; }
.foot a { color: var(--muted); }

/* ---- menu (dialog on narrow screens) ---- */
.menu {
    width: min(440px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    margin: 12px 12px auto auto;
    padding: 0;
    border: 1px solid var(--line); border-radius: 16px;
    background: var(--side); color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    overflow: hidden;
}
.menu[open] { display: flex; flex-direction: column; }
.menu::backdrop { background: rgba(8, 14, 18, .5); }
.menu-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.menu-title { margin: 0; font-weight: 700; }
.menu-close, .topbar-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 40px; height: 40px; padding: 0 10px;
    background: none; border: 1px solid transparent; border-radius: 10px;
    color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.menu-close:hover, .topbar-btn:hover { background: var(--accent-soft); }
.menu-close svg, .topbar-btn svg { width: 22px; height: 22px; }
/* The menu itself scrolls when it is taller than the screen. */
.menu-body {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 14px;
}
.menu .side-foot { margin-top: 4px; }

/* ---- narrow screens: headings become a table of contents in the page ---- */
@media (max-width: 960px) {
    .layout { display: block; }
    .sidebar { display: none; }
    .topbar {
        position: sticky; top: 0; z-index: 20;
        display: flex; align-items: center; justify-content: space-between;
        height: var(--topbar-h); padding: 0 8px 0 16px;
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--line);
    }
    .topbar .brand-mark { width: 26px; height: 26px; }
    .topbar .brand-name { font-size: 16.5px; }
    .topbar-btn { border-color: var(--line-strong); }
    html { scroll-padding-top: calc(var(--topbar-h) + 12px); }
    .doc-body h2, .doc-body h3, .doc-body h4 { scroll-margin-top: calc(var(--topbar-h) + 12px); }
    .main { padding: 24px 16px 32px; }

    .toc-inline { margin: 24px 0 8px; padding: 14px 16px 12px; }
    .toc-list { display: block; }
    .toc-list > li { border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
    .toc-list > li:first-child { border-top: 0; }
    .toc-list > li > a { padding: 9px 2px; font-weight: 400; font-size: 15px; }
    .toc-list > li > a::before { min-width: 2.4em; background: none; color: var(--muted); padding: 0; }
    .toc-list ol { display: block; margin: -4px 0 6px 2.4em; }
    .toc-list ol a { padding: 5px 0 5px 12px; font-size: 14px; color: var(--muted); border-left: 1px solid var(--line-strong); }

    .doc-body h2 { margin-top: 44px; font-size: 21px; }
    .doc-body h3 { font-size: 17.5px; }
    .anchor { display: none; }
    .doc .code-block { margin-left: -16px; margin-right: -16px; }
    .doc pre { border-radius: 0; padding: 14px 16px; }
    .pager { grid-template-columns: 1fr; }
    .pager-next { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .sidebar, .topbar, .menu, .pager, .copy, .anchor { display: none !important; }
    .layout { display: block; }
}
/* A row of badges (versions, GitHub / GitLab, license) */
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; line-height: 0; }
.badges a { display: inline-block; line-height: 0; }
.badges img { height: 20px; width: auto; border-radius: 0; }

/* ---- callouts: GitHub's > [!NOTE] … [!CAUTION] and HackMD's :::success / info / warning / danger ---- */
.callout {
    --c: #2563eb;
    position: relative; margin: 18px 0; padding: 12px 16px 12px 16px;
    border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line));
    border-left: 4px solid var(--c); border-radius: 12px;
    background: color-mix(in srgb, var(--c) 7%, var(--surface));
}
.callout-tip { --c: #16a34a; }
.callout-success { --c: #059669; }
.callout-important { --c: #7c3aed; }
.callout-warning { --c: #d97706; }
.callout-caution { --c: #dc2626; }
.callout svg { width: 19px; height: 19px; flex: none; fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.callout-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px !important; font-weight: 700; color: var(--c); }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-plain { display: flex; gap: 10px; align-items: flex-start; }
.callout-plain > svg { margin-top: 4px; }
.callout-plain .callout-body { flex: 1; min-width: 0; }
@media (prefers-color-scheme: dark) {
    .callout { background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
    .callout-title { color: color-mix(in srgb, var(--c) 70%, #fff); }
}

/* ---- folded parts: <details> and HackMD's :::spoiler ---- */
.doc details {
    margin: 16px 0; border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface); overflow: hidden;
}
.doc details > summary {
    display: flex; align-items: center; gap: 8px; padding: 11px 16px;
    cursor: pointer; font-weight: 650; list-style: none; user-select: none;
}
.doc details > summary::-webkit-details-marker { display: none; }
.doc details > summary::before {
    content: ""; width: 7px; height: 7px; flex: none; margin-right: 2px;
    border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
    transform: rotate(-45deg); transition: transform .18s ease;
}
.doc details[open] > summary::before { transform: rotate(45deg); }
.doc details > summary:hover { background: var(--accent-soft); }
.doc details[open] > summary { border-bottom: 1px solid var(--line); }
.doc details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.doc details > .details-body { margin: 12px 16px 14px; }
.doc details > .details-body > :first-child { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .doc details > summary::before { transition: none; } }

/* ---- lessons: numbered ## chapters, ### sections folded under them ---- */
.ch-num {
    display: inline-block; min-width: 2.2em; margin-right: .5em; padding: .2em .45em;
    font: 700 .6em/1.2 var(--mono); letter-spacing: .04em; text-align: center; vertical-align: .3em;
    color: var(--accent); background: var(--accent-soft); border-radius: 7px;
}
.doc details.sec { margin: 10px 0; border-radius: 12px; }
.doc details.sec + details.sec { margin-top: 8px; }
.doc details.sec > summary {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 12px;
    padding: 13px 18px; font-weight: 400;
}
.doc details.sec > summary::before { align-self: center; margin: 0 2px 0 0; }
.doc-body details.sec h3 { margin: 0; font-size: 18px; scroll-margin-top: 16px; }
.sec-hint { grid-column: 2; margin-top: 2px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.doc details.sec[open] .sec-hint { display: none; }
.doc details.sec > .sec-body { margin: 0; padding: 2px 20px 16px 39px; }
.doc details.sec > .sec-body > :first-child { margin-top: 12px; }
.doc details.sec > .sec-body > :last-child { margin-bottom: 4px; }

/* ---- the right rail: this page's contents and progress (wide screens only) ---- */
.rail { display: none; }
.rail-inner {
    position: sticky; top: 0; max-height: 100vh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 40px 20px 24px 4px; scrollbar-width: thin;
}
.rail-title { margin: 0 0 10px; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.rail-progress { height: 4px; margin: 0 0 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.rail-toc, .rail-toc ol { list-style: none; margin: 0; padding: 0; }
.rail-toc { counter-reset: rtoc; border-left: 1px solid var(--line-strong); }
.rail-toc > li { counter-increment: rtoc; }
.rail-toc a {
    display: flex; gap: 8px; margin-left: -1px; padding: 5px 8px 5px 12px;
    border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.5;
}
.rail-toc > li > a::before { content: counter(rtoc, decimal-leading-zero); flex: none; font: 600 11.5px/1.9 var(--mono); opacity: .7; }
.rail-toc ol { display: none; }
.rail-toc li.is-open > ol { display: block; }
.rail-toc ol a { padding-left: 38px; font-size: 13px; }
.rail-toc a:hover { color: var(--text); }
.rail-toc a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 650; }
.rail-toc code { font-size: .92em; background: none; padding: 0; }
.rail-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 18px 0 0; font-size: 13px; }
.rail-top { color: var(--muted); text-decoration: none; }
.rail-top:hover { color: var(--accent); }

@media (min-width: 1240px) {
    .has-rail { --side-w: 264px; --rail-w: 260px; }
    .has-rail .layout { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w); }
    .has-rail .rail { display: block; }
    .has-rail .sidebar .nav-toc { display: none; }
    .has-rail .read-progress { display: none; }
    .has-rail .main { padding: 40px clamp(28px, 3vw, 56px); }
    .has-rail .doc, .has-rail .pager, .has-rail .foot { max-width: 800px; }
    .has-rail .doc { font-size: 16.5px; }
}
@media (max-width: 960px) {
    .doc details.sec > summary { padding: 12px 14px; }
    .doc details.sec > .sec-body { padding: 2px 14px 14px; }
    .doc details.sec .code-block { margin-left: 0; margin-right: 0; }
    .doc details.sec pre { border-radius: 10px; }
    .doc-body details.sec h3 { font-size: 16.5px; scroll-margin-top: calc(var(--topbar-h) + 12px); }
}
@media print {
    .rail, .read-progress, .fold-all, .sec-hint { display: none !important; }
}
