/* browser-clip documentation. Light and dark themes (system preference, or the toggle).
   From terminal-clip docs-src/assets/docs.css @ f2cc02a. Changed: nothing yet; .term styles unused. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-raised: #ffffff;
  --bg-side: #fafbfc;
  --text: #1c2128;
  --text-soft: #424a55;
  --muted: #69717d;
  --border: #e3e7ec;
  --border-strong: #cfd5dc;
  --accent: #0a7f91;
  --accent-strong: #06606e;
  --accent-soft: #e5f5f7;
  --link: #0a6e7e;
  --code-bg: #eff2f5;
  --code-text: #1c2128;
  --block-bg: #15171c;
  --block-fg: #d5d8de;
  --block-border: #262a33;
  --head-bg: #1d2027;
  --mark: #fff3b0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .08);
  --note: #2f6fdf;
  --tip: #11845b;
  --important: #7b4ad6;
  --warning: #b26a00;
  --caution: #d23b3b;
  --radius: 10px;
  --top: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116;
    --bg-soft: #151a21;
    --bg-raised: #161b22;
    --bg-side: #0b0e12;
    --text: #e4e8ee;
    --text-soft: #c3cad4;
    --muted: #8c95a3;
    --border: #232a34;
    --border-strong: #303844;
    --accent: #5fd3e3;
    --accent-strong: #8ae6f2;
    --accent-soft: rgba(95, 211, 227, .1);
    --link: #74d8e6;
    --code-bg: #1b2129;
    --code-text: #e4e8ee;
    --block-bg: #12151b;
    --block-border: #232933;
    --head-bg: #181c23;
    --mark: rgba(255, 214, 102, .28);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    --note: #6ea2ff;
    --tip: #3fc58b;
    --important: #a98bff;
    --warning: #f0a83a;
    --caution: #ff7070;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-soft: #151a21;
  --bg-raised: #161b22;
  --bg-side: #0b0e12;
  --text: #e4e8ee;
  --text-soft: #c3cad4;
  --muted: #8c95a3;
  --border: #232a34;
  --border-strong: #303844;
  --accent: #5fd3e3;
  --accent-strong: #8ae6f2;
  --accent-soft: rgba(95, 211, 227, .1);
  --link: #74d8e6;
  --code-bg: #1b2129;
  --code-text: #e4e8ee;
  --block-bg: #12151b;
  --block-border: #232933;
  --head-bg: #181c23;
  --mark: rgba(255, 214, 102, .28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --note: #6ea2ff;
  --tip: #3fc58b;
  --important: #a98bff;
  --warning: #f0a83a;
  --caution: #ff7070;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, video { max-width: 100%; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--bg); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---- Top bar ---------------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: #15171c; color: #66d9e8;
  font: 700 13px/1 var(--mono);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; }
.top-spacer { flex: 1; }
.search { position: relative; width: min(420px, 42vw); }
.search input {
  width: 100%; height: 38px;
  padding: 0 64px 0 36px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: 14px;
}
.search input:focus { outline: none; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 9px; top: 9px; }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  max-height: min(70vh, 560px); overflow: auto;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px;
}
.search-results[hidden] { display: none; }
.search-results a { display: block; padding: 9px 11px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--accent-soft); text-decoration: none; }
.search-results .r-page { font-size: 12px; color: var(--muted); }
.search-results .r-head { font-weight: 600; font-size: 14.5px; }
.search-results .r-text { font-size: 13px; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-results .empty { padding: 14px; color: var(--muted); font-size: 14px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border); border-radius: 9px;
  background: transparent; color: var(--text-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* ---- Layout ------------------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 232px;
  max-width: 1480px;
  margin: 0 auto;
}
.sidebar {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 22px 14px 40px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg-side);
  scrollbar-width: thin;
}
.nav-section { margin-bottom: 22px; }
.nav-section h2 {
  margin: 0 0 6px 10px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 10px; margin: 1px 0;
  border-radius: 7px;
  color: var(--text-soft); font-size: 14.5px; line-height: 1.4;
}
.nav-section a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-section a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-section .num { font: 600 11.5px/1.4 var(--mono); color: var(--muted); min-width: 1.4em; }
.nav-section a[aria-current="page"] .num { color: inherit; }

.content { min-width: 0; padding: 40px 56px 80px; }
.article { max-width: 800px; margin: 0 auto; }
.toc {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 40px 20px 40px 8px;
  font-size: 13.5px;
  scrollbar-width: thin;
}
.toc h2 { margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 0 3px 14px; margin-left: -1px; color: var(--muted); border-left: 2px solid transparent; line-height: 1.45; }
.toc li.l3 a { padding-left: 26px; font-size: 13px; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--accent-strong); border-left-color: var(--accent); }

/* ---- Article typography ------------------------------------------------------------------------- */
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.article h1 { font-size: 2.35rem; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 14px; font-weight: 750; }
.article .lead { font-size: 1.18rem; line-height: 1.6; color: var(--text-soft); margin: 0 0 30px; }
.article h2 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -.015em; margin: 52px 0 14px; padding-top: 22px; border-top: 1px solid var(--border); font-weight: 700; }
.article h3 { font-size: 1.18rem; line-height: 1.35; margin: 34px 0 10px; font-weight: 650; }
.article h4 { font-size: 1rem; margin: 26px 0 8px; font-weight: 650; }
.article h1 + h2, .article .lead + h2 { margin-top: 30px; }
.article h2, .article h3, .article h4 { position: relative; }
.anchor { margin-left: 8px; color: var(--border-strong); font-weight: 400; opacity: 0; transition: opacity .15s; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; }
.article p, .article ul, .article ol { margin: 0 0 16px; }
.article li { margin: 4px 0; }
.article li > ul, .article li > ol { margin: 4px 0 6px; }
.article ul, .article ol { padding-left: 1.5em; }
.article hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }
.article strong { font-weight: 650; }
.article blockquote { margin: 0 0 16px; padding: 4px 18px; border-left: 3px solid var(--border-strong); color: var(--text-soft); }
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--code-bg); color: var(--code-text);
  padding: .12em .38em; border-radius: 5px;
  overflow-wrap: anywhere;
}
a code { color: var(--link); }
kbd {
  display: inline-block;
  font: 600 11.5px/1 var(--mono);
  padding: 4px 6px 3px;
  min-width: 1.7em; text-align: center;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
  background: var(--bg-raised); color: var(--text-soft);
}

