@font-face {
  font-family: Plex Arabic;
  src: url(assets/plex-arabic-400.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Plex Arabic;
  src: url(assets/plex-arabic-500.woff2) format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Plex Arabic;
  src: url(assets/plex-arabic-600.woff2) format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Plex Arabic;
  src: url(assets/plex-arabic-700.woff2) format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: Manrope;
  src: url(assets/manrope.woff2) format("woff2");
  font-weight: 600 800;
  font-display: swap;
}

:root {
  --sky: #7CC6FE;
  --ice: #F4FAFF;
  --rose: #E39695;
  --orange: #FF8600;
  --ink: #162d45;
  --muted: #4e637a;
  --line: #dce8f2;
  --canvas: #edf4fa;
  --arabic: "Plex Arabic", Tahoma, Arial, sans-serif;
  --numeric: Manrope, Arial, sans-serif;
  --paper-width: 210mm;
  --paper-height: 297mm;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 94px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 400 1rem/1.65 var(--arabic);
}
button { font: inherit; }
a { color: inherit; }
h1, h2, h3, p, figure, table, ol { margin: 0; }
bdi { font-family: var(--numeric); }
:focus-visible { outline: 2px solid #176ba5; outline-offset: 4px; }

.site-header {
  position: sticky;
  z-index: 3;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1096px, calc(100% - 64px));
  min-height: 74px;
  margin-inline: auto;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand strong, .brand small { display: block; line-height: 1.35; }
.brand strong { font-size: 1.05rem; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.brand-icon, .print-card-icon {
  display: grid;
  place-items: center;
  inline-size: 42px;
  block-size: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--sky);
}
.icon-book {
  position: relative;
  display: inline-block;
  inline-size: 21px;
  block-size: 16px;
  direction: ltr;
}
.icon-book::before, .icon-book::after {
  position: absolute;
  top: 1px;
  width: 10px;
  height: 14px;
  border: 1.7px solid currentColor;
  content: "";
}
.icon-book::before { left: 0; border-radius: 2px 4px 1px 2px; transform: skewY(8deg); }
.icon-book::after { right: 0; border-radius: 4px 2px 2px 1px; transform: skewY(-8deg); }
.print-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 16px;
  min-height: 42px;
  color: var(--ink);
  background: var(--sky);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .9325rem;
  font-weight: 700;
  cursor: pointer;
}
.print-button:hover { background: #9bd3fe; border-color: #64aff0; }
.icon-print {
  position: relative;
  display: inline-block;
  width: 17px;
  height: 11px;
  border: 1.65px solid currentColor;
  border-radius: 3px;
  margin-block: 3px;
}
.icon-print::before, .icon-print::after {
  position: absolute;
  inset-inline: 3px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-radius: 1px;
  background: var(--sky);
  content: "";
}
.icon-print::before { top: -5px; border-bottom: 0; }
.icon-print::after { bottom: -5px; }

.reader {
  display: grid;
  grid-template-columns: 270px minmax(0, var(--paper-width));
  align-items: start;
  gap: 32px;
  width: min(1096px, calc(100% - 64px));
  margin: 29px auto 64px;
}
.sidebar { position: sticky; top: 103px; padding-block-start: 37px; }
.contents {
  overflow: hidden;
  padding: 16px 12px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 10px #25476c06;
}
.contents h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 5px 11px;
  padding: 0 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 1.03rem;
}
.icon-list {
  width: 17px;
  height: 14px;
  display: inline-block;
  color: #3476a8;
  background:
    radial-gradient(circle, currentColor 1px, transparent 1.5px) 100% 0 / 4px 5px repeat-y,
    linear-gradient(to bottom, transparent 1.5px, currentColor 1.5px 2.8px, transparent 2.8px) 0 0 / 11px 5px repeat-y;
}
.contents ol { list-style: none; padding: 0; display: grid; gap: 3px; }
.contents a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}
.contents a span {
  min-width: 28px;
  padding-block: 2px;
  border-radius: 5px;
  background: #f0f5f9;
  font: 700 .72rem/1.75 var(--numeric);
  text-align: center;
  direction: ltr;
}
.contents a:hover { background: var(--ice); color: var(--ink); }
.contents a[aria-current] {
  background: #e8f5ff;
  border-color: #d9edff;
  color: var(--ink);
  font-weight: 700;
}
.contents a[aria-current] span { background: var(--sky); color: var(--ink); }
.print-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 15px 13px;
  margin-top: 15px;
  border: 1px solid #d9eaf8;
  background: var(--ice);
  border-radius: 13px;
}
.material-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid #96cfff;
  background: #e6f4ff;
  color: #204c70;
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
}
.material-entry:hover { background: #d7ecff; text-decoration: underline; }
.print-card-icon { width: 35px; height: 35px; border-radius: 9px; background: #dcefff; color: #225d8c; }
.print-card strong { font-size: .92rem; }
.print-card p { font-size: .81rem; color: var(--muted); }
.icon-file {
  display: inline-block;
  width: 13px;
  height: 16px;
  position: relative;
  vertical-align: middle;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}
.icon-file::after {
  position: absolute;
  inset: 6px 2px auto;
  border-top: 1px solid currentColor;
  box-shadow: 0 3px 0 currentColor;
  content: "";
}
.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  min-height: 37px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 600;
}
.preview-bar > span { display: flex; align-items: center; gap: 7px; }
.preview-bar .icon-file { color: #39739f; }
.preview-details i { height: 4px; width: 4px; background: #8aa3b9; border-radius: 50%; }

.sheet {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: var(--paper-height);
  padding: 12mm 14mm 10mm;
  margin-block-end: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 32px #264d7610, 0 2px 6px #264d7609;
}
.sheet-header, .sheet-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .7rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}
.sheet-header {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.sheet-header > span:first-child, .sheet-footer > span { display: flex; align-items: center; gap: 7px; }
.sheet-header i { width: 8px; height: 8px; border-radius: 2px; background: var(--sky); }
.sheet-footer {
  padding-top: 13px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}
.sheet-footer i { width: 3px; height: 3px; background: #7c98b1; border-radius: 50%; }
.sheet-footer bdi { direction: ltr; font-size: .72rem; color: #395776; letter-spacing: .04em; }

.cover-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding-block: clamp(34px, 6vw, 73px) 40px;
}
.cover-hero h1 {
  font-size: clamp(4.25rem, 10vw, 6.1rem);
  font-weight: 700;
  line-height: 1.06;
  margin-block: 9px 15px;
}
.cover-hero p {
  max-inline-size: 20em;
  color: var(--muted);
  font-size: 1.16rem;
  font-weight: 500;
}
.cover-hero h1, .cover-hero p, .cover-hero .eyebrow { position: relative; }
.cover-art {
  position: absolute;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  left: 0;
  top: 15%;
  width: min(41%, 256px);
  height: 73%;
  color: #b8defa;
  background: radial-gradient(circle at 1.5px 1.5px, #d4e9fb 1px, transparent 1.6px) 0 0 / 13px 13px;
  mask-image: linear-gradient(90deg, #000 15%, #000 60%, transparent);
}
.cover-art span { font: italic 9rem/1 Georgia, serif; transform: translateX(-8%); }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #375674;
  font-size: .9rem;
  font-weight: 700;
}
.eyebrow::before {
  width: 19px;
  height: 3px;
  border-radius: 4px;
  background: var(--orange);
  content: "";
}
.plot { background: var(--ice); border: 1px solid #d7eafa; border-radius: 12px; }
.plot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 3px;
}
.plot-head h2 { font-size: 1.17rem; }
.plot-head p { color: var(--muted); font-size: .83rem; }
.plot-equation {
  color: #184d77;
  padding: 7px 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #d9ebf8;
  direction: ltr;
  font-size: 1.03rem;
}
.plot img { display: block; width: 100%; height: auto; }
.plot-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 8px;
  padding: 11px 18px;
  border-top: 1px solid #dcebf8;
  color: #3a526b;
  font-size: .81rem;
}
.area-plot .plot-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cover-legend { flex-wrap: nowrap; }
.swatch { flex: 0 0 auto; width: 10px; height: 10px; display: inline-block; border-radius: 2px; }
.sky { background: var(--sky); }
.rose { background: var(--rose); }
.cover-roadmap { margin-block: 30px; }
.cover-roadmap h2 { font-size: 1.15rem; margin-bottom: 10px; }
.cover-topics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cover-topics > div {
  border: 1px solid var(--line);
  border-top: 3px solid var(--sky);
  border-radius: 7px;
  padding: 11px 12px;
}
.cover-topics > div:nth-child(2) { border-top-color: var(--rose); }
.cover-topics > div:nth-child(3) { border-top-color: var(--orange); }
.cover-topics strong, .cover-topics span { display: block; }
.cover-topics strong { font-size: .93rem; }
.cover-topics span { color: var(--muted); font-size: .79rem; margin-top: 3px; }

.page-heading { margin-block: 26px 20px; }
.page-heading h2 { font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.28; margin-block: 3px 7px; }
.page-heading p { color: var(--muted); }
.sheet h3 { font-size: 1.07rem; line-height: 1.45; }
.definition, .worked, .note { padding: 13px 17px; border: 1px solid var(--line); border-radius: 9px; }
.definition { background: var(--ice); border-color: #d7eafa; border-inline-start: 4px solid var(--sky); }
.definition h3, .worked h3 { margin-bottom: 5px; }
.topic { margin-block: 17px; }
.topic h3 { margin-bottom: 8px; }
.rules { border-collapse: separate; border-spacing: 0; width: 100%; line-height: 1.45; }
.rules th, .rules td { text-align: start; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.rules thead th { background: #e8f5ff; }
.rules th:first-child { border-start-start-radius: 6px; }
.rules th:last-child { border-start-end-radius: 6px; }
.rules td:first-child { width: 37%; }
.rules tbody tr:nth-child(even) { background: #f8fbfe; }
.worked { background: #f7fbff; }
.worked + .worked, .definition + .worked { margin-top: 12px; }
.worked-plain { background: #fff; }
.box-label {
  display: inline-block;
  padding: 1px 7px;
  margin-bottom: 5px;
  color: #254e73;
  background: #dcefff;
  border-radius: 4px;
  font-size: .76rem;
  font-weight: 700;
}
.note {
  margin-block: 15px 23px;
  background: #fff6f5;
  border-color: #f0d5d3;
  border-inline-start: 4px solid var(--rose);
}
.note p { color: #4f4e61; }
.step-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
}
.step-flow li {
  display: flex;
  align-items: start;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.step-flow bdi, .exercise-top bdi, .answer-grid bdi {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  color: #1e4c72;
  background: #e5f3ff;
  border-radius: 5px;
  font-size: .74rem;
  font-weight: 800;
}
.step-flow li > div > strong, .step-flow li > div > span { display: block; }
.step-flow li > div > span { font-size: .79rem; color: var(--muted); }
.solution-steps { margin-block: 5px; padding-inline-start: 23px; }
.solution-steps li::marker { color: #3977a4; }
.compact { padding-block: 9px; }
.area-topic { margin-bottom: 0; }
.area-plot { margin-block: 10px; }
.area-plot .plot-legend { padding-block: 5px; column-gap: 14px; }

.katex, .katex-display { direction: ltr; unicode-bidi: isolate; }
.katex {
  font-size: 1.06em;
  /* Keep KaTeX's internal alignment independent of the surrounding text. */
  text-align-last: auto;
}
.katex-display { margin: .56em 0; }
.compact .katex-display { margin: .34em 0; }

.exercise-grid, .answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); list-style: none; padding: 0; }
.exercise-grid { gap: 13px; margin-bottom: 25px; }
.exercise-grid > li {
  display: flex;
  flex-direction: column;
  min-height: 194px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.exercise-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.exercise-grid .katex-display { margin-block: .42em; }
.writing {
  position: relative;
  height: 56px;
  margin-top: auto;
}
.writing::before {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  height: 1px;
  background: #cbdce9;
  box-shadow: 0 -18px #cbdce9, 0 -36px #cbdce9;
  content: "";
}
.exam-question {
  padding: 13px 15px 9px;
  margin-bottom: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.exam-question h3 { margin-bottom: 4px; }
.exam-question h3 a { color: #275980; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.exam-question .writing { height: 34px; margin-top: 5px; }
.exam-question .writing::before { box-shadow: 0 -18px #cbdce9; }
.exam-key { padding: 12px 15px; margin-top: 6px; background: var(--ice); border-radius: 8px; }
.exam-key p + p { margin-top: 3px; }
.answer-grid { gap: 7px; margin-bottom: 8px; }
.answer-grid li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }

@media screen and (max-width: 1050px) {
  .reader { grid-template-columns: 230px minmax(0, 1fr); gap: 20px; }
  .sheet { padding-inline: clamp(25px, 5vw, 52px); }
}
@media screen and (max-width: 820px) {
  .site-bar, .reader { width: min(var(--paper-width), calc(100% - 32px)); }
  .reader { display: block; margin-top: 15px; }
  .sidebar { position: static; padding: 0; margin-bottom: 16px; }
  .contents { padding: 10px; }
  .contents h2 { padding-block-end: 7px; margin-block-end: 6px; }
  .contents ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contents a { min-height: 37px; }
  .print-card { display: none; }
  .sheet { min-height: 0; }
  .sheet-footer { margin-top: 18px; }
}
@media screen and (max-width: 480px) {
  html { scroll-padding-top: 74px; }
  .site-bar { min-height: 62px; }
  .brand { gap: 7px; }
  .brand-icon { width: 34px; height: 34px; border-radius: 9px; }
  .brand strong { font-size: .87rem; }
  .brand small { font-size: .71rem; }
  .print-button { padding-inline: 9px; font-size: .81rem; }
  .contents a { font-size: .78rem; gap: 4px; padding-inline: 2px; }
  .contents a span { min-width: 23px; }
  .sheet { padding: 19px 15px 16px; }
  .cover-hero { padding-block: 33px 26px; }
  .cover-hero h1 { font-size: 3.9rem; }
  .cover-hero p { font-size: 1rem; }
  .cover-art span { font-size: 6.5rem; }
  .plot-head { padding-inline: 9px; }
  .plot-head h2 { font-size: .95rem; }
  .plot-head p, .plot-legend { font-size: .75rem; }
  .plot-equation { padding: 4px 6px; }
  .plot-legend { padding-inline: 9px; }
  .cover-topics { gap: 5px; }
  .cover-topics > div { padding: 6px; }
  .cover-topics strong { font-size: .79rem; }
  .cover-topics span { font-size: .71rem; }
  .step-flow, .exercise-grid { grid-template-columns: 1fr; }
  .answer-grid { grid-template-columns: 1fr; }
  .rules th, .rules td { padding-inline: 5px; }
  .katex-display > .katex { font-size: .85em; }
  .area-topic > .katex-display > .katex { font-size: .71em; }
}

@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { background: #fff; }
  body { color: #122b43; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .screen-only { display: none !important; }
  .reader, .document { display: block; margin: 0; width: auto; }
  .sheet {
    position: relative;
    display: block;
    width: var(--paper-width);
    height: var(--paper-height);
    min-height: 0;
    padding: 12mm 14mm 16mm;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
  }
  .sheet:last-child { break-after: auto; }
  .sheet-header > span:first-child, .sheet-footer > span { display: block; white-space: nowrap; }
  .sheet-header i, .sheet-footer i { display: inline-block; margin-left: 4px; vertical-align: middle; }
  .sheet-footer { position: absolute; left: 14mm; right: 14mm; bottom: 9mm; }
  .cover-hero { padding-block: 73px 40px; direction: ltr; }
  .cover-hero h1, .cover-hero p, .cover-hero .eyebrow { direction: rtl; }
  .cover-hero p { margin-left: auto; }
  .cover-art { width: 36%; }
  .cover-hero h1 { font-size: 6.1rem; }
  .page-heading h2 { font-size: 2.8rem; }
  .cover-topics, .step-flow, .exercise-grid, .answer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    justify-content: space-between;
  }
  .cover-topics > div, .step-flow li { width: 32%; }
  .exercise-grid > li, .answer-grid > li { width: 49%; }
  .exercise-grid > li { margin-bottom: 12px; }
  .answer-grid > li { margin-bottom: 6px; }
}
