@font-face { font-family: "SindhiNaskh"; src: url("NotoNaskhArabic.ttf") format("truetype"); font-display: swap; }

:root {
  --bg: #ffffff; --bg-soft: #f7f8fa; --bg-code: #f4f5f7; --ink: #1d2127; --ink-2: #4a525d; --muted: #6b7480;
  --line: #e6e8ec; --accent: #1a5fd0; --accent-soft: #eaf1fd; --ok: #18794e; --ok-soft: #e8f5ee; --bad: #b42318;
  --bad-soft: #fdeeec; --warn: #8a5a00; --warn-soft: #fdf5e3; --header-h: 60px; --side-w: 264px; --toc-w: 220px;
}
:root[data-theme="dark"] {
  --bg: #111418; --bg-soft: #161a1f; --bg-code: #1b2027; --ink: #e6e9ed; --ink-2: #c2c8d0; --muted: #959eaa;
  --line: #262c34; --accent: #78a5f5; --accent-soft: #1a2638; --ok: #52c48e; --ok-soft: #13271e; --bad: #f6776c;
  --bad-soft: #2b1715; --warn: #f0b74e; --warn-soft: #2a2213;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --bg-soft: #161a1f; --bg-code: #1b2027; --ink: #e6e9ed; --ink-2: #c2c8d0; --muted: #959eaa;
    --line: #262c34; --accent: #78a5f5; --accent-soft: #1a2638; --ok: #52c48e; --ok-soft: #13271e; --bad: #f6776c;
    --bad-soft: #2b1715; --warn: #f0b74e; --warn-soft: #2a2213;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ar { font-family: "SindhiNaskh", "Noto Naskh Arabic", serif; direction: rtl; unicode-bidi: isolate; }
.doc p .ar, .doc li .ar, .doc td .ar, .call .ar { font-size: 1.3em; line-height: 1; }  /* dots must be visible */

/* header */
.top { position: sticky; top: 0; z-index: 20; height: var(--header-h); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.top .in { height: 100%; display: flex; align-items: center; gap: 22px; padding: 0 20px; max-width: 1440px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 16.5px; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid;
  place-items: center; font-family: "SindhiNaskh", serif; font-size: 17px; line-height: 1; }
.top nav { display: flex; gap: 4px; margin-left: 8px; }
.top nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 6px; font-size: 14.5px; }
.top nav a:hover, .top nav a.on { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.top .sp { flex: 1; }
.iconbtn { border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); width: 34px; height: 34px;
  border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { color: var(--ink); background: var(--bg-soft); }
.iconbtn svg { width: 17px; height: 17px; }
.menu-btn { display: none; }

/* layout */
.shell { max-width: 1440px; margin: 0 auto; display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w); }
.side { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto;
  border-right: 1px solid var(--line); padding: 20px 14px 40px 20px; }
.side h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 10px 6px;
  font-weight: 600; }
.side h4:first-child { margin-top: 2px; }
.side a { display: block; color: var(--ink-2); padding: 5px 10px; border-radius: 6px; font-size: 14.5px; }
.side a:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.content { padding: 36px 48px 80px; min-width: 0; }
.doc { max-width: 780px; margin: 0 auto; }
.toc { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 36px 20px 40px 8px; }
.toc h5 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.toc a { display: block; color: var(--muted); font-size: 13.5px; padding: 3px 0 3px 10px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }
.toc a.l3 { padding-left: 22px; }
@media (max-width: 1200px) { .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 30; top: var(--header-h); left: 0; width: 280px; background: var(--bg);
    transform: translateX(-100%); transition: transform .2s; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  body.nav-open .side { transform: none; }
  .menu-btn { display: grid; }
  .top nav { display: none; }
  .content { padding: 24px 16px 60px; }
}

/* typography */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.doc h1 { font-size: 34px; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 12px; font-weight: 650; }
.doc .lede { font-size: 18px; color: var(--ink-2); margin: 0 0 28px; }
.doc h2 { font-size: 23px; margin: 42px 0 12px; padding-top: 6px; font-weight: 640; letter-spacing: -.005em; }
.doc h3 { font-size: 18px; margin: 28px 0 8px; font-weight: 620; }
.doc h2 .anchor, .doc h3 .anchor { opacity: 0; margin-left: 6px; color: var(--muted); font-weight: 400; }
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: 1; }
.doc p, .doc li { color: var(--ink); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
code { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace; font-size: .88em;
  background: var(--bg-code); padding: 2px 5px; border-radius: 5px; }
pre { position: relative; background: var(--bg-code); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.6; }
pre code { background: none; padding: 0; font-size: inherit; }
pre .copy { position: absolute; top: 8px; right: 8px; border: 1px solid var(--line); background: var(--bg);
  color: var(--muted); font: 12px system-ui, sans-serif; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .15s; }
pre:hover .copy, pre .copy:focus { opacity: 1; }
pre .label { display: block; font: 11.5px system-ui, sans-serif; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .06em; }
.c-com { color: var(--muted); }

/* tables */
.tbl { overflow-x: auto; margin: 16px 0 20px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; font-size: 13px; color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hl td { background: var(--accent-soft); }

/* callouts and cards */
.call { border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--bg-soft);
  border-radius: 8px; padding: 12px 16px; margin: 18px 0; }
.call.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.call.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.call.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.call > :first-child { margin-top: 0; } .call > :last-child { margin-bottom: 0; }
.call b.t { display: block; margin-bottom: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 22px 0; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; color: var(--ink); background: var(--bg); }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 24px 0; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .k { font-size: 13px; color: var(--muted); }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 15px; cursor: pointer; font-family: inherit; }
:root[data-theme="dark"] .btn { color: #0f1216; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0f1216; } }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.sec { background: transparent; color: var(--accent); border-color: var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; }
.pager a { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--ink); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { display: block; color: var(--muted); font-size: 12.5px; }
.pager .next { text-align: right; grid-column: 2; }
.foot { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 40px; padding-top: 16px; }
figure.diagram { margin: 20px 0; border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--bg-soft); }
figure.diagram figcaption { font-size: 13px; color: var(--muted); margin-top: 10px; }
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 10px; align-items: center; }
.flow .box { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; text-align: center; }
.flow .box b { display: block; font-size: 14.5px; }
.flow .arr { color: var(--muted); }
@media (max-width: 700px) { .flow { grid-template-columns: 1fr; } .flow .arr { transform: rotate(90deg); justify-self: center; } }
