/* ═══════════════════════════════════════════════════════════════════════════════
   baleropy docs — design system
   RTL-first (Persian), switches to LTR for English. Uses logical properties only.
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  --font: "Vazirmatn", "Vazir", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;

  --bg: #f7f9f8;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f8;
  --bg-code: #0f1623;
  --fg: #182521;
  --fg-soft: #4f625b;
  --fg-mute: #788780;
  --line: #e1e9e5;

  --brand: #087f5b;
  --brand-2: #126b70;
  --brand-3: #2c806c;
  --brand-soft: rgba(8, 127, 91, 0.09);
  --grad: linear-gradient(120deg, var(--brand), var(--brand-2));

  --ok: #12b886;
  --info: #3b82f6;
  --warn: #f59f00;
  --bad: #f0506e;

  --shadow: 0 1px 2px rgba(20, 40, 30, 0.04), 0 6px 20px rgba(20, 40, 30, 0.05);
  --shadow-lg: 0 18px 48px rgba(20, 40, 30, 0.12);
  --radius: 14px;
  --header-h: 64px;
  --sidebar-w: 292px;
  --toc-w: 232px;

  /* code colours (code blocks are always dark) */
  --c-fg: #d7e0f0;
  --c-kw: #c792ea;
  --c-str: #a5e075;
  --c-com: #637394;
  --c-num: #f78c6c;
  --c-fn: #82aaff;
  --c-cls: #ffcb6b;
  --c-deco: #f07178;
  --c-op: #89ddff;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elev: #121a2e;
  --bg-soft: #18223a;
  --bg-code: #080d19;
  --fg: #e8edf8;
  --fg-soft: #aab6d0;
  --fg-mute: #7886a6;
  --line: #243050;
  --brand-soft: rgba(8, 127, 91, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; scrollbar-gutter: stable; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 18px); }
body {
  margin: 0;
  overflow-x: clip;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--fg);
  background: var(--bg);
  transition: background 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[lang="en"] body { line-height: 1.75; font-size: 16px; }
::selection { background: var(--brand); color: #fff; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }

/* ── reading progress ─────────────────────────────────────────────────────────── */
#progress {
  position: fixed; inset-block-start: 0; inset-inline: 0; height: 3px; z-index: 100;
  background: var(--grad); transform-origin: var(--origin, right); transform: scaleX(0);
}
html[dir="ltr"] #progress { --origin: left; }

/* ── header ───────────────────────────────────────────────────────────────────── */
.header {
  position: sticky; inset-block-start: 0; z-index: 60; height: var(--header-h);
  display: flex; align-items: center; gap: 14px; padding-inline: 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-block-end: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 800; font-size: 19px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px rgba(76, 111, 255, 0.35); transition: transform 0.4s cubic-bezier(.3,1.6,.5,1); }
.brand:hover .logo { transform: rotate(-12deg) scale(1.1); }
.brand small { font-weight: 500; color: var(--fg-mute); font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg-soft); }
.spacer { flex: 1; }
.icon-btn {
  height: 38px; min-width: 38px; padding-inline: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); border-radius: 11px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.icon-btn:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 6px 16px var(--brand-soft); }
