/* .NET Interview Handbook */
:root {
  --font: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --radius: 14px;
  --brand: #7c5cff;
  --brand-2: #22d3ee;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d14; --bg-2: #0f131c; --surface: #131927; --surface-2: #192133; --border: #232c3f; --border-2: #2e3a52;
  --text: #e7ebf3; --text-2: #b4bdcc; --muted: #8590a3; --heading: #ffffff;
  --accent: #a78bfa; --accent-soft: rgba(124, 92, 255, .14); --accent-line: rgba(167, 139, 250, .35);
  --good: #34d399; --good-soft: rgba(52, 211, 153, .10); --bad: #f87171; --bad-soft: rgba(248, 113, 113, .10);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .09);
  --code-bg: #0b0f19; --code-head: #121828; --code-text: #d6deeb; --inline-bg: rgba(167, 139, 250, .13); --inline-text: #d8ccff;
  --tk-k: #c792ea; --tk-t: #82aaff; --tk-s: #ecc48d; --tk-c: #8b99b0; --tk-n: #f78c6c;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -18px rgba(0,0,0,.8);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fb; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f3f4f8; --border: #e4e7ef; --border-2: #d3d8e4;
  --text: #1d2433; --text-2: #3e4759; --muted: #596377; --heading: #0c1220;
  --accent: #5b3fd9; --accent-soft: rgba(91, 63, 217, .08); --accent-line: rgba(91, 63, 217, .3);
  --good: #047857; --good-soft: rgba(15, 159, 110, .08); --bad: #ba2525; --bad-soft: rgba(220, 59, 59, .07);
  --warn: #7a4c0a; --warn-soft: rgba(234, 179, 8, .1);
  --code-bg: #0f1422; --code-head: #171e30; --code-text: #d6deeb; --inline-bg: rgba(91, 63, 217, .09); --inline-text: #4a2fc2;
  --tk-k: #c792ea; --tk-t: #82aaff; --tk-s: #ecc48d; --tk-c: #7a88a3; --tk-n: #f78c6c;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px -16px rgba(16,24,40,.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 130px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16.5px; line-height: 1.75; }
html[lang="ar"] body { font-family: var(--font-ar); font-size: 17px; line-height: 1.95; }
::selection { background: var(--accent-soft); }
bdi { unicode-bidi: isolate; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.35; letter-spacing: -.01em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; line-height: 1.55; }
b, strong { color: var(--heading); font-weight: 650; }
p { margin: 0 0 12px; }
ul, ol { margin: 6px 0 14px; padding-inline-start: 24px; }
li { margin: 5px 0; }
li::marker { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { width: auto; height: auto; clip-path: none; inset-inline-start: 12px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------ buttons & chips */
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s, transform .15s; }
.btn:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b3fd9); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--heading); border-color: var(--border-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.lvl { font-family: var(--font); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.lvl.j, .chip.lvl.j { color: #34d399; border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.lvl.m, .chip.lvl.m { color: #60a5fa; border-color: rgba(96,165,250,.35); background: rgba(96,165,250,.08); }
.lvl.s, .chip.lvl.s { color: #f472b6; border-color: rgba(244,114,182,.35); background: rgba(244,114,182,.08); }
[data-theme="light"] .lvl.j { color: #047857; } [data-theme="light"] .lvl.m { color: #1d4ed8; } [data-theme="light"] .lvl.s { color: #be185d; }

/* ------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); }
.logo-mark { font-family: var(--font); font-weight: 800; font-size: 12.5px; letter-spacing: .02em; color: #fff; padding: 6px 7px; border-radius: 8px;
  background: linear-gradient(135deg, #7c5cff, #512bd4); box-shadow: 0 4px 14px -4px rgba(124,92,255,.6); direction: ltr; }
.logo-text { font-family: var(--font); font-size: 16px; font-weight: 500; white-space: nowrap; direction: ltr; }
.logo-text b { font-weight: 800; }
.byline { font-family: var(--font); font-size: 12.5px; color: var(--muted); text-decoration: none; padding-inline-start: 12px; border-inline-start: 1px solid var(--border); direction: ltr; white-space: nowrap; }
.byline:hover { color: var(--accent); }
.search { position: relative; flex: 1 1 auto; min-width: 0; max-width: 440px; margin-inline-start: auto; }
.search input { width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; padding-inline-start: 36px; }
.search input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.search-results { position: absolute; top: calc(100% + 6px); inset-inline: 0; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.6); padding: 6px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 14px; line-height: 1.5; }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); }
.search-results small { display: block; color: var(--muted); font-size: 12px; }
.search-results .empty { padding: 10px; color: var(--muted); font-size: 14px; }
.menu-btn { display: none; }

/* ------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); max-width: 1320px; margin: 0 auto; }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; padding: 22px 14px 40px; border-inline-end: 1px solid var(--border); scrollbar-width: thin; }
.sidebar ul { list-style: none; padding: 0; margin: 0 0 8px; }
.sidebar li { margin: 1px 0; }
.sidebar a { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14px; line-height: 1.5; }
.sidebar a:hover { color: var(--heading); background: var(--surface); }
.sidebar a.active { color: var(--heading); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
html[dir="rtl"] .sidebar a.active { box-shadow: inset -2px 0 0 var(--accent); }
.sidebar a.done .nav-no { color: var(--good); }
.sidebar a.done .nav-no::after { content: " ✓"; }
.nav-no { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex: 0 0 32px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.nav-title { flex: 1; min-width: 0; }
html[dir="rtl"] .nav-title { text-align: right; }
.nav-group { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 10px 6px; }
html[lang="ar"] .nav-group { letter-spacing: 0; font-size: 12.5px; text-transform: none; }
.nav-home { display: block; padding: 6px 10px; font-weight: 600; color: var(--text); text-decoration: none; }
.content { overflow-wrap: break-word; min-width: 0; padding: 36px 48px 80px; max-width: 1000px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------ topic header */
.kicker { font-size: 13px; font-weight: 700; color: var(--accent); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }
html[lang="ar"] .kicker { letter-spacing: 0; text-transform: none; }
.topic-head { padding-bottom: 22px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.topic-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 10px; }
.topic-nav { position: sticky; top: 64px; z-index: 6; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.topic-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 7px 12px; font-size: 14px; font-weight: 600; border-radius: 8px; text-decoration: none; }
.topic-nav a:hover, .topic-nav a:focus-visible { background: var(--accent-soft); }
.reasoning { color: var(--text-2); font-size: 14px; margin: 10px 0 18px; }
.reasoning summary { cursor: pointer; min-height: 44px; padding: 8px 0; color: var(--accent); font-weight: 600; }
.practice-solution > summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--accent); font-weight: 600; }
.lead { font-size: 18px; color: var(--text-2); margin: 0 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sec-title { font-size: 25px; margin: 52px 0 18px; }
.sec-title::before { content: ""; display: inline-block; vertical-align: -4px; width: 6px; height: 24px; margin-inline-end: 12px; border-radius: 4px; background: linear-gradient(180deg, var(--brand), var(--brand-2)); }

/* ------------------------------------------------ concept card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px 14px; margin: 18px 0 22px; box-shadow: var(--shadow); }
.card > h3 { position: relative; font-size: 22px; margin: 0 0 16px; }
.card > h3 .en-sub { display: block; font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--muted); direction: ltr; text-align: start; letter-spacing: 0; }
html[dir="rtl"] .card > h3 .en-sub { text-align: right; }
.anchor { position: absolute; inset-inline-start: -20px; color: var(--muted); opacity: 0; text-decoration: none; font-weight: 400; }
.card > h3:hover .anchor { opacity: 1; }
.sec { margin: 20px 0 6px; }
.sec > h4 { font-size: 16.5px; margin: 0 0 8px; color: var(--accent); }
.analogy { background: var(--warn-soft); border: 1px solid rgba(251,191,36,.22); border-radius: 12px; padding: 14px 18px; margin: 10px 0 16px; }
.analogy > :last-child, .tip > :last-child, .warn > :last-child, .note > :last-child { margin-bottom: 0; }
.tip, .warn, .note { border-radius: 12px; padding: 12px 18px; margin: 12px 0 16px; border: 1px solid; }
.tip { background: var(--good-soft); border-color: rgba(52,211,153,.25); }
.warn { background: var(--bad-soft); border-color: rgba(248,113,113,.25); }
.note { background: var(--accent-soft); border-color: var(--accent-line); }
.tip > b:first-child, .warn > b:first-child, .note > b:first-child { display: block; margin-bottom: 2px; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps > li { counter-increment: s; position: relative; padding-inline-start: 40px; margin: 12px 0; }
.steps > li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: 3px; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); font: 700 13px/24px var(--font); text-align: center; }
.explain { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; margin: 0 0 16px; }
.explain > b:first-child { display: block; color: var(--muted); font-size: 13.5px; margin-bottom: 4px; }
.explain ol { list-style: none; padding: 0; margin: 0; }
.explain li { margin: 6px 0; }
.explain .n { display: inline-block; min-width: 32px; font-family: var(--mono); font-size: 13px; color: var(--warn); font-weight: 600; }

/* ------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.6; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
html[dir="rtl"] :is(th, td) { text-align: right; }
th { background: var(--surface-2); color: var(--heading); font-weight: 650; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td.ltr, .ltr { direction: ltr; }

/* ------------------------------------------------ code */
code { font-family: var(--mono); font-size: .86em; background: var(--inline-bg); color: var(--inline-text); padding: 2px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
.code { margin: 12px 0 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); direction: ltr; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: var(--code-head); border-bottom: 1px solid rgba(255,255,255,.06); font-family: var(--font); font-size: 12px; color: #8b95ab; }
.code-head .dots { display: inline-flex; gap: 6px; margin-inline-end: 10px; }
.code-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: #2b3348; display: block; }
.code-actions { display: flex; gap: 4px; }
.code-actions button { min-height: 44px; min-width: 44px; font: 600 12px var(--font); color: #b6c0d6; background: transparent; border: 1px solid rgba(255,255,255,.08); border-radius: 7px; padding: 4px 9px; cursor: pointer; }
.code-actions button:hover { color: #fff; border-color: rgba(255,255,255,.2); }
.copy-status { margin: 0; padding: 10px 14px; color: #fbbf24; font: 14px/1.6 var(--font); }
pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.8px; line-height: 1.7; color: var(--code-text); direction: ltr; text-align: left; tab-size: 4; scrollbar-width: thin; }
pre code { background: none; color: inherit; padding: 0; font-size: inherit; overflow-wrap: anywhere; border-radius: 0; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.code.nowrap pre, .code.nowrap pre code { white-space: pre; overflow-wrap: normal; }
.tk-k { color: var(--tk-k); } .tk-t { color: var(--tk-t); } .tk-s { color: var(--tk-s); } .tk-c { color: var(--tk-c); font-style: italic; } .tk-n { color: var(--tk-n); }

/* wrong vs right: stacked, full width */
.cmp { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 18px; }
.cmp-item { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--code-bg); direction: ltr; }
.cmp-item .code { margin: 0; border: 0; border-radius: 0; }
.cmp-label { font-family: var(--font-ar); font-size: 13.5px; font-weight: 700; padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
html[dir="rtl"] .cmp-label { direction: rtl; }
.cmp-item.bad { border-color: rgba(248,113,113,.4); }
.cmp-item.bad .cmp-label { background: rgba(248,113,113,.12); color: #fca5a5; }
.cmp-item.good { border-color: rgba(52,211,153,.4); }
.cmp-item.good .cmp-label { background: rgba(52,211,153,.12); color: #6ee7b7; }

/* ------------------------------------------------ interview Q&A */
.qa-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; margin-bottom: 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.seg button { min-height: 44px; font: 600 13px var(--font); padding: 6px 11px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--heading); box-shadow: inset 0 0 0 1px var(--accent-line); }
.qa-search { flex: 1; min-width: 160px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
details.qa { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin: 10px 0; }
details.qa:hover, details.qa[open] { border-color: var(--border-2); }
details.qa.hidden { display: none; }
details.qa > summary { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; cursor: pointer; list-style: none; }
details.qa > summary::-webkit-details-marker { display: none; }
details.qa > summary::after { content: ""; width: 9px; height: 9px; margin-top: 8px; flex: none; border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
details.qa[open] > summary::after { transform: rotate(-135deg); margin-top: 12px; }
.qn { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 3px; min-width: 34px; }
.qa-q { flex: 1; min-width: 0; overflow-wrap: anywhere; font-family: var(--font); font-weight: 600; color: var(--heading); line-height: 1.55; direction: ltr; text-align: left; }
html[dir="rtl"] .qa-q { text-align: right; unicode-bidi: plaintext; }
details.qa .lvl { margin-top: 2px; }
.qa-body { padding: 0 20px 16px; border-top: 1px solid var(--border); }
.qa-explain { padding-top: 14px; }
.answer { direction: ltr; text-align: left; margin-top: 14px; padding: 14px 18px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-family: var(--font); font-size: 15.5px; line-height: 1.75; }
.answer-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 6px; }
.answer p:last-child { margin-bottom: 0; }

/* ------------------------------------------------ quiz */
.quiz { margin: 18px 0; }
.quiz-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.quiz-note { color: var(--text-2); font-size: 14px; }
.score { color: var(--good); font-family: var(--mono); }
.q { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin: 12px 0; }
.q .qt { direction: ltr; text-align: left; font-family: var(--font); font-weight: 650; color: var(--heading); margin-bottom: 10px; line-height: 1.55; }
.q .opts { direction: ltr; text-align: left; list-style: upper-alpha; padding-left: 28px; margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; }
.q .opts li { border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); margin: 6px 0; }
.q .opts button { display: block; width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: inherit; cursor: pointer; overflow-wrap: anywhere; }
.q:not(.done) .opts li:hover { border-color: var(--accent-line); }
.q .opts button[aria-pressed="true"] { box-shadow: inset 3px 0 0 currentColor; }
.q .option-state { display: block; font-size: 13px; font-weight: 600; }
.q .right .option-state { color: var(--good); }
.q .wrong .option-state { color: var(--bad); }
.quiz-feedback { margin: 0; }
.quiz-feedback:not(:empty) { margin-top: 12px; font-weight: 600; }
.q .opts li.right { background: var(--good-soft); border-color: var(--good); }
.q .opts li.wrong { background: var(--bad-soft); border-color: var(--bad); }
.q.done .opts button { cursor: default; }
.q .why { display: none; margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border-inline-start: 3px solid var(--warn); font-size: 15px; }
.q.done .why { display: block; }

/* ------------------------------------------------ pager */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--heading); font-weight: 600; background: var(--surface); }
.pager a:hover { border-color: var(--accent-line); }
.pager small { color: var(--muted); font-weight: 500; }
.pager .next { text-align: end; }
.done-btn { align-self: center; font: 600 14px var(--font-ar); padding: 10px 16px; border-radius: 10px; border: 1px dashed var(--border-2); background: transparent; color: var(--text-2); cursor: pointer; }
.done-btn.on { border-style: solid; border-color: var(--good); color: var(--good); background: var(--good-soft); }

/* ------------------------------------------------ home */
.hero { padding: 26px 0 30px; }
.badge { display: inline-block; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.15; margin: 0 0 18px; letter-spacing: -.025em; }
html[lang="ar"] .hero h1 { line-height: 1.45; letter-spacing: 0; }
.hero .brand-word { color: var(--accent); }
.topic-intro { margin: 0 0 24px; padding: 0 0 18px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.topic-intro p { margin: 8px 0; }
.topic-intro b { color: var(--heading); }
.worked-example { margin: 14px 0 20px; padding: 14px 18px; border-inline-start: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }
[dir="rtl"] .worked-example { border-radius: 8px 0 0 8px; }
.worked-example > b { color: var(--heading); }
.worked-example ol { padding-inline-start: 24px; margin: 8px 0 0; }
.worked-example li { padding-inline-start: 3px; margin: 10px 0; }
.term-hint { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.term-ref { display: inline; font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px dotted var(--accent); border-radius: 0; padding: 0 1px; cursor: help; }
.term-ref:hover { color: var(--accent); background: var(--accent-soft); }
.term-popover { box-sizing: border-box; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; padding: 24px; overflow: auto; color: var(--text); background: var(--surface); border: 1px solid var(--accent-line); border-radius: 14px; box-shadow: 0 16px 60px rgba(0,0,0,.28); }
.term-popover > strong { display: block; text-align: start; color: var(--heading); font-size: 17px; line-height: 1.5; }
.term-popover p { margin: 14px 0 20px; }
.term-popover::backdrop { background: rgba(0,0,0,.12); }
@media print {
  .term-hint, .term-popover { display: none !important; }
  .term-ref { border: 0; }
}
.resume-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; margin: 0 0 28px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface); }
.resume-panel h2 { font-size: 20px; margin: 0 0 4px; }
.resume-panel p { margin: 4px 0; }
.resume-topic { font-weight: 600; color: var(--heading); }
.resume-note { font-size: 14px; color: var(--text-2); }
.resume-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hero .lead { max-width: 720px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 28px; }
.hero-actions .btn { padding: 12px 18px; font-size: 15px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; }
.stats > div { display: flex; flex-direction: column; padding: 12px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); min-width: 120px; }
.stats b { font-family: var(--font); font-size: 26px; font-weight: 800; }
.stats span { color: var(--muted); font-size: 13px; }
.stats .lv { flex-direction: row; align-items: center; gap: 8px; }
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.progress { flex: 1; max-width: 360px; height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #7c5cff, #22d3ee); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease-out); }
html[dir="rtl"] .progress-bar { transform-origin: right; }
.progress-text { font-size: 13px; color: var(--muted); }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 10px; }
.how > div { padding: 16px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); }
.how b { display: block; margin-bottom: 4px; }
.how span { color: var(--text-2); font-size: 14.5px; }
.study-paths { margin: 40px 0; padding-block: 24px; border-block: 1px solid var(--border); }
.study-paths h2 { margin: 0 0 8px; font-size: 25px; }
.study-paths > p { font-size: 14px; color: var(--text-2); }
.study-paths ol { list-style: none; padding: 0; margin: 20px 0; }
.study-path { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; padding: 18px 0; margin: 0; border-top: 1px solid var(--border); }
.study-path h3 { margin: 2px 0; }
.study-path p { margin: 0 0 6px; }
.path-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.path-links a { display: inline-block; min-height: 44px; padding-block: 10px; font-size: 14px; }
.not-found { max-width: 680px; padding: 64px 24px; margin: auto; }
.not-found > .brand { margin-bottom: 56px; }
.not-found h1 { font-size: clamp(32px, 6vw, 48px); }
.group-title { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 40px 0 12px; }
html[lang="ar"] .group-title { letter-spacing: 0; font-size: 17px; text-transform: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.topic-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.topic-card:hover { border-color: var(--accent-line); }
.tc-no { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.tc-title { font-weight: 700; color: var(--heading); font-size: 16.5px; line-height: 1.45; }
.tc-desc { font-size: 13.5px; color: var(--muted); line-height: 1.6; flex: 1; }
.tc-meta { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.topic-card.done::after { content: "✓"; position: absolute; top: 14px; inset-inline-end: 16px; color: var(--good); font-weight: 800; }
.author-card { display: flex; gap: 20px; align-items: flex-start; margin: 56px 0 10px; padding: 24px; border-radius: 16px; border: 1px solid var(--border); background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--surface); }
.author-card img, .footer-author img { border-radius: 50%; object-fit: cover; border: 2px solid var(--accent-line); flex: none; }
.author-card h3 { margin: 0 0 6px; font-family: var(--font); }
.author-kicker { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 4px; }
.author-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ------------------------------------------------ footer */
.footer { border-top: 1px solid var(--border); background: var(--bg-2); margin-top: 40px; }
.footer-inner { max-width: 1320px; margin: 0 auto; padding: 30px 28px 10px; display: flex; flex-wrap: wrap; gap: 28px; justify-content: space-between; align-items: flex-start; }
.footer-brand p { color: var(--muted); font-size: 14px; margin-top: 10px; max-width: 360px; }
.footer-author { display: flex; gap: 14px; align-items: center; max-width: 620px; }
.footer-author p { margin: 0; font-size: 14px; color: var(--text-2); }
.footer-credit, .footer-role, .footer-contact { display: block; }
.footer-credit a { white-space: nowrap; }
html[dir="rtl"] .footer-role { text-align: right; }
.social { display: flex; gap: 6px; }
.social a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); }
.social a:hover { color: var(--heading); border-color: var(--accent-line); }
.copyright { max-width: 1320px; margin: 0 auto; padding: 8px 28px 26px; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { visibility: hidden; position: fixed; top: 64px; inset-inline-start: 0; z-index: 40; width: min(300px, 100vw); background: var(--bg); transform: translateX(-105%); transition: transform .2s; box-shadow: 20px 0 40px -20px rgba(0,0,0,.6); }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  body.nav-open .sidebar { visibility: visible; transform: none; }
  .menu-btn { display: inline-grid; }
  .content { padding: 28px 22px 70px; }
}
@media (max-width: 720px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar .icon-btn { width: 44px; height: 44px; flex: none; }
  .topbar .btn.lang { padding: 9px 10px; flex: none; }
  .logo-text { display: none; }
  .hide-sm, .byline { display: none; }
  .logo-text { font-size: 14px; }
  .lang span { display: none; }
  .search { max-width: none; }
  .card { padding: 18px 16px 8px; border-radius: 12px; }
  .how { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr 1fr; }
  .pager .done-btn { grid-column: 1 / -1; grid-row: 1; }
  details.qa > summary { padding: 12px 14px; gap: 8px; }
  .qa-body { padding: 0 14px 14px; }
  pre { font-size: 13px; padding: 14px; }
  .author-card { flex-direction: column; }
  .study-path { grid-template-columns: 1fr; gap: 8px; }
  .footer-author { flex-wrap: wrap; }
  .topic-nav a { padding-inline: 9px; font-size: 13px; }
}

/* ------------------------------------------------ print / PDF */
.print-body { background: #fff; }
.print-body .content { max-width: none; padding: 0; }
.book-cover { text-align: center; padding: 30vh 0 0; break-after: page; }
.book-cover .logo-mark { font-size: 22px; padding: 10px 12px; }
.book-cover h1 { font-size: 40px; margin: 22px 0 8px; }
.book-topic { break-before: page; }
@media print {
  @page { size: A4; margin: 16mm 14mm; }
  html, body { background: #fff !important; }
  body { font-size: 11pt; }
  .topbar, .sidebar, .footer, .pager, .topic-nav, .qa-tools, .quiz-bar, .head-actions, .code-actions, .anchor { display: none !important; }
  .card, .q, details.qa { box-shadow: none; break-inside: avoid-page; }
  .card { break-inside: auto; }
  pre { white-space: pre-wrap; word-break: break-word; font-size: 9pt; }
  .code, .cmp-item, table { break-inside: avoid; }
  details.qa > summary::after { display: none; }
  .q .why { display: block; }
  .q .opts li { cursor: default; }
  a { color: inherit; text-decoration: none; }
}

/* optional / bonus content */
.bonus { display: inline-block; vertical-align: middle; margin-inline-start: 8px; font: 700 10.5px var(--font); letter-spacing: .04em; text-transform: uppercase; color: #f5b83d; border: 1px solid rgba(245,184,61,.4); background: rgba(245,184,61,.08); padding: 1px 7px; border-radius: 999px; }
[data-theme="light"] .bonus { color: #855500; border-color: #c48a21; background: #fff8e8; }
.card > h3 .bonus { font-size: 11px; }
.opt-note { font-size: 14.5px; color: var(--text-2); background: rgba(245,184,61,.07); border: 1px dashed rgba(245,184,61,.35); border-radius: 10px; padding: 8px 14px; margin: 0 0 14px; }
.card.opt { border-style: dashed; border-color: rgba(245,184,61,.35); }
.cmp-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 10px 0 14px; }
.cmp-text p:last-child { margin: 0; }
/* Feedback stays brief; reading content never waits for an animation. */
@keyframes settle-in {
  from { opacity: .7; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: .6; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero > h1, .hero > .lead, .hero-actions { animation: settle-in 320ms var(--ease-out) both; }
  .hero > .lead { animation-delay: 40ms; }
  .hero-actions { animation-delay: 80ms; }
  .btn, .icon-btn, .done-btn, .code-actions button { transition: transform 140ms var(--ease-out); }
  :is(.btn, .icon-btn, .done-btn, .code-actions button):active { transform: scale(.98); }
  .topic-card { transition: transform 180ms var(--ease-out); }
  .theme-btn svg { transition: transform 240ms var(--ease-out); }
  [data-theme="dark"] .theme-btn svg { transform: rotate(-30deg); }
  .search-results:not([hidden]) { animation: settle-in 160ms var(--ease-out); }
  details.qa[open] > .qa-body, details.practice-solution[open] > :not(summary), .q.done .why { animation: settle-in 180ms var(--ease-out); }
  .option-state, .quiz-feedback:not(:empty), .copy-status:not([hidden]) { animation: fade-in 160ms var(--ease-out); }
  details.qa > summary::after, .sidebar { transition-timing-function: var(--ease-out); }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-1px); }
  .topic-card:hover { transform: translateY(-2px); }
  .btn:active, .topic-card:active { transform: scale(.98); }
}
@media (prefers-reduced-motion: reduce), print {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
