/* Life on Replay — "Sadu weaving meets the late-night rebroadcast" (see docs/design-brief.md) */
:root {
  --sand: #f2e8d5;            /* undyed wool: page */
  --paper: #faf4e8;           /* raised surfaces */
  --paper-2: #ece0c8;
  --ink: #1b1d26;             /* indigo-black */
  --ink-2: #4a4552;
  --muted: #5d5862;
  --coral: #c0573f;           /* madder, decorative */
  --signal: #a3312a;          /* madder: timestamps, current item, buttons */
  --signal-ink: #fff7ec;
  --signal-text: #a3312a;
  --coral-text: #8f2c25;
  --amber: #d9952b;           /* dawn: glow and progress */
  --amber-soft: rgba(217, 149, 43, .26);
  --amber-text: #8a5a0e;      /* amber for text: 4.8:1 on wool */
  --grid: rgba(27, 29, 38, .05);
  --grid-strong: rgba(27, 29, 38, .1);
  --rule: rgba(27, 29, 38, .2);
  --card: rgba(250, 244, 232, .8);
  --shadow: 0 1px 0 rgba(27,29,38,.06), 0 12px 30px -18px rgba(60,30,20,.45);
  --f-display: "Gloock", Georgia, serif;
  --f-body: "Newsreader", "Noto Naskh Arabic", Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 42rem;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sand: #121319; --paper: #1b1c25; --paper-2: #23242f; --ink: #efe5d1; --ink-2: #c9bfae; --muted: #9a93a0;
    --coral: #e2685c; --signal: #e2685c; --signal-ink: #1a0f0d; --signal-text: #ec7d71; --coral-text: #ec7d71;
    --amber: #f0b354; --amber-text: #f0b354; --amber-soft: rgba(240, 179, 84, .16);
    --grid: rgba(239,229,209,.04); --grid-strong: rgba(239,229,209,.08);
    --rule: rgba(239,229,209,.18); --card: rgba(27,28,37,.82); --shadow: 0 1px 0 rgba(0,0,0,.3), 0 14px 34px -20px rgba(0,0,0,.85);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sand: #121319; --paper: #1b1c25; --paper-2: #23242f; --ink: #efe5d1; --ink-2: #c9bfae; --muted: #9a93a0;
  --coral: #e2685c; --signal: #e2685c; --signal-ink: #1a0f0d; --signal-text: #ec7d71; --coral-text: #ec7d71;
  --amber: #f0b354; --amber-text: #f0b354; --amber-soft: rgba(240, 179, 84, .16);
  --grid: rgba(239,229,209,.04); --grid-strong: rgba(239,229,209,.08);
  --rule: rgba(239,229,209,.18); --card: rgba(27,28,37,.82); --shadow: 0 1px 0 rgba(0,0,0,.3), 0 14px 34px -20px rgba(0,0,0,.85);
  color-scheme: dark;
}
html[lang="ar"] {
  --f-display: "Aref Ruqaa", "Noto Naskh Arabic", serif;
  --f-body: "Noto Naskh Arabic", "Newsreader", serif;
  --f-mono: "IBM Plex Mono", "Noto Naskh Arabic", monospace;
}
/* Sadu band: rows of small triangles over a diamond chain, used as a mask so it takes any colour */
:root {
  --sadu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='14' viewBox='0 0 24 14'%3E%3Cpath d='M0 0h24v1.5H0zM0 12.5h24V14H0zM0 3l3 3 3-3 3 3 3-3 3 3 3-3 3 3 3-3v1.6l-3 3-3-3-3 3-3-3-3 3-3-3-3 3-3-3z M12 6.2l2.6 2.6L12 11.4 9.4 8.8z M0 6.2l2.6 2.6L0 11.4zM24 6.2l-2.6 2.6 2.6 2.6z'/%3E%3C/svg%3E");
  --weave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M0 0l7 7 7-7zM14 14l7 7 7-7zM14 0l7 7 7-7zM0 14l7 7 7-7z'/%3E%3C/svg%3E");
}
/* Arabic letters must stay joined: no tracking or uppercase transforms */
html[lang="ar"] body * { letter-spacing: 0 !important; text-transform: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--sand);
  /* dawn at the top of every page, over undyed wool */
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -12%, var(--amber-soft), transparent 62%),
    radial-gradient(ellipse 80% 40% at 50% -8%, color-mix(in srgb, var(--coral) 14%, transparent), transparent 70%);
  background-repeat: no-repeat;
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-x: hidden;
}
html[lang="ar"] body { font-size: 1.15rem; line-height: 1.95; }
a { color: inherit; text-decoration-color: var(--coral); text-underline-offset: .2em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--signal-text); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { inset-inline-start: 8px; }

