:root {
  color-scheme: light;
  --ink: #162a36;
  --muted: #60717b;
  --paper: #fbfaf6;
  --surface: #fff;
  --line: #d8d7cf;
  --teal: #176d68;
  --teal-soft: #dff0eb;
  --rust: #b44f2e;
  --rust-soft: #f6e4dc;
  --gold: #b7872d;
  --gold-soft: #f4ead2;
  --navy: #0f2837;
  --focus: #0567c9;
  --shadow: 0 14px 38px rgb(15 40 55 / 9%);
  font-family: "Geeza Pro", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; }
body { margin: 0; overflow-x: clip; color: var(--ink); background: var(--paper); line-height: 1.72; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; inset-block-start: .5rem; inset-inline-start: .5rem; padding: .65rem 1rem; color: #fff; background: var(--focus); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  z-index: 40;
  inset-block-start: 0;
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(280px, 1.2fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 76px;
  padding: .75rem clamp(1rem, 3vw, 2.5rem);
  color: #fff;
  background: var(--navy);
  box-shadow: 0 3px 16px rgb(8 25 34 / 25%);
}
.brand { display: flex; gap: .75rem; align-items: center; }
.brand-mark { display: grid; width: 2.6rem; height: 2.6rem; place-items: center; border: 1px solid rgb(255 255 255 / 45%); border-radius: 50%; color: var(--navy); background: #fff; font-weight: 900; }
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand small { color: #b9cbd4; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box input { width: 100%; min-height: 44px; padding: .65rem 1rem .65rem 3rem; border: 1px solid #526977; border-radius: .8rem; color: #fff; background: #1b394a; }
.search-box input::placeholder { color: #bdcbd2; }
.search-box kbd { position: absolute; inset-inline-end: .65rem; padding: .08rem .42rem; border: 1px solid #738896; border-radius: .3rem; color: #d9e3e8; background: #254657; direction: ltr; }
.top-actions { display: flex; gap: .15rem; align-items: center; white-space: nowrap; }
.top-actions a, .icon-button { padding: .45rem .68rem; border-radius: .55rem; }
.top-actions a:hover, .top-actions a[aria-current="page"] { background: #294a5c; }
.icon-button { display: none; border: 1px solid #6d8491; color: #fff; background: transparent; }
.progress-strip { position: sticky; z-index: 39; inset-block-start: 76px; height: 4px; background: #cad5d9; }
.progress-strip span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--rust), var(--gold)); }

.shell { display: grid; grid-template-columns: 310px minmax(0, 1fr); max-width: 1680px; min-height: calc(100vh - 80px); margin: auto; }
.course-rail { position: sticky; inset-block-start: 80px; align-self: start; height: calc(100vh - 80px); overflow: auto; border-inline-end: 1px solid var(--line); background: #f1f2ed; }
.rail-head { display: flex; justify-content: space-between; align-items: baseline; padding: 1rem 1.2rem; border-block-end: 1px solid var(--line); }
.rail-head p { margin: 0; font-weight: 800; }
.rail-head strong { color: var(--teal); font-size: .82rem; }
.module-group { border-block-end: 1px solid var(--line); }
.module-group summary { display: grid; grid-template-columns: 2.4rem 1fr; gap: .65rem; align-items: center; padding: .9rem 1.05rem; cursor: pointer; font-weight: 800; }
.module-group summary::marker { color: var(--teal); }
.module-number { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: .55rem; color: var(--teal); background: var(--teal-soft); direction: ltr; font-size: .78rem; }
.topic-links { padding: 0 .8rem .8rem; }
.topic-link { display: grid; grid-template-columns: 1.35rem 1fr; gap: .55rem; align-items: start; padding: .55rem .65rem; border-radius: .55rem; color: #42555f; font-size: .88rem; line-height: 1.45; }
.topic-link:hover, .topic-link[aria-current="page"] { color: var(--ink); background: #fff; box-shadow: 0 2px 7px rgb(15 40 55 / 7%); }
.topic-link .status-dot { display: grid; width: 1.1rem; height: 1.1rem; margin-block-start: .12rem; place-items: center; border: 1px solid #9faaa9; border-radius: 50%; font-size: .7rem; }
.topic-link[data-complete="true"] .status-dot { border-color: var(--teal); color: #fff; background: var(--teal); }

main { min-width: 0; }
#app { width: min(1180px, calc(100% - 3rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 4.7rem) 0 6rem; }
.search-results { position: fixed; z-index: 50; inset-block-start: 70px; inset-inline: 320px 2rem; max-height: 70vh; overflow: auto; padding: .65rem; border: 1px solid var(--line); border-radius: 0 0 1rem 1rem; background: #fff; box-shadow: var(--shadow); }
.search-result { display: grid; grid-template-columns: 4rem 1fr; gap: .8rem; padding: .8rem; border-radius: .65rem; }
.search-result:hover, .search-result:focus { background: var(--teal-soft); }
.search-result code { color: var(--teal); font-weight: 800; }
.search-empty { padding: 1rem; color: var(--muted); }

.eyebrow { margin: 0 0 .5rem; color: var(--teal); font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2.2rem, 5vw, 5rem); letter-spacing: -.04em; }
h2 { margin: 0 0 .75rem; font-size: clamp(1.45rem, 3vw, 2.15rem); }
h3 { margin: 0 0 .45rem; font-size: 1.05rem; }
p { text-wrap: pretty; }
.lead { max-width: 760px; margin: 1rem 0 0; color: #3e535e; font-size: 1.14rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 2rem; align-items: end; padding-block-end: 2.2rem; border-block-end: 1px solid var(--line); }
.hero-meta { display: grid; gap: .7rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; }
.hero-meta div { display: flex; justify-content: space-between; gap: 1rem; }
.hero-meta span { color: var(--muted); }
.confidence { display: inline-flex; gap: .35rem; align-items: center; width: fit-content; padding: .25rem .55rem; border-radius: 99px; background: var(--gold-soft); font-size: .78rem; font-weight: 800; }
.confidence[data-level="high"] { color: #075248; background: var(--teal-soft); }
.confidence[data-level="low"], .confidence[data-level="uncertain"] { color: #7a351f; background: var(--rust-soft); }
.topic-controls { display: flex; flex-wrap: wrap; gap: .55rem; margin-block: 1.2rem 2rem; }
.button { display: inline-flex; gap: .45rem; align-items: center; justify-content: center; min-height: 42px; padding: .55rem .9rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: #fff; cursor: pointer; font-weight: 800; }
.button:hover { border-color: var(--teal); }
.button.primary { border-color: var(--teal); color: #fff; background: var(--teal); }
.button[aria-pressed="true"] { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.button:disabled { cursor: not-allowed; opacity: .45; }

.section-nav { position: sticky; z-index: 15; inset-block-start: 80px; display: flex; gap: .4rem; overflow-x: auto; margin: 0 -1rem 1.4rem; padding: .55rem 1rem; border-block: 1px solid var(--line); background: rgb(251 250 246 / 95%); scrollbar-width: thin; }
.section-nav button { flex: 0 0 auto; padding: .35rem .65rem; border: 0; border-radius: 99px; color: var(--muted); background: transparent; cursor: pointer; font-size: .8rem; font-weight: 800; }
.section-nav button:hover { color: var(--teal); background: var(--teal-soft); }
.study-section { scroll-margin-top: 145px; padding: clamp(1.4rem, 4vw, 2.4rem) 0; border-block-end: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: 2.3rem 1fr; gap: .8rem; align-items: start; margin-block-end: 1.1rem; }
.section-index { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--teal); font-weight: 900; direction: ltr; }
.section-head p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .9rem; }
.card { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: 0 4px 16px rgb(15 40 55 / 4%); }
.card p { margin: .35rem 0 0; }
.card .basis { color: var(--muted); font-size: .73rem; }
.callout { padding: 1rem 1.1rem; border-inline-start: 4px solid var(--teal); background: var(--teal-soft); }
.callout.warn { border-color: var(--rust); background: var(--rust-soft); }
.callout p { margin: .2rem 0; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.term-table, .data-table { width: 100%; border-collapse: collapse; background: #fff; }
.term-table th, .term-table td, .data-table th, .data-table td { padding: .7rem .8rem; border: 1px solid var(--line); text-align: start; vertical-align: top; }
.term-table th, .data-table th { background: #edf0ed; font-size: .82rem; }
.term-table [lang="en"], .ltr { direction: ltr; unicode-bidi: isolate; font-family: "SFMono-Regular", Consolas, monospace; }
.term-table [lang="en"] { color: #0e5c62; font-weight: 800; }
.steps { counter-reset: procedure; margin: 0; padding: 0; list-style: none; }
.steps li { position: relative; min-height: 3.8rem; margin-inline-start: 1.25rem; padding: 0 2.7rem 1.3rem 0; border-inline-start: 2px solid #bfd0cc; }
.steps li::before { counter-increment: procedure; content: counter(procedure); position: absolute; inset-inline-start: -1.05rem; inset-block-start: -.15rem; display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); direction: ltr; font-weight: 900; }
.steps li:last-child { border-color: transparent; }
.self-check { display: grid; gap: .45rem; margin-block-start: 1rem; }
.self-check label { display: flex; gap: .55rem; align-items: start; }

.board { overflow: hidden; border: 1px solid #48626e; border-radius: 1.15rem; color: #eef5f7; background: var(--navy); box-shadow: var(--shadow); }
.board-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .85rem 1rem; border-block-end: 1px solid #3a5562; background: #163747; }
.board-head p { margin: 0; color: #bed0d8; font-size: .82rem; }
.board-frame { min-height: 340px; padding: clamp(1rem, 4vw, 2rem); }
.frame-label { color: #89d2c8; font-size: .78rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.frame-focus { margin: .4rem 0 1.2rem; font-size: clamp(1.2rem, 3vw, 1.75rem); font-weight: 850; }
.artifact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .65rem; margin-block: 1rem; }
.artifact { padding: .75rem; border: 1px solid #52707d; border-radius: .65rem; background: #1a3a49; }
.artifact strong { display: block; color: #91d8cf; font-size: .75rem; }
.artifact span { display: block; margin-block-start: .2rem; overflow-wrap: anywhere; direction: auto; unicode-bidi: plaintext; font-family: "SFMono-Regular", Consolas, monospace; }
.step-check { margin-block-start: 1rem; padding: .75rem 1rem; border-inline-start: 4px solid var(--gold); color: #f5e7c6; background: #1f4050; }
.board-controls { display: flex; justify-content: space-between; gap: .7rem; padding: .9rem 1rem; border-block-start: 1px solid #3a5562; background: #112e3c; }
.board-controls .button { border-color: #5d7884; color: #fff; background: #1c4152; }
.board-controls .button:disabled { opacity: .35; }
.dots { display: flex; gap: .3rem; align-items: center; }
.dot { width: .55rem; height: .55rem; border: 0; border-radius: 50%; background: #607b87; }
.dot[aria-current="step"] { width: 1.3rem; border-radius: 99px; background: #87d2c8; }
.diagram { min-height: 130px; margin-block: 1rem; padding: 1rem; border: 1px solid #4b6672; border-radius: .8rem; background: #0c2431; direction: ltr; }
.diagram figcaption { margin-block-end: .75rem; color: #bdd0d8; direction: rtl; font-size: .76rem; }
.diagram-flow { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; justify-content: center; min-height: 80px; }
.diagram-node { padding: .55rem .8rem; border: 2px solid #70b9b0; border-radius: .55rem; color: #fff; background: #173c4c; overflow-wrap: anywhere; text-align: center; unicode-bidi: plaintext; }
.diagram-node.active { border-color: #efbd63; background: #64491d; }
.diagram-arrow { color: #87d2c8; font-weight: 900; }
.diagram svg { display: block; width: 100%; max-height: 235px; overflow: visible; }
.diagram svg text { fill: #fff; font: 700 13px "SFMono-Regular", Consolas, monospace; }
.diagram svg .edge-label { fill: #9fdbd4; font-size: 11px; }
.diagram svg circle { fill: #153949; stroke: #78c4ba; stroke-width: 2; }
.diagram svg circle.active { fill: #6c4b18; stroke: #f1bf63; stroke-width: 4; }
.diagram table { width: 100%; border-collapse: collapse; color: #fff; direction: ltr; }
.diagram th, .diagram td { padding: .45rem; border: 1px solid #55717c; text-align: center; }
.diagram th { color: #9fdbd4; background: #183a49; }
.diagram .active-cell { color: #1d2830; background: #f1bf63; font-weight: 900; }
.static-frames { margin-block-start: 1rem; }
.static-frames summary { cursor: pointer; color: var(--teal); font-weight: 850; }
.static-frame { margin-block: .7rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .7rem; background: #fff; break-inside: avoid; }
.static-frame h3 { color: var(--teal); }
.static-frame .ltr { overflow-wrap: anywhere; }

.practice-list { display: grid; gap: .9rem; }
.practice-card { border: 1px solid var(--line); border-radius: .85rem; background: #fff; overflow: hidden; }
.practice-card summary { padding: 1rem; cursor: pointer; font-weight: 850; }
.practice-answer { padding: 0 1rem 1rem; border-block-start: 1px solid var(--line); }
.practice-answer strong { color: var(--teal); }
.misconception { border-inline-start: 4px solid var(--rust); }
.source-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-block-start: .7rem; }
.source-chip { padding: .2rem .5rem; border: 1px solid #b8c6ca; border-radius: 99px; color: #405964; background: #f1f4f4; direction: ltr; font-family: "SFMono-Regular", Consolas, monospace; font-size: .72rem; }
.connection-map { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; }
.connection-map > div { padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
.connection-map .current { color: #fff; background: var(--teal); }
.topic-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-block-start: 2.5rem; }
.topic-pager a { padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: #fff; }
.topic-pager small { display: block; color: var(--muted); }

.map-hero { padding-block-end: 2rem; }
.map-stats { display: flex; flex-wrap: wrap; gap: .7rem; margin-block-start: 1.4rem; }
.stat { min-width: 130px; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: .75rem; background: #fff; }
.stat strong { display: block; color: var(--teal); font-size: 1.5rem; }
.journey { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-block: 2rem; }
.journey-step { min-height: 125px; padding: 1rem; border-radius: .8rem; color: #fff; background: var(--navy); }
.journey-step:nth-child(2) { background: var(--teal); }
.journey-step:nth-child(3) { color: var(--ink); background: var(--gold-soft); }
.journey-step:nth-child(4) { color: var(--ink); background: var(--rust-soft); }
.journey-step span { display: block; margin-block-end: .35rem; font: 900 .75rem/1 "SFMono-Regular", Consolas, monospace; opacity: .7; }
.module-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.module-card { display: flex; flex-direction: column; min-height: 310px; padding: 1.15rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: 0 5px 18px rgb(15 40 55 / 5%); }
.module-card > p { color: var(--muted); }
.module-topics { display: grid; gap: .35rem; margin-block-start: auto; }
.module-topic { display: flex; justify-content: space-between; gap: 1rem; padding: .48rem .55rem; border-radius: .5rem; }
.module-topic:hover { background: var(--teal-soft); }
.module-topic code { color: var(--teal); font-weight: 800; }
.synthesis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .8rem; margin-block-start: 1rem; }
.synthesis-card { padding: 1rem; border-block-start: 4px solid var(--gold); background: #fff; box-shadow: var(--shadow); }
.exam-bank { display: grid; gap: 1rem; }
.exam-item { padding: 1.1rem; border: 1px solid var(--line); border-radius: .9rem; background: #fff; }
.exam-item header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; }
.scope-warning { margin-block: 2rem; padding: 1.2rem; border: 1px solid #dfad9a; border-radius: .8rem; background: var(--rust-soft); }
.scope-warning h2 { color: #78351e; }

.print-course { display: none; }
.print-topic { break-before: page; }
.print-topic:first-child { break-before: auto; }
.print-topic h1 { font-size: 2rem; }
.print-topic h2 { margin-block-start: 1.1rem; font-size: 1.25rem; }
.print-topic h3 { font-size: 1rem; }
.print-topic p, .print-topic li, .print-topic td { font-size: .85rem; line-height: 1.55; }
.print-topic .source-chips { break-inside: avoid; }
.print-exam { break-inside: avoid; }
.print-cover { display: grid; min-height: 90vh; place-content: center; text-align: center; break-after: page; }
.print-cover h1 { font-size: 3rem; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr minmax(240px, 1.1fr) auto; }
  .top-actions { display: none; }
  .icon-button { display: inline-flex; }
  .shell { grid-template-columns: 1fr; }
  .course-rail { position: fixed; z-index: 45; inset-block: 80px 0; inset-inline-start: 0; width: min(340px, 92vw); height: auto; visibility: hidden; pointer-events: none; box-shadow: var(--shadow); transform: translateX(110%); }
  .course-rail[data-open="true"] { visibility: visible; pointer-events: auto; transform: none; }
  .search-results { inset-inline: 1rem; }
  .hero { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 70px; padding: .65rem .8rem; }
  .brand small { display: none; }
  .search-box { grid-column: 1 / -1; grid-row: 2; }
  .progress-strip { inset-block-start: 124px; }
  .course-rail { inset-block-start: 124px; }
  #app { width: min(100% - 1.4rem, 1180px); padding-block-start: 2rem; }
  h1 { font-size: clamp(2rem, 13vw, 3.2rem); }
  .journey { grid-template-columns: 1fr 1fr; }
  .connection-map { grid-template-columns: 1fr; }
  .topic-pager { grid-template-columns: 1fr; }
  .section-nav { inset-block-start: 124px; }
  .board-head, .board-controls { align-items: stretch; }
  .board-controls { flex-wrap: wrap; }
  .board-frame { min-height: 390px; }
}

@media (prefers-reduced-motion: no-preference) {
  .course-rail { transition: transform .18s ease-out; }
  .topic-link, .button, .module-topic { transition: background-color .12s linear, border-color .12s linear, color .12s linear; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@page { size: A4; margin: 14mm 13mm 16mm; }
@media print {
  :root { --paper: #fff; --surface: #fff; }
  body { color: #111; background: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .topbar, .progress-strip, .course-rail, .search-results, .section-nav, .topic-controls, .topic-pager, .interactive-only, .skip-link { display: none !important; }
  .shell { display: block; }
  #app { width: auto; max-width: none; margin: 0; padding: 0; }
  body[data-view="print"] #app > :not(.print-course) { display: none !important; }
  .print-course { display: block; }
  .card, .practice-card, .static-frame, .callout, table, figure { break-inside: avoid; box-shadow: none; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .study-section { padding: .85rem 0; }
  .board { display: none; }
  .static-frames { display: block; }
  .static-frames > summary { display: none; }
  .static-frames[open] .static-frame, .static-frames .static-frame { display: block; }
  a { color: #111; }
}
