/* Self-hosted fonts (SIL Open Font License), copied from @fontsource at build time.
   A font downloads only when text in its script is on the page. local() comes first, so phones that
   already have the font (Android ships Noto Naskh, Devanagari and Bengali) download nothing.
   Variable fonts are declared once per weight so a local regular face is never faked into bold.
   Latin text uses the system font. */
@font-face {
  font-family: "Noto Nastaliq Urdu"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Noto Nastaliq Urdu"), local("NotoNastaliqUrdu-Regular"), url(/fonts/noto-nastaliq-urdu-arabic-400.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Naskh Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Noto Naskh Arabic"), local("NotoNaskhArabic-Regular"), url(/fonts/noto-naskh-arabic-arabic-wght.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Naskh Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: local("Noto Naskh Arabic Bold"), local("NotoNaskhArabic-Bold"), url(/fonts/noto-naskh-arabic-arabic-wght.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Vazirmatn"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/vazirmatn-arabic-wght.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Noto Sans Devanagari"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Noto Sans Devanagari"), local("NotoSansDevanagari-Regular"), url(/fonts/noto-sans-devanagari-devanagari-wght.woff2) format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
@font-face {
  font-family: "Noto Sans Devanagari"; font-style: normal; font-weight: 700; font-display: swap;
  src: local("Noto Sans Devanagari Bold"), local("NotoSansDevanagari-Bold"), url(/fonts/noto-sans-devanagari-devanagari-wght.woff2) format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Noto Sans Bengali"), local("NotoSansBengali-Regular"), url(/fonts/noto-sans-bengali-bengali-wght.woff2) format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 700; font-display: swap;
  src: local("Noto Sans Bengali Bold"), local("NotoSansBengali-Bold"), url(/fonts/noto-sans-bengali-bengali-wght.woff2) format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1;
}

/* Urdu and Punjabi names on pages in other languages (welcome page, language menu): use a Nastaliq
   font the device already has (iPhones, Macs, many PCs), and never download one just for a name. */
@font-face {
  font-family: "Nastaliq Installed"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Noto Nastaliq Urdu"), local("NotoNastaliqUrdu-Regular"), local("Urdu Typesetting");
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC;
}

/* Availit World styles.
   Colours are tokens (light, then dark). Layout uses logical properties (inline/block, start/end),
   so the same rules work left to right and right to left. Each writing system gets its own font,
   size and line height through html[data-script]. Never add letter-spacing to Arabic-script text,
   and never fake bold or italics in Nastaliq. Grid columns that hold text use minmax(0, 1fr).

   The look: cool paper, cobalt for actions and structure, amber only for probabilities
   (the bars a model's next-token odds are drawn with). Code and the model panel are dark in both themes. */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --raised: #f8f9fc;
  --sunken: #e9edf5;
  --line: #d3dae6;
  --line-soft: #e3e8f0;
  --text: #121a33;
  --text-2: #3a4563;
  --muted: #5b6684;
  --accent: #2d46e0;
  --accent-ink: #2238c4;
  --accent-wash: #e3e8ff;
  --on-accent: #ffffff;
  --prob: #e8a317;
  --prob-ink: #8a5a00;
  --prob-wash: #fcf1d8;
  --good: #13795a;
  --good-wash: #ddf3ea;
  --bad: #c8372d;
  --bad-wash: #fbe5e2;
  --code-bg: #10172f;
  --code-raised: #18213f;
  --code-line: #2a3559;
  --code-text: #e6eaf7;
  --code-muted: #8d98bd;
  --code-accent: #ffc857;
  --focus: #2d46e0;
  --shadow: 0 1px 2px rgba(18, 26, 51, .06);
  --r: 14px;
  --r-sm: 6px;
  --r-xs: 4px;
  --ease: cubic-bezier(.22, 1, .36, 1);

  --latin: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --latin-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Roboto Mono", "Liberation Mono", monospace;
  --system: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", Tahoma, "Nirmala UI", sans-serif;
  --font-ui: var(--latin);
  --font-display: var(--latin-display);
  --scale: 1;
  --lh: 1.65;
  --lh-tight: 1.25;
  --strong: 700;
  --semi: 600;
  --display-weight: 650;
  --track: -.022em;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1022;
    --surface: #121a33;
    --raised: #18223f;
    --sunken: #0a0e1c;
    --line: #26314f;
    --line-soft: #1d2742;
    --text: #e7ebf7;
    --text-2: #b8c1dd;
    --muted: #8d98bd;
    --accent: #8fa2ff;
    --accent-ink: #a9b8ff;
    --accent-wash: #1c2654;
    --on-accent: #0b1022;
    --prob: #f4bc4a;
    --prob-ink: #f4bc4a;
    --prob-wash: #2e2410;
    --good: #5bd3a4;
    --good-wash: #10302a;
    --bad: #ff8a80;
    --bad-wash: #3a1a1c;
    --code-bg: #070b19;
    --code-raised: #0f1630;
    --code-line: #222c4c;
    --focus: #a9b8ff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1022;
  --surface: #121a33;
  --raised: #18223f;
  --sunken: #0a0e1c;
  --line: #26314f;
  --line-soft: #1d2742;
  --text: #e7ebf7;
  --text-2: #b8c1dd;
  --muted: #8d98bd;
  --accent: #8fa2ff;
  --accent-ink: #a9b8ff;
  --accent-wash: #1c2654;
  --on-accent: #0b1022;
  --prob: #f4bc4a;
  --prob-ink: #f4bc4a;
  --prob-wash: #2e2410;
  --good: #5bd3a4;
  --good-wash: #10302a;
  --bad: #ff8a80;
  --bad-wash: #3a1a1c;
  --code-bg: #070b19;
  --code-raised: #0f1630;
  --code-line: #222c4c;
  --focus: #a9b8ff;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- writing systems ---------- */
html[data-script="nastaliq"] {
  /* Nastaliq is tall and slanted: bigger size, much more line height, one weight only. */
  --font-ui: "Noto Nastaliq Urdu", "Urdu Typesetting", "Noto Naskh Arabic", var(--latin);
  --font-display: var(--font-ui);
  --scale: 1.12;
  --lh: 2.3;
  --lh-tight: 2;
  --strong: 400;
  --semi: 400;
  --display-weight: 400;
  --track: 0;
  font-synthesis: none;
}
html[data-script="naskh"] {
  --font-ui: "Noto Naskh Arabic", "Segoe UI", Tahoma, var(--latin);
  --font-display: var(--font-ui);
  --scale: 1.1;
  --lh: 1.95;
  --lh-tight: 1.6;
  --semi: 700;
  --display-weight: 700;
  --track: 0;
  font-synthesis: none;
}
html[data-script="vazir"] {
  --font-ui: "Vazirmatn", "Segoe UI", Tahoma, var(--latin);
  --font-display: var(--font-ui);
  --scale: 1.02;
  --lh: 1.9;
  --lh-tight: 1.55;
  --display-weight: 750;
  --track: 0;
}
html[data-script="deva"] {
  --font-ui: "Noto Sans Devanagari", "Nirmala UI", Mangal, var(--latin);
  --font-display: var(--font-ui);
  --scale: 1.04;
  --lh: 1.85;
  --lh-tight: 1.5;
  --semi: 700;
  --display-weight: 700;
  --track: 0;
  font-synthesis: none;
}
html[data-script="beng"] {
  --font-ui: "Noto Sans Bengali", "Nirmala UI", Vrinda, var(--latin);
  --font-display: var(--font-ui);
  --scale: 1.05;
  --lh: 1.85;
  --lh-tight: 1.5;
  --semi: 700;
  --display-weight: 700;
  --track: 0;
  font-synthesis: none;
}
/* Chinese and Japanese use the device's own fonts (a web font would be several megabytes).
   The page leaves the gap between Han characters and Latin words or digits to text-autospace. */
html[data-script="hans"] {
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --font-display: var(--font-ui);
  --lh: 1.8;
  --lh-tight: 1.4;
  --display-weight: 700;
  --track: 0;
}
html[data-script="jpan"] {
  --font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans CJK JP", "Noto Sans JP", "Source Han Sans JP", sans-serif;
  --font-display: var(--font-ui);
  --lh: 1.8;
  --lh-tight: 1.4;
  --display-weight: 700;
  --track: 0;
  line-break: strict;
}
html:is([data-script="hans"], [data-script="jpan"]) { text-autospace: normal; }
/* Russian is Cyrillic in the same system fonts as Latin text; only English words are isolated in <bdi>. */
html[data-script="cyrl"] { --track: -.012em; }
/* Long words in these languages break with a hyphen rather than mid-word. */
main :is(p, li):is(:lang(de), :lang(ru), :lang(tr), :lang(fr), :lang(es), :lang(pt)) { hyphens: auto; }
body, button, input, select { font-family: var(--font-ui); }
bdi[lang="en"], [lang="en"].en-fallback { font-family: var(--latin); }
bdi[lang="en"] { font-size: .92em; }
html:is([data-script="latin"], [data-script="cyrl"], [data-script="hans"], [data-script="jpan"]) bdi[lang="en"] { font-size: 1em; }
/* An English lesson shown on a page in another script uses Latin type and Latin spacing. */
[data-fallback="1"] { font-family: var(--latin); --lh: 1.65; --lh-tight: 1.25; --strong: 700; --semi: 600; --display-weight: 650; --track: -.022em; }
code, kbd, pre, .mono { font-family: var(--mono); font-variant-ligatures: none; }
/* numbered lists count in the same digits as the text (the language table's nu); :where keeps
   every "list-style: none" list above this rule */
:where(ol:lang(ur), ol:lang(pnb), ol:lang(ps), ol:lang(fa)) { list-style-type: persian; }
:where(ol:lang(sd), ol:lang(ar)) { list-style-type: arabic-indic; }
:where(ol:lang(bn)) { list-style-type: bengali; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-size="1"] { font-size: 112.5%; }
html[data-size="2"] { font-size: 125%; }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-size: calc(1.0625rem * var(--scale));
  line-height: var(--lh);
  overflow-wrap: break-word;
}
main { flex: 1 0 auto; overflow-wrap: anywhere; }
h1, h2, h3 { line-height: var(--lh-tight); margin: 0; font-weight: var(--semi); }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }
a { color: var(--accent-ink); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
html.in-app .offline-card { display: none !important; }
html:not(.js) .js-only { display: none !important; }
html.js .no-js { display: none !important; }
.visually-hidden { position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* emphasis: weight plus colour, so scripts without bold still show it */
b { font-weight: var(--strong); color: var(--text); }
html[data-script="nastaliq"] b { color: var(--accent-ink); }
i { font-style: italic; }
html:not([data-script="latin"], [data-script="cyrl"]) i { font-style: normal; color: var(--accent-ink); }
[data-fallback="1"] i { font-style: italic; color: inherit; }
code { font-size: .9em; }
:not(pre) > code:not(.expr) { padding: .05em .35em; border-radius: var(--r-xs); background: var(--sunken); border: 1px solid var(--line-soft); white-space: break-spaces; }

/* mirror arrows, the speaker and bars for right-to-left (the ltr rule comes second, so an English article inside an rtl page stays ltr) */
[dir="rtl"] .flip-rtl, [dir="rtl"] .bar-svg { transform: scaleX(-1); }
[dir="ltr"] .flip-rtl, [dir="ltr"] .bar-svg { transform: none; }

.skip {
  position: absolute; inset-inline-start: 16px; inset-block-start: -10rem;
  z-index: 50; padding: .5rem 1rem; border-radius: var(--r-sm);
  background: var(--accent); color: var(--on-accent); text-decoration: none;
}
.skip:focus { inset-block-start: .75rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .5rem 1rem;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: var(--semi); line-height: var(--lh-tight);
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn svg { inline-size: 1.2rem; block-size: 1.2rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-quiet { background: transparent; }
.btn-sm { min-height: 2.4rem; padding: .25rem .75rem; font-size: .9em; }
.btn-lg { min-height: 3.25rem; padding-inline: 1.5rem; font-size: 1.05em; }
.btn-icon { inline-size: 2.75rem; padding: 0; position: relative; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:hover { border-color: var(--line); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
html[data-script="nastaliq"] .btn { line-height: 1.75; padding-block: .125rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 20;
  background: var(--bg);
  border-block-end: 1px solid var(--line-soft);
}
.topbar-inner {
  max-inline-size: 76rem; margin-inline: auto; padding: .5rem 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .75rem;
}
.brand { display: flex; align-items: center; gap: .75rem; min-inline-size: 0; color: var(--text); text-decoration: none; justify-self: start; }
.brand-mark { flex: none; inline-size: 2.3rem; block-size: 2.3rem; }
.bm-bg { fill: var(--code-bg); }
.bm-bar { fill: var(--code-accent); }
.bm-2 { opacity: .7; }
.bm-3 { opacity: .45; }
[dir="rtl"] .brand-mark, [dir="rtl"] .welcome-mark { transform: scaleX(-1); }
.brand-text { display: grid; min-inline-size: 0; }
.brand-name {
  font-family: var(--latin-display); font-weight: 700; font-size: 1.02em; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-tag { font-size: .8em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: var(--lh-tight); padding-block: .1em; }
html[data-script="nastaliq"] .brand-tag { line-height: 1.9; }
.controls { display: flex; align-items: center; gap: .5rem; }
.top-nav { display: none; }
.btn-lang { padding-inline: .75rem 1rem; }
.btn-lang .lang-label { font-family: var(--system); }
.size-dots { position: absolute; inset-block-end: .5rem; inset-inline: 0; display: flex; justify-content: center; gap: 2px; }
.size-dots i { inline-size: 4px; block-size: 4px; border-radius: 50%; background: var(--line); }
.size-dots i.on { background: var(--accent); }
#sizeBtn svg { margin-block-end: .25rem; }
.read-progress { position: absolute; inset-inline: 0; inset-block-end: -1px; block-size: 3px; }
.read-progress span { display: block; block-size: 100%; background: var(--prob); transform: scaleX(0); transform-origin: left center; }
[dir="rtl"] .read-progress span { transform-origin: right center; }

@media (min-width: 60rem) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .top-nav { display: flex; justify-content: center; gap: .25rem; }
  .top-nav a { padding: .5rem .75rem; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-weight: var(--semi); line-height: var(--lh-tight); }
  .top-nav a:hover { color: var(--text); background: var(--surface); }
  .top-nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-wash); }
}
@media (max-width: 34rem) {
  .brand { gap: .5rem; }
  .brand-tag { display: none; }
  .brand-name { white-space: normal; overflow: visible; text-overflow: clip; font-size: .9em; line-height: 1.12; max-inline-size: 5rem; }
  .controls { gap: .25rem; }
  .btn-icon { inline-size: 2.6rem; min-height: 2.6rem; }
  .btn-lang { min-height: 2.6rem; padding-inline: .5rem .75rem; max-inline-size: 9.5rem; }
  .btn-lang .lang-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* The brand keeps its smallest size and the language name gives way, so the two never overlap. */
  .topbar-inner { grid-template-columns: min-content minmax(0, 1fr); gap: .5rem; container-type: inline-size; }
  .controls { min-inline-size: 0; justify-content: flex-end; }
  .controls > * { flex: none; }
  .controls > .btn-lang { flex: 0 1 auto; min-inline-size: 0; }
}
/* Very narrow screen or very large text: show only the logo, and keep the name for screen readers. */
@container (max-width: 18em) {
  .brand-text { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- shared pieces ---------- */
.wrap { max-inline-size: 76rem; margin-inline: auto; padding: 1.25rem 16px 3rem; inline-size: 100%; }
.wrap:focus { outline: none; }
@media (min-width: 64rem) { .wrap { padding-block-start: 2rem; } }
.crumbs { margin-block-end: 1rem; }
.crumbs a { display: inline-flex; align-items: center; gap: .25rem; font-weight: var(--semi); text-decoration: none; padding-block: .25rem; color: var(--text-2); }
.crumbs a:hover { color: var(--accent-ink); }
.crumbs svg { inline-size: 1.1rem; block-size: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.label { display: block; font-size: .85em; font-weight: var(--semi); color: var(--muted); }
.chip {
  display: inline-flex; align-items: flex-start; gap: .5rem; justify-self: start;
  padding: .25rem .75rem; border-radius: var(--r-sm); font-size: .85em; line-height: var(--lh-tight);
}
.chip svg { inline-size: 1.05rem; block-size: 1.05rem; flex: none; margin-block-start: .15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
html[data-script="nastaliq"] .chip svg { margin-block-start: .5em; }
.status-source, .status-reviewed { background: var(--good-wash); color: var(--good); }
.status-ai-draft, .status-partial, .status-fallback { background: var(--prob-wash); color: var(--prob-ink); }
.banner {
  margin-block-start: 1rem; padding: .75rem 1rem; border-radius: var(--r-sm);
  background: var(--prob-wash); color: var(--text); border: 1px solid color-mix(in srgb, var(--prob) 40%, transparent);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
}
.banner > svg { inline-size: 1.25rem; block-size: 1.25rem; flex: none; fill: none; stroke: var(--prob-ink); stroke-width: 2; stroke-linecap: round; }
.banner p { flex: 1 1 16rem; }
.sep { display: inline-block; inline-size: 1px; block-size: .9em; background: currentColor; opacity: .35; vertical-align: middle; margin-inline: .5rem; }
.muted { color: var(--muted); }
.hint { font-size: .88em; color: var(--muted); }
.lead { color: var(--text-2); max-inline-size: 42rem; }
.count { font-size: .85em; color: var(--muted); font-weight: var(--semi); }
.en-fallback { font-family: var(--latin); }

/* the bars used for probabilities everywhere */
.bar-svg { inline-size: 100%; block-size: .55rem; overflow: visible; }
.bar-bg { fill: var(--sunken); }
.bar-fg { fill: var(--prob); transition: width .35s var(--ease); }

/* ---------- course home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; align-items: center;
  padding-block: .5rem 2.5rem;
}
@media (min-width: 58rem) { .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 3.5rem; padding-block: 2rem 3.5rem; } }
.hero-copy { display: grid; gap: 1rem; }
.hero h1 {
  font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track);
  font-size: clamp(2.3rem, 1.4rem + 3.6vw, 4rem); line-height: 1.04; max-inline-size: 14ch;
}
html:not([data-script="latin"], [data-script="cyrl"]) .hero h1 { line-height: var(--lh-tight); max-inline-size: none; font-size: clamp(2rem, 1.3rem + 2.8vw, 3.2rem); }
html[data-script="nastaliq"] .hero h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.8rem); line-height: 1.95; }
.hero-intro { color: var(--text-2); font-size: 1.12em; max-inline-size: 38rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.progress-line { color: var(--muted); font-size: .92em; font-weight: var(--semi); }
.promises { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.promises li { display: flex; align-items: flex-start; gap: .5rem; color: var(--text-2); font-size: .92em; line-height: var(--lh-tight); }
.promises svg, .outcomes svg { inline-size: 1.1rem; block-size: 1.1rem; flex: none; fill: none; stroke: var(--good); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; margin-block-start: .1em; }
html[data-script="nastaliq"] .promises svg, html[data-script="nastaliq"] .outcomes svg { margin-block-start: .5em; }
.draft-note { margin-block-start: .25rem; }

/* the model panel: what a language model does, once */
.hero-model {
  margin: 0; padding: 1.25rem 1.25rem 1rem; border-radius: var(--r);
  background: var(--code-bg); color: var(--code-text);
  display: grid; gap: 1rem;
}
@media (min-width: 40rem) { .hero-model { padding: 1.5rem 1.75rem 1.5rem; } }
.hm-prompt { font-size: 1.35em; line-height: var(--lh-tight); display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .1em; min-block-size: 1.4em; }
html[data-script="nastaliq"] .hm-prompt { line-height: 2; }
.hm-text { color: var(--code-text); }
.hm-next { color: var(--code-accent); }
.hm-next:not(:empty) { padding-inline-start: .25em; }
.caret { display: inline-block; inline-size: .55em; block-size: 1.05em; background: var(--code-accent); align-self: center; margin-inline-start: .2em; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hm-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.hm-bars li { display: grid; grid-template-columns: minmax(4.5rem, .9fr) minmax(0, 2fr) 3.6rem; align-items: center; gap: .75rem; padding: .25rem .5rem; border-radius: var(--r-sm); }
.hm-tok { font-size: .98em; line-height: var(--lh-tight); }
.hm-p { font-family: var(--mono); font-size: .82em; color: var(--code-muted); text-align: end; font-variant-numeric: tabular-nums; }
.hero-model .bar-bg { fill: rgba(255, 255, 255, .07); }
.hero-model .bar-fg { fill: var(--code-accent); }
.hm-bars li.is-picked { background: rgba(255, 200, 87, .12); }
.hm-bars li.is-picked .hm-tok { color: var(--code-accent); }
.hero-model figcaption { font-size: .88em; color: var(--code-muted); line-height: calc(var(--lh) - .1); }
.hm-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem 1rem; align-items: end; }
.hero-model .ctl label, .hero-model .ctl-val { color: var(--code-text); }
.hero-model .btn-primary { background: var(--code-accent); border-color: var(--code-accent); color: #10172f; }
.hero-model .btn-primary:hover { background: #ffd57d; border-color: #ffd57d; }
.hero-model input[type="range"] { accent-color: var(--code-accent); }
.is-new { animation: pop .4s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(.25em); } to { opacity: 1; transform: none; } }
/* one entrance: the bars grow in when the page opens */
@media (prefers-reduced-motion: no-preference) {
  .hm-bars .bar-fg { animation: grow .9s var(--ease) both; transform-box: fill-box; transform-origin: left center; }
  .hm-bars li:nth-child(2) .bar-fg { animation-delay: .06s; }
  .hm-bars li:nth-child(3) .bar-fg { animation-delay: .12s; }
  .hm-bars li:nth-child(4) .bar-fg { animation-delay: .18s; }
  .hm-bars li:nth-child(5) .bar-fg { animation-delay: .24s; }
  .hm-bars li:nth-child(6) .bar-fg { animation-delay: .3s; }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

.outcomes { padding-block: 2rem; border-block-start: 1px solid var(--line-soft); display: grid; gap: 1rem; }
@media (min-width: 58rem) { .outcomes { grid-template-columns: minmax(0, .8fr) minmax(0, 2fr); gap: 3.5rem; } }
.outcomes h2, .path h2 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: 1.6em; }
.outcomes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem 2rem; }
@media (min-width: 44rem) { .outcomes ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.outcomes li { display: flex; gap: .5rem; align-items: flex-start; line-height: calc(var(--lh) - .15); }

.path { padding-block: 2rem 1rem; border-block-start: 1px solid var(--line-soft); }
.path-intro { color: var(--text-2); margin-block: .5rem 1.5rem; max-inline-size: 42rem; }
.parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; }
.part {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem;
  padding: 1.25rem 1rem 1rem; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line-soft); box-shadow: var(--shadow);
  scroll-margin-block-start: 5rem;
}
@media (min-width: 58rem) { .part { grid-template-columns: minmax(0, .85fr) minmax(0, 2fr); gap: 2.5rem; padding: 1.75rem 2rem 1.5rem; } }
.part-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 58rem) { .part-head { position: sticky; inset-block-start: 5rem; align-self: start; grid-template-columns: minmax(0, 1fr); gap: .5rem; } }
.part-num { font-family: var(--latin-display); font-size: 2.6rem; font-weight: 300; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; min-inline-size: 1.4ch; }
html:not([data-script="latin"], [data-script="cyrl"]) .part-num { font-family: var(--font-ui); font-weight: var(--semi); font-size: 2.2rem; line-height: 1.3; }
html[data-script="nastaliq"] .part-num { line-height: 1.9; }
.part-title { display: grid; gap: .25rem; }
.part-kicker { font-size: .84em; color: var(--muted); line-height: var(--lh-tight); }
.part-title h3 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: 1.35em; }
.part-text { color: var(--text-2); font-size: .93em; line-height: calc(var(--lh) - .1); }
.part-progress { display: grid; gap: .25rem; margin-block-start: .5rem; font-size: .84em; color: var(--muted); }
.part-progress .bar-fg { fill: var(--good); }
.part-lessons { list-style: none; margin: 0; padding: 0; display: grid; }
.part-lessons li + li { border-block-start: 1px solid var(--line-soft); }
.lrow {
  display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); gap: .25rem .75rem; align-items: start;
  padding: .75rem .25rem; color: var(--text); text-decoration: none; border-radius: var(--r-sm);
}
@media (min-width: 40rem) { .lrow { grid-template-columns: 2.4rem minmax(0, 1fr) auto; } }
.lrow:hover { background: var(--raised); }
.lrow:hover .lr-title { color: var(--accent-ink); }
.lr-num {
  inline-size: 2.2rem; block-size: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--text-2); font-size: .85rem; font-weight: var(--semi); font-variant-numeric: tabular-nums; line-height: 1;
}
html[data-script="nastaliq"] .lr-num { padding-block-start: .35em; }
.lrow.is-done .lr-num { background: var(--good); border-color: var(--good); color: var(--on-accent); }
.lrow.is-started .lr-num { border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.lr-body { display: grid; gap: .125rem; min-inline-size: 0; }
.lr-title { font-weight: var(--semi); line-height: var(--lh-tight); font-size: 1.02em; }
.lr-hook { color: var(--text-2); font-size: .9em; line-height: calc(var(--lh) - .15); }
.lr-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; color: var(--muted); font-size: .82em; line-height: var(--lh-tight); }
@media (min-width: 40rem) { .lr-meta { grid-column: auto; flex-direction: column; align-items: flex-end; text-align: end; padding-block-start: .25rem; } }
.lr-en { color: var(--prob-ink); }
.lr-state { display: inline-flex; align-items: center; gap: .25rem; }
.lr-state:empty { display: none; }
.lr-state svg { inline-size: 1rem; block-size: 1rem; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.lrow.is-done .lr-state { color: var(--good); font-weight: var(--semi); }
.lrow.is-started .lr-state { color: var(--accent-ink); font-weight: var(--semi); }

.offline-card {
  margin-block-start: 2rem; padding: 1.5rem 1.25rem; display: grid; gap: .75rem;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line-soft);
}
@media (min-width: 40rem) { .offline-card { padding: 1.75rem 2rem; } }
.offline-card h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.3em; display: flex; align-items: center; gap: .5rem; }
.offline-card h2 svg { inline-size: 1.5rem; block-size: 1.5rem; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.offline-card p { color: var(--text-2); max-inline-size: 42rem; }
.offline-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
#packMeter { flex-wrap: wrap; gap: .5rem; }
#packMeter .meter-bar { flex-basis: 100%; }
.offline-status { font-weight: var(--semi); font-size: .92em; }
.offline-status:empty { display: none; }
.offline-status.is-good { color: var(--good); }
.offline-status.is-bad { color: var(--bad); }
.install-hint { font-size: .88em; color: var(--muted); }
.meter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.meter-bar { flex: 1 1 5rem; block-size: .45rem; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.meter-bar span { display: block; block-size: 100%; inline-size: 0; background: var(--good); border-radius: inherit; transition: inline-size .3s; }
.meter-text { font-size: .85em; color: var(--muted); font-weight: var(--semi); }

/* ---------- lesson ---------- */
.l-head { display: grid; gap: .75rem; max-inline-size: 48rem; }
.l-kicker { display: flex; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .9em; line-height: var(--lh-tight); }
.l-head h1 {
  font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track);
  font-size: clamp(2rem, 1.3rem + 2.8vw, 3.2rem); line-height: 1.08;
}
html:not([data-script="latin"], [data-script="cyrl"]) .l-head h1 { line-height: var(--lh-tight); font-size: clamp(1.8rem, 1.25rem + 2.2vw, 2.7rem); }
html[data-script="nastaliq"] .l-head h1 { font-size: clamp(1.65rem, 1.15rem + 2vw, 2.4rem); line-height: 1.95; }
[data-fallback="1"].l-head h1 { line-height: 1.08; font-size: clamp(2rem, 1.3rem + 2.8vw, 3.2rem); }
.hook { color: var(--text-2); font-size: 1.15em; max-inline-size: 42rem; line-height: calc(var(--lh) - .1); }
.l-goals { margin-block-start: .5rem; padding: 1rem 1.25rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); max-inline-size: 42rem; }
.l-goals h2 { font-size: .95em; color: var(--muted); margin-block-end: .5rem; }
.l-goals ul { margin: 0; padding-inline-start: 1.25rem; display: grid; gap: .25rem; }
.l-goals li::marker { color: var(--accent); }
.l-status { margin-block-start: 1rem; }

.toc-top { margin-block-start: 1.25rem; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--surface); }
.toc-top summary { cursor: pointer; padding: .75rem 1rem; font-weight: var(--semi); }
.toc-top ol { margin: 0; padding-block: 0 1rem; padding-inline: 2.5rem 1rem; display: grid; gap: .25rem; font-size: .93em; }
.toc-top a { text-decoration: none; }
.l-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; margin-block-start: 1.75rem; }
.toc-side { display: none; }
@media (min-width: 66rem) {
  .toc-top { display: none; }
  .l-layout { grid-template-columns: 14rem minmax(0, 46rem); gap: 3.5rem; }
  .toc-side { display: block; position: sticky; inset-block-start: 5.5rem; align-self: start; max-block-size: calc(100vh - 7rem); overflow-y: auto; padding-block-end: 1rem; }
}
.toc-title { font-size: .85em; font-weight: var(--semi); color: var(--muted); margin-block-end: .5rem; }
.toc-side ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .125rem; border-inline-start: 1px solid var(--line); counter-reset: toc; }
.toc-side a {
  display: block; padding: .25rem .75rem; margin-inline-start: -1px; border-inline-start: 2px solid transparent;
  color: var(--text-2); text-decoration: none; font-size: .9em; line-height: var(--lh-tight);
}
html[data-script="nastaliq"] .toc-side a { line-height: 1.9; }
.toc-side a:hover { color: var(--text); }
.toc-side a[aria-current="true"] { color: var(--accent-ink); border-inline-start-color: var(--accent); font-weight: var(--semi); }