/* ---- Code blocks -------------------------------------------------------------------------------- */
.code {
  position: relative;
  margin: 0 0 20px;
  border: 1px solid var(--block-border);
  border-radius: var(--radius);
  background: var(--block-bg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.code-head {
  display: flex; align-items: center; gap: 10px;
  min-height: 38px; padding: 0 8px 0 14px;
  background: var(--head-bg);
  border-bottom: 1px solid var(--block-border);
  color: #9aa3b2; font: 12.5px/1 var(--mono);
}
.code-head .file { color: #c9ced6; font-weight: 600; }
.code-head .lang { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.code-head .spacer { flex: 1; }
.code-head a, .code-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 9px;
  border: 1px solid #2c313b; border-radius: 6px;
  background: transparent; color: #aab2bf;
  font: 12px/1 var(--font); cursor: pointer;
}
.code-head a:hover, .code-btn:hover { background: #262b34; color: #e6e9ef; text-decoration: none; }
.code-btn.ok { color: #8fd694; border-color: #3c5a40; }
.code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  color: var(--block-fg);
  font: 13.5px/1.62 var(--mono);
  tab-size: 4;
  scrollbar-width: thin;
  scrollbar-color: #3a404b transparent;
}
.code pre code { background: none; padding: 0; font-size: inherit; color: inherit; border-radius: 0; overflow-wrap: normal; }
.code.no-head .code-btn { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; background: #1d2027; }
.code.no-head:hover .code-btn, .code.no-head .code-btn:focus { opacity: 1; }
.t-com { color: #7d8594; font-style: italic; }
.t-key { color: #66d9e8; }
.t-str { color: #a8e6ad; }
.t-val { color: #e6e9ef; }
.t-num { color: #f7ca6b; }
.t-bool { color: #d9aaf5; }
.t-punc { color: #8a93a2; }
.t-tag { color: #ff9e9e; }
.t-ph { color: #f7ca6b; }
.t-cmd { color: #8cbcff; font-weight: 600; }
.t-flag { color: #d9aaf5; }
.t-var { color: #f7ca6b; }
.t-kw { color: #d9aaf5; }
.t-prompt { color: #7d8594; user-select: none; }
.t-out { color: #aeb5c0; }

/* Tabs */
.tabset { margin: 0 0 20px; }
.tabset .code { margin: 0; border-top-left-radius: 0; }
.tablist { display: flex; gap: 2px; flex-wrap: wrap; }
.tablist button {
  padding: 7px 14px;
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--bg-soft); color: var(--muted);
  font: 600 13px/1.2 var(--font); cursor: pointer;
}
.tablist button[aria-selected="true"] { background: var(--block-bg); border-color: var(--block-border); color: #e6e9ef; }

/* ---- Terminal snippets (engine output as HTML) ------------------------------------------------- */
.term {
  margin: 0 0 20px;
  border-radius: var(--radius);
  background: var(--term-bg);
  color: var(--term-fg);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255, 255, 255, .05);
  overflow: hidden;
}
.term.light { box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(0, 0, 0, .08); }
.term pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13.5px/1.42 var(--mono); scrollbar-width: thin; }
.term .cur { background: var(--term-cur); color: var(--term-bg); }
.term-title { padding: 7px 14px; font: 600 12px/1.2 var(--font); color: var(--term-fg); opacity: .65; border-bottom: 1px solid rgba(127, 127, 127, .18); }
.style-list { margin: 0 0 24px; }
.style-item { margin: 0 0 14px; }
.style-item .term { margin: 0; }
.style-item .term pre { padding: 10px 14px; font-size: 13px; }
.style-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin: 0 0 6px; font-size: 13.5px; }
.style-head code { font-weight: 600; }
.style-head code.tpl { font-weight: 400; color: var(--text-soft); }
.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin: 0 0 24px; }
.term-grid .term { margin: 0; }
.term-grid figure { margin: 0; }
.term-grid figcaption { margin-top: 6px; }

/* ---- Callouts ------------------------------------------------------------------------------------ */
.callout {
  --c: var(--note);
  margin: 0 0 20px;
  padding: 12px 16px 2px;
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-left: 4px solid var(--c);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 7%, var(--bg));
}
.callout.tip { --c: var(--tip); }
.callout.important { --c: var(--important); }
.callout.warning { --c: var(--warning); }
.callout.caution { --c: var(--caution); }
.callout-title { margin: 0 0 6px !important; font-weight: 700; color: var(--c); font-size: 14.5px; }
.callout p, .callout ul, .callout ol { margin-bottom: 10px; }
.callout .code { margin-bottom: 12px; }

/* ---- Tables -------------------------------------------------------------------------------------- */
.table-wrap { margin: 0 0 22px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
th, td { padding: 9px 13px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--bg-soft); font-weight: 650; font-size: 13.5px; color: var(--text-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { font-size: .84em; }
td:first-child code { white-space: nowrap; }
.tc-def { color: var(--muted); }

/* ---- Media --------------------------------------------------------------------------------------- */
.media { margin: 6px 0 26px; }
.media .frame {
  position: relative;
  border-radius: 12px; overflow: hidden;
  background: #0b0d11;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.media video, .media img { display: block; width: 100%; height: auto; }
.media.portrait .frame { max-width: 360px; margin: 0 auto; }
.media.narrow .frame { max-width: 560px; margin: 0 auto; }
figcaption, .caption { margin-top: 9px; font-size: 13.5px; color: var(--muted); text-align: center; line-height: 1.5; }
figcaption code { font-size: .9em; }
.media-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin: 0 0 26px; }
.media-row .media { margin: 0; }
.missing {
  display: grid; place-items: center; aspect-ratio: 16 / 9;
  color: #8a93a2; font: 13px var(--mono); padding: 20px; text-align: center;
  background: repeating-linear-gradient(45deg, #15171c, #15171c 12px, #191c22 12px, #191c22 24px);
}

/* ---- Home ----------------------------------------------------------------------------------------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; margin: 6px 0 44px; }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.3rem) !important; margin-bottom: 14px !important; }
.hero .tagline { font-size: 1.22rem; color: var(--text-soft); max-width: 680px; margin: 0 0 22px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  font-weight: 600; font-size: 15px; color: var(--text);
  background: var(--bg-raised);
}
.btn:hover { text-decoration: none; background: var(--bg-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #062a30; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #062a30; } }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0 0 30px; }
.card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-raised); color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card h3 { margin: 6px 0 6px !important; font-size: 1.02rem !important; }
.card p { margin: 0 !important; font-size: 14.5px; color: var(--text-soft); line-height: 1.55; }
.card .ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); }
.card .ico svg { width: 19px; height: 19px; }
.steps-list { counter-reset: step; list-style: none; padding: 0 !important; }
.steps-list > li { counter-increment: step; position: relative; padding-left: 44px; margin: 0 0 18px; }
.steps-list > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
  font: 700 14px/1 var(--font);
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 0 0 30px; }
.gallery .media { margin: 0; }
.gallery h3 { margin: 10px 0 4px !important; font-size: 1rem !important; }
.gallery p { margin: 0 !important; font-size: 14px; color: var(--text-soft); }
.example { margin: 0 0 48px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-soft); }
details.source { margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius); }
details.source > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14.5px; list-style: none; display: flex; gap: 8px; align-items: center; }
details.source > summary::-webkit-details-marker { display: none; }
details.source > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.source[open] > summary::before { transform: rotate(90deg); }
details.source > .code { margin: 0; border: 0; border-top: 1px solid var(--block-border); border-radius: 0 0 var(--radius) var(--radius); }

/* Swatches (themes) */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; margin: 0 0 26px; }
.theme-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-raised); }
.theme-card .term { margin: 0; border-radius: 0; box-shadow: none; }
.theme-card .term pre { font-size: 12.5px; padding: 12px 14px; }
.theme-meta { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13.5px; }
.theme-meta code { font-weight: 600; }
.theme-meta .spacer { flex: 1; }
.swatches { display: grid; grid-template-columns: repeat(8, 12px); gap: 2px; }
.swatches i { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .25); }

/* Diagram */
.diagram { margin: 4px 0 26px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; min-width: 560px; font-family: var(--font); }
.diagram .box { fill: var(--bg-raised); stroke: var(--border-strong); }
.diagram .box.accent { stroke: var(--accent); fill: var(--accent-soft); }
.diagram text { fill: var(--text); font-size: 13px; }
.diagram .sub { fill: var(--muted); font-size: 11.5px; }
.diagram .arrow { stroke: var(--muted); fill: none; stroke-width: 1.5; }
.diagram .arrowhead { fill: var(--muted); }
.diagram .curve { stroke: var(--accent); fill: none; stroke-width: 2.5; }
.diagram .grid { stroke: var(--border); stroke-width: 1; }
.diagram .axis { stroke: var(--muted); stroke-width: 1.2; }
.diagram .band { fill: var(--accent-soft); }

/* Prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 56px 0 0; padding-top: 26px; border-top: 1px solid var(--border); }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.pager .ttl { font-weight: 650; color: var(--accent-strong); }
.pager .next { text-align: right; grid-column: 2; }
.page-foot { margin-top: 30px; font-size: 13px; color: var(--muted); }

/* ---- Responsive ------------------------------------------------------------------------------------ */
@media (max-width: 1240px) {
  .shell { grid-template-columns: 260px minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 36px 44px 72px; }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--top); left: 0; bottom: 0; z-index: 35;
    width: min(300px, 86vw); height: auto;
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .content { padding: 26px 16px 64px; }
  .search { width: auto; flex: 1; }
  .brand small { display: none; }
  .search kbd { display: none; }
  .search input { padding-right: 12px; }
  .article h1 { font-size: 1.9rem; }
  .article h2 { font-size: 1.35rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .code pre, .term pre { font-size: 12.5px; }
}
@media (max-width: 520px) {
  .brand .name { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .code-btn { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
}

/* Gallery thumbnails share one shape; vertical clips are letterboxed. */
.gallery .media .frame { aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; max-width: none; }
.gallery .media img { width: 100%; height: 100%; object-fit: contain; }
.gallery .media.portrait .frame { max-width: none; margin: 0; }
@media (max-width: 900px) {
  .hero .tagline { font-size: 1.06rem; }
}
@media (max-width: 900px) {
  .article .lead { font-size: 1.05rem; }
}