/* ---------- header ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
  background: var(--sand);
  background: color-mix(in srgb, var(--sand) 86%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--f-display); font-size: 1.05rem; white-space: nowrap; }
.mark {
  width: 26px; height: 26px; flex: none; transform: rotate(45deg) scale(.78); border-radius: 2px;
  background:
    linear-gradient(var(--sand), var(--sand)) center / 40% 40% no-repeat,
    conic-gradient(var(--signal) 0 25%, var(--ink) 0 50%, var(--signal) 0 75%, var(--ink) 0);
}
.bar-nav { display: flex; align-items: center; gap: 8px; }
.toc { position: relative; }
.toc summary {
  list-style: none; cursor: pointer; font-family: var(--f-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 12px; border: 1px solid var(--rule); border-radius: 999px;
}
.toc summary::-webkit-details-marker { display: none; }
.toc[open] summary { background: var(--ink); color: var(--paper); }
.toc ol {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); margin: 0; padding: 8px; list-style: none;
  width: min(360px, calc(100vw - 32px)); background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow);
}
.toc li a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; text-decoration: none; line-height: 1.35; font-size: .95rem; }
.toc li a:hover, .toc li a[aria-current] { background: var(--paper-2); color: var(--ink); }
.toc .n { font-family: var(--f-mono); font-size: .7rem; color: var(--signal-text); padding-top: .2em; }
.toc .extra { border-top: 1px dashed var(--rule); margin-top: 4px; padding-top: 4px; }
.lang { font-family: var(--f-mono); font-size: .75rem; padding: 7px 10px; text-decoration: none; border-radius: 999px; }
html[lang="en"] .lang { font-family: "Noto Naskh Arabic", serif; font-size: .95rem; padding-block: 3px; }
.theme { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.theme span { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 1.5px solid var(--ink); }
@media (max-width: 360px) { .brand { font-size: .9rem; gap: 7px; } .brand .mark { width: 22px; height: 22px; } }

/* ---------- woven texture behind heads ---------- */
.lattice {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: var(--grid-strong);
  -webkit-mask: var(--weave) 0 0 / 28px 28px, radial-gradient(ellipse 70% 90% at 50% 0%, #000 20%, transparent 75%);
          mask: var(--weave) 0 0 / 28px 28px, radial-gradient(ellipse 70% 90% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}

/* ---------- hero (home) ---------- */
.hero { position: relative; padding: clamp(48px, 10vw, 120px) var(--gutter) 40px; max-width: 72rem; margin: 0 auto; overflow: hidden; }
.hero > *:not(.lattice) { position: relative; }
.kicker { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--signal-text); margin: 0 0 10px; }
html[lang="ar"] .kicker { font-family: var(--f-body); letter-spacing: 0; font-size: .95rem; font-weight: 600; }
.hero h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2.6rem, 9vw, 6.4rem); line-height: .98; margin: 0; letter-spacing: -.02em; max-width: 12ch; }
html[lang="ar"] .hero h1 { line-height: 1.25; letter-spacing: 0; font-weight: 700; }
.hero .sub { font-size: clamp(1.05rem, 2.4vw, 1.35rem); max-width: 36rem; color: var(--ink-2); margin: 18px 0 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px; text-decoration: none;
  background: var(--signal-text); color: var(--signal-ink); font-family: var(--f-mono); font-size: .8rem; box-shadow: var(--shadow);
}
.btn:hover { color: var(--signal-ink); transform: translateY(-1px); }