.l-article { display: grid; gap: 3rem; min-inline-size: 0; }
.l-sec { display: grid; gap: 1rem; scroll-margin-block-start: 5.5rem; min-inline-size: 0; }
.l-sec > p, .l-sec > .b-list, .l-sec > .b-steps { max-inline-size: 42rem; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.sec-head h2 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: 1.6em; }
html[data-script="nastaliq"] .sec-head h2 { font-size: 1.45em; }
.listen-btn { flex: none; }
.listen-btn svg { inline-size: 1.05rem; block-size: 1.05rem; }

.b-list { margin: 0; padding-inline-start: 1.25rem; display: grid; gap: .5rem; }
.b-list li::marker { color: var(--accent); }
.b-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; counter-reset: s; }
.b-steps li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: .75rem; align-items: start; }
.b-steps .n {
  inline-size: 2rem; block-size: 2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-ink); font-weight: var(--semi); font-size: .9rem; line-height: 1;
}
html[data-script="nastaliq"] .b-steps .n { padding-block-start: .35em; }

/* notes: a tinted panel with a small label; each kind has its own tint */
.note { margin: 0; padding: 1rem 1.25rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); border-inline-start: 4px solid var(--accent); display: grid; gap: .5rem; max-inline-size: 44rem; }
.note-label { display: flex; align-items: center; gap: .5rem; font-size: .85em; font-weight: var(--semi); color: var(--accent-ink); line-height: var(--lh-tight); }
.note-label svg { inline-size: 1.1rem; block-size: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.note h3 { font-size: 1.05em; }
.note-body { display: grid; gap: .7em; color: var(--text-2); }
.note-analogy { background: var(--accent-wash); border-color: transparent; border-inline-start-color: var(--accent); }
.note-analogy .note-body { color: var(--text); }
.note-example { border-inline-start-color: var(--good); }
.note-example .note-label { color: var(--good); }
.note-deep { background: var(--raised); border-inline-start-color: var(--text-2); }
.note-deep .note-label { color: var(--text-2); }
.note-myth { background: var(--prob-wash); border-color: transparent; border-inline-start-color: var(--prob); }
.note-myth .note-label { color: var(--prob-ink); }
.note-myth .note-body { color: var(--text); }
.note-tip { border-inline-start-color: var(--prob); }
.note-tip .note-label { color: var(--prob-ink); }

/* formulas: each line in code type, with its meaning in words under it */
.b-math { margin: 0; padding: 1rem 1.25rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); display: grid; gap: .75rem; }
.b-math figcaption, .b-table figcaption, .b-flow figcaption, .b-stack figcaption, .b-bars figcaption, .b-tokens figcaption, .b-trace figcaption { font-weight: var(--semi); font-size: .95em; }
.math-lines { display: grid; gap: .75rem; }
.ml { display: grid; gap: .25rem; }
code.expr { font-size: 1.02em; color: var(--accent-ink); white-space: pre-wrap; overflow-wrap: anywhere; justify-self: start; }
.say { color: var(--text-2); font-size: .93em; }

