/* KASBB user guide: same palette and type as the kasbb.com landing page (logo navy, paper, logo blue). */
:root {
  --ink: #14213d;
  --ink-2: #0e182e;
  --paper: #f5f7fa;
  --card: #ffffff;
  --line: #dbe2ec;
  --muted: #586477;
  --text: #14213d;
  --blue: #2563eb;
  --blue-ink: #1d4ed8;
  --blue-soft: #e7eefd;
  --on-ink: #e9eef6;
  --on-ink-muted: #aab6cc;
  --tip: #0f7a43; --tip-soft: #e7f5ed;
  --warn: #9a5b00; --warn-soft: #fdf3e2;
  --code-bg: #eef2f7;
  --display: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  --radius: 14px;
  --top: 64px;
  --side: 290px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1524; --card: #111e31; --line: #23344d; --muted: #9aa8bc; --text: #e6ecf5;
    --blue: #6d9bff; --blue-ink: #9dbcff; --blue-soft: #16294a;
    --tip: #5fd197; --tip-soft: #10291e; --warn: #f2b35a; --warn-soft: #2d2213; --code-bg: #18273d;
    --ink: #08111e; --ink-2: #0f1c2f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b1524; --card: #111e31; --line: #23344d; --muted: #9aa8bc; --text: #e6ecf5;
  --blue: #6d9bff; --blue-ink: #9dbcff; --blue-soft: #16294a;
  --tip: #5fd197; --tip-soft: #10291e; --warn: #f2b35a; --warn-soft: #2d2213; --code-bg: #18273d;
  --ink: #08111e; --ink-2: #0f1c2f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--text); font-family: var(--body); font-size: 17px; line-height: 1.85; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; background: var(--blue); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 10px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding-inline: max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-left)); background: var(--ink); color: var(--on-ink);
  border-bottom: 1px solid rgba(255,255,255,.06); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand strong { display: block; font-family: var(--display); font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand small { display: block; font-size: 12px; color: var(--on-ink-muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--blue); display: grid; place-items: center; color: #fff; }
:root[data-theme="dark"] .brand-mark { background: #2563eb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark { background: #2563eb; } }
.menu-btn { display: none; background: none; border: 0; color: inherit; padding: 8px; margin-inline-start: -8px; border-radius: 8px; cursor: pointer; }
.menu-btn:hover { background: rgba(255,255,255,.08); }
.search-btn { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; height: 40px; padding-inline: 12px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: var(--on-ink-muted); font: inherit; font-size: 15px; cursor: pointer; }
.search-btn:hover { background: rgba(255,255,255,.1); color: var(--on-ink); }
.search-btn span { flex: 1; text-align: start; }
.search-btn kbd { font-family: inherit; font-size: 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 0 6px; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
.sidebar { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; background: var(--ink-2); color: var(--on-ink);
  padding: 20px 14px 40px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title { margin: 0 0 6px; padding-inline: 12px; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--on-ink-muted); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: 7px 12px; border-radius: 9px; color: var(--on-ink); text-decoration: none; font-size: 15px; line-height: 1.5; }
.sidebar a:hover { background: rgba(255,255,255,.07); }
.sidebar a[aria-current="page"] { background: #2563eb; color: #fff; font-weight: 600; }
.scrim { display: none; }

.content { display: grid; grid-template-columns: minmax(0, 820px) 220px; gap: 48px; justify-content: center;
  padding: 40px max(16px, env(safe-area-inset-left)) 80px max(16px, env(safe-area-inset-right)); }
article { min-width: 0; }
.crumb { margin: 0 0 6px; color: var(--blue); font-weight: 600; font-size: 14px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.35; text-wrap: balance; color: var(--text); }
h1 { font-size: clamp(28px, 4vw, 38px); margin: 0 0 12px; font-weight: 800; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 28px; }
h2 { font-size: 24px; margin: 48px 0 14px; padding-top: 22px; border-top: 1px solid var(--line); font-weight: 700; }
h3 { font-size: 19px; margin: 32px 0 10px; font-weight: 700; }
h2, h3 { position: relative; }
.anchor { position: absolute; inset-inline-start: -1.1em; color: var(--line); text-decoration: none; opacity: 0; transition: opacity .15s; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
p { margin: 0 0 14px; }
article ul, article ol { padding-inline-start: 1.4em; margin: 0 0 16px; }
article li { margin-bottom: 6px; }
article li > ul, article li > ol { margin-top: 6px; }
strong { font-weight: 700; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--code-bg); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

/* Numbered steps: every ordered list in an article reads as a step list */
article ol { list-style: none; counter-reset: step; padding: 0; }
article ol > li { counter-increment: step; position: relative; padding-inline-start: 46px; margin-bottom: 12px; min-height: 32px; }
article ol > li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue-ink); font-weight: 700; font-size: 15px; display: grid; place-items: center; font-family: var(--display); }

/* Menu path chip */
.path { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; background: var(--blue-soft); color: var(--blue-ink); border-radius: 8px;
  padding: 0 8px; font-weight: 600; font-size: .92em; line-height: 1.9; }
.path .sep { opacity: .6; margin-inline: 4px; }

/* Figures */
figure { margin: 22px 0 28px; }
figure a.zoom { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: 0 18px 40px -28px rgba(13,27,46,.45); cursor: zoom-in; }
figure.fig-mobile { max-width: 300px; margin-inline: auto; }
figure.fig-mobile a.zoom { border-radius: 22px; }
figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); text-align: center; }

/* Callouts */
.callout { border-radius: 12px; padding: 14px 18px; margin: 20px 0; border: 1px solid; }
.callout-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout-tip { background: var(--tip-soft); border-color: color-mix(in srgb, var(--tip) 30%, transparent); }
.callout-tip .callout-head { color: var(--tip); }
.callout-note { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.callout-note .callout-head { color: var(--blue-ink); }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout-warn .callout-head { color: var(--warn); }
.callout ol > li { padding-inline-start: 40px; }
.callout ol > li::before { width: 28px; height: 28px; font-size: 14px; background: var(--card); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 16px 0 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th, td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: color-mix(in srgb, var(--blue-soft) 60%, var(--card)); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Table of contents */
.toc { position: sticky; top: calc(var(--top) + 32px); align-self: start; font-size: 14px; max-height: calc(100vh - var(--top) - 64px); overflow-y: auto; }
.toc p { margin: 0 0 8px; font-weight: 700; color: var(--muted); font-size: 13px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.toc a { display: block; padding: 4px 12px; margin-inline-start: -2px; border-inline-start: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.5; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--blue); border-color: var(--blue); font-weight: 600; }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; }
.pager a { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; text-decoration: none; color: var(--text); font-weight: 600; background: var(--card); }
.pager a:hover { border-color: var(--blue); }
.pager small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.pager .next { text-align: end; }

/* Home page */
.home .content { grid-template-columns: minmax(0, 1040px); }
.home h1 { font-size: clamp(30px, 5vw, 46px); }
.hero { background: var(--ink); color: var(--on-ink); border-radius: 20px; padding: clamp(24px, 4vw, 44px); margin-bottom: 36px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; }
.hero h2 { color: #fff; border: 0; margin: 0 0 10px; padding: 0; font-size: clamp(22px, 3vw, 30px); }
.hero p { color: var(--on-ink-muted); }
.hero img { border-radius: 12px; box-shadow: 0 24px 60px -24px rgba(0,0,0,.6); }
.hero .btn { display: inline-flex; align-items: center; gap: 8px; background: #2563eb; color: #fff; text-decoration: none; padding: 10px 18px; border-radius: 10px; font-weight: 600; margin-top: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 18px 0 28px; }
.cards a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.cards a:hover { border-color: var(--blue); transform: translateY(-2px); }
.cards strong { display: block; font-family: var(--display); font-size: 16.5px; margin-bottom: 4px; }
.cards span { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.cards em { font-style: normal; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--blue-soft); color: var(--blue-ink); margin-bottom: 10px; font-weight: 700; font-family: var(--display); }

/* Search dialog */
.search-dialog { position: fixed; inset: 0; z-index: 80; background: rgba(8, 17, 30, .55); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search-dialog[hidden] { display: none; }
.search-panel { width: min(640px, 100%); background: var(--card); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); overflow: hidden; display: flex; flex-direction: column; max-height: 75vh; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-field input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 18px; color: var(--text); min-width: 0; }
.search-close { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 6px; font: inherit; font-size: 12px; padding: 2px 8px; cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--blue-soft); }
.search-results b { display: block; font-weight: 600; }
.search-results small { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.search-results mark { background: color-mix(in srgb, var(--blue) 22%, transparent); color: inherit; border-radius: 3px; }
.search-empty { padding: 18px; color: var(--muted); text-align: center; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(8,17,30,.88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox button { position: absolute; top: 12px; inset-inline-end: 16px; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 26px; cursor: pointer; }

/* Responsive */
@media (max-width: 1200px) {
  .content { grid-template-columns: minmax(0, 820px); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; top: var(--top); inset-inline-start: 0; width: min(320px, 86vw); z-index: 50; transform: translateX(100%); transition: transform .2s ease; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: var(--top) 0 0; background: rgba(8,17,30,.45); z-index: 45; }
  .scrim[hidden] { display: none; }
  .search-btn { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  .content { padding-top: 28px; }
  .hero { grid-template-columns: 1fr; }
  .anchor { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand small { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: start; }
  h2 { font-size: 21px; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .scrim { display: none !important; }
  .layout, .content { display: block; padding: 0; }
}

/* KASBB brand in the top bar */
.brand-logo { height: 30px; width: auto; flex: none; }
.brand-text { border-inline-start: 1px solid rgba(255,255,255,.18); padding-inline-start: 12px; min-width: 0; }
.home-link, .wa-link { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding-inline: 14px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; flex: none; }
.home-link { color: var(--on-ink); border: 1px solid rgba(255,255,255,.18); }
.home-link:hover { background: rgba(255,255,255,.08); }
.wa-link { color: #fff; background: #128c4a; }
.wa-link:hover { background: #0e7a40; }
@media (max-width: 1100px) { .brand-text small { display: none; } }
@media (max-width: 900px) { .home-link span, .wa-link span { display: none; } .home-link, .wa-link { width: 40px; padding: 0; justify-content: center; } }
@media (max-width: 520px) { .brand-text { display: none; } .brand-logo { height: 26px; } }