/* ---------- chapter head ---------- */
.chapter-head { position: relative; padding: clamp(36px, 8vw, 88px) var(--gutter) 28px; max-width: 72rem; margin: 0 auto; overflow: hidden; }
.chapter-head.plain { padding: 24px; min-height: 40px; }
.chapter-head > *:not(.lattice) { position: relative; }
.big-n {
  position: absolute !important; inset-inline-end: var(--gutter); top: 10px; font-family: var(--f-display); font-size: clamp(7rem, 26vw, 18rem);
  line-height: 1; color: transparent; -webkit-text-stroke: 1.5px var(--coral); opacity: .55; user-select: none;
}
.chapter-head h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 6.4vw, 4.2rem); line-height: 1.05; margin: 0 0 22px; max-width: 16ch; letter-spacing: -.01em; }
html[lang="ar"] .chapter-head h1 { line-height: 1.35; font-weight: 700; letter-spacing: 0; }

/* ---------- prose ---------- */
.prose { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 8px var(--gutter) 40px; }
.prose > * { max-width: var(--measure); }
.prose h2 {
  font-family: var(--f-display); font-weight: 400; font-size: clamp(1.5rem, 3.6vw, 2rem); line-height: 1.2; margin: 2.4em 0 .6em;
  padding-top: .6em; border-top: 1px solid var(--rule); position: relative;
}
.prose h2::before { content: "§"; font-family: var(--f-mono); font-size: .7rem; color: var(--signal-text); position: absolute; top: -1.1em; inset-inline-start: 0; }
html[lang="ar"] .prose h2 { font-weight: 700; }
.prose h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.25rem; margin: 1.8em 0 .4em; }
html[lang="ar"] .prose h3 { font-weight: 500; }
.prose blockquote {
  margin: 1.2em 0 2em; padding: 0; border: 0; font-family: var(--f-display); font-size: clamp(1.35rem, 3.4vw, 1.9rem); line-height: 1.35; color: var(--ink);
  position: relative; padding-inline-start: 1.2em;
}
.prose blockquote::before { content: ""; position: absolute; inset-inline-start: 0; top: .2em; bottom: .2em; width: 4px; background: var(--signal); border-radius: 2px; }
.prose blockquote p { margin: 0; }
.prose blockquote .ts { font-size: .7rem; vertical-align: middle; }
html[lang="ar"] .prose blockquote { font-family: var(--f-body); font-weight: 600; line-height: 1.9; }
.prose ul, .prose ol { padding-inline-start: 1.3em; }
.prose li { margin: .55em 0; }
.prose li::marker { color: var(--coral); }
.prose strong { font-weight: 600; }
.prose code { font-family: var(--f-mono); font-size: .8em; background: var(--paper-2); padding: .1em .35em; border-radius: 4px; }
.table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); max-width: none !important; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; line-height: 1.5; }
.prose th, .prose td { padding: 10px 12px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose th { font-family: var(--f-mono); font-weight: 600; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); background: var(--paper-2); }
html[lang="ar"] .prose th { font-family: var(--f-body); font-size: .9rem; letter-spacing: 0; }
.prose tr:last-child td { border-bottom: 0; }

/* timestamp chip */
.ts {
  display: inline-flex; align-items: center; gap: .35em; padding: .14em .6em .14em .5em; margin: 0 .1em; border-radius: 999px;
  font-family: var(--f-mono); font-size: .72rem; line-height: 1.7; text-decoration: none; white-space: nowrap; direction: ltr;
  color: var(--signal-text); border: 1px solid var(--signal); border: 1px solid color-mix(in srgb, var(--signal) 45%, transparent); background: transparent; background: color-mix(in srgb, var(--signal) 8%, transparent);
  vertical-align: .08em;
}
.ts span { font-size: .6em; }
.ts:hover { background: var(--signal); color: var(--signal-ink); }
.ts.big { font-size: .8rem; padding: .4em .9em; }

/* home cards */
.cards { list-style: none; padding: 0; margin: 1.5em 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; max-width: none !important; }
.prose.home { max-width: 72rem; }
.card a {
  display: grid; gap: 8px; min-height: 170px; padding: 18px; text-decoration: none; border-radius: 12px; position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--rule); box-shadow: var(--shadow); transition: transform .25s ease, border-color .25s;
}
.card a::after { content: ""; position: absolute; inset-inline-end: -30px; bottom: -30px; width: 110px; height: 110px; opacity: .35;
  background: repeating-linear-gradient(45deg, transparent 0 8px, var(--coral) 8px 9px), repeating-linear-gradient(-45deg, transparent 0 8px, var(--coral) 8px 9px); border-radius: 50%; }