/* code: dark in both themes */
.b-code { margin: 0; border-radius: var(--r-sm); background: var(--code-bg); color: var(--code-text); overflow: hidden; }
.b-code figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding-block: .5rem; padding-inline: 1rem .5rem; border-block-end: 1px solid var(--code-line); font-size: .85em; color: var(--code-muted); }
.code-title { flex: 1 1 auto; color: var(--code-text); }
.code-lang { font-family: var(--mono); font-size: .9em; }
.copy-btn { display: inline-flex; align-items: center; gap: .25rem; min-block-size: 2.2rem; padding: .25rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--code-line); background: var(--code-raised); color: var(--code-text); cursor: pointer; font-size: .95em; line-height: 1.2; }
.copy-btn:hover { border-color: var(--code-accent); }
.copy-btn.is-done { color: var(--code-accent); }
.copy-btn svg { inline-size: 1rem; block-size: 1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.b-code pre, .ev pre { margin: 0; padding: 1rem 1rem 1rem; font-size: .84rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.b-code pre .c { color: var(--code-muted); }
.b-code pre .p { color: var(--code-accent); user-select: none; }
.code-notes { margin: 0; padding-block: .75rem 1rem; padding-inline: 2.25rem 1rem; border-block-start: 1px solid var(--code-line); display: grid; gap: .25rem; font-size: .9em; color: var(--code-text); line-height: 1.55; }
.code-notes code { background: var(--code-raised); border-color: var(--code-line); color: var(--code-accent); }

/* tables: on a phone, a table with many columns becomes one card per row */
.b-table { margin: 0; display: grid; gap: .5rem; min-inline-size: 0; }
.b-table table { inline-size: 100%; border-collapse: collapse; font-size: .92em; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-sm); overflow: hidden; }
.b-table th, .b-table td { padding: .5rem .75rem; text-align: start; vertical-align: top; border-block-end: 1px solid var(--line-soft); line-height: calc(var(--lh) - .2); }
.b-table thead th { background: var(--raised); font-weight: var(--semi); color: var(--text-2); font-size: .92em; }
.b-table tbody tr:last-child td, .b-table tbody tr:last-child th { border-block-end: 0; }
.b-table tbody th { font-weight: var(--semi); color: var(--text); }
.b-table td.mono { font-size: .9em; overflow-wrap: normal; } /* long names wrap only after . _ - / (blocks.js adds <wbr>) */
.table-note { font-size: .85em; color: var(--muted); }
@media (max-width: 40rem) {
  .stack-sm table, .stack-sm tbody, .stack-sm tr, .stack-sm td, .stack-sm tbody th { display: block; inline-size: 100%; }
  .stack-sm tbody th { padding: .25rem .75rem .25rem; border: 0; }
  .stack-sm thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  .stack-sm table { border: 0; background: none; }
  .stack-sm tr { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: .5rem .25rem; margin-block-end: .5rem; }
  .stack-sm td { border: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .75rem; padding: .25rem .75rem; }
  .stack-sm td::before { content: attr(data-h); color: var(--muted); font-size: .9em; font-family: var(--font-ui); }
  .stack-sm td:first-child { font-weight: var(--semi); }
  .stack-sm td.mono { white-space: normal; overflow-wrap: anywhere; }
}

.b-compare { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
@media (min-width: 40rem) {
  .b-compare.cols-2, .b-compare.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .b-compare.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.cmp { padding: 1rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); display: grid; gap: .5rem; align-content: start; }
.cmp h3 { font-size: 1.02em; color: var(--accent-ink); }
.cmp ul { margin: 0; padding-inline-start: 1rem; display: grid; gap: .25rem; font-size: .93em; color: var(--text-2); }

/* flow: boxes joined by arrows; down on a phone, across on a wide screen */
.b-flow { margin: 0; display: grid; gap: .75rem; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
.flow li { position: relative; padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); display: grid; gap: .125rem; }
.flow li + li::before {
  content: ""; position: absolute; inset-block-start: -1rem; inset-inline-start: 1.25rem;
  inline-size: .6rem; block-size: .6rem; border-block-end: 2px solid var(--accent); border-inline-end: 2px solid var(--accent); transform: rotate(45deg);
}
.fn-label { font-weight: var(--semi); line-height: var(--lh-tight); }
.fn-sub { font-size: .86em; color: var(--muted); line-height: calc(var(--lh) - .2); }
@media (min-width: 48rem) {
  .flow { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1.5rem; }
  .flow li + li::before { inset-block-start: 50%; inset-inline-start: -1rem; margin-block-start: -.25rem; transform: rotate(-45deg); }
  [dir="rtl"] .flow li + li::before { transform: rotate(135deg); }
  [dir="ltr"] .flow li + li::before { transform: rotate(-45deg); }
}

/* stack: layers, the top one first */
.b-stack { margin: 0; display: grid; gap: .75rem; }
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.stack li { padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr); gap: .125rem; }
@media (min-width: 40rem) { .stack li { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1rem; align-items: baseline; } }
.stack li:nth-child(1) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stack li:nth-child(1) .sl-sub { color: var(--on-accent); opacity: .85; }
.stack li:nth-child(2) { background: var(--accent-wash); border-color: transparent; }
.sl-label { font-weight: var(--semi); line-height: var(--lh-tight); }
.sl-sub { font-size: .88em; color: var(--text-2); line-height: calc(var(--lh) - .2); }

/* bar charts */
.b-bars { margin: 0; padding: 1rem 1.25rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); display: grid; gap: .75rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; align-items: center; }
.bar-label { font-size: .92em; line-height: var(--lh-tight); }
.bar-val { font-size: .88em; font-variant-numeric: tabular-nums; color: var(--text-2); grid-column: 2; grid-row: 1; }
.bars .bar-svg { grid-column: 1 / -1; }
.bar-note { grid-column: 1 / -1; font-size: .82em; color: var(--muted); }
.bars li:not(.hi) .bar-fg { fill: color-mix(in srgb, var(--prob) 55%, var(--sunken)); }
.bars li.hi .bar-label, .bars li.hi .bar-val { font-weight: var(--semi); color: var(--text); }