.icon-btn:active { transform: translateY(0) scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }
.search-btn { min-width: 220px; justify-content: space-between; color: var(--fg-mute); font-weight: 500; }
.search-btn kbd { font-family: var(--mono); font-size: 11px; background: var(--bg-soft); padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); }
.menu-btn { display: none; }
.lang-btn .flag { font-size: 11px; background: var(--grad); color: #fff; padding: 1px 7px; border-radius: 6px; letter-spacing: 0.5px; }

/* ── layout ───────────────────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); gap: 0; max-width: 1560px; margin-inline: auto; }
.layout.no-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.layout.landing { display: block; max-width: none; }

.sidebar {
  position: sticky; inset-block-start: var(--header-h); align-self: start; height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: 22px 16px 60px 14px; border-inline-end: 1px solid var(--line); scrollbar-width: thin;
}
.nav-group { margin-block-end: 6px; }
.nav-title {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: start;
  background: none; border: 0; color: var(--fg); font-weight: 800; font-size: 13.5px; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  letter-spacing: 0.2px;
}
.nav-title:hover { background: var(--bg-soft); }
.nav-title .chev { width: 14px; height: 14px; transition: transform 0.3s; color: var(--fg-mute); }
.nav-group.collapsed .chev { transform: rotate(90deg); }
html[dir="ltr"] .nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.35s ease; }
.nav-group.collapsed .nav-items { grid-template-rows: 0fr; }
.nav-items > div { overflow: hidden; }
.nav-link {
  position: relative; display: block; padding: 6px 14px; margin-inline-start: 10px; border-inline-start: 2px solid var(--line);
  color: var(--fg-soft); font-size: 14.5px; line-height: 1.7; transition: color 0.2s, border-color 0.2s, background 0.2s, padding 0.2s;
}
.nav-link:hover { color: var(--fg); text-decoration: none; border-color: var(--fg-mute); padding-inline-start: 18px; }
.nav-link.active { color: var(--brand); font-weight: 700; border-color: var(--brand); background: linear-gradient(to var(--grad-dir, left), transparent, var(--brand-soft)); }
html[dir="ltr"] .nav-link.active { --grad-dir: right; }
.nav-link .tag { font-size: 10px; font-family: var(--mono); background: var(--bg-soft); color: var(--fg-mute); padding: 0 6px; border-radius: 6px; margin-inline-start: 6px; }

.main { min-width: 0; padding: 34px clamp(18px, 4vw, 56px) 80px; }
#main { min-width: 0; overflow-wrap: anywhere; }
.page, .page > *, .page li, .callout .body, .method-card { min-width: 0; }
.page > * { max-width: 100%; }
.toc {
  position: sticky; inset-block-start: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 34px 14px 40px 8px; font-size: 13.5px; scrollbar-width: thin;
}
.toc h4 { margin: 0 0 10px; font-size: 12px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 1px; }
.toc a { display: block; padding: 4px 12px; color: var(--fg-mute); border-inline-start: 2px solid var(--line); line-height: 1.6; transition: all 0.2s; }
.toc a.l3 { padding-inline-start: 26px; font-size: 12.5px; }
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.active { color: var(--brand); border-color: var(--brand); font-weight: 700; }

/* ── page content ─────────────────────────────────────────────────────────────── */
.page { max-width: 880px; margin-inline: auto; animation: pageIn 0.55s cubic-bezier(.2,.8,.2,1); }
.page.leaving { animation: pageOut 0.18s ease forwards; }
@keyframes pageIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pageOut { to { opacity: 0; transform: translateY(-8px); } }

.crumbs { color: var(--fg-mute); font-size: 13px; margin-block-end: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs span:not(:last-child)::after { content: "›"; margin-inline-start: 8px; opacity: 0.6; }
html[dir="rtl"] .crumbs span:not(:last-child)::after { content: "‹"; }

.page h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.35; margin: 0 0 14px; font-weight: 900; letter-spacing: -0.5px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: gradMove 8s ease infinite; }
@keyframes gradMove { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.page .lead { font-size: 18.5px; color: var(--fg-soft); margin: 0 0 28px; }
.page h2 { font-size: 27px; margin: 52px 0 14px; font-weight: 800; line-height: 1.5; padding-block-end: 10px; border-block-end: 1px solid var(--line); position: relative; }
.page h2::after { content: ""; position: absolute; inset-inline-start: 0; inset-block-end: -1px; width: 64px; height: 3px; background: var(--grad); border-radius: 3px; transition: width 0.5s; }
.page h2:hover::after { width: 130px; }
.page h3 { font-size: 20px; margin: 34px 0 8px; font-weight: 800; }
.page h4 { font-size: 16.5px; margin: 24px 0 6px; font-weight: 800; color: var(--fg-soft); }
.page p { margin: 0 0 16px; }
.page ul, .page ol { margin: 0 0 18px; padding-inline-start: 26px; }
.page li { margin-block: 5px; }
.page li::marker { color: var(--brand); font-weight: 800; }
.page hr { border: 0; border-block-start: 1px dashed var(--line); margin-block: 34px; }
.page strong { font-weight: 800; }
.page blockquote { margin: 18px 0; padding: 4px 18px; border-inline-start: 4px solid var(--brand-2); background: var(--bg-soft); border-radius: 0 12px 12px 0; color: var(--fg-soft); }
html[dir="rtl"] .page blockquote { border-radius: 12px 0 0 12px; }
.anchor { opacity: 0; margin-inline-start: 8px; font-weight: 400; color: var(--brand); transition: opacity 0.2s; }
.page h2:hover .anchor, .page h3:hover .anchor { opacity: 1; text-decoration: none; }

code { font-family: var(--mono); font-size: 0.86em; direction: ltr; unicode-bidi: isolate; background: var(--bg-soft); color: var(--brand-2); padding: 2px 7px; border-radius: 7px; border: 1px solid var(--line); }
:root[data-theme="dark"] code { color: #8fb0ff; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--bg-elev); border: 1px solid var(--line); border-block-end-width: 3px; padding: 1px 8px; border-radius: 7px; }

/* tables */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; margin: 18px 0 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.8; }
th { background: var(--bg-soft); text-align: start; font-weight: 800; padding: 11px 16px; white-space: nowrap; }
td { padding: 10px 16px; border-block-start: 1px solid var(--line); vertical-align: top; }
tr { transition: background 0.2s; }
tbody tr:hover { background: var(--brand-soft); }
td code { white-space: nowrap; }
.req { color: var(--bad); font-weight: 800; font-size: 12px; }
.opt { color: var(--fg-mute); font-size: 12px; }

/* code blocks */
.code {
  position: relative; margin: 20px 0 26px; border-radius: var(--radius); overflow: hidden; background: var(--bg-code); direction: ltr; text-align: left;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, 0.06); transition: transform 0.3s, box-shadow 0.3s;
}
.code:hover { transform: translateY(-3px); box-shadow: 0 26px 70px rgba(18, 28, 70, 0.35); }
.code-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(255, 255, 255, 0.04); border-block-end: 1px solid rgba(255, 255, 255, 0.06); }
.dots { display: flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.code-title { flex: 1; text-align: center; font-family: var(--mono); font-size: 12px; color: #7f8db1; }
.copy {
  font-family: var(--font); font-size: 12px; font-weight: 600; color: #b9c5e2; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 11px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.copy:hover { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.06); }
.copy.done { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop 0.4s; }
@keyframes pop { 50% { transform: scale(1.25); } }
.code pre { margin: 0; padding: 16px 20px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.8px; line-height: 1.75; color: var(--c-fg); tab-size: 4; }
.code pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; display: block; }
.code.out { box-shadow: none; border-style: dashed; }
.code.out pre { color: #9fe3c7; }
.t-kw { color: var(--c-kw); } .t-str { color: var(--c-str); } .t-com { color: var(--c-com); font-style: italic; }
.t-num { color: var(--c-num); } .t-fn { color: var(--c-fn); } .t-cls { color: var(--c-cls); }
.t-deco { color: var(--c-deco); } .t-op { color: var(--c-op); } .t-self { color: #ff9ac1; font-style: italic; }
.t-prompt { color: #7f8db1; user-select: none; }

/* callouts */
.callout { --c: var(--info); display: flex; gap: 14px; margin: 22px 0; padding: 14px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--c) 9%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); border-inline-start: 5px solid var(--c); animation: slideIn 0.6s both; }
.callout .ico { flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 900; font-size: 15px; margin-block-start: 2px; }
.callout .body > :last-child { margin-block-end: 0; }
.callout .body > :first-child { margin-block-start: 0; }
.callout .ttl { font-weight: 800; margin: 0 0 4px; color: var(--c); }
.callout.tip { --c: var(--ok); } .callout.warn { --c: var(--warn); } .callout.danger { --c: var(--bad); } .callout.note { --c: var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(var(--sx, 20px)); } to { opacity: 1; transform: none; } }
html[dir="ltr"] .callout { --sx: -20px; }

/* method header */
.method-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 14px; }
.method-head .pill { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; color: #fff; background: var(--grad); }
.method-head .ret { font-family: var(--mono); font-size: 13px; color: var(--fg-mute); direction: ltr; }
.sig { direction: ltr; text-align: left; font-family: var(--mono); font-size: 13.5px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; margin: 0 0 16px; overflow-x: auto; white-space: pre; }
.method-card { border: 1px solid var(--line); border-radius: 18px; padding: 6px 26px 12px; background: var(--bg-elev); margin: 30px 0; box-shadow: var(--shadow); transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s; position: relative; }
.method-card::before { content: ""; position: absolute; inset-inline-start: -1px; inset-block: 22px; width: 4px; border-radius: 4px; background: var(--grad); }
.method-card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 14px 40px var(--brand-soft); }
.method-card h2 { border: 0; margin-block-start: 18px; padding: 0; font-family: var(--mono); font-size: 22px; direction: ltr; text-align: start; }
.method-card h2::after { display: none; }

/* steps */
.steps { counter-reset: step; list-style: none; padding: 0 !important; margin: 24px 0; }
.steps > li { counter-increment: step; position: relative; padding-inline-start: 58px; margin-block: 0 22px; min-height: 42px; }
.steps > li::before { content: counter(step); position: absolute; inset-inline-start: 0; inset-block-start: 0; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 900; font-size: 18px; box-shadow: 0 8px 20px rgba(76, 111, 255, 0.35); }
.steps > li::after { content: ""; position: absolute; inset-inline-start: 19px; inset-block-start: 46px; inset-block-end: -18px; width: 2px; background: repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 12px); }
.steps > li:last-child::after { display: none; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin: 22px 0 30px; }
.card {
  position: relative; display: block; padding: 20px 20px 18px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--fg);
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1), box-shadow 0.3s, border-color 0.3s; overflow: hidden; box-shadow: var(--shadow);
}
.card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 0%), var(--brand-soft), transparent 45%); opacity: 0; transition: opacity 0.3s; }
.card:hover { transform: translateY(-6px); border-color: var(--brand); text-decoration: none; box-shadow: 0 18px 44px var(--brand-soft); }
.card:hover::before { opacity: 1; }
.card .em { font-size: 28px; display: block; margin-block-end: 8px; transition: transform 0.4s cubic-bezier(.3,1.8,.5,1); }
.card:hover .em { transform: scale(1.25) rotate(-8deg); }
.card b { display: block; font-size: 16.5px; margin-block-end: 4px; }
.card span { color: var(--fg-mute); font-size: 14px; line-height: 1.7; display: block; }

