/* System Design Primer reading site */
:root {
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #fbfaf7;
  --panel: #f3f1ec;
  --raised: #ffffff;
  --text: #1d2126;
  --muted: #5c636d;
  --faint: #8a9099;
  --line: #e2dfd8;
  --accent: #2b59c3;
  --accent-soft: #e6edfb;
  --done: #1d8049;
  --done-soft: #e3f3e9;
  --part: #b7791f;
  --code-bg: #f2f0ea;
  --mark: #fff0a8;
  --danger: #b3261e;
  --shadow: 0 10px 30px rgba(20, 24, 30, .12);
  --img-bg: transparent;
  --top: 56px;
  --side: 300px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --panel: #1b1e22; --raised: #20242a; --text: #e5e6e3; --muted: #a3a9b1; --faint: #7d838b;
    --line: #2d3238; --accent: #8db0ff; --accent-soft: #1f2a40; --done: #52c587; --done-soft: #17301f;
    --part: #e2ae4f; --code-bg: #1e2125; --mark: #5a4b12; --danger: #ff8a80; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --img-bg: #f4f4f2; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --panel: #1b1e22; --raised: #20242a; --text: #e5e6e3; --muted: #a3a9b1; --faint: #7d838b;
  --line: #2d3238; --accent: #8db0ff; --accent-soft: #1f2a40; --done: #52c587; --done-soft: #17301f;
  --part: #e2ae4f; --code-bg: #1e2125; --mark: #5a4b12; --danger: #ff8a80; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --img-bg: #f4f4f2; color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); line-height: 1.65; }
:root[data-face="serif"] .doc, :root[data-face="serif"] .home .lede, :root[data-face="serif"] .howto { font-family: var(--serif); }
/* Chinese and Japanese: system CJK faces after the Latin ones, a little more leading */
:root:lang(ja) { --body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, Meiryo, "Noto Sans JP", "Noto Sans CJK JP", sans-serif; --serif: "Iowan Old Style", Georgia, "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", serif; }
:root:lang(zh-Hans) { --body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif; --serif: "Iowan Old Style", Georgia, "Songti SC", STSong, SimSun, "Noto Serif SC", "Noto Serif CJK SC", serif; }
:root:lang(zh-TW) { --body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", sans-serif; --serif: "Iowan Old Style", Georgia, "Songti TC", PMingLiU, "Noto Serif TC", "Noto Serif CJK TC", serif; }
:root:lang(ja) body, :root:lang(zh-Hans) body, :root:lang(zh-TW) body { line-height: 1.8; }
:root:lang(ja) .doc { line-break: strict; }
.doc .body[lang="en"] { line-height: 1.65; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: .75rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; background: var(--raised); color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--raised); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: .95rem; white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--panel); color: var(--text); }
.aa { font-weight: 700; font-size: .9rem; }
.menu-btn { display: none; }
#search-btn { display: none; }
.tools { margin-left: auto; display: flex; gap: 4px; }
.lang { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: 10px; color: var(--muted); font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.lang:hover, .lang:focus-within { background: var(--panel); color: var(--text); }
.lang:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.lang select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; border: 0; }
.top-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.top-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.search { position: relative; flex: 0 1 420px; margin-left: 24px; }
.search input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); color: var(--text); padding: 0 34px 0 36px; font: inherit; font-size: .9rem; }
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ic { position: absolute; left: 11px; top: 10px; color: var(--faint); pointer-events: none; }
.search-kbd { position: absolute; right: 9px; top: 9px; pointer-events: none; }
.search input:focus ~ .search-kbd { display: none; }
.results { position: absolute; top: 46px; left: 0; width: min(620px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.results a.sel, .results a:hover { background: var(--accent-soft); }
.results .r-t { font-weight: 600; font-size: .9rem; }
.results .r-t small { color: var(--muted); font-weight: 400; }
.results .r-x { color: var(--muted); font-size: .82rem; line-height: 1.5; margin-top: 2px; }
.results mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.results .r-none { padding: 12px; color: var(--muted); font-size: .9rem; }

.settings { position: absolute; right: 12px; top: calc(var(--top) - 4px); width: 300px; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; font-size: .88rem; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 11px; cursor: pointer; font-size: .85rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.set-check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; color: var(--muted); cursor: pointer; }
.set-check input { margin-top: 3px; accent-color: var(--accent); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 16px 12px 40px; font-size: .86rem; overscroll-behavior: contain; }
.side-top { padding: 0 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.side-home { display: block; color: var(--text); text-decoration: none; font-weight: 650; padding: 6px 0; }
.side-home.on { color: var(--accent); }
.overall { margin-top: 6px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--done); border-radius: 99px; transition: width .3s; }
.overall-t { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.nav-part { margin-top: 14px; }
.nav-part-t { display: flex; justify-content: space-between; margin: 0 8px 4px; font-size: .74rem; letter-spacing: .02em; color: var(--muted); font-weight: 650; }
.nav-part-n { font-weight: 500; color: var(--faint); }
.side ol { list-style: none; margin: 0; padding: 0; }
.nav-page { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.4; }
.nav-page:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.current > .nav-page { background: var(--raised); box-shadow: 0 0 0 1px var(--line); font-weight: 650; }
.nav-page.plain { color: var(--muted); }
.nav-secs { margin: 4px 0 8px 17px !important; border-left: 1px solid var(--line); }
.nav-sec { display: flex; gap: 8px; align-items: flex-start; padding: 4px 8px 4px 12px; color: var(--muted); text-decoration: none; line-height: 1.35; font-size: .82rem; border-radius: 0 6px 6px 0; }
.nav-sec:hover { color: var(--text); }
.nav-sec.active { color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); margin-left: -1px; }
.nav-sec .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--faint); margin-top: .38em; }
.nav-sec.read .dot { background: var(--done); border-color: var(--done); }