.card a:hover { transform: translateY(-3px); border-color: var(--signal-text); color: var(--ink); }
.card-n { font-family: var(--f-display); font-size: 2.4rem; line-height: 1; color: var(--signal-text); }
.card-t { font-family: var(--f-display); font-size: 1.15rem; line-height: 1.25; }
html[lang="ar"] .card-t { font-weight: 500; line-height: 1.6; }
.card-m { font-family: var(--f-mono); font-size: .68rem; color: var(--muted); align-self: end; }
html[lang="ar"] .card-m { font-family: var(--f-body); font-size: .85rem; }

/* pager & footer */
.pager { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto 40px; padding: 0 var(--gutter); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; background: var(--card); line-height: 1.35; }
.pager a:hover { border-color: var(--signal-text); }
.pager small { display: block; font-family: var(--f-mono); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--signal-text); margin-bottom: 4px; }
html[lang="ar"] .pager small { font-family: var(--f-body); font-size: .85rem; letter-spacing: 0; }
.pager .next { text-align: end; }
.foot { border-top: 1px solid var(--rule); padding: 24px var(--gutter) 40px; font-size: .85rem; color: var(--muted); text-align: center; }
.foot p { margin: .3em 0; }

/* ---------- widgets ---------- */
.widget {
  max-width: none !important; margin: 1.4em 0 1em; padding: clamp(14px, 3vw, 22px); border-radius: 14px; position: relative;
  background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--shadow);
}
.widget::before { content: attr(data-fig); position: absolute; top: -.8em; inset-inline-start: 16px; padding: 0 8px; background: var(--sand);
  font-family: var(--f-mono); font-size: .65rem; letter-spacing: .08em; color: var(--signal-text); text-transform: uppercase; }
.widget h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; margin: 0 0 .6em; }
.widget .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.widget button.chip, .widget .seg button {
  font: inherit; font-family: var(--f-mono); font-size: .72rem; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rule); background: transparent; color: var(--ink);
}
html[lang="ar"] .widget button.chip, html[lang="ar"] .widget .seg button { font-family: var(--f-body); font-size: .9rem; padding: 4px 12px; }
.widget button[aria-pressed="true"], .widget .seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.widget button.go { background: var(--signal-text); color: var(--signal-ink); border-color: var(--signal-text); }
.widget input[type="range"] { width: 100%; accent-color: var(--signal-text); }
.widget .note { font-size: .9rem; color: var(--ink-2); margin: .6em 0 0; line-height: 1.55; }
.widget .label { font-family: var(--f-mono); font-size: .68rem; fill: var(--muted); color: var(--muted); }
html[lang="ar"] .widget .label { font-family: var(--f-body); font-size: .8rem; }
.widget svg { display: block; width: 100%; height: auto; overflow: visible; }
.widget .panel { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--paper-2); font-size: .95rem; line-height: 1.55; }
.widget .panel b { font-weight: 600; }
.widget .big-stat { font-family: var(--f-display); font-size: 2rem; color: var(--signal-text); line-height: 1; direction: ltr; unicode-bidi: isolate; }
.widget .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .widget .grid2 { grid-template-columns: 1fr; } }
.widget .col { padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--rule); }
.widget .col h4 { margin: 0 0 6px; font-family: var(--f-mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--signal-text); }
html[lang="ar"] .widget .col h4 { font-family: var(--f-body); font-size: .95rem; letter-spacing: 0; }
.widget .col ul { margin: 0; padding-inline-start: 1.1em; font-size: .95rem; }
.draw path.ln, .draw polyline.ln { stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000); animation: draw 1.4s ease forwards .2s; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- load choreography ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero > *:not(.lattice), .chapter-head > *:not(.lattice) { animation: rise .8s cubic-bezier(.2,.7,.2,1) both; }
  .hero > :nth-child(2), .chapter-head > :nth-child(2) { animation-delay: .05s; }
  .hero > :nth-child(3), .chapter-head > :nth-child(3) { animation-delay: .15s; }
  .hero > :nth-child(4), .chapter-head > :nth-child(4) { animation-delay: .25s; }
  .hero > :nth-child(5), .chapter-head > :nth-child(5) { animation-delay: .35s; }
  .big-n { animation: ghost 1.4s ease both !important; }
  .lattice { animation: fade 1.6s ease both; }
  .reveal > * { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(.35s + var(--d, 0) * 60ms); }
  .card { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(.5s + var(--i) * 70ms); }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ghost { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: .55; transform: none; } }