/* prev/next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-block-start: 64px; }
.pager a { display: block; padding: 16px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-elev); color: var(--fg); transition: all 0.3s; }
.pager a:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-4px); box-shadow: 0 14px 34px var(--brand-soft); }
.pager small { display: block; color: var(--fg-mute); font-size: 12.5px; margin-block-end: 2px; }
.pager b { font-size: 16px; }
.pager .next { text-align: end; }
.pager a .arr { display: inline-block; transition: transform 0.3s; }
.pager .next:hover .arr { transform: translateX(var(--ax, -6px)); }
.pager .prev:hover .arr { transform: translateX(calc(var(--ax, -6px) * -1)); }
html[dir="ltr"] .pager { --ax: 6px; }

/* search modal */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: flex-start; justify-content: center; padding: 11vh 16px 16px; background: rgba(7, 12, 28, 0.55); backdrop-filter: blur(6px); }
.modal.open { display: flex; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.search-box { width: min(640px, 100%); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; animation: dropIn 0.3s cubic-bezier(.2,.9,.3,1.2); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-20px) scale(0.97); } }
.search-box input { width: 100%; border: 0; outline: 0; background: none; font: inherit; font-size: 18px; padding: 20px 24px; color: var(--fg); border-block-end: 1px solid var(--line); }
.results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.result { display: block; padding: 10px 16px; border-radius: 12px; color: var(--fg); }
.result:hover, .result.sel { background: var(--brand-soft); text-decoration: none; }
.result b { display: block; font-size: 15px; }
.result small { color: var(--fg-mute); font-size: 12.5px; }
.result mark { background: rgba(245, 159, 0, 0.35); color: inherit; border-radius: 4px; padding: 0 2px; }
.no-result { text-align: center; color: var(--fg-mute); padding: 30px; }

