:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --rail-bg: #fbfcfd;
  --line: #e6e9ee;
  --line-strong: #d5dbe3;
  --ink: #14212b;
  --ink-2: #33434f;
  --muted: #5f6f7b;
  --faint: #5f6e79;
  --teal: #0f8f85;
  --teal-dark: #0b6f68;
  --teal-soft: #e5f5f2;
  --teal-ring: rgba(15, 143, 133, .22);
  --focus: #0a6fd6;
  --hover: #eef1f4;
  --surface-2: #f8fafb;
  --surface-3: #f3f5f7;
  --topbar-bg: rgba(255, 255, 255, .86);
  --backdrop: rgba(20, 33, 43, .38);
  --shadow: rgba(20, 33, 43, .05);
  --shadow-teal: rgba(15, 143, 133, .14);
  --code-bg: #f3f5f7;
  --radius: 10px;
  --radius-sm: 7px;
  --rail-width: 16rem;
  --header-height: 3.25rem;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: .32s;
  font: 16px Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: .9375rem; line-height: 1.55; overflow-y: scroll; }
::selection { background: var(--teal-soft); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: #cdd5de transparent; }
[hidden] { display: none !important; }
a { color: var(--teal-dark); text-decoration: none; text-underline-offset: 3px; transition: color .15s var(--ease); }
a:hover { color: var(--teal); }
button, input { font: inherit; }
button { cursor: pointer; }
svg { display: block; }
:where(a, button, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 10px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 8px 24px var(--backdrop); transition: top .2s var(--ease); }
.skip:focus { top: 12px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--header-height); background: var(--topbar-bg); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); font-size: .9375rem; font-weight: 700; letter-spacing: .01em; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; color: #fff; background: linear-gradient(135deg, #16a397, #0b6f68); box-shadow: 0 1px 2px rgba(11, 111, 104, .3), inset 0 1px 0 rgba(255, 255, 255, .2); }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: .6875rem; font-weight: 500; letter-spacing: .04em; text-transform: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions button { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 500; white-space: nowrap; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease); }
.header-actions button:hover { background: var(--hover); border-color: #c3cbd5; color: var(--ink); }
.header-actions button:active { transform: translateY(1px); }
.header-actions .nav-toggle { display: none; }
.lib-link { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; color: var(--teal-dark); background: var(--teal-soft); border: 1px solid transparent; border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 600; transition: background .15s var(--ease), color .15s var(--ease); }
.lib-link:hover { background: var(--teal); color: #fff; }
.progress { position: absolute; bottom: -1px; left: 0; width: 100%; height: 2px; pointer-events: none; background: transparent; }
.progress span { display: block; width: 0; height: 2px; background: linear-gradient(90deg, #16a397, #0b6f68); transition: width .12s linear; }

/* Layout */
.app-shell { width: 100%; max-width: 1440px; margin: 0 auto; }
.layout { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); align-items: start; }

/* Contents rail */
.contents-rail { position: sticky; top: var(--header-height); height: calc(100dvh - var(--header-height)); overflow: auto; padding: 14px 10px 24px 14px; background: transparent; border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: #cdd5de transparent; }
.contents-rail::-webkit-scrollbar { width: 6px; }
.contents-rail::-webkit-scrollbar-thumb { background: #cdd5de; border-radius: 6px; }
.contents-rail::-webkit-scrollbar-track { background: transparent; }
.nav-title { display: flex; justify-content: space-between; align-items: center; min-height: 22px; padding: 0 8px; margin-bottom: 4px; }
.nav-title strong { color: var(--faint); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.close-nav { display: none; width: 30px; height: 30px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: var(--radius-sm); font-size: 1.25rem; line-height: 1; transition: background .15s var(--ease), color .15s var(--ease); }
.close-nav:hover { background: var(--hover); color: var(--ink); }
.contents-rail nav { position: relative; }
/* Explorer tree */
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree > ul > li + li { margin-top: 2px; }
.tree .row { display: flex; align-items: center; gap: 2px; min-height: 26px; border-radius: var(--radius-sm); transition: background .15s var(--ease); }
.tree .row:hover { background: var(--hover); }
.tree .label { flex: 1; min-width: 0; padding: 3px 6px 3px 2px; color: var(--muted); font-size: .8125rem; line-height: 1.35; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.tree .row.depth-0 .label { color: var(--ink); font-weight: 600; font-size: .875rem; }
.tree .row:hover .label { color: var(--ink); }
.tree li.is-current > .row { background: var(--teal-soft); }
.tree li.is-current > .row .label { color: var(--teal-dark); font-weight: 600; }
.tree .twisty { flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; color: var(--faint); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.tree .twisty::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--ease); }
.tree li.is-open > .row > .twisty::before { transform: rotate(45deg); }
.tree .twisty:hover { background: var(--line); color: var(--ink); }
.tree .twisty.is-leaf::before { display: none; }
.tree li > ul { display: none; position: relative; margin: 1px 0 2px 11px; padding-left: 8px; }
.tree li > ul::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 1px; background: var(--line-strong); }
.tree li.is-open > ul { display: block; animation: unfold .22s var(--ease); }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tree .depth-2 .label, .tree .depth-3 .label { font-size: .8125rem; }
.tree a.toc-link { display: block; padding: 2px 6px 2px 20px; color: var(--muted); font-size: .78rem; line-height: 1.4; border-radius: var(--radius-sm); }
.tree a.toc-link:hover { background: var(--hover); color: var(--ink); }
.tree a.toc-link[aria-current=location] { color: var(--teal-dark); font-weight: 600; }
.nav-indicator { position: absolute; left: -1px; top: 0; width: 2px; height: 0; background: var(--teal); border-radius: 2px; opacity: 0; transition: transform var(--dur) var(--ease), height var(--dur) var(--ease), opacity .2s var(--ease); will-change: transform; }
.nav-indicator.is-on { opacity: 1; }
.nav-footer { margin: 20px 10px 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .75rem; }
.nav-footer a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.nav-footer a::before { content: "↑"; font-size: .8125rem; }
.nav-footer a:hover { color: var(--teal-dark); }

/* Content */
.content { min-width: 0; min-height: calc(100dvh - var(--header-height)); padding: 22px 40px 56px; background: var(--surface); scroll-margin-top: var(--header-height); }
.content > .hero, .content > .section, .content > .page-footer, .content > .nojs, .content > .pager { max-width: 58rem; }
.content p { max-width: 80ch; }
.hero { padding-bottom: 14px; margin-bottom: 0; border-bottom: 1px solid var(--line); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; font-size: .78rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--teal-dark); }
.crumbs .sep { color: var(--faint); }
.crumbs [aria-current=page] { color: var(--ink); font-weight: 500; }
.hero:has(.crumbs)::before { display: none; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.pager a { display: flex; flex-direction: column; gap: 1px; padding: 9px 13px; font-size: .875rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); font-weight: 600; transition: border-color .15s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease); }
.pager a small { color: var(--faint); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.pager a.next { grid-column: 2; text-align: right; align-items: flex-end; }
.pager a:hover { border-color: var(--teal); box-shadow: 0 4px 14px var(--shadow-teal); transform: translateY(-1px); }
.hero::before { content: "Engineering guide"; display: inline-block; margin-bottom: 8px; padding: 4px 10px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 999px; font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
h1 { color: var(--ink); font-size: 1.875rem; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; margin: 0 0 6px; text-wrap: balance; }
.intro { color: var(--muted); font-size: .9688rem; line-height: 1.55; margin: 0; text-wrap: pretty; }
.quick-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick-links a { display: inline-flex; align-items: center; padding: 4px 11px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; font-size: .8125rem; font-weight: 500; transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease); }
.quick-links a:hover { color: var(--teal-dark); border-color: var(--teal); background: var(--teal-soft); transform: translateY(-1px); box-shadow: 0 4px 12px var(--shadow-teal); }

.section { padding: 22px 0 6px; scroll-margin-top: calc(var(--header-height) + 12px); }
.section + .section { border-top: 1px solid var(--line); margin-top: 10px; }
.section-head { margin-bottom: 10px; }
.section-head h2 { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.375rem; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.section-num { flex: none; display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 8px; font: 600 .75rem/1 "JetBrains Mono", Consolas, "Cascadia Mono", monospace; letter-spacing: .02em; align-self: center; }
h3 { color: var(--ink); font-size: 1rem; line-height: 1.4; font-weight: 650; letter-spacing: -.01em; margin: 18px 0 6px; }
p { margin: 0 0 9px; color: var(--ink-2); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
.ui { color: var(--ink); font-weight: 600; font-size: .97em; }
.small { color: var(--muted); font-size: .8438rem; }

/* Steps */
.steps { list-style: none; counter-reset: step; margin: 8px 0 12px; padding: 0; }
.steps > li { position: relative; counter-increment: step; padding: 0 0 10px 36px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 22px; height: 22px; color: var(--teal-dark); background: var(--teal-soft); border: 1px solid rgba(15, 143, 133, .25); border-radius: 50%; font-size: .75rem; font-weight: 650; }
.steps > li::after { content: ""; position: absolute; left: 10.5px; top: 26px; bottom: 2px; width: 1px; background: var(--line); }
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.steps p { margin: 0; padding-top: 2px; }
.result { display: block; color: var(--ink-2); font-size: .8125rem; margin: 5px 0 0 !important; padding: 6px 10px 6px 12px; background: var(--surface-2); border-left: 2px solid var(--teal); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.result::before { content: "Result"; display: block; color: var(--teal-dark); font-size: .6875rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; }

/* Tables */
.table-wrap { overflow: auto; max-width: 100%; margin: 10px 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px var(--shadow); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .8438rem; line-height: 1.45; }
th { color: var(--muted); background: var(--surface-2); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; padding: 7px 12px; border-bottom: 1px solid var(--line); }
td { padding: 7px 12px; vertical-align: top; color: var(--ink-2); border-top: 1px solid var(--line); }
tr:first-child td { border-top: 0; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td:first-child { min-width: 150px; color: var(--ink); }
td p { margin-bottom: 5px; }
caption { caption-side: top; color: var(--muted); font-size: .8125rem; text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
ul { padding-left: 21px; }
li { padding-left: 2px; margin-bottom: 6px; }

/* Diagrams */
.diagram { margin: 14px 0; padding: 14px 16px; background: linear-gradient(180deg, var(--surface-2), var(--surface-3)); border: 1px solid var(--line); border-radius: var(--radius); }
.caption-label { color: var(--faint); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.mode-diagram { display: grid; grid-template-columns: 1fr auto 2fr; align-items: center; gap: 16px; }
.diagram-node { padding: 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 1px 2px var(--shadow); font-size: .8438rem; text-align: center; transition: border-color .15s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease); }
.diagram-node strong { display: block; color: var(--ink); font-weight: 650; }
.diagram-node span { color: var(--muted); font-size: .75rem; }
.mode-nodes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-diagram a { color: var(--ink); }
.mode-nodes a { display: block; padding: 9px 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 500; text-align: center; transition: border-color .15s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease), color .15s var(--ease); }
.mode-diagram a:hover { color: var(--teal-dark); border-color: var(--teal); box-shadow: 0 4px 14px var(--shadow-teal); transform: translateY(-1px); }
.diagram-arrow { color: var(--faint); font-size: 1.25rem; }
.flow { display: flex; align-items: stretch; gap: 10px; }
.flow .diagram-node { flex: 1; }
.rank { color: var(--teal-dark); font: 600 .6875rem Consolas, "Cascadia Mono", monospace; letter-spacing: .04em; margin-bottom: 6px; }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot-title { color: var(--teal-dark); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.slot-grid .diagram-node { text-align: left; }
.slot-grid p { font-size: .8125rem; margin: 6px 0 0; }
.slot-grid strong { font-size: .875rem; }
.slot-grid .arrow { color: var(--teal); }
figcaption { color: var(--muted); font-size: .78rem; line-height: 1.5; margin-top: 10px; }
.subsection { margin-top: 28px; padding-top: 6px; border-top: 1px solid var(--line); }
kbd, code { color: var(--ink); background: var(--code-bg); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; font: .75rem Consolas, "Cascadia Mono", monospace; overflow-wrap: anywhere; }
.nojs { padding: 12px 16px; margin: 20px 0 0; background: var(--surface-2); border-left: 2px solid var(--line-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .8438rem; }
.page-footer { display: flex; align-items: center; gap: 10px; color: var(--faint); margin-top: 20px; padding: 14px 0 0; border-top: 1px solid var(--line); font-size: .75rem; }

/* Watch link */
.watch-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; padding: 5px 12px 5px 10px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 999px; font-size: .8125rem; font-weight: 600; transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease); }
.watch-link:hover { background: var(--teal); color: #fff; transform: translateY(-1px); }
.watch-len { opacity: .75; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Feature grid + structure map */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.fg-card { display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 10px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); transition: border-color .15s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease); }
.fg-card:hover { color: var(--teal-dark); border-color: var(--teal); box-shadow: 0 6px 16px -8px var(--shadow-teal); transform: translateY(-1px); }
.fg-num { color: var(--faint); font: 600 .6875rem Consolas, "Cascadia Mono", monospace; letter-spacing: .04em; }
.fg-title { font-size: .875rem; font-weight: 600; line-height: 1.3; }
.fg-vid { color: var(--teal); font-size: .7rem; margin-left: 4px; }
.fg-sub { color: var(--muted); font-size: .72rem; }
.panel-map svg { display: block; max-width: 720px; margin: 0 auto; }
.pm-link { stroke: var(--line-strong); stroke-width: 1.2; }
.pm-link-2 { stroke-dasharray: 2 3; }
.pm-dot { fill: var(--teal); stroke: var(--surface); stroke-width: 2; }
.pm-dot-2 { fill: var(--faint); opacity: .7; }
.pm-root { fill: var(--ink); stroke: var(--teal); stroke-width: 3; }
.pm-label { fill: var(--ink-2); font-size: 11.5px; font-weight: 500; }
.pm-root-label { fill: var(--ink); font-size: 12.5px; font-weight: 700; }

/* Video library */
.library .hero { padding-bottom: 12px; }
.vtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 12px; }
.vtab { padding: 5px 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; font-size: .8125rem; font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.vtab:hover { border-color: var(--teal); color: var(--teal-dark); }
.vtab.is-on { color: #fff; background: var(--teal-dark); border-color: var(--teal-dark); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 14px; }
.vcard { display: flex; flex-direction: column; gap: 8px; padding: 0; text-align: left; background: transparent; border: 0; border-radius: var(--radius); color: inherit; }
.vthumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #0b0e14; border-radius: var(--radius); border: 1px solid var(--line); transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.vthumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vthumb::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(0,0,0,.0), rgba(0,0,0,.25)); opacity: 0; transition: opacity .2s var(--ease); }
.vcard:hover .vthumb { transform: translateY(-2px); box-shadow: 0 14px 28px -14px rgba(20, 33, 43, .5); }
.vcard:hover .vthumb::after { opacity: 1; }
.vlen { position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 2px 6px; color: #fff; background: rgba(0,0,0,.75); border-radius: 4px; font: 500 .72rem/1.4 Consolas, "Cascadia Mono", monospace; }
.vmeta { display: flex; flex-direction: column; gap: 1px; padding: 0 2px; }
.vtitle { color: var(--ink); font-size: .9063rem; font-weight: 600; line-height: 1.3; }
.vsub { color: var(--muted); font-size: .78rem; }
.vnone { margin-top: 20px; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 16, .8); backdrop-filter: blur(6px); animation: fadein .2s var(--ease); }
.lb-dialog { position: relative; width: min(1100px, 100%); background: #0b0e14; border: 1px solid #2a3340; border-radius: 14px; overflow: hidden; box-shadow: 0 40px 100px rgba(0,0,0,.6); animation: unfold .25s var(--ease); }
.lb-head { display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; color: #e8edf1; font-size: .9063rem; font-weight: 600; border-bottom: 1px solid #1f2731; }
.lb-page { margin-left: auto; color: #4fd1c5; font-size: .8125rem; font-weight: 500; }
.lb-close { width: 32px; height: 32px; padding: 0; color: #c3ccd4; background: #151b21; border: 1px solid #2a3340; border-radius: 8px; font-size: 1.25rem; line-height: 1; }
.lb-close:hover { color: #fff; background: #1e262e; }
.lb-dialog video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
body.lb-open { overflow: hidden; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 540px) { .vgrid { grid-template-columns: 1fr 1fr; gap: 12px 10px; } .vtitle { font-size: .8125rem; } .lightbox { padding: 0; } .lb-dialog { border-radius: 0; } }

/* Reveal on scroll (JS adds .reveal; observer adds .is-visible) */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s var(--ease), transform .55s var(--ease); }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* Mobile drawer backdrop */
.backdrop { position: fixed; inset: 0; z-index: 35; background: var(--backdrop); opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility 0s linear var(--dur); }
.nav-open .backdrop { opacity: 1; visibility: visible; transition: opacity var(--dur) var(--ease); }

/* Theme toggle */
.theme-toggle .icon-moon, .theme-toggle .icon-sun { display: none; }
.theme-toggle[aria-pressed=false] .icon-moon, .theme-toggle[aria-pressed=true] .icon-sun { display: block; }
.theme-toggle { width: 32px; padding: 0 !important; justify-content: center; }
.theme-toggle svg { transition: transform .4s var(--ease); }
.theme-toggle:hover svg { transform: rotate(18deg); }

/* Dark theme: applied only when the reader chose it (assets/theme.js) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #151b21;
  --rail-bg: #0f1419;
  --line: #232c35;
  --line-strong: #303b46;
  --ink: #e8edf1;
  --ink-2: #c3ccd4;
  --muted: #93a1ad;
  --faint: #93a1ad;
  --teal: #2fc4b6;
  --teal-dark: #4fd1c5;
  --teal-soft: rgba(47, 196, 182, .13);
  --teal-ring: rgba(47, 196, 182, .3);
  --focus: #6ab3ff;
  --hover: #1e262e;
  --surface-2: #1a2129;
  --surface-3: #171e25;
  --topbar-bg: rgba(21, 27, 33, .84);
  --backdrop: rgba(0, 0, 0, .55);
  --shadow: rgba(0, 0, 0, .35);
  --shadow-teal: rgba(47, 196, 182, .12);
  --code-bg: #1e262e;
}
.theme-transition, .theme-transition * { transition: background-color .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease) !important; }

@media (max-width: 1100px) and (min-width: 901px) {
  :root { --rail-width: 15.5rem; }
  .content { padding: 20px 28px 48px; }
}
@media (max-width: 900px) {
  .topbar-inner { padding: 0 16px; }
  .js .header-actions .nav-toggle { display: inline-flex; }
  .layout { display: block; }
  .contents-rail { position: fixed; top: 0; left: 0; z-index: 40; width: min(20rem, 86vw); height: 100dvh; padding: 20px 14px 28px 18px; background: var(--surface); border-right: 1px solid var(--line); box-shadow: 0 24px 60px rgba(20, 33, 43, .22); transform: translateX(-104%); visibility: hidden; transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur); }
  .nav-open .contents-rail { transform: none; visibility: visible; transition: transform var(--dur) var(--ease); }
  .js .close-nav { display: grid; place-items: center; }
  .content { padding: 18px 20px 48px; }
  h1 { font-size: 2.125rem; }
  .section { padding: 36px 0 16px; }
  .flow { gap: 6px; }
}
@media (max-width: 540px) {
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: 1; }
  .brand { font-size: .875rem; gap: 10px; }
  .brand small { font-size: .625rem; }
  .brand-icon { width: 30px; height: 30px; border-radius: 8px; }
  .content { padding: 16px 16px 40px; }
  h1 { font-size: 1.875rem; }
  .intro { font-size: 1rem; }
  .section-head h2 { font-size: 1.3125rem; }
  .table-wrap table { min-width: 450px; }
  .diagram { padding: 16px; }
  .mode-diagram { grid-template-columns: 1fr; }
  .mode-diagram > .diagram-arrow { text-align: center; transform: rotate(90deg); }
  .mode-nodes { grid-template-columns: repeat(2, 1fr); }
  .flow { flex-direction: column; }
  .flow .diagram-node { width: 100%; }
  .flow .diagram-arrow { transform: rotate(90deg); line-height: 1; text-align: center; }
  .slot-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; --surface: #fff; --surface-2: #fff; --surface-3: #fff; --ink: #111; --ink-2: #111; --muted: #444; --faint: #444; --line: #bbb; --line-strong: #bbb; --teal-soft: #fff; --teal-dark: #0b6f68; --code-bg: #f3f5f7; }
  body { background: white; color: #111; font-size: 10pt; line-height: 1.5; }
  .app-shell { max-width: none; }
  .topbar { position: static; height: auto; background: white; backdrop-filter: none; border-bottom: 1px solid #bbb; }
  .topbar-inner { display: block; padding: 0 0 14px; }
  .brand { color: #111; }
  .brand small { color: #444; }
  .brand-icon { print-color-adjust: exact; }
  .header-actions, .contents-rail, .backdrop, .skip, .progress, .quick-links, .hero::before, .watch-link, .pager, .lib-link { display: none !important; }
  .layout { display: block; }
  .content { padding: 20px 0; min-height: 0; }
  .content > *, .content p { max-width: none; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  h1 { font-size: 25pt; }
  .section-head h2 { font-size: 17pt; }
  .section-num { background: none; padding: 0; min-width: 0; }
  .section { padding: 22px 0; break-inside: auto; }
  .section-head { break-after: avoid; }
  .diagram, .steps > li, tr { break-inside: avoid; }
  .diagram { background: white; }
  .table-wrap { overflow: visible; box-shadow: none; }
  table { min-width: 0 !important; font-size: 9pt; }
  th { font-size: 8pt; }
  a { color: #111; text-decoration: underline; }
  @page { size: A4; margin: 16mm; }
}