@keyframes fade { from { opacity: 0; } }

/* language splash */
.splash { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.splash .inner { position: relative; text-align: center; display: grid; gap: 22px; }
.splash h1 { font-family: "Gloock", serif; font-weight: 400; font-size: clamp(2.2rem, 8vw, 4.5rem); margin: 0; line-height: 1.05; }
.splash h1 span { display: block; font-family: "Aref Ruqaa", serif; font-weight: 700; font-size: .8em; margin-top: .25em; }
.splash .choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.splash .choices a { min-width: 150px; padding: 14px 22px; border-radius: 999px; text-decoration: none; border: 1.5px solid var(--ink); font-size: 1.1rem; }
.splash .choices a:first-child { background: var(--ink); color: var(--paper); }
.splash .choices a:hover { background: var(--signal); border-color: var(--signal-text); color: var(--signal-ink); }

/* hero figure: the episode as a broadcast tape, chapters as woven diamonds */
.tape { margin: 34px 0 0; max-width: 46rem; position: relative; }
.tape svg { width: 100%; height: auto; display: block; overflow: visible; }
.tape .track { fill: var(--rule); }
.tape .played { fill: var(--signal); }
.tape .tick { fill: var(--ink); }
.tape .tick.lit { fill: var(--amber); }
.tape .head { fill: var(--signal); }
.tape svg, .tape text { direction: ltr; unicode-bidi: isolate; }
.tape text { font-family: "IBM Plex Mono", monospace; font-size: 11px; fill: var(--muted); }
html[lang="ar"] .tape .rec { font-family: "Noto Naskh Arabic", serif; font-size: 13px; letter-spacing: 0; }
@media (max-width: 600px) { .tape text { font-size: 17px; } html[lang="ar"] .tape .rec { font-size: 19px; } .tape { margin-top: 26px; } }
.tape .rec { fill: var(--signal); font-weight: 500; letter-spacing: .08em; }
@media (prefers-reduced-motion: no-preference) {
  .tape .played { animation: play 2.4s cubic-bezier(.3,.1,.2,1) both .6s; transform-box: fill-box; }
  html[dir="ltr"] .tape .played { transform-origin: left; }
  html[dir="rtl"] .tape .played { transform-origin: right; }
  .tape .tick { animation: fade .3s ease both; animation-delay: calc(.7s + var(--i) * 140ms); }
  .tape .rec { animation: blink 1.6s steps(2, end) infinite 3s; }
}
@keyframes play { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes blink { 50% { opacity: .25; } }
.tsw { white-space: nowrap; }

/* ---------- navigation: home link, drawer, bottom bar ---------- */
.home-link { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 12px; border-radius: 999px; text-decoration: none; border: 1px solid transparent; }
.home-link:hover { border-color: var(--rule); }
.home-link.is-here { color: var(--signal-text); }
.home-link svg, .icon-btn svg, .bn svg, .drawer-home svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
html[dir="rtl"] svg.dir { transform: scaleX(-1); }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.bar .open-menu { display: none; }

.drawer {
  margin: 0; margin-inline-start: auto; height: 100vh; height: 100dvh; max-height: none; width: min(380px, 88vw); padding: 0; border: 0;
  border-inline-start: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  display: none; flex-direction: column; box-shadow: var(--shadow);
}
.drawer[open] { display: flex; animation: drawer-in .24s cubic-bezier(.2,.8,.2,1) both; }
.drawer.closing { animation: drawer-out .18s ease-in both; }
.drawer::backdrop { background: rgba(0,0,0,.45); background: color-mix(in srgb, var(--ink) 45%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { to { transform: translateX(100%); } }
html[dir="rtl"] .drawer[open] { animation-name: drawer-in-rtl; }
html[dir="rtl"] .drawer.closing { animation-name: drawer-out-rtl; }
@keyframes drawer-in-rtl { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out-rtl { to { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule);
  background: repeating-linear-gradient(45deg, transparent 0 9px, var(--rule) 9px 10px); }
.drawer-title { font-family: var(--f-display); font-size: 1.15rem; }
.drawer nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.drawer a { text-decoration: none; }
.drawer-home { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 8px; font-weight: 600; }
.drawer-label { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--signal-text); margin: 14px 12px 6px; }
.drawer ol, .drawer-extra { list-style: none; margin: 0; padding: 0; }
.drawer ol a { display: flex; gap: 12px; padding: 10px 12px; border-radius: 8px; line-height: 1.4; }
.drawer ol .n { font-family: var(--f-mono); font-size: .72rem; color: var(--signal-text); padding-top: .25em; min-width: 1.6em; }
.drawer-extra { border-top: 1px dashed var(--rule); margin-top: 10px; padding-top: 8px; }
.drawer-extra a { display: block; padding: 10px 12px; border-radius: 8px; }
.drawer a:hover, .drawer a[aria-current] { background: var(--paper-2); }
.drawer a[aria-current] { box-shadow: inset 3px 0 0 var(--signal); }
html[dir="rtl"] .drawer a[aria-current] { box-shadow: inset -3px 0 0 var(--signal); }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); }
.drawer-foot .lang { border: 1px solid var(--rule); }

.bottom-nav { display: none; }
@media (max-width: 720px) {
  .bar .toc, .bar .lang, .bar > .bar-nav > .theme, .home-link { display: none; }
  .bar .open-menu { display: grid; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--paper); background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule); box-shadow: 0 -6px 20px rgba(0,0,0,.08);
  }
  .bn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: 0; background: none; color: var(--ink);
    font: inherit; font-family: var(--f-mono); font-size: .62rem; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; border-radius: 10px; cursor: pointer; }
  .bn svg { width: 22px; height: 22px; }
  .bn[aria-current] { color: var(--signal-text); }
  .bn[aria-disabled] { opacity: .3; }
  .bn:active { background: var(--paper-2); }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}