/* status circle */
.st { flex: none; width: 16px; height: 16px; margin-top: .12em; border-radius: 50%; border: 1.5px solid var(--faint); position: relative; }
.s-part .st { border-color: var(--part); background: conic-gradient(var(--part) var(--pct, 50%), transparent 0); }
.s-done .st { border-color: var(--done); background: var(--done); }
.s-done .st::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.main { min-width: 0; padding: 40px 48px 80px; }
.scrim { position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 18; }

/* ---------- article ---------- */
.doc { max-width: 42rem; margin: 0 auto; }
.crumb { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 8px; color: var(--muted); font-size: .8rem; font-family: var(--body); }
.crumb span:first-child { color: var(--accent); font-weight: 650; }
.doc h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 16px; letter-spacing: -.01em; font-family: var(--body); }
.page-meter { font-family: var(--body); font-size: .82rem; color: var(--muted); margin-bottom: 28px; display: flex; gap: 10px; align-items: center; }
.page-meter .bar { flex: 0 0 140px; }
.doc h2, .doc h3, .doc h4, .doc h5, .doc h6 { font-family: var(--body); line-height: 1.3; scroll-margin-top: calc(var(--top) + 16px); }
.doc h2 { font-size: 1.45rem; margin: 2.4em 0 .6em; padding-top: .2em; }
.doc h3 { font-size: 1.18rem; margin: 1.9em 0 .5em; }
.doc h4 { font-size: 1.02rem; margin: 1.6em 0 .4em; }
.doc h5, .doc h6 { font-size: .95rem; margin: 1.4em 0 .3em; color: var(--muted); }
.doc p, .doc ul, .doc ol { margin: 0 0 1em; }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li { margin: .25em 0; }
.doc li > ul, .doc li > ol { margin: .25em 0; }
.doc strong { font-weight: 650; }
.doc blockquote { margin: 0 0 1.2em; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text); }
.doc blockquote p:last-child { margin-bottom: 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.doc img { max-width: 100%; height: auto; border-radius: 8px; background: var(--img-bg); }
.doc p[align="center"], .doc [align="center"] { text-align: center; }
.doc p[align="center"] i, .doc p[align="center"] em { display: block; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.doc p > img:only-child { display: block; margin: 0 auto; }
.doc a[target="_blank"]::after { content: "↗"; font-size: .7em; margin-left: 2px; vertical-align: super; opacity: .55; }
.doc .intro > p:first-child img, .doc p[align="center"] img { cursor: zoom-in; }

.doc code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .1em .35em; border-radius: 5px; }
.code { margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: hidden; }
.code pre { margin: 0; padding: 14px 16px; overflow: auto; font-size: .8rem; line-height: 1.55; tab-size: 4; }
.code code { background: none; padding: 0; font-size: inherit; }
.code-cap { font-family: var(--mono); font-size: .75rem; color: var(--muted); margin: 0 0 -1px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px 10px 0 0; display: inline-block; }
.code-cap + .code { border-top-left-radius: 0; }

.tbl { margin: 0 0 1.2em; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.tbl table { border-collapse: collapse; width: 100%; font-size: .86rem; line-height: 1.5; font-family: var(--body); }
.tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: var(--panel); font-weight: 650; }
.tbl tr:last-child td { border-bottom: 0; }

/* sections and read marks */
.sec { position: relative; }
.sec-head { display: flex; align-items: flex-start; gap: 12px; margin: 2.4em 0 .6em; }
.doc .sec-head h2 { flex: 1; margin: 0; padding-top: 0; }
.mark { flex: none; display: inline-flex; align-items: center; gap: 6px; margin-top: .2em; height: 30px; padding: 0 10px 0 6px; border: 1px solid var(--line); border-radius: 99px; background: var(--raised); color: var(--muted); font-family: var(--body); font-size: .72rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.mark .st { width: 18px; height: 18px; margin: 0; }
.mark:hover { border-color: var(--done); color: var(--done); }
.mark[aria-pressed="true"] { border-color: var(--done); color: var(--done); background: var(--done-soft); }
.mark[aria-pressed="true"] .st { border-color: var(--done); background: var(--done); }
.mark[aria-pressed="true"] .st::after { content: ""; position: absolute; left: 5.5px; top: 2px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.mark.pulse { animation: pulse .6s ease; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.sec.is-read .sec-head h2 { color: var(--muted); }

.further { margin: 1.6em 0; padding: 4px 18px 6px; border: 1px dashed var(--line); border-radius: 12px; font-size: .88rem; }
.further > h2 { font-size: .95rem; margin: .9em 0 .4em; color: var(--muted); }
.doc .further-h { font-size: .9rem; color: var(--muted); }
.doc .further-h + ul { font-size: .88rem; }

.page-end { max-width: 42rem; margin: 48px auto 0; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }
.page-end-status { color: var(--muted); font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font-weight: 600; font-size: .9rem; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #10131a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #10131a; } }
.btn.done { background: var(--done-soft); border-color: var(--done); color: var(--done); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

.pn { max-width: 42rem; margin: 20px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pn a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); line-height: 1.35; }
.pn a:hover { border-color: var(--accent); }
.pn small { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 2px; }
.pn span { font-weight: 600; font-size: .92rem; }
.pn-next { text-align: right; grid-column: 2; }
.credit { max-width: 42rem; margin: 40px auto 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: .78rem; line-height: 1.55; }
.credit a { color: var(--muted); }

/* ---------- home ---------- */
.home { max-width: 52rem; margin: 0 auto; }
.hero { margin: 8px 0 28px; }
.eyebrow { color: var(--accent); font-weight: 650; font-size: .85rem; margin: 0 0 6px; }
.hero h1 { font-size: 2.6rem; line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.lede { font-size: 1.1rem; color: var(--muted); margin: 0; max-width: 40rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 18px 0 0; }
.hero-actions .btn { gap: 8px; }
.hero-note { color: var(--muted); font-size: .82rem; max-width: 30rem; line-height: 1.45; }
.dash { border: 1px solid var(--line); background: var(--raised); border-radius: 16px; padding: 22px; display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; }
.dash-main { display: flex; gap: 18px; align-items: center; }
.ring { position: relative; width: 76px; height: 76px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.4; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--done); stroke-linecap: round; transition: stroke-dasharray .4s; }
.ring-t { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.dash-big { margin: 0; font-weight: 650; font-size: 1.1rem; }
.dash-small { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.dash-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.dash-where { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .85rem; }
.dash-where:empty { display: none; }
h2.block { font-size: 1.3rem; margin: 44px 0 14px; }
.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.toc-part { border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px 10px; background: var(--raised); }
.toc-part-h { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 6px; }
.toc-part h2 { font-size: 1rem; margin: 0; }
.toc-part-n { color: var(--muted); font-size: .78rem; }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-page { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .9rem; line-height: 1.4; }
.toc-page:hover { background: var(--panel); }
.toc-t { flex: 1; }
.toc-meta { display: flex; gap: 10px; color: var(--faint); font-size: .76rem; white-space: nowrap; margin-top: .15em; }
.howto { color: var(--text); }
.howto p { margin: 0 0 .9em; }
.keys { color: var(--muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.keys kbd { margin-left: 8px; }
.keys kbd:first-child { margin-left: 0; }
.tools-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.home .credit { max-width: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .85rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.zoom { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .8); display: grid; place-items: center; padding: 20px; cursor: zoom-out; overflow: auto; }
.zoom img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 8px; }

/* ---------- code colors ---------- */
.hljs-comment, .hljs-quote { color: #6a737d; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: #b3245d; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #217a3a; }
.hljs-number, .hljs-symbol { color: #9a5b00; }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section { color: #2b59c3; }
.hljs-params, .hljs-variable, .hljs-attr, .hljs-property { color: #6f42c1; }
.hljs-meta { color: #6a737d; }
.hljs-deletion { color: #b3261e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hljs-comment { color: #8b949e; }
  :root:not([data-theme="light"]) .hljs-keyword, :root:not([data-theme="light"]) .hljs-literal, :root:not([data-theme="light"]) .hljs-built_in, :root:not([data-theme="light"]) .hljs-selector-tag { color: #ff8bb3; }
  :root:not([data-theme="light"]) .hljs-string, :root:not([data-theme="light"]) .hljs-regexp { color: #7ee2a0; }
  :root:not([data-theme="light"]) .hljs-number, :root:not([data-theme="light"]) .hljs-symbol { color: #f2c46d; }
  :root:not([data-theme="light"]) .hljs-title, :root:not([data-theme="light"]) .hljs-section { color: #8db0ff; }
  :root:not([data-theme="light"]) .hljs-params, :root:not([data-theme="light"]) .hljs-variable, :root:not([data-theme="light"]) .hljs-attr, :root:not([data-theme="light"]) .hljs-property { color: #c9a4ff; }
}
:root[data-theme="dark"] .hljs-comment { color: #8b949e; }
:root[data-theme="dark"] .hljs-keyword, :root[data-theme="dark"] .hljs-literal, :root[data-theme="dark"] .hljs-built_in, :root[data-theme="dark"] .hljs-selector-tag { color: #ff8bb3; }
:root[data-theme="dark"] .hljs-string, :root[data-theme="dark"] .hljs-regexp { color: #7ee2a0; }
:root[data-theme="dark"] .hljs-number, :root[data-theme="dark"] .hljs-symbol { color: #f2c46d; }
:root[data-theme="dark"] .hljs-title, :root[data-theme="dark"] .hljs-section { color: #8db0ff; }
:root[data-theme="dark"] .hljs-params, :root[data-theme="dark"] .hljs-variable, :root[data-theme="dark"] .hljs-attr, :root[data-theme="dark"] .hljs-property { color: #c9a4ff; }

/* ---------- translations ---------- */
.lang-note { font-family: var(--body); font-size: .88rem; line-height: 1.55; color: var(--text); background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 0 0 24px; }
.untranslated { font-family: var(--body); font-size: .8rem; line-height: 1.5; color: var(--muted); border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin: 4px 0 16px; }
.trans-credit { font-size: .95rem; color: var(--muted); }

/* ---------- narrow screens ---------- */
@media (max-width: 1000px) {
  .layout { display: block; }
  .menu-btn { display: inline-grid; }
  .side { position: fixed; top: var(--top); left: 0; bottom: 0; width: min(320px, 86vw); height: auto; z-index: 20; transform: translateX(-102%); transition: transform .22s ease; }
  body.nav-open .side { transform: none; box-shadow: var(--shadow); }
  .main { padding: 28px 24px 64px; }
}
@media (max-width: 720px) {
  .top { gap: 6px; padding: 0 8px; }
  .search { position: absolute; left: 8px; right: 8px; top: 8px; margin: 0; display: none; }
  body.search-open .search { display: block; }
  body.search-open .brand, body.search-open .tools, body.search-open .menu-btn { visibility: hidden; }
  .search-kbd { display: none; }
  .results { width: 100%; }
  #search-btn { display: inline-grid; }
  .brand span { font-size: .9rem; }
  .lang { padding: 0; width: 38px; justify-content: center; }
  .lang-t { display: none; }
  .icon-btn { width: 38px; }
  .tools { gap: 0; flex: none; }
  .brand { min-width: 0; gap: 8px; }
  .brand span { overflow: hidden; text-overflow: ellipsis; }
  .settings { left: 8px; right: 8px; width: auto; }
  .main { padding: 22px 16px 56px; }
  .doc h1 { font-size: 1.7rem; }
  .doc h2 { font-size: 1.28rem; }
  .sec-head { flex-direction: column; gap: 8px; }
  .mark { margin-top: 0; }
  .hero h1 { font-size: 2rem; }
  .dash { grid-template-columns: 1fr; padding: 18px; }
  .dash-actions { justify-content: flex-start; }
  .page-end { padding: 16px; }
  .pn { grid-template-columns: 1fr; }
  .pn-next { grid-column: 1; }
  .code pre { font-size: .74rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .top, .side, .page-end, .pn, .mark, .scrim { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
}
