/* ===================================================================
   bale xyz — documentation stylesheet
   No build step, no CDN. Works from file:// and GitHub Pages alike.
   =================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-code: #1e2430;
  --bg-elev: #ffffff;
  --fg: #16181d;
  --fg-soft: #5b6270;
  --fg-faint: #8b93a1;
  --line: #e4e7ec;
  --line-strong: #cfd4dc;
  --brand: #1f6feb;
  --brand-soft: #e7f0ff;
  --brand-fg: #0b47a1;
  --accent: #0e9f6e;
  --accent-soft: #e3f8ef;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #c81e1e;
  --danger-soft: #fee2e2;
  --code-fg: #e6edf3;
  --code-key: #7ee787;
  --code-str: #a5d6ff;
  --code-com: #8b949e;
  --code-num: #ffab70;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Vazirmatn", sans-serif;
  /* Persian pages use a dedicated stack so Arabic-script shaping and
     line-height behave correctly, with no webfont download. */
  --sans-fa: "Vazirmatn", "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro",
    "Segoe UI", Tahoma, "Iranian Sans", "B Nazanin", sans-serif;
  --sidebar-w: 274px;
  --topbar-h: 58px;
  --maxw: 830px;
}

html[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #151a22;
  --bg-elev: #171d26;
  --fg: #e6edf3;
  --fg-soft: #9aa4b2;
  --fg-faint: #6b7684;
  --line: #232a35;
  --line-strong: #303a48;
  --brand: #4d8dfa;
  --brand-soft: #16263f;
  --brand-fg: #9cc2ff;
  --accent: #34d399;
  --accent-soft: #10281f;
  --warn: #fbbf24;
  --warn-soft: #2a2010;
  --danger: #f87171;
  --danger-soft: #2b1414;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.72;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 80;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15.5px; letter-spacing: -.01em;
  color: var(--fg); text-decoration: none; white-space: nowrap;
}
.logo-mark {
  width: 27px; height: 27px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--brand), #7b5cff 60%, var(--accent));
  display: grid; place-items: center;
  color: #fff; font-size: 14px; font-weight: 800;
}
.logo small {
  font-weight: 500; font-size: 11px; color: var(--fg-faint);
  border: 1px solid var(--line); border-radius: 20px; padding: 1px 7px;
  letter-spacing: .02em;
}
.topbar-spacer { flex: 1; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-elev);
  color: var(--fg-soft); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--fg); border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; }

.menu-btn { display: none; }

/* ---------- search ---------- */
.search-wrap { position: relative; width: 250px; max-width: 34vw; }
.search-wrap input {
  width: 100%; height: 34px;
  padding: 0 10px 0 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font-family: inherit; font-size: 13.5px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-wrap input:focus {
  border-color: var(--brand);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search-wrap input::placeholder { color: var(--fg-faint); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--fg-faint); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto; padding: 5px;
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--fg); font-size: 13.5px;
}
.search-results a:hover, .search-results a.sel { background: var(--brand-soft); color: var(--brand-fg); }
.search-results a span { display: block; font-size: 11.5px; color: var(--fg-faint); }
.search-results .empty { padding: 12px 10px; color: var(--fg-faint); font-size: 13px; }

/* ---------- layout ---------- */
.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: none;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 22px 14px 60px 20px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  overscroll-behavior: contain;
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 9px; border: 3px solid var(--bg); }

.nav-group { margin-bottom: 20px; }
.nav-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--fg-faint);
  padding: 0 10px; margin-bottom: 7px;
}
.nav a {
  display: block;
  padding: 5.5px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 13.6px;
  line-height: 1.45;
  border-left: 2px solid transparent;
  transition: color .12s, background .12s;
}
.nav a:hover { color: var(--fg); background: var(--bg-soft); }
.nav a.active {
  color: var(--brand-fg);
  background: var(--brand-soft);
  font-weight: 600;
  border-left-color: var(--brand);
}
.nav a code { font-size: 12.4px; }

main {
  flex: 1; min-width: 0;
  padding: 40px 44px 110px;
  display: flex; justify-content: center; gap: 26px;
}
.content { width: 100%; max-width: var(--maxw); min-width: 0; flex: 1 1 auto; }