body.menu-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .drawer[open], .drawer.closing { animation: none; } }
.drawer.fallback { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 50; }

/* audit fixes: Arabic emphasis and label sizes */
html[lang="ar"] em, html[lang="ar"] i { font-style: normal; color: var(--ink-2); font-weight: 600; }
html[lang="ar"] .kicker, html[lang="ar"] .pager small, html[lang="ar"] .drawer-label, html[lang="ar"] .bn, html[lang="ar"] .toc summary { font-size: .82rem; }
.table-wrap:focus-visible { outline-offset: 2px; }

/* Try-it additions */
.widget .fund-l { fill: var(--ink-2); }
.widget .pipe-step.lost { opacity: .45; text-decoration: line-through; text-decoration-color: var(--coral-text); }
.widget .published-first .pipe-branch { opacity: .45; }
.widget h4.sub-h { font-family: var(--f-display); font-weight: 400; font-size: 1.05rem; margin: 0 0 .6em; }
.widget .fields { gap: 14px; align-items: flex-end; }
.widget .field { display: grid; gap: 4px; flex: 1 1 180px; }
.widget .field input { font: inherit; font-family: var(--f-mono); font-size: 1rem; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); width: 100%; box-sizing: border-box; }
.widget .plan-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--rule); }
.widget .plan-row b { white-space: nowrap; font-family: var(--f-mono); }
.widget .plan-row.total { border-bottom: 0; font-weight: 600; }
.widget .plan-row.total b { color: var(--signal-text); }
.widget .deal-flow { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.widget .deal-flow li { position: relative; padding: 10px; border: 1px solid var(--rule); border-radius: 10px; font-size: .9rem; line-height: 1.4; transition: opacity .25s, border-color .25s; }
.widget .deal-flow li .pn { display: block; font-family: var(--f-mono); font-size: .75rem; color: var(--signal-text); margin-bottom: 4px; }
.widget .deal-flow li.on { border-color: var(--signal-text); }
.widget .deal-flow li.dim { opacity: .45; }
.widget .deal-io { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }
.widget .deal-io p { margin: 2px 0 0; }
@media (max-width: 560px) { .widget .deal-flow { grid-template-columns: 1fr 1fr; } .widget .deal-io { grid-template-columns: 1fr; } }

/* ---------- study tools (stage 6) ---------- */
.widget .ask { margin-top: -.3em; }
.widget .row.spread { justify-content: space-between; }
.widget .stack { display: flex; flex-direction: column; gap: 8px; }
.widget button.chip.wide { text-align: start; border-radius: 12px; padding: 9px 12px; font-family: var(--f-body); font-size: .95rem; line-height: 1.4; }
.widget button.chip.tiny { padding: 2px 8px; font-size: .65rem; margin-inline-start: 6px; }
html[lang="ar"] .widget button.chip.tiny { font-size: .75rem; }
.widget button:disabled { opacity: .55; cursor: default; }
.widget button:focus-visible, .widget input:focus-visible, .widget a:focus-visible { outline: 2px solid var(--signal-text); outline-offset: 2px; }
.widget .seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.widget .seg button { font-family: var(--f-body); font-size: .85rem; }
.widget .q { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.widget .field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.widget .field label { font-size: .85rem; color: var(--ink-2); }
.widget input[type="text"] { font: inherit; font-size: 1rem; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); width: 100%; box-sizing: border-box; }
.widget input[type="text"]::placeholder { color: var(--muted); opacity: .8; }
.widget .empty { color: var(--muted); list-style: none; margin-inline-start: -1.1em; }
.widget .scoreboard { text-align: center; padding: 12px; border-radius: 10px; background: var(--paper-2); }
.widget .score { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 6px; font-size: .95rem; }
.widget .clock { direction: ltr; unicode-bidi: isolate; }
.widget .meter { height: 6px; border-radius: 99px; background: var(--rule); margin: 12px 0 10px; overflow: hidden; }
.widget .meter i { display: block; height: 100%; width: 0; background: var(--signal-text); }
.widget .jar-wrap { max-width: 220px; margin: 10px auto 6px; }
.widget .ladder .rung { font-size: 12px; }
.widget .big-stat.small { font-size: 1.4rem; margin: 10px 0; }
.widget .chip.take[aria-pressed="true"] { background: transparent; color: var(--muted); border-style: dashed; border-color: var(--muted); text-decoration: line-through; }
.widget .scene { margin: 10px 0; }
.widget .scene .ctx { margin: 0 0 8px; font-weight: 600; }
.widget .circ { cursor: pointer; }
.widget .out { margin-top: 12px; }
.widget[data-widget="kit"] { padding-top: clamp(16px, 3vw, 24px); }
.kit-list { list-style: none; margin: 8px 0 18px; padding: 0 !important; }
.kit-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 9px 4px; border-bottom: 1px solid var(--rule); margin: 0 !important; }
.kit-list li::marker { content: none; }
.kit-list input[type="checkbox"] { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--signal-text); }
.kit-list label { cursor: pointer; line-height: 1.45; }
.kit-list li.on label { font-weight: 600; }
.kit-list .ch { white-space: nowrap; text-decoration: none; padding-top: 3px; }
.widget .actions { margin-top: 14px; }