/* footer + back to top */
.footer { border-block-start: 1px solid var(--line); padding: 28px 24px 40px; text-align: center; color: var(--fg-mute); font-size: 14px; }
.to-top { position: fixed; inset-block-end: 24px; inset-inline-end: 24px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; cursor: pointer; box-shadow: 0 10px 28px rgba(76, 111, 255, 0.45); opacity: 0; transform: translateY(20px) scale(0.8); pointer-events: none; transition: all 0.35s cubic-bezier(.3,1.5,.5,1); z-index: 50; display: grid; place-items: center; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { transform: translateY(-4px) scale(1.1); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2,.8,.2,1); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }

/* ── landing ──────────────────────────────────────────────────────────────────── */
.hero { position: relative; overflow: hidden; padding: 70px 24px 90px; isolation: isolate; }
.hero .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; z-index: -1; animation: drift 18s ease-in-out infinite alternate; }
.hero .b1 { width: 480px; height: 480px; background: var(--brand); inset-block-start: -140px; inset-inline-start: -100px; }
.hero .b2 { width: 520px; height: 520px; background: var(--brand-2); inset-block-start: 40px; inset-inline-end: -160px; animation-delay: -6s; }
.hero .b3 { width: 380px; height: 380px; background: var(--brand-3); inset-block-end: -160px; inset-inline-start: 38%; animation-delay: -11s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 26px 26px; mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 70%); opacity: 0.9; }
.hero-in { max-width: 1180px; margin-inline: auto; display: grid; grid-template-columns: 1.05fr 1fr; gap: 54px; align-items: center; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 18px; }
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; padding: 5px 13px; border-radius: 99px; background: color-mix(in srgb, var(--bg-elev) 80%, transparent); border: 1px solid var(--line); backdrop-filter: blur(6px); animation: floaty 5s ease-in-out infinite; }
.badge:nth-child(2) { animation-delay: -1.2s; } .badge:nth-child(3) { animation-delay: -2.4s; }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes floaty { 50% { transform: translateY(-6px); } }
.hero h1 { font-size: clamp(38px, 5.4vw, 66px); line-height: 1.3; margin: 0 0 18px; font-weight: 900; letter-spacing: -1px; }
.hero h1 .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 220% 100%; animation: gradMove 7s ease infinite; }
.hero p.sub { font-size: 20px; color: var(--fg-soft); max-width: 560px; margin: 0 0 30px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { position: relative; display: inline-flex; align-items: center; gap: 9px; padding: 13px 26px; border-radius: 14px; font-weight: 800; font-size: 16px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); cursor: pointer; overflow: hidden; transition: transform 0.25s, box-shadow 0.25s; }
.btn:hover { transform: translateY(-3px); text-decoration: none; box-shadow: 0 12px 28px rgba(20, 30, 60, 0.15); }
.btn.primary { color: #fff; border: 0; background: var(--grad); background-size: 200% 100%; box-shadow: 0 12px 30px rgba(76, 111, 255, 0.4); animation: gradMove 6s ease infinite; }
.btn.primary::after { content: ""; position: absolute; inset-block: 0; width: 60px; inset-inline-start: -80px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); transform: skewX(-20deg); animation: shine 3.5s infinite; }
@keyframes shine { 40%, 100% { inset-inline-start: 130%; } }
.install { margin-block-start: 26px; display: inline-flex; align-items: center; gap: 12px; direction: ltr; font-family: var(--mono); font-size: 14px; padding: 11px 16px; border-radius: 12px; background: var(--bg-code); color: #b9c8ea; border: 1px solid rgba(255, 255, 255, 0.07); cursor: pointer; transition: transform 0.2s; max-width: 100%; overflow-x: auto; }
.install:hover { transform: scale(1.02); }
.install .p { color: var(--brand); }

.phone { position: relative; width: min(390px, 100%); margin-inline: auto; border-radius: 34px; padding: 12px; background: linear-gradient(160deg, #26304f, #0d1325); box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.07) inset; animation: floaty 7s ease-in-out infinite; }
.phone-screen { border-radius: 24px; overflow: hidden; background: #0e1526; height: 470px; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #141d35; color: #fff; font-weight: 800; font-size: 15px; }
.chat-head .av { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-size: 17px; }
.chat-head small { display: block; color: #6fe3b9; font-weight: 500; font-size: 11.5px; }
.chat-body { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 9px; overflow: hidden; justify-content: flex-end; }
.msg { unicode-bidi: plaintext; text-align: start; max-width: 82%; padding: 9px 14px; border-radius: 16px; font-size: 14px; line-height: 1.7; color: #e9eefc; animation: bubble 0.45s cubic-bezier(.2,1.2,.4,1) both; white-space: pre-line; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, #3b7bff, #5b5cf0); border-end-end-radius: 4px; }
.msg.bot { align-self: flex-start; background: #1c2744; border-end-start-radius: 4px; }
.msg .btns { display: flex; gap: 6px; margin-block-start: 8px; flex-wrap: wrap; }
.msg .btns span { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 9px; color: #fff; background: #3a4a77; }
.msg .btns .g { background: #1fa86a; } .msg .btns .r { background: #e04e66; } .msg .btns .b { background: #3d6bff; }
@keyframes bubble { from { opacity: 0; transform: translateY(14px) scale(0.85); } }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #1c2744; border-radius: 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8da0d6; animation: dot 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { transform: translateY(-6px); opacity: 1; } 0%,60%,100% { opacity: 0.5; } }

.stats { max-width: 1000px; margin: -40px auto 0; padding-inline: 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; position: relative; z-index: 2; }
.stat { text-align: center; padding: 20px 10px; border-radius: 18px; background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat b { display: block; font-size: 34px; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.3; }
.stat span { color: var(--fg-mute); font-size: 14px; }
.stat b::after { content: attr(data-suffix); }

.section { max-width: 1120px; margin: 0 auto; padding: 86px 24px 0; }
.section h2.big { font-size: clamp(28px, 3.6vw, 40px); text-align: center; margin: 0 0 8px; font-weight: 900; }
.section p.sub-c { text-align: center; color: var(--fg-soft); max-width: 640px; margin: 0 auto 40px; }
.feat { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.feat .card { padding: 24px; }

.try { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: stretch; }
.try .code { margin: 0; }

/* animated flow diagram */
.flow-wrap { margin: 28px 0; padding: 26px 18px 20px; border-radius: 20px; background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; direction: ltr; }
.flow { min-width: 0; }
.flow-row { display: flex; align-items: stretch; gap: 0; direction: ltr; }
.node { position: relative; flex: 1; min-width: 0; overflow-wrap: anywhere; text-align: center; padding: 14px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-soft); cursor: pointer; transition: all 0.35s; font-size: 13px; line-height: 1.5; }
.node .e { font-size: 24px; display: block; margin-block-end: 4px; transition: transform 0.4s cubic-bezier(.3,1.8,.5,1); }
.node b { display: block; font-size: 13px; font-family: var(--mono); }
.node small { color: var(--fg-mute); font-size: 11.5px; font-family: var(--font); }
.node.on { background: var(--brand-soft); border-color: var(--brand); transform: translateY(-8px); box-shadow: 0 16px 34px var(--brand-soft); }
.node.on .e { transform: scale(1.3) rotate(-6deg); }
.flow-row.reverse { flex-direction: row-reverse; }
.flow-row.short { width: calc(66.667% - 8px); }
.flow-row.short .node { flex: 1; }
.link { flex: 0 0 24px; align-self: center; height: 3px; background: repeating-linear-gradient(90deg, var(--fg-mute) 0 6px, transparent 6px 12px); background-size: 24px 3px; animation: dash 0.9s linear infinite; opacity: 0.55; border-radius: 3px; }
.link.on { opacity: 1; background: repeating-linear-gradient(90deg, var(--brand) 0 6px, transparent 6px 12px); }
.flow-turn { position: relative; height: 28px; }
.flow-turn .link { position: absolute; inset-block: 0; width: 3px; height: auto; background: repeating-linear-gradient(180deg, var(--fg-mute) 0 6px, transparent 6px 12px); background-size: 3px 24px; animation-name: dash-vertical; }
.flow-turn.right .link { inset-inline-end: calc(16.667% - 8px); }
.flow-turn.left .link { inset-inline-end: calc(83.333% + 8px); }
.flow-turn .link.on { background: repeating-linear-gradient(180deg, var(--brand) 0 6px, transparent 6px 12px); }
@keyframes dash { to { background-position: 24px 0; } }
@keyframes dash-vertical { to { background-position: 0 24px; } }
.flow-info { margin-block-start: 18px; min-height: 76px; padding: 14px 18px; border-radius: 14px; background: var(--bg-soft); direction: inherit; transition: all 0.3s; }
.flow-info b { color: var(--brand); }
.flow-ctl { display: flex; gap: 10px; margin-block-start: 14px; direction: inherit; }

.btn-demo { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; padding: 22px; border-radius: 18px; background: var(--bg-soft); border: 1px dashed var(--line); }
.bb { position: relative; overflow: hidden; border: 0; cursor: pointer; font-weight: 800; font-size: 15px; padding: 11px 26px; border-radius: 12px; color: #fff; background: #3a4a77; transition: transform 0.2s, box-shadow 0.2s, filter 0.2s; }
.bb:hover { transform: translateY(-3px); filter: brightness(1.1); }
.bb:active { transform: scale(0.95); }
.bb.success { background: #1fa86a; box-shadow: 0 8px 20px rgba(31, 168, 106, 0.4); }
.bb.danger { background: #e04e66; box-shadow: 0 8px 20px rgba(224, 78, 102, 0.4); }
.bb.primary { background: #3d6bff; box-shadow: 0 8px 20px rgba(61, 107, 255, 0.4); }
.bb .rip { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.55); transform: scale(0); animation: ripple 0.6s ease-out; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
.demo-note { flex-basis: 100%; font-size: 14px; color: var(--fg-mute); min-height: 24px; }

.quiz-demo { min-width: 0; max-width: 100%; margin: 22px 0; padding: 20px; border-radius: 18px; background: var(--bg-soft); border: 1px dashed var(--line); }
.pg-input { width: 100%; max-width: 100%; min-width: 0; font: inherit; direction: ltr; text-align: left; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); font-family: var(--mono); font-size: 14px; }
.pg-out { margin-block-start: 12px; display: grid; gap: 8px; }
.pg-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-width: 0; max-width: 100%; padding: 9px 14px; border-radius: 11px; background: var(--bg-elev); border: 1px solid var(--line); direction: ltr; font-family: var(--mono); font-size: 13.5px; animation: slideIn 0.4s both; }
.pg-row.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--bg-elev)); }
.pg-row.no { opacity: 0.55; }

.sidebar-backdrop { display: none; }

/* ── responsive ───────────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .layout, .layout.no-toc { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; inset-block: var(--header-h) 0; inset-inline-start: 0; z-index: 70; width: min(86vw, 330px); max-width: calc(100vw - 24px); height: auto; background: var(--bg-elev); transform: translateX(105%); transition: transform 0.3s ease; box-shadow: var(--shadow-lg); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  html[dir="ltr"] .sidebar { transform: translateX(-105%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open { overflow: hidden; overscroll-behavior: none; }
  body.nav-open .sidebar { touch-action: pan-y; }
  .sidebar-backdrop { display: block; position: fixed; inset: var(--header-h) 0 0; z-index: 65; width: 100%; border: 0; padding: 0; background: rgba(5, 10, 25, 0.38); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s ease, visibility 0.3s ease; }
  body.nav-open .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  body.nav-open .sidebar { display: block !important; }
  .search-btn { min-width: 0; } .search-btn span, .search-btn kbd { display: none; }
  .hero-in, .try { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); margin-block-start: -20px; }
  .brand small { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 15.5px; }
  .pager { grid-template-columns: 1fr; }
  .page h2 { font-size: 23px; }
  .header { padding-inline: 12px; gap: 8px; }
  .method-card { padding-inline: 16px; }
  .quiz-demo { padding: 12px; }
  .callout { gap: 10px; padding: 12px; }
  .table-wrap table { min-width: 520px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
@media print {
  .header, .sidebar, .toc, .to-top, #progress, .pager { display: none !important; }
  .layout { display: block; } .code { box-shadow: none; }
}

/* ── mobile fixes ─────────────────────────────────────────────────────────────── */
.hero-in > *, .feat > *, .try > *, .stats > * { min-width: 0; }
.install { max-width: 100%; white-space: nowrap; }
@media (max-width: 700px) {
  .lang-btn #lang-name, .header a.icon-btn[aria-label="GitHub"] { display: none; }
  .header { gap: 6px; }
  .flow-wrap { padding-inline: 10px; }
}

/* Restrained documentation and landing-page presentation. */
.header { background: var(--bg-elev); backdrop-filter: none; -webkit-backdrop-filter: none; }
.brand .logo { background: var(--brand); box-shadow: none; }
.brand:hover .logo, .icon-btn:hover, .card:hover, .pager a:hover { transform: none; }
.icon-btn:hover { box-shadow: none; }
.page h1 { background: none; color: var(--fg); animation: none; }
.page h2::after, .page h2:hover::after { display: none; }
.callout, .method-card { animation: none; box-shadow: none; }
.method-card:hover { transform: none; box-shadow: var(--shadow); }
.table-wrap { box-shadow: none; }
.hero { position: relative; overflow: hidden; padding: 72px 24px 64px; background: var(--bg-elev); border-block-end: 1px solid var(--line); }
.hero::after { display: none; }
.hero-in { max-width: 1120px; margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr); gap: clamp(32px, 6vw, 80px); align-items: center; }
.hero-copy { min-width: 0; }
.hero .eyebrow { margin: 0 0 18px; color: var(--brand); font-size: 14px; font-weight: 700; }
.hero h1 { margin: 0 0 18px; color: var(--fg); font-size: clamp(36px, 4.7vw, 58px); font-weight: 800; line-height: 1.28; letter-spacing: -0.5px; }
.hero h1 span { color: var(--brand); }
.hero p.sub { max-width: 580px; margin: 0 0 26px; color: var(--fg-soft); font-size: 18px; line-height: 1.9; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn { padding: 10px 17px; border-radius: 9px; font-size: 14px; font-weight: 700; transition: background 0.18s, border-color 0.18s, color 0.18s; }
.btn:hover { transform: none; box-shadow: none; }
.btn.primary { background: var(--brand); animation: none; box-shadow: none; }
.btn.primary:hover { background: #06684b; }
.btn.primary::after { display: none; }
.github-link { padding-inline: 6px; color: var(--fg-soft); font-size: 14px; font-weight: 600; }
.github-link:hover { color: var(--brand); text-decoration: none; }
.install { display: flex; width: fit-content; max-width: 100%; flex-wrap: wrap; gap: 12px; margin-block-start: 24px; padding: 0; overflow: visible; border: 0; background: none; color: var(--fg-mute); font-family: var(--font); font-size: 13px; }
.install button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-soft); color: var(--fg); cursor: pointer; font-family: var(--mono); font-size: 12px; }
.install button:hover { border-color: var(--brand); }
.install button[data-copied="true"]::after { content: "  ✓"; color: var(--brand); }
.hero-code { min-width: 0; }
.hero-code .code { margin: 0; border: 1px solid #26352f; border-radius: 12px; box-shadow: 0 12px 30px rgba(24, 50, 39, 0.12); }
.hero-code .code-bar { padding-inline: 18px; }
.hero-code .code pre { padding: 20px; font-size: 12.5px; }
.section { max-width: 1120px; padding: 68px 24px 0; }
.section-heading { margin-block-end: 28px; }
.section h2.big { margin: 0 0 6px; text-align: start; font-size: clamp(24px, 3vw, 32px); font-weight: 750; }
.section p.sub-c { max-width: 680px; margin: 0; color: var(--fg-mute); text-align: start; }
.feat { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feat .card.feature-card { min-height: 154px; padding: 20px; border-radius: 10px; box-shadow: none; }
.card::before, .card:hover::before { display: none; }
.card:hover { border-color: var(--brand); box-shadow: none; }
.feature-card .feature-index { display: block; margin-block-end: 14px; color: var(--brand); font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.feature-card b { margin-block-end: 5px; font-size: 15px; }
.feature-card > span:last-child { color: var(--fg-mute); font-size: 13.5px; }
.resources-section { padding-block-end: 80px; }
.resource-list { border-block-start: 1px solid var(--line); }
.resource-link { display: grid; grid-template-columns: 48px minmax(0, 1fr) 24px; align-items: center; gap: 14px; padding: 16px 8px; border-block-end: 1px solid var(--line); color: var(--fg); }
.resource-link:hover { background: var(--bg-elev); color: var(--brand); text-decoration: none; }
.resource-index { color: var(--brand); font-family: var(--mono); font-size: 12px; }
.resource-link b, .resource-link small { display: block; }
.resource-link b { font-size: 15px; }
.resource-link small { margin-block-start: 2px; color: var(--fg-mute); font-size: 13px; }
.resource-arrow { color: var(--fg-mute); text-align: end; }

@media (max-width: 900px) {
  .hero-in { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .hero-code { max-width: 680px; width: 100%; }
  .feat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .hero { padding: 48px 18px 42px; }
  .hero h1 { font-size: 35px; }
  .hero p.sub { font-size: 16px; }
  .hero-code .code pre { padding: 15px; font-size: 11.5px; }
  .section { padding: 48px 18px 0; }
  .feat { grid-template-columns: minmax(0, 1fr); }
  .feat .card.feature-card { min-height: 0; }
  .resources-section { padding-block-end: 52px; }
  .install { gap: 8px; }
}