/* ---------- typography ---------- */
h1, h2, h3, h4 { line-height: 1.28; letter-spacing: -.018em; font-weight: 700; }
h1 { font-size: 2.08rem; margin: 0 0 12px; }
h2 {
  font-size: 1.42rem; margin: 52px 0 14px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
h2:first-of-type { border-top: none; padding-top: 0; margin-top: 34px; }
h3 { font-size: 1.1rem; margin: 34px 0 10px; }
h4 { font-size: .96rem; margin: 24px 0 8px; color: var(--fg-soft); }
p { margin: 0 0 15px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 15px; padding-left: 22px; }
li { margin: 4px 0; }
li > p { margin-bottom: 6px; }

hr { border: none; border-top: 1px solid var(--line); margin: 34px 0; }

blockquote {
  margin: 18px 0; padding: 12px 17px;
  border-left: 3px solid var(--brand);
  background: var(--bg-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--fg-soft);
}
blockquote p:last-child { margin-bottom: 0; }

.lead { font-size: 1.05rem; color: var(--fg-soft); margin-bottom: 26px; }

/* ---------- code ---------- */
code {
  font-family: var(--mono);
  font-size: .865em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .11em .38em;
  color: var(--brand-fg);
  white-space: nowrap;
}
html[data-theme="dark"] code { color: #ffc9a8; }

pre {
  position: relative;
  margin: 18px 0;
  padding: 16px 18px;
  background: var(--bg-code);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .06);
  font-size: 13.4px;
  line-height: 1.66;
}
pre code {
  background: none; border: none; padding: 0;
  color: var(--code-fg); font-size: inherit; white-space: pre;
}
pre::-webkit-scrollbar { height: 9px; }
pre::-webkit-scrollbar-thumb { background: #40495a; border-radius: 9px; }

pre .tok-key { color: var(--code-key); }
pre .tok-str { color: var(--code-str); }
pre .tok-com { color: var(--code-com); font-style: italic; }
pre .tok-num { color: var(--code-num); }
pre .tok-fn  { color: #d2a8ff; }

.copy-btn {
  position: absolute; top: 9px; right: 9px;
  height: 27px; padding: 0 10px;
  font: inherit; font-size: 11.5px; font-weight: 600;
  color: #b9c2cf; background: #2b3340;
  border: 1px solid #3a4351; border-radius: 6px;
  cursor: pointer; opacity: 0;
  transition: opacity .15s, background .15s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: #3a4351; color: #fff; }
.copy-btn.done { background: var(--accent); border-color: var(--accent); color: #06231a; }

/* file-name label above a block */
.filename {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 0 0;
  padding: 7px 14px;
  background: #262d3a;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid rgba(255, 255, 255, .06);
  border-bottom: none;
  font-family: var(--mono); font-size: 12px; color: #9aa4b2;
}
.filename + pre { margin-top: 0; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  background: var(--bg-soft);
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg-soft);
  position: sticky; top: 0;
}
tbody tr:last-child td, tbody tr:last-child th { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--bg-soft) 60%, transparent); }
td code { white-space: nowrap; font-size: .84em; }

/* ---------- callouts ---------- */
.note, .tip, .warn, .danger, .success {
  margin: 18px 0; padding: 13px 16px 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  border-left-width: 3px;
  font-size: 14.4px;
}
.note { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.tip { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.success { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.note p:last-child, .tip p:last-child, .warn p:last-child,
.danger p:last-child, .success p:last-child { margin-bottom: 0; }
.note strong:first-child, .tip strong:first-child, .warn strong:first-child,
.danger strong:first-child { display: block; margin-bottom: 3px; }

/* ---------- cards / feature grid ---------- */
.grid { display: grid; gap: 14px; margin: 22px 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.card {
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card h3, .card h4 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; font-size: 13.8px; color: var(--fg-soft); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--brand); box-shadow: var(--shadow-lg); text-decoration: none; }
.card .icon { font-size: 19px; margin-bottom: 7px; display: block; }

/* ---------- hero (index page) ---------- */
.hero { padding: 22px 0 8px; }
.hero h1 { font-size: 2.5rem; letter-spacing: -.028em; }
.hero .lead { font-size: 1.14rem; max-width: 44em; }

.badges { display: flex; flex-wrap: wrap; gap: 7px; margin: 20px 0 26px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 25px; padding: 0 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--bg-soft); color: var(--fg-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge.info { background: var(--brand-soft); color: var(--brand-fg); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 19px;
  border-radius: 9px;
  font-size: 14.5px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .12s, box-shadow .15s, background .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 3px rgba(31, 111, 235, .35); }
.btn-primary:hover { background: var(--brand-fg); }
html[data-theme="dark"] .btn-primary:hover { background: #3b7df5; }
.btn-ghost { background: var(--bg-elev); color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-soft); }

/* ---------- stat strip ---------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px; margin: 30px 0; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stat { background: var(--bg-elev); padding: 15px 16px; }
.stat b { display: block; font-size: 1.55rem; line-height: 1.15; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ---------- steps ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 22px 0; }
.steps > li {
  position: relative;
  counter-increment: step;
  padding: 0 0 20px 42px;
  border-left: 2px solid var(--line);
  margin-left: 14px;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: -15px; top: -3px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 0 0 4px var(--bg);
}
.steps > li > strong:first-child,
.steps > li > p:first-child strong { font-size: 15px; }
.steps > li pre { margin: 10px 0 4px; }

/* ---------- api signature blocks ---------- */
.api {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
  background: var(--bg-elev);
}
.api-head {
  padding: 11px 15px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13.2px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
}
.api-head .name { font-weight: 700; color: var(--brand-fg); }
.api-head .kw { color: var(--fg-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.api-body { padding: 13px 15px; font-size: 14.2px; }
.api-body > p:first-child { margin-top: 0; }
.api-body > p:last-child, .api-body > pre:last-child { margin-bottom: 0; }
.api-body dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13.6px; }
.api-body dt { font-family: var(--mono); color: var(--brand-fg); font-size: 12.8px; }
.api-body dd { margin: 0; color: var(--fg-soft); }

/* ---------- footer nav ---------- */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 56px; padding-top: 24px;
  border-top: 1px solid var(--line);
}
.pager a {
  display: block; padding: 13px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--fg);
  transition: border-color .15s, background .15s;
}
.pager a:hover { border-color: var(--brand); background: var(--bg-soft); }
.pager a span { display: block; font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; margin-bottom: 2px; }
.pager a.next { text-align: right; grid-column: 2; }
.pager a small { color: var(--fg-soft); font-size: 13.5px; }

.pagefoot {
  margin-top: 34px; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.8px; color: var(--fg-faint);
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
}

/* ---------- toc (in-page) ---------- */
.toc {
  position: sticky; top: calc(var(--topbar-h) + 24px);
  align-self: flex-start;
  width: 190px; flex: 0 0 auto;
  max-height: calc(100vh - var(--topbar-h) - 60px);
  overflow-y: auto;
  padding: 8px 8px 8px 0;
  font-size: 12.9px;
  display: none;
}
.toc-title { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--fg-faint); margin: 0 0 8px 11px; }
.toc a { display: block; padding: 3.5px 0 3.5px 11px; color: var(--fg-faint); border-left: 2px solid var(--line); text-decoration: none; line-height: 1.45; }
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.toc a.lvl3 { padding-left: 22px; font-size: 12.4px; }

/* ---------- rtl (Persian pages) ---------- */
[dir="rtl"] {
  font-family: var(--sans-fa);
  line-height: 1.85;
}
/* `row` already follows the writing direction: in RTL the first flex item
   (the sidebar) lands on the right.  `row-reverse` would undo that. */
[dir="rtl"] .shell { flex-direction: row; }
[dir="rtl"] .sidebar {
  border-right: none; border-left: 1px solid var(--line);
  padding: 22px 20px 60px 14px;
}
[dir="rtl"] .nav a {
  border-left: none; border-right: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .nav a.active { border-right-color: var(--brand); }
[dir="rtl"] .nav-title { letter-spacing: 0; text-transform: none; font-size: 11.5px; }

/* Headings and prose read right-to-left; identifiers stay left-to-right. */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4,
[dir="rtl"] p, [dir="rtl"] li, [dir="rtl"] td, [dir="rtl"] th,
[dir="rtl"] .lead, [dir="rtl"] .stat b, [dir="rtl"] .stat span { text-align: right; }
[dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] .api-head, [dir="rtl"] .filename {
  direction: ltr; text-align: left; font-family: var(--mono);
}
[dir="rtl"] .api-body dt { direction: ltr; text-align: left; }
[dir="rtl"] .api-body dd { text-align: right; }

/* Lists, quotes and step markers. */
[dir="rtl"] ul, [dir="rtl"] ol { padding-left: 0; padding-right: 22px; }
[dir="rtl"] blockquote {
  border-left: none; border-right: 3px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .steps > li {
  border-left: none; border-right: 2px solid var(--line);
  padding: 0 42px 20px 0; margin-left: 0; margin-right: 14px;
}
[dir="rtl"] .steps > li:last-child { border-right-color: transparent; }
[dir="rtl"] .steps > li::before { left: auto; right: -15px; }

/* Table of contents. */
[dir="rtl"] .toc a {
  border-left: none; border-right: 2px solid var(--line);
  padding: 3.5px 11px 3.5px 0; text-align: right;
}
[dir="rtl"] .toc a.active { border-right-color: var(--brand); }
[dir="rtl"] .toc a.lvl3 { padding-right: 22px; }
[dir="rtl"] .toc-title { margin: 0 11px 8px 0; letter-spacing: 0; text-transform: none; font-size: 11.5px; }

/* Copy button and search box flip sides. */
[dir="rtl"] .copy-btn { right: auto; left: 9px; }
[dir="rtl"] .search-wrap input { padding: 0 32px 0 10px; }
[dir="rtl"] .search-icon { left: auto; right: 10px; }

/* Pager: "next" moves to the left column and right-aligns in RTL. */
[dir="rtl"] .pager a.next { text-align: left; }
[dir="rtl"] .pager a.prev { text-align: right; }

/* The language switcher keeps its own LTR ordering. */
.lang-switch { direction: ltr; display: flex; gap: 2px; }
.lang-switch a {
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  padding: 5px 9px; border-radius: 6px; text-decoration: none;
  color: var(--fg-faint); border: 1px solid var(--line);
  background: var(--bg-soft); transition: color .12s, border-color .12s;
}
.lang-switch a:hover { color: var(--fg); border-color: var(--line-strong); }
.lang-switch a.active {
  color: #fff; background: var(--brand); border-color: var(--brand);
}
[dir="rtl"] .lang-switch { margin-left: 0; margin-right: 8px; }

/* ---------- responsive ---------- */
@media (min-width: 1200px) {
  .toc { display: block; }
}
@media (max-width: 1024px) {
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0;
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-lg);
    z-index: 70;
    width: 290px;
  }
  .sidebar.open { transform: translateX(0); }
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(102%); }
  [dir="rtl"] .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  main { padding: 30px 26px 90px; }
  .scrim {
    position: fixed; inset: 0; top: var(--topbar-h);
    background: rgba(0, 0, 0, .4); z-index: 65;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 640px) {
  body { font-size: 15.4px; }
  h1 { font-size: 1.66rem; }
  .hero h1 { font-size: 1.94rem; }
  h2 { font-size: 1.24rem; margin-top: 40px; }
  main { padding: 24px 17px 80px; }
  .search-wrap { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .logo small { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: 1; text-align: left; }
  pre { font-size: 12.4px; padding: 14px; margin-left: -3px; margin-right: -3px; }
  .stat b { font-size: 1.3rem; }
  /* The copy button is always visible on touch, so reserve room for it
     instead of letting it sit on top of the first line of code. */
  .copy-btn { opacity: 1; }
  pre { padding-top: 44px; }
  pre .copy-btn { top: 8px; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .copy-btn, .scrim { display: none !important; }
  main { padding: 0; }
  pre { border: 1px solid #ccc; box-shadow: none; }
  a { color: inherit; }
}