/* tokens: each piece in its own box, spaces shown */
.b-tokens { margin: 0; display: grid; gap: .5rem; padding: 1rem 1.25rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); }
.tok-row { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; }
.tok { display: inline-block; padding: .125rem .5rem; border-radius: var(--r-xs); background: var(--prob-wash); border: 1px solid color-mix(in srgb, var(--prob) 45%, transparent); font-size: .95em; line-height: 1.6; white-space: pre; color: var(--text); }
.tok:nth-child(even) { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.tok .sp { color: var(--muted); }
html[data-script="nastaliq"] .tok { line-height: 2.1; }
.tok-meta { display: flex; flex-wrap: wrap; align-items: center; font-size: .85em; color: var(--muted); }

/* traces: an agent run, one event at a time */
.b-trace { margin: 0; display: grid; gap: .75rem; }
.trace { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.ev { padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); border-inline-start: 4px solid var(--line); display: grid; gap: .25rem; min-inline-size: 0; }
.ev-who { font-size: .8em; font-weight: var(--semi); color: var(--muted); line-height: var(--lh-tight); }
.ev-text { display: grid; gap: .5em; font-size: .95em; }
.ev pre { border-radius: var(--r-sm); background: var(--code-bg); color: var(--code-text); padding: .75rem .75rem; font-size: .8rem; }
.ev-user { border-inline-start-color: var(--accent); }
.ev-user .ev-who { color: var(--accent-ink); }
.ev-system { background: var(--raised); }
.ev-model { border-inline-start-color: var(--prob); }
.ev-model .ev-who { color: var(--prob-ink); }
.ev-think { border-inline-start-color: var(--prob); border-style: dashed; border-inline-start-style: solid; }
.ev-think .ev-text { color: var(--text-2); font-style: italic; }
html:not([data-script="latin"], [data-script="cyrl"]) .ev-think .ev-text { font-style: normal; }
.ev-tool { border-inline-start-color: var(--good); background: var(--raised); }
.ev-tool .ev-who { color: var(--good); }
.ev-harness { border-inline-start-color: var(--text-2); background: var(--sunken); }
html.js .b-trace[data-play] .ev.is-later { display: none; }
.trace-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.trace-count { font-size: .85em; color: var(--muted); margin-inline-start: .25rem; }

/* the lab: every hands-on demo sits on a dot grid */
.lab {
  margin: 0; padding: 1rem 1rem 1.25rem; border-radius: var(--r);
  background-color: var(--surface);
  background-image: radial-gradient(color-mix(in srgb, var(--line) 80%, transparent) 1px, transparent 1.2px);
  background-size: 16px 16px;
  border: 1px solid var(--line);
  display: grid; gap: 1rem; min-inline-size: 0;
}
@media (min-width: 40rem) { .lab { padding: 1.25rem 1.5rem 1.5rem; } }
.lab figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.lab-label { display: inline-block; padding: .125rem .5rem; border-radius: var(--r-xs); background: var(--code-bg); color: var(--code-accent); font-size: .78em; font-weight: var(--semi); line-height: 1.6; }
html[data-script="nastaliq"] .lab-label { line-height: 2; }
.lab-title { font-weight: var(--semi); font-size: 1.05em; }
.lab-text { display: grid; gap: .6em; color: var(--text-2); max-inline-size: 42rem; }
.lab-nojs { color: var(--muted); font-size: .9em; }
.demo-root { display: grid; gap: 1rem; min-inline-size: 0; }
.demo-hint { font-size: .88em; color: var(--muted); max-inline-size: 42rem; }
.demo-out { font-size: .95em; line-height: calc(var(--lh) - .1); }
.demo-out:empty { display: none; }
.demo-formula { font-size: .92em; }
.demo-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.demo-actions .btn svg { inline-size: 1.1rem; block-size: 1.1rem; }
.verdict { padding: .5rem .75rem; border-radius: var(--r-sm); font-weight: var(--semi); }
.verdict.is-fits { background: var(--good-wash); color: var(--good); }
.verdict.is-tight { background: var(--prob-wash); color: var(--prob-ink); }
.verdict.is-noFit { background: var(--bad-wash); color: var(--bad); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; font-size: .85em; color: var(--muted); }
.key { display: inline-block; inline-size: .8rem; block-size: .8rem; border-radius: 2px; vertical-align: middle; margin-inline-end: .25rem; flex: none; }

/* demo controls */
.ctl-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem 1.25rem; }
@media (min-width: 36rem) { .ctl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ctl { display: grid; gap: .25rem; min-inline-size: 0; }
.ctl-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.ctl label, .ctl-label { font-size: .88em; font-weight: var(--semi); color: var(--text-2); line-height: var(--lh-tight); }
.ctl-val { font-family: var(--mono); font-size: .85em; color: var(--text); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { inline-size: 100%; accent-color: var(--accent); margin: 0; min-block-size: 1.75rem; }
.ctl select, .ctl input[type="text"] {
  inline-size: 100%; min-block-size: 2.6rem; padding: .25rem .5rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); line-height: var(--lh-tight);
}
.ctl input[type="text"] { font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-btn {
  min-block-size: 2.4rem; padding: .25rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; line-height: var(--lh-tight);
}
html[data-script="nastaliq"] .chip-btn { line-height: 1.9; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* plots are pictures of maths, so they always run left to right */
.plot { inline-size: 100%; max-inline-size: 34rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); padding: .5rem; }
.plot-svg { inline-size: 100%; block-size: auto; overflow: visible; }
.plot-square { max-inline-size: 22rem; margin-inline: auto; }
/* strokes keep their screen width whatever the plot's own units are */
.plot-svg line, .plot-svg polygon, .plot-svg path, .plot-svg circle { vector-effect: non-scaling-stroke; }
.plot .axis { stroke: var(--line); stroke-width: 1.2; }
.plot .grid { stroke: var(--line-soft); stroke-width: 1; }
.pt circle { fill: var(--muted); }
.pt-label { font-size: .42px; fill: var(--text-2); font-family: var(--font-ui); }
.pt.is-on circle { fill: var(--accent); }
.pt.is-on .pt-label { fill: var(--text); font-weight: 700; }
.vec { stroke-width: 3; stroke-linecap: round; }
.vec-a { stroke: var(--accent); }
.vec-b { stroke: var(--prob); }
.vec.dashed { stroke-dasharray: 5 4; }
.target { fill: none; stroke: var(--prob); stroke-width: 2; }
.curve { fill: none; stroke: var(--accent); stroke-width: 2.2; }
.trail circle { fill: var(--prob); opacity: .7; }
.ball { fill: var(--prob); stroke: var(--surface); stroke-width: 2; transition: cx .1s, cy .1s; }
.edge { stroke-linecap: round; }
.edge.pos { stroke: var(--accent); }
.edge.neg { stroke: var(--bad); }
.edge-label { font-size: 11px; fill: var(--text-2); font-family: var(--mono); }
.node circle { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.node text { font-size: 12px; text-anchor: middle; fill: var(--text); font-family: var(--mono); }
.node-out.is-on circle { fill: var(--prob-wash); stroke: var(--prob); }
.fit-line { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.resid line { stroke: var(--prob); stroke-width: 1.4; stroke-dasharray: 3 2; }
.pt-dot { fill: var(--text-2); }
.axis-label { font-size: 10px; fill: var(--muted); font-family: var(--font-ui); }
.shape-orig { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.shape-new { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.levels line { stroke: var(--line); stroke-width: .7; stroke-dasharray: 2 3; }
.q-orig { fill: none; stroke: var(--muted); stroke-width: 1; }
.q-new { fill: var(--prob); }
.q-seps line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; }
.key-orig { border: 1px solid var(--muted); }
.key-new { background: var(--prob); }

/* sampler */
.smp-prompt { font-size: 1.2em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .1em; }
.smp-next { color: var(--prob-ink); font-weight: var(--semi); }
.smp-next:not(:empty) { padding-inline-start: .25em; }
.smp-prompt .caret { background: var(--prob); }
.smp-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.smp-bars li { display: grid; grid-template-columns: minmax(4.5rem, 1fr) minmax(0, 2.2fr) minmax(4.2rem, auto); gap: .75rem; align-items: center; padding: .125rem .25rem; border-radius: var(--r-sm); }
.smp-p { font-family: var(--mono); font-size: .82em; text-align: end; color: var(--text-2); }
.smp-bars li.is-off { opacity: .45; }
.smp-bars li.is-off .smp-p { font-family: var(--font-ui); }
.smp-bars li.is-picked { background: var(--prob-wash); }
.smp-bars li.is-picked .smp-tok { font-weight: var(--semi); }

/* byte-pair encoding */
.bpe-words { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.bpe-words li { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; }
.bpe-n { font-family: var(--mono); font-size: .85em; color: var(--muted); }
.bpe-merges { margin: 0; padding-inline-start: 1.5rem; display: grid; gap: .25rem; font-size: .9em; color: var(--text-2); }
.bpe-merges:empty { display: none; }
.tok-new { background: var(--good-wash) !important; border-color: var(--good) !important; }

/* attention */
.att-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.att-tok {
  display: grid; gap: .25rem; justify-items: stretch; min-inline-size: 3.2rem; padding: .25rem .5rem .25rem;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: center; line-height: var(--lh-tight);
}
.att-word { font-size: .98em; }
.att-bar { display: block; block-size: .35rem; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.att-bar span { display: block; block-size: 100%; inline-size: 0; background: var(--prob); transition: inline-size .3s; }
.att-w { font-family: var(--mono); font-size: .72em; color: var(--muted); min-block-size: 1.2em; }
.att-tok.is-cur { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-wash); }
.att-tok.is-future { opacity: .4; }

/* long-context attention patterns: 48 tokens, the last one is being written */
.pat-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .25rem; max-inline-size: 40rem; }
@media (min-width: 36rem) { .pat-grid { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: .25rem; } }
.pat-cell { display: block; aspect-ratio: 1; border-radius: var(--r-xs); background: var(--sunken); border: 1px solid var(--line-soft); transition: background-color .2s, border-color .2s, opacity .2s; }
.pat-cell.is-read { background: var(--prob); border-color: var(--prob); }
.pat-cell.is-cur { background: var(--accent); border-color: var(--accent); }
.pat-cell.is-sum { background: color-mix(in srgb, var(--prob) 55%, var(--sunken)); border-color: var(--prob); }
.pat-cell.is-merged { background: color-mix(in srgb, var(--text-2) 18%, var(--sunken)); }
.pat-cell.is-folded { background: color-mix(in srgb, var(--good) 30%, var(--sunken)); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
/* compressed: each group of 4 tokens is drawn as one joined bar, like the single summary entry it becomes */
.is-compressed .pat-cell { border-radius: 0; }
.is-compressed .pat-cell.is-q0 { border-start-start-radius: 6px; border-end-start-radius: 6px; }
.is-compressed .pat-cell.is-q { border-start-end-radius: 6px; border-end-end-radius: 6px; }

/* memory calculator */
.mem-meter { position: relative; display: flex; block-size: 1.6rem; border-radius: var(--r-sm); background: var(--sunken); overflow: hidden; --limit: 100%; }
.mem-meter::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: var(--limit); inline-size: 2px; background: var(--text); }
.mem-w { display: block; background: var(--accent); transition: inline-size .3s; }
.mem-k { display: block; background: var(--prob); transition: inline-size .3s; }
.key-w { background: var(--accent); }
.key-k { background: var(--prob); }
.mem-legend { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; font-size: .92em; }
.mem-legend div { display: flex; gap: .5rem; align-items: baseline; }
.mem-legend dt { color: var(--text-2); }
.mem-legend dd { margin: 0; font-variant-numeric: tabular-nums; }

/* one request: prefill then decode, as one time bar */
.tl-bar { display: flex; block-size: 1.6rem; border-radius: var(--r-sm); background: var(--sunken); overflow: hidden; border: 1px solid var(--line); }
.tl-pre { display: block; background: var(--accent); transition: inline-size .3s; }
.tl-dec { display: block; background: var(--prob); transition: inline-size .3s; }

/* roofline: the slope is memory speed, the flat roof is computing power */
.roof { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.roof-dot { fill: var(--prob); stroke: var(--surface); stroke-width: 1.5; transition: cx .2s, cy .2s; }
.roof-dot.is-over { fill: var(--bad); }
.roof-pre { fill: var(--surface); stroke: var(--text-2); stroke-width: 1.8; transition: cx .2s, cy .2s; }
.key-dot { background: var(--prob); border-radius: 50%; }
.key-pre { border: 2px solid var(--text-2); border-radius: 50%; }

/* mcpctx: tool definitions from MCP servers in the context window */
.mc-s0, .mc-search { background: var(--accent); }
.mc-s1, .mc-found { background: var(--prob); }
.mc-s2 { background: var(--good); }
.mc-s3 { background: var(--text-2); }
.mc-s4 { background: var(--muted); }

/* trace events in the MCP lesson: the client inside the host, and the server */
.ev-client { border-inline-start-color: var(--accent); background: var(--sunken); }
.ev-client .ev-who { color: var(--accent-ink); }
.ev-server { border-inline-start-color: var(--good); background: var(--raised); }
.ev-server .ev-who { color: var(--good); }

/* perm: what a harness lets an agent do in each permission mode */
.pm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.pm-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; align-items: start; padding: .5rem .75rem; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--surface); }
.pm-act { min-inline-size: 0; overflow-wrap: anywhere; }
.pm-out { padding: .125rem .5rem; border-radius: 999px; font-size: .82em; font-weight: var(--semi); white-space: nowrap; }
html[data-script="nastaliq"] .pm-out { font-weight: 400; line-height: 2; }
.pm-run { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.pm-ask { background: var(--prob-wash); color: var(--prob-ink); }
.pm-block { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pm-undo { grid-column: 1 / -1; font-size: .84em; color: var(--muted); }

/* chain: chance a whole task succeeds as the number of steps grows */
.ch-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.ch-base { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-dasharray: 5 4; }
.ch-dot { fill: var(--prob); stroke: var(--surface); stroke-width: 2; }
.key-ch-line { background: var(--accent); }
.key-ch-base { background: var(--muted); }

/* passk: right at least once (pass@k) against right every time (pass^k) */
.pk-any { fill: none; stroke: var(--good); stroke-width: 2.4; stroke-linejoin: round; stroke-dasharray: 7 3; }
.pk-mark { stroke: var(--muted); stroke-width: 1; }
.key-pk-any { background: var(--good); }
/* imgtok: a picture cut into image tokens */
.it-pic { fill: var(--prob-wash); stroke: var(--prob); stroke-width: 1.5; }
.it-off { fill: var(--sunken); stroke: none; opacity: .92; }
.it-grid { stroke: var(--accent); stroke-width: 1; stroke-opacity: .28; }
.it-tile { fill: none; stroke: var(--accent); stroke-width: 2; }
.b-demo .bars { margin-block-start: .5rem; }
/* vidtok: a video as a stack of latent frames */
.vt-frame { fill: var(--surface); stroke: var(--accent); stroke-width: 1; stroke-opacity: .45; }
/* sound: a wave and the numbers stored for it */
.snd-axis { stroke: var(--line); stroke-width: 1; }
.snd-wave { fill: none; stroke: var(--muted); stroke-width: 1; }
.snd-step { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.snd-dot { fill: var(--accent); }
/* wer: what was said against what the machine wrote */
.wer-text {
  inline-size: 100%; padding: .5rem .5rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; line-height: var(--lh); resize: vertical;
}
.wer-align { margin: 0; line-height: 2; overflow-wrap: anywhere; }
.wer-align del { color: var(--bad); text-decoration-thickness: 2px; }
.wer-align ins { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .25em; background: var(--good-wash); }
.drift-room { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.drift-plan { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.drift-path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.drift-look { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.drift-goal { fill: var(--good); }
.drift-bot { fill: var(--accent); }
.ci-grid { stroke: var(--line-soft); stroke-width: 1; }
.ci-whisker { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.ci-true { stroke: var(--text-2); stroke-width: 1.5; }
.ci-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.ci-pos { fill: var(--accent); }
.ci-neg { fill: var(--bad); }
.ci-tie { fill: var(--muted); }
.ci-zero { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.eq { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .125rem; padding: .75rem .75rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); font-family: var(--mono); font-size: 1.1em; line-height: 1.6; }
.eq-op { padding: .125rem .125rem; color: var(--muted); }
.eq-part { font: inherit; color: inherit; background: var(--accent-wash); border: 1px solid transparent; border-radius: var(--r-sm); padding: .125rem .25rem; cursor: pointer; }
.eq-part:hover { border-color: var(--accent); }
.eq-part[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.bar-tick { stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* toolcall: the conversation as API messages, or as the raw text the model reads */
.tc-box { display: grid; gap: .5rem; margin-block-start: .5rem; }
.tc-raw { margin: 0; padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--code-bg); color: var(--code-text); font-family: var(--mono); font-size: .78rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.tc-gen { background: color-mix(in srgb, var(--prob) 32%, transparent); border-radius: 2px; }
.key-tc-gen { background: color-mix(in srgb, var(--prob) 55%, var(--code-bg)); }

/* resend: input tokens sent each turn of a chat, split into repeats and new tokens */
.rs-hit, .key-rs-hit { fill: var(--accent); background: var(--accent); }
.rs-new, .key-rs-new { fill: var(--prob); background: var(--prob); }

/* offload: how each token's time splits between GPU memory and system memory */
.off-bar { display: flex; block-size: 1.1rem; margin-block: 1rem .5rem; border-radius: var(--r-sm); background: var(--sunken); }
.off-bar span { display: block; block-size: 100%; transition: inline-size .25s; }
.off-g, .key-off-g { background: var(--accent); }
.off-c, .key-off-c { background: var(--prob); }
.off-bar .off-g { border-start-start-radius: var(--r-sm); border-end-start-radius: var(--r-sm); }
.off-bar .off-c { border-start-end-radius: var(--r-sm); border-end-end-radius: var(--r-sm); }

/* batching: one row per slot, one block per request */
.bt-idle { fill: var(--sunken); }
.bt-pre, .key-bt-pre { fill: var(--prob); background: var(--prob); }
.bt-job, .key-bt-job { fill: var(--accent); background: var(--accent); }
.key-bt-idle { background: var(--sunken); border: 1px solid var(--line); }
.bt-label { fill: var(--on-accent); font-size: 9px; font-family: var(--mono); }
.bt-end { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 3 3; }

/* speculative decoding: one group per pass of the big model */
.spec-row { display: flex; flex-wrap: wrap; gap: .5rem .5rem; }
.spec-row:empty { display: none; }
.spec-pass { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-xs); background: var(--sunken); border: 1px solid var(--line-soft); }
.spec-cell { display: block; inline-size: .8rem; block-size: .8rem; border-radius: 2px; }
.spec-cell.is-acc, .key-acc { background: var(--good); }
.spec-cell.is-own, .key-own { background: var(--accent); }
.spec-cell.is-rej, .key-rej { background: transparent; border: 1px dashed var(--muted); }

/* GRPO: a group of 8 sampled answers with rewards and advantages */
.grpo-q { margin: 0; font-weight: var(--semi); }
.grpo-group { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.grpo-group:empty { display: none; }
@media (min-width: 36rem) { .grpo-group { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grpo-a { display: grid; gap: .125rem; padding: .5rem .5rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-size: .88em; line-height: var(--lh-tight); }
.grpo-ans { font-family: var(--mono); font-size: 1.05em; }
.grpo-r, .grpo-adv { color: var(--text-2); font-variant-numeric: tabular-nums; }
.grpo-a.is-right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.grpo-a.is-wrong { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }

/* mixture of experts */
.moe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 36rem) { .moe-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.moe-ex { display: grid; gap: .125rem; padding: .5rem .5rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-size: .85em; line-height: var(--lh-tight); transition: background-color .2s, border-color .2s; }
.moe-name { font-weight: var(--semi); }
.moe-gate { font-family: var(--mono); color: var(--prob-ink); min-block-size: 1.2em; }
.moe-load { font-family: var(--mono); color: var(--muted); font-size: .9em; }
.moe-ex.is-on { background: var(--prob-wash); border-color: var(--prob); }
.moe-shared { border-style: dashed; }
.moe-shared.is-on { background: var(--accent-wash); border-color: var(--accent); }

/* diffusion */
.diff-wrap { display: flex; justify-content: center; }
.diff-canvas { inline-size: min(100%, 15rem); block-size: auto; aspect-ratio: 1; image-rendering: pixelated; border-radius: var(--r-sm); border: 1px solid var(--line); }

/* context window */
.ctx-frame { display: grid; gap: .5rem; }
.ctx-title { font-size: .85em; font-weight: var(--semi); color: var(--text-2); }
.ctx-bar { display: flex; block-size: 2rem; border-radius: var(--r-sm); background: var(--sunken); overflow: hidden; border: 1px solid var(--line); }
.ctx-bar .seg { display: block; block-size: 100%; border-inline-end: 1px solid var(--surface); transition: inline-size .3s; }
.ctx-marks { position: relative; block-size: .6rem; }
.ctx-marks span { position: absolute; inset-block: 0; inline-size: 2px; background: var(--muted); opacity: .6; }
.ctx-marks .m80 { inset-inline-start: 80%; background: var(--bad); opacity: .8; }
.ctx-cache { display: flex; block-size: .45rem; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.ctx-cache-fill { display: block; block-size: 100%; inline-size: 0; transition: inline-size .3s; }
.ctx-cache-fill, .key-cache { background: repeating-linear-gradient(135deg, var(--good) 0 4px, color-mix(in srgb, var(--good) 40%, transparent) 4px 7px); }
.seg-system { background: var(--text-2); }
.seg-tools { background: var(--muted); }
.seg-task { background: var(--accent); }
.seg-turn { background: var(--prob); }
.seg-stub { background: color-mix(in srgb, var(--prob) 35%, var(--sunken)); }
.seg-summary { background: var(--good); }
.ctx-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .88em; color: var(--text-2); }
.ctx-legend li { display: flex; align-items: center; }

/* cost */
.cost-out { display: grid; gap: .25rem; padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--raised); border: 1px solid var(--line-soft); }
.review-list, .review-path { margin: 0 0 .5rem; padding-inline-start: 1.4em; display: grid; gap: .25rem; }
.review-path { margin-block-end: 0; }
.review-why { color: var(--muted); }
.review-path .is-done > a { color: var(--good); }

/* number formats */
.table-wrap { min-inline-size: 0; }
.float-table { inline-size: 100%; border-collapse: collapse; font-size: .9em; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.float-table th, .float-table td { padding: .5rem .75rem; text-align: start; vertical-align: top; border-block-end: 1px solid var(--line-soft); }
.float-table thead th { background: var(--raised); color: var(--text-2); font-size: .92em; }
.float-table tbody th { font-family: var(--mono); font-weight: var(--semi); white-space: nowrap; }
.float-bits-n { display: block; font-family: var(--font-ui); font-weight: normal; font-size: .85em; color: var(--muted); }
.fval { display: block; font-family: var(--mono); }
.fbits { display: block; font-family: var(--mono); font-size: .78em; letter-spacing: .02em; word-break: break-all; margin-block-start: .25rem; }
.fb-s { color: var(--bad); }
.fb-e { color: var(--accent-ink); }
.fb-m { color: var(--prob-ink); }
.key.fb-s { background: var(--bad); }
.key.fb-e { background: var(--accent); }
.key.fb-m { background: var(--prob); }
.float-table td.bad { color: var(--bad); }
@media (max-width: 30rem) {
  .float-table thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  .float-table, .float-table tbody, .float-table tr, .float-table th, .float-table td { display: block; inline-size: 100%; }
  .float-table tr { border-block-end: 1px solid var(--line); padding-block: .25rem; }
  .float-table th, .float-table td { border: 0; padding-block: .25rem; }
  .float-table td::before { content: attr(data-h); display: block; font-size: .8em; color: var(--muted); }
}

/* matrix */
.demo-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 44rem) { .demo-split { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.mat-side { display: grid; gap: .75rem; }
.mat { display: grid; grid-template-columns: repeat(2, minmax(0, 5.5rem)); gap: .5rem; padding: .5rem .75rem; border-inline: 2px solid var(--text-2); border-radius: 8px; justify-self: start; }
.mat input { inline-size: 100%; min-block-size: 2.5rem; padding: .25rem .5rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); text-align: center; }

/* ---------- quick checks, sorting and the quiz ---------- */
.b-check { display: grid; gap: .5rem; }
.check-label { display: flex; align-items: center; gap: .5rem; font-size: .85em; font-weight: var(--semi); color: var(--accent-ink); }
.check-label svg { inline-size: 1.05rem; block-size: 1.05rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.b-sort { display: grid; gap: .75rem; }
.sort-list, .quiz { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.sort-item { padding: 1rem 1rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); }
.sort-item.is-right { border-color: color-mix(in srgb, var(--good) 55%, transparent); background: var(--good-wash); }
.sort-item.is-wrong { border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: var(--bad-wash); }
.sort-text { font-weight: var(--semi); }
.sort-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .5rem; margin-block-start: .5rem; }
.choice {
  display: flex; align-items: center; gap: .5rem; min-block-size: 2.75rem;
  padding: .5rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-align: start; cursor: pointer;
  line-height: var(--lh-tight); transition: border-color .15s, background-color .15s;
}
html[data-script="nastaliq"] .choice { line-height: 1.85; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); }
.choice:disabled { cursor: default; color: var(--text); }
.choice.is-answer { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.choice.is-chosen:not(.is-answer) { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.dot { inline-size: .7rem; block-size: .7rem; border-radius: 50%; flex: none; }
.dot-0 { background: var(--accent); }
.dot-1 { background: var(--prob); }
.dot-2 { background: var(--good); }
.dot-3 { background: var(--bad); }
.sort-result { display: flex; align-items: center; gap: .5rem; font-weight: var(--semi); font-size: .92em; }
.sort-result:empty { display: none; }
.sort-result:not(:empty) { margin-block-start: .5rem; }
.sort-result:focus { outline: none; }
.is-right .sort-result { color: var(--good); }
.is-wrong .sort-result { color: var(--bad); }
.sort-result svg, .mark svg { inline-size: 1.1rem; block-size: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nojs-answer { margin-block-start: .5rem; font-size: .92em; color: var(--text-2); }
.nojs-answer summary { cursor: pointer; color: var(--accent-ink); font-weight: var(--semi); }

.q fieldset { margin: 0; padding: 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); min-inline-size: 0; }
.b-check .q fieldset { border-color: var(--line); }
.q legend { display: flex; gap: .5rem; align-items: flex-start; font-weight: var(--semi); padding: 0; margin-block-end: .75rem; float: inline-start; inline-size: 100%; }
.q legend + * { clear: both; }
.q-num { flex: none; inline-size: 1.7rem; block-size: 1.7rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent-ink); font-size: .85rem; line-height: 1; margin-block-start: .1em; }
html[data-script="nastaliq"] .q-num { padding-block-start: .3em; margin-block-start: .45em; }
.q-choices { display: grid; gap: .5rem; }
.choice-block { inline-size: 100%; }
.mark { inline-size: 1.4rem; block-size: 1.4rem; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); }
.is-answer .mark { background: var(--good); border-color: var(--good); color: var(--on-accent); }
.choice.is-chosen:not(.is-answer) .mark { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
html:not(.js) .q-choices .choice { cursor: default; }
html:not(.js) .q-choices .mark { display: none; }
.q-why { font-size: .93em; color: var(--text-2); }
.q-why:empty { display: none; }
.q-why:not(:empty) { margin-block-start: .75rem; }
.q-why:focus { outline: none; }
.q.is-right .q-why > b:first-child { color: var(--good); }
.q.is-wrong .q-why > b:first-child { color: var(--bad); }

/* end of the lesson */
.l-recap, .l-words, .l-papers, .l-quiz { display: grid; gap: 1rem; scroll-margin-block-start: 5.5rem; }
.l-recap h2, .l-words h2, .l-papers h2, .l-quiz h2 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: 1.45em; }
.l-recap { padding: 1.25rem 1.25rem 1.25rem; border-radius: var(--r); background: var(--code-bg); color: var(--code-text); }
.l-recap ul { margin: 0; padding-inline-start: 1.25rem; display: grid; gap: .5rem; }
.l-recap li::marker { color: var(--code-accent); }
.l-recap b { color: var(--code-accent); }
.l-recap code { background: var(--code-raised); border-color: var(--code-line); }
.words { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .125rem; }
@media (min-width: 44rem) { .words { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .125rem 1.5rem; } }
.words div { padding-block: .5rem; border-block-end: 1px solid var(--line-soft); }
.words dt { font-weight: var(--semi); }
.words dd { margin: .125rem 0 0; color: var(--text-2); font-size: .93em; }
.papers { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.paper {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; align-items: center;
  padding: .75rem 1rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line-soft); color: var(--text); text-decoration: none;
}
.paper:hover { border-color: var(--accent); }
.paper-title { font-family: var(--latin); font-weight: 600; line-height: 1.35; }
.paper-meta { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; font-family: var(--mono); font-size: .78em; color: var(--muted); }
.paper svg { grid-column: 2; grid-row: 1 / span 2; inline-size: 1.1rem; block-size: 1.1rem; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.paper-why { font-size: .9em; color: var(--text-2); padding-inline: 1rem; margin-block-start: .25rem; }

.l-done { margin-block-start: 1rem; padding: 2rem 1.25rem; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); display: grid; justify-items: center; text-align: center; gap: .75rem; }
.done-badge { inline-size: 4rem; block-size: 4rem; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--muted); }
.done-badge svg { inline-size: 1.9rem; block-size: 1.9rem; fill: currentColor; }
.l-done.is-done .done-badge { background: var(--prob); color: var(--code-bg); box-shadow: 0 0 0 8px var(--prob-wash); }
.l-done h2 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: 1.6em; }
.l-done:not(.is-done) h2 { color: var(--muted); }
.l-done h2:focus { outline: none; }
.done-score { font-size: 1.1em; font-weight: var(--semi); }
.done-key { max-inline-size: 32rem; color: var(--text-2); }
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.l-report { margin-block-start: 1rem; padding: 1.25rem 1.25rem; border-radius: var(--r); border: 1px dashed var(--line); display: grid; justify-items: start; gap: .5rem; }
.l-report h2 { font-size: 1.15em; font-weight: var(--semi); }
.l-report p { color: var(--text-2); max-inline-size: 40rem; }
@media (prefers-reduced-motion: no-preference) {
  .l-done.just-done .done-badge { animation: badge .45s var(--ease); }
  @keyframes badge { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
}
.next-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem;
  inline-size: min(100%, 30rem); padding: 1rem 1rem; border-radius: var(--r-sm);
  background: var(--accent); color: var(--on-accent); text-decoration: none; text-align: start;
}
.next-card:hover { background: var(--accent-ink); }
.next-card .label { color: var(--on-accent); opacity: .85; }
.next-card .nc-title { display: block; font-weight: var(--semi); line-height: var(--lh-tight); margin-block-start: .125rem; }
.next-card svg { inline-size: 1.4rem; block-size: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- about and privacy ---------- */
.page-head { display: grid; gap: .75rem; padding-block: .5rem 1.5rem; max-inline-size: 46rem; }
.page-head h1 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--track); font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem); line-height: 1.1; }
html:not([data-script="latin"], [data-script="cyrl"]) .page-head h1 { line-height: var(--lh-tight); }
.page-head p { color: var(--text-2); font-size: 1.1em; }
.page-body { display: grid; gap: 0; max-inline-size: 46rem; border-block-start: 1px solid var(--line-soft); }
.page-section { padding-block: 1.5rem; border-block-end: 1px solid var(--line-soft); display: grid; gap: .5rem; }
.page-section h2 { font-size: 1.15em; color: var(--text); }
.prose { display: grid; gap: .8em; color: var(--text-2); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-block-start: .5rem; }

/* certificate page */
.cert-card { max-inline-size: 46rem; margin-block-end: 1.5rem; padding: 1.25rem 1.25rem; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); display: grid; gap: 1rem; }
.cert-card > div { display: grid; gap: 1rem; }
.cert-ready { display: flex; align-items: center; gap: .75rem; font-size: 1.1em; font-weight: var(--semi); }
.cert-star { flex: none; inline-size: 2.6rem; block-size: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--prob); color: var(--code-bg); }
.cert-star svg { inline-size: 1.4rem; block-size: 1.4rem; fill: currentColor; }
.cert-name { display: grid; gap: .5rem; }
.cert-name label { font-weight: var(--semi); }
.cert-name input {
  inline-size: 100%; min-block-size: 3rem; padding: .5rem .75rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 1.15em; line-height: var(--lh-tight);
}
.cert-msg:empty { display: none; }
.cert-msg { color: var(--bad); font-weight: var(--semi); }
.cert-canvas { display: block; inline-size: 100%; block-size: auto; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; }

/* ---------- welcome (root) ---------- */
.welcome { text-align: center; padding-block: 1.5rem 2rem; display: grid; justify-items: center; gap: .75rem; }
.welcome-mark { inline-size: 4rem; block-size: 4rem; }
.welcome h1 { font-family: var(--latin-display); font-weight: 650; font-size: clamp(2.4rem, 1.5rem + 3.4vw, 3.8rem); letter-spacing: -.03em; line-height: 1.05; }
.welcome p { color: var(--text-2); font-size: 1.1em; max-inline-size: 34rem; }
.welcome-count { font-size: .9em !important; color: var(--muted) !important; display: flex; align-items: center; }
.continue { margin-block-end: 1.5rem; display: flex; justify-content: center; }
.lang-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
@media (min-width: 36rem) { .lang-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 60rem) { .lang-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.lang-card {
  block-size: 100%; display: grid; gap: .25rem; align-content: start; padding: 1rem 1.25rem 1rem;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line-soft);
  color: var(--text); text-decoration: none; font-family: var(--system);
}
.lang-card:hover { border-color: var(--accent); }
.lang-card.is-suggested { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.lang-card-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .5rem; }
.lang-card .ln { font-size: 1.35rem; font-weight: 700; line-height: 1.5; }
.lang-card :lang(ur), .lang-card :lang(pnb), .continue :lang(ur), .continue :lang(pnb) { font-family: "Nastaliq Installed", var(--system); font-weight: 400; }
.lang-card .lt:lang(ur), .lang-card .lt:lang(pnb) { line-height: 1.9; }
.lang-card .le { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.lang-card .lt { color: var(--text-2); font-size: .95rem; line-height: 1.6; }
.lang-card .lchip { font-size: .72rem; line-height: 1.35; padding: .125rem .5rem; border-radius: var(--r-xs); white-space: nowrap; }

/* ---------- footer ---------- */
.site-foot { max-inline-size: 76rem; inline-size: 100%; margin: 0 auto; padding: 1.5rem 16px 2.5rem; border-block-start: 1px solid var(--line-soft); text-align: center; color: var(--text-2); font-size: .9em; display: grid; gap: .5rem; }
.foot-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; }
.foot-nav a { font-weight: var(--semi); padding-block: .25rem; }
.site-foot .muted { font-size: .92em; }
.foot-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .25rem .75rem; }
.link-btn { border: 0; background: none; padding: .25rem .25rem; color: var(--accent-ink); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.foot-note:empty { display: none; }
.chrome-en { font-family: var(--latin); line-height: 1.65; }
.preview-tag { display: inline-block; padding: .125rem .5rem; border-radius: var(--r-xs); background: var(--prob-wash); color: var(--prob-ink); font-weight: var(--semi); }

/* ---------- language dialog ---------- */
.sheet {
  padding: 0; border: 0; border-radius: var(--r);
  inline-size: min(30rem, calc(100vw - 32px)); max-block-size: min(88vh, 46rem);
  background: var(--surface); color: var(--text); box-shadow: 0 16px 40px rgba(7, 11, 25, .22);
}
.sheet::backdrop { background: rgba(7, 11, 25, .55); }
.sheet-inner { padding: 1rem 1rem 1.5rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-block-end: .5rem; }
.sheet-head h2 { font-size: 1.2em; }
.lang-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.lang-item {
  inline-size: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto 1.4rem; align-items: center; gap: .75rem;
  padding: .5rem 1rem; min-block-size: 3.4rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--raised); color: var(--text); text-decoration: none; text-align: start;
}
.lang-item:hover { border-color: var(--accent); }
.lang-item[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-wash); }
.lang-names { display: grid; min-inline-size: 0; }
.lang-names > span { justify-self: start; }
.lang-native { font-family: var(--system); font-size: 1.1rem; font-weight: 600; line-height: 1.5; }
.lang-native:lang(ur), .lang-native:lang(pnb) { font-family: "Nastaliq Installed", var(--system); font-weight: 400; }
html[data-script="nastaliq"] .lang-native:lang(ur), html[data-script="nastaliq"] .lang-native:lang(pnb) { font-family: var(--font-ui); }
.lang-english { font-family: var(--latin); font-size: .8rem; color: var(--muted); line-height: 1.3; }
.lang-chip { font-size: .75em; padding: .125rem .5rem; border-radius: var(--r-xs); white-space: nowrap; line-height: var(--lh-tight); }
.lang-state svg { inline-size: 1.3rem; block-size: 1.3rem; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 40rem) {
  .sheet {
    inline-size: 100%; max-inline-size: 100%; margin: auto 0 0; border-radius: var(--r) var(--r) 0 0;
    max-block-size: 88vh;
  }
  .sheet-inner { padding-inline: 16px; padding-block-end: max(1.5rem, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; animation: none !important; }
}
@media print {
  .topbar, .site-foot, .toc-side, .toc-top, .offline-card, .sort-choices, .q-choices .mark, .demo-root, .trace-ctrl, .l-done, .l-report, .copy-btn { display: none !important; }
  html.js .b-trace[data-play] .ev.is-later { display: grid !important; }
  body { background: #fff; color: #000; }
  /* the certificate prints alone, on its own landscape page */
  .page-cert main > :not(.cert-card), .page-cert .cert-card > :not(#certForm), .page-cert #certForm > :not(.cert-out),
  .page-cert .cert-out > :not(.cert-canvas) { display: none !important; }
  .page-cert .cert-card { border: 0; padding: 0; margin: 0; max-inline-size: none; }
  .page-cert .wrap { padding: 0; max-inline-size: none; }
  /* sized by height: at full width the A4-shaped drawing is a little taller than the page inside its margins */
  .page-cert .cert-canvas { border: 0; border-radius: 0; page: cert; display: block; inline-size: auto; block-size: 190mm; max-inline-size: 100%; margin-inline: auto; }
}
@page cert { size: A4 landscape; margin: 8mm; }