@media print {
  .bar, .bottom-nav, .foot, .drawer, .chapter-head, .skip, .pager { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal > * { opacity: 1 !important; transform: none !important; }
  .widget { box-shadow: none !important; border: 0 !important; padding: 0 !important; background: none !important; }
  .widget::before, .widget .actions, .widget .note, .kit-list input, .kit-list .ch { display: none !important; }
  .kit-list li:not(.on), .widget .field.blank { display: none !important; }
  .kit-list li { grid-template-columns: 1fr; border: 0; padding: 2px 0; }
  .kit-list li.on label::before { content: "☐  "; }
  .widget input[type="text"] { border: 0; border-bottom: 1px solid #999; border-radius: 0; padding: 4px 0; background: none; }
}

/* ---------- Sadu bands ---------- */
.sadu, .bar::after, .foot::before {
  content: ""; display: block; height: 14px; background: var(--signal);
  -webkit-mask: var(--sadu) 0 0 / 24px 14px repeat-x; mask: var(--sadu) 0 0 / 24px 14px repeat-x;
}
.bar { flex-wrap: wrap; border-bottom: 0; padding-bottom: 0; }
.bar::after { flex: 1 0 100%; margin: 10px calc(-1 * var(--gutter)) 0; height: 10px; -webkit-mask-size: 17px 10px; mask-size: 17px 10px; }
.foot { border-top: 0; padding-top: 0; }
.foot::before { margin: 0 calc(-1 * var(--gutter)) 24px; opacity: .85; }
.prose h2 { border-top: 0; padding-top: 1.1em; }
.prose h2::before {
  content: ""; top: 0; width: 72px; height: 7px; background: var(--signal);
  -webkit-mask: var(--sadu) 0 0 / 12px 7px repeat-x; mask: var(--sadu) 0 0 / 12px 7px repeat-x;
}
.prose h2::after { content: ""; position: absolute; top: 3px; inset-inline-start: 80px; inset-inline-end: 0; height: 1px; background: var(--rule); }

/* broadcast details: the replay chip, the tape counter on chapter heads */
.ts { border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; }
.ts span { font-size: .55em; }
.ts.big { font-size: .78rem; padding: .5em 1em; background: var(--signal); color: var(--signal-ink); border-color: var(--signal); box-shadow: var(--shadow); }
.ts.big:hover { background: var(--ink); color: var(--sand); border-color: var(--ink); }
.kicker::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: var(--signal); margin-inline-end: .6em; vertical-align: .05em; box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent); }
.big-n { -webkit-text-stroke: 1.5px var(--amber); opacity: .7; }
html[lang="ar"] .big-n { font-family: "Gloock", serif; }
.hero h1 { letter-spacing: -.01em; }
html[lang="ar"] .hero h1, html[lang="ar"] .chapter-head h1 { font-weight: 700; line-height: 1.45; }
html[lang="ar"] .prose h2, html[lang="ar"] .prose h3 { font-weight: 700; line-height: 1.6; }
.prose blockquote { font-style: normal; }
.prose blockquote::before { background: linear-gradient(var(--signal), var(--amber)); }
html[lang="ar"] .prose blockquote { font-family: var(--f-body); }
.card a { border-radius: 6px; }
.card a::after { width: 100%; height: 7px; inset-inline: 0; bottom: 0; border-radius: 0; opacity: .8; background: var(--signal);
  -webkit-mask: var(--sadu) 0 0 / 12px 7px repeat-x; mask: var(--sadu) 0 0 / 12px 7px repeat-x; }
.card-n { font-family: "Gloock", serif; color: var(--amber-text); -webkit-text-stroke: 0; }
html[lang="ar"] .card-t { font-family: var(--f-display); font-weight: 700; font-size: 1.3rem; line-height: 1.5; }
.widget { border-radius: 8px; }
.widget::before { background: var(--sand); color: var(--signal-text); }
.widget .meter i { background: linear-gradient(90deg, var(--signal), var(--amber)); }
html[dir="rtl"] .widget .meter i { background: linear-gradient(-90deg, var(--signal), var(--amber)); }

/* page load: the band weaves in from the start edge, dawn brightens, then the heading rises */
@media (prefers-reduced-motion: no-preference) {
  .bar::after, .foot::before { animation: weave 1.1s cubic-bezier(.6,.1,.2,1) both .1s; }
  html[dir="rtl"] .bar::after, html[dir="rtl"] .foot::before { animation-name: weave-rtl; }
  .prose h2::before { animation: weave .9s cubic-bezier(.6,.1,.2,1) both .5s; }
  html[dir="rtl"] .prose h2::before { animation-name: weave-rtl; }
  body { animation: dawn 1.8s ease-out both; }
}
@keyframes weave { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes weave-rtl { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes dawn { from { background-position: 0 -120px, 0 -120px; } to { background-position: 0 0, 0 0; } }

/* the chapters menu sits above the Sadu band, with room below the header */
.toc { z-index: 30; }
.toc ol { z-index: 30; top: calc(100% + 22px); }
