:root {
  --ink: #102a3a;
  --muted: #536b78;
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #edf5f3;
  --navy: #123b4a;
  --navy-2: #0a2d3b;
  --teal: #0f8b8d;
  --teal-soft: #d9f1ed;
  --coral: #ef6a5b;
  --coral-soft: #fde5df;
  --gold: #e6aa42;
  --gold-soft: #fff0cb;
  --violet: #7768ae;
  --violet-soft: #ece8fb;
  --line: #d5dfdc;
  --shadow: 0 18px 60px rgba(16, 42, 58, 0.11);
  --shadow-small: 0 8px 24px rgba(16, 42, 58, 0.08);
  --radius: 22px;
  --radius-small: 14px;
  --content: 1180px;
  --reading: 820px;
  --accent: var(--teal);
  --accent-soft: var(--teal-soft);
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #ecf4f2;
  --muted: #afc2c7;
  --paper: #091e27;
  --surface: #102d38;
  --surface-2: #163945;
  --navy: #b9ebe4;
  --navy-2: #071820;
  --teal: #55d3c6;
  --teal-soft: #143f42;
  --coral: #ff8a7c;
  --coral-soft: #4c2929;
  --gold: #f4c15f;
  --gold-soft: #46391c;
  --violet: #b8a8f1;
  --violet-soft: #302c4b;
  --line: #31505a;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
  --shadow-small: 0 8px 24px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, color-mix(in srgb, var(--teal-soft) 70%, transparent) 0, transparent 28rem),
    radial-gradient(circle at 95% 24%, color-mix(in srgb, var(--coral-soft) 55%, transparent) 0, transparent 25rem),
    var(--paper);
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 12%, transparent) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  content: "";
  opacity: 0.25;
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--coral);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4 {
  margin-block: 0 0.55em;
  color: var(--ink);
  line-height: 1.35;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.2rem, 5.5vw, 5rem);
  letter-spacing: -0.045em;
}

h2 {
  font-size: clamp(1.65rem, 3vw, 2.7rem);
  letter-spacing: -0.025em;
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

h4 {
  font-size: 1.05rem;
}

p,
ul,
ol {
  margin-block: 0 1.1em;
}

ul,
ol {
  padding-inline-start: 1.35rem;
}

li + li {
  margin-block-start: 0.38em;
}

strong {
  color: var(--navy);
}

code,
.term-en,
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

code {
  border: 1px solid var(--line);
  border-radius: 0.45em;
  padding: 0.08em 0.38em;
  background: var(--surface-2);
  color: var(--coral);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.container {
  width: min(calc(100% - 2rem), var(--content));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.7rem;
  inset-inline-start: 0.7rem;
  z-index: 1000;
  translate: 0 -160%;
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  background: var(--ink);
  color: var(--surface);
}

.skip-link:focus {
  translate: 0;
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 999;
  height: 4px;
  background: transparent;
}

.reading-progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
  transition: width 80ms linear;
}

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  border-block-end: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 8px;
  aspect-ratio: 1;
  border: 2px solid var(--surface);
  border-radius: 50%;
  content: "";
}

.brand-mark::before {
  translate: -7px -6px;
}

.brand-mark::after {
  translate: 7px 6px;
}

.brand-mark span {
  width: 23px;
  height: 2px;
  rotate: 38deg;
  background: var(--surface);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.nav-link,
.icon-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.nav-link:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero {
  position: relative;
  padding-block: clamp(3.5rem, 8vw, 7rem) 4rem;
  overflow: clip;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-block-end: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 800;
}

.eyebrow::before {
  width: 8px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 18%, transparent);
  content: "";
}

.hero-copy > p {
  max-width: 64ch;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.5vw, 1.24rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-block-start: 1.6rem;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-small);
  transition: translate 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  translate: 0 -2px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 14px 32px color-mix(in srgb, var(--accent) 22%, transparent);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.network-visual {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 93%, transparent), color-mix(in srgb, var(--surface-2) 85%, transparent));
  box-shadow: var(--shadow);
}

.network-visual::before {
  position: absolute;
  width: 170px;
  aspect-ratio: 1;
  inset-block-start: -60px;
  inset-inline-end: -50px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--coral) 20%, transparent);
  filter: blur(2px);
  content: "";
}

.network-svg {
  width: 100%;
  min-height: 330px;
}

.network-svg .link {
  stroke: color-mix(in srgb, var(--muted) 45%, transparent);
  stroke-width: 2;
  stroke-dasharray: 7 10;
  animation: dash-flow 7s linear infinite;
}

.network-svg .node-ring {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 3;
}

.network-svg .node-core {
  fill: var(--accent);
}

.network-svg .central {
  fill: var(--ink);
}

.network-svg text {
  fill: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.network-svg .central-label {
  fill: var(--surface);
}

.network-svg .packet {
  fill: var(--coral);
  filter: drop-shadow(0 3px 4px rgba(239, 106, 91, 0.35));
}

.network-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-block-start: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.legend-chip {
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-block: 1.8rem 0;
}

.stat {
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 0.85rem;
}

.stat strong {
  display: block;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 0.82rem;
}

.section-block {
  padding-block: clamp(3.5rem, 7vw, 6rem);
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
  align-items: end;
  gap: 2rem;
  margin-block-end: 2.2rem;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

.course-summary {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.2rem;
}

.summary-panel,
.concept-map,
.search-panel,
.content-card,
.definition-card,
.example-card,
.diagram-card,
.quiz-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-small);
}

.summary-panel,
.concept-map {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.summary-panel p:last-child,
.concept-map p:last-child {
  margin-block-end: 0;
}

.concept-flow {
  display: grid;
  gap: 0.55rem;
  margin-block-start: 1rem;
}

.concept-node {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
  background: var(--surface);
}

.concept-node span:first-child {
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.concept-arrow {
  height: 18px;
  margin-inline-start: 18px;
  border-inline-start: 2px dashed var(--line);
}

.search-panel {
  position: relative;
  margin-block-end: 1.2rem;
  padding: 0.8rem;
}

.search-panel label {
  display: block;
  margin-block-end: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.search-panel input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0.35rem 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
}

.search-panel:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.lecture-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.lecture-card {
  --card-accent: var(--teal);
  position: relative;
  grid-column: span 4;
  display: flex;
  min-height: 430px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 1.45rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-small);
  transition: translate 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.lecture-card:nth-child(4),
.lecture-card:nth-child(5) {
  grid-column: span 6;
}

.lecture-card::before {
  position: absolute;
  width: 180px;
  aspect-ratio: 1;
  inset-block-start: -85px;
  inset-inline-end: -75px;
  border: 28px solid color-mix(in srgb, var(--card-accent) 14%, transparent);
  border-radius: 50%;
  content: "";
  transition: scale 300ms ease;
}

.lecture-card:hover {
  translate: 0 -5px;
  border-color: color-mix(in srgb, var(--card-accent) 60%, var(--line));
  box-shadow: var(--shadow);
}

.lecture-card:hover::before {
  scale: 1.16;
}

.lecture-card[data-lecture="2"] { --card-accent: var(--violet); }
.lecture-card[data-lecture="3"] { --card-accent: var(--coral); }
.lecture-card[data-lecture="4"] { --card-accent: var(--gold); }
.lecture-card[data-lecture="5"] { --card-accent: #3f76c5; }

.lecture-number {
  position: relative;
  display: grid;
  width: 48px;
  aspect-ratio: 1;
  place-items: center;
  margin-block-end: 1.4rem;
  border-radius: 15px;
  background: color-mix(in srgb, var(--card-accent) 16%, var(--surface));
  color: var(--card-accent);
  font-size: 1.2rem;
  font-weight: 900;
}

.lecture-card h3 {
  position: relative;
  font-size: 1.35rem;
}

.lecture-card p {
  color: var(--muted);
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-block: auto 1rem;
  padding: 0;
  list-style: none;
}

.topic-tags li {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.58rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.lecture-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border-block-start: 1px solid var(--line);
  padding-block-start: 1rem;
}

.lecture-meta span {
  color: var(--muted);
  font-size: 0.82rem;
}

.details-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--card-accent);
  font-weight: 900;
  text-decoration: none;
}

.details-link::after {
  content: "←";
  transition: translate 160ms ease;
}

.details-link:hover::after {
  translate: -4px 0;
}

.no-results {
  display: none;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.no-results.is-visible {
  display: block;
}

.learning-path {
  counter-reset: path;
  display: grid;
  gap: 0;
}

.path-step {
  counter-increment: path;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 1rem;
  min-height: 105px;
}

.path-marker {
  position: relative;
  display: grid;
  width: 44px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-weight: 900;
}

.path-marker::before {
  content: counter(path, decimal-leading-zero);
}

.path-step:not(:last-child) .path-marker::after {
  position: absolute;
  inset-block-start: 44px;
  height: 61px;
  border-inline-start: 2px dashed var(--line);
  content: "";
}

.path-copy {
  padding-block-end: 1.4rem;
}

.path-copy p {
  margin: 0;
  color: var(--muted);
}

.coverage-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1.5rem;
  border-radius: 30px;
  padding: clamp(1.5rem, 4vw, 2.8rem);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow);
}

.coverage-banner h2,
.coverage-banner strong {
  color: var(--surface);
}

.coverage-banner p {
  max-width: 70ch;
  margin: 0;
  color: color-mix(in srgb, var(--surface) 76%, transparent);
}

.coverage-ring {
  display: grid;
  width: 128px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--coral) 0 34%, var(--gold) 34% 58%, var(--teal) 58% 100%);
  color: var(--ink);
}

.coverage-ring::before {
  display: grid;
  width: 94px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  content: "186\A شريحة";
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  white-space: pre;
}

.site-footer {
  margin-block-start: 5rem;
  border-block-start: 1px solid var(--line);
  padding-block: 2rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-inner p {
  margin: 0;
}

/* Lecture pages */
.lecture-page[data-lecture="1"] { --accent: var(--teal); --accent-soft: var(--teal-soft); }
.lecture-page[data-lecture="2"] { --accent: var(--violet); --accent-soft: var(--violet-soft); }
.lecture-page[data-lecture="3"] { --accent: var(--coral); --accent-soft: var(--coral-soft); }
.lecture-page[data-lecture="4"] { --accent: #b87a10; --accent-soft: var(--gold-soft); }
.lecture-page[data-lecture="5"] { --accent: #3f76c5; --accent-soft: #e3edff; }
[data-theme="dark"] .lecture-page[data-lecture="5"],
[data-theme="dark"].lecture-page[data-lecture="5"] { --accent-soft: #18365a; }

.lecture-hero {
  position: relative;
  padding-block: clamp(3rem, 7vw, 5.5rem) 3rem;
  overflow: clip;
}

.lecture-hero::after {
  position: absolute;
  z-index: -1;
  width: 420px;
  aspect-ratio: 1;
  inset-block-start: -230px;
  inset-inline-end: -120px;
  border: 70px solid color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 50%;
  content: "";
}

.lecture-hero h1 {
  max-width: 15ch;
  font-size: clamp(2.3rem, 5vw, 4.3rem);
}

.lecture-hero p {
  max-width: 72ch;
  color: var(--muted);
  font-size: 1.08rem;
}

.lecture-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 1.4rem;
}

.meta-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  align-items: start;
  gap: clamp(2rem, 5vw, 4.5rem);
}

.lesson-content {
  min-width: 0;
}

.lecture-toc {
  position: sticky;
  inset-block-start: 92px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-small);
}

.lecture-toc strong {
  display: block;
  margin-block-end: 0.6rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.lecture-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lecture-toc li + li {
  margin-block-start: 0.2rem;
}

.lecture-toc a {
  display: block;
  border-radius: 10px;
  padding: 0.38rem 0.55rem;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.lecture-toc a:hover,
.lecture-toc a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.content-section {
  margin-block-end: 1.3rem;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: clamp(1.25rem, 3.2vw, 2.35rem);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-small);
}

.content-section > :last-child {
  margin-block-end: 0;
}

.section-number {
  display: inline-flex;
  margin-block-end: 0.6rem;
  border-radius: 999px;
  padding: 0.24rem 0.62rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}

.slide-ref {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-inline-start: 0.45rem;
  border-radius: 999px;
  padding: 0.18rem 0.52rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.lead {
  color: var(--muted);
  font-size: 1.08rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-block: 1.2rem;
}

.card-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-card,
.definition-card,
.example-card,
.quiz-card {
  padding: 1.1rem;
}

.content-card h3,
.definition-card h3,
.example-card h3,
.quiz-card h3 {
  font-size: 1.05rem;
}

.content-card p:last-child,
.definition-card p:last-child,
.example-card p:last-child {
  margin: 0;
}

.definition-card {
  border-block-start: 4px solid var(--accent);
}

.example-card {
  border-block-start: 4px solid var(--gold);
}

.callout {
  position: relative;
  margin-block: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-inline-start: 5px solid var(--accent);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
}

.callout.warning {
  border-color: color-mix(in srgb, var(--coral) 38%, var(--line));
  border-inline-start-color: var(--coral);
  background: color-mix(in srgb, var(--coral-soft) 74%, var(--surface));
}

.callout.solution {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  border-inline-start-color: var(--gold);
  background: color-mix(in srgb, var(--gold-soft) 74%, var(--surface));
}

.callout strong:first-child {
  display: block;
  margin-block-end: 0.35rem;
}

.callout p:last-child,
.callout ul:last-child,
.callout ol:last-child {
  margin-block-end: 0;
}

.table-wrap {
  margin-block: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow-x: auto;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

caption {
  padding: 0.8rem 1rem;
  color: var(--ink);
  font-weight: 800;
  text-align: start;
}

th,
td {
  border-block-end: 1px solid var(--line);
  padding: 0.72rem 0.8rem;
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--navy);
  font-size: 0.88rem;
  white-space: nowrap;
}

tr:last-child td {
  border-block-end: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 40%, transparent);
}

.formula {
  margin-block: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  overflow-x: auto;
  background: var(--navy-2);
  color: #f7fbfa;
  direction: ltr;
  font-family: Cambria, Georgia, serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
  text-align: center;
  unicode-bidi: isolate;
}

.formula small {
  display: block;
  margin-block-start: 0.45rem;
  color: #bcd0d5;
  direction: rtl;
  font-family: Tahoma, Arial, sans-serif;
  font-size: 0.72em;
}

.steps {
  counter-reset: steps;
  display: grid;
  gap: 0.65rem;
  margin-block: 1rem;
  padding: 0;
  list-style: none;
}

.steps > li {
  counter-increment: steps;
  position: relative;
  min-height: 48px;
  margin: 0;
  padding: 0.55rem 3.2rem 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.steps > li::before {
  position: absolute;
  inset-block-start: 0.55rem;
  inset-inline-start: 0.55rem;
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  content: counter(steps);
  font-weight: 900;
}

.diagram-card {
  position: relative;
  margin-block: 1.3rem;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  overflow: hidden;
}

.diagram-card figcaption {
  margin-block-start: 0.8rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.diagram-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1rem;
}

.diagram-title h3 {
  margin: 0;
}

.play-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.38rem 0.68rem;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.play-button:hover {
  border-color: var(--accent);
}

.node-diagram {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 180px;
}

.diagram-node {
  position: relative;
  z-index: 2;
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 0.8rem;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow-small);
}

.diagram-node small {
  display: block;
  color: var(--muted);
}

.arrow-line {
  position: relative;
  height: 3px;
  background: var(--line);
}

.arrow-line::after {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: -2px;
  width: 9px;
  aspect-ratio: 1;
  border-block-start: 3px solid var(--line);
  border-inline-end: 3px solid var(--line);
  content: "";
  rotate: 45deg;
  translate: 0 -50%;
}

.moving-packet {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 0;
  width: 15px;
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--coral);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--coral) 35%, transparent);
  translate: 0 -50%;
  animation: packet-move 2.2s ease-in-out infinite;
}

.layer-stack {
  display: grid;
  gap: 0.45rem;
}

.layer {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: var(--surface);
  text-align: center;
}

.layer.accent {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.layer-stack.is-playing .layer {
  animation: layer-highlight 560ms ease both;
}

.layer-stack.is-playing .layer:nth-child(2) { animation-delay: 120ms; }
.layer-stack.is-playing .layer:nth-child(3) { animation-delay: 240ms; }
.layer-stack.is-playing .layer:nth-child(4) { animation-delay: 360ms; }
.layer-stack.is-playing .layer:nth-child(5) { animation-delay: 480ms; }

.node-diagram.is-playing .moving-packet,
.diagram-card .is-playing .moving-packet {
  animation-name: packet-replay;
}

.timeline-diagram {
  display: grid;
  gap: 1rem;
}

.process-line {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 0.7rem;
}

.process-track {
  position: relative;
  height: 4px;
  background: var(--line);
}

.event-dot {
  position: absolute;
  inset-block-start: 50%;
  display: grid;
  width: 28px;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  translate: -50% -50%;
  box-shadow: 0 0 0 2px var(--accent);
}

.event-dot:nth-child(1) { inset-inline-start: 18%; }
.event-dot:nth-child(2) { inset-inline-start: 48%; }
.event-dot:nth-child(3) { inset-inline-start: 79%; }

details {
  margin-block: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
}

summary {
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
}

details[open] summary {
  margin-block-end: 0.6rem;
  color: var(--accent);
}

.slide-map {
  columns: 2 280px;
  column-gap: 1rem;
  margin-block: 1rem;
}

.slide-map details {
  break-inside: avoid;
  margin-block-start: 0;
}

.answer-button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.answer {
  display: none;
  margin-block-start: 0.8rem;
  border-block-start: 1px solid var(--line);
  padding-block-start: 0.8rem;
}

.answer.is-visible {
  display: block;
  animation: reveal-up 240ms ease both;
}

.lecture-pager {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin-block-start: 1.2rem;
}

.pager-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.pager-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pager-link small {
  display: block;
  color: var(--muted);
}

.back-to-top {
  position: fixed;
  inset-block-end: 1rem;
  inset-inline-end: 1rem;
  z-index: 80;
  display: grid;
  width: 46px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-small);
  opacity: 0;
  translate: 0 15px;
  pointer-events: none;
  transition: opacity 180ms ease, translate 180ms ease;
  cursor: pointer;
}

.back-to-top.is-visible {
  opacity: 1;
  translate: 0;
  pointer-events: auto;
}

.js [data-reveal] {
  opacity: 0;
  translate: 0 18px;
}

.js [data-reveal].is-revealed {
  animation: reveal-up 520ms cubic-bezier(.2,.75,.25,1) both;
}

.is-filtered {
  display: none !important;
}

@keyframes reveal-up {
  from { opacity: 0; translate: 0 18px; }
  to { opacity: 1; translate: 0; }
}

@keyframes dash-flow {
  to { stroke-dashoffset: -85; }
}

@keyframes packet-move {
  0%, 12% { inset-inline-start: 0; opacity: 0; }
  22% { opacity: 1; }
  78% { opacity: 1; }
  88%, 100% { inset-inline-start: calc(100% - 15px); opacity: 0; }
}

@keyframes packet-replay {
  0%, 12% { inset-inline-start: 0; opacity: 0; }
  22% { opacity: 1; }
  78% { opacity: 1; }
  88%, 100% { inset-inline-start: calc(100% - 15px); opacity: 0; }
}

@keyframes layer-highlight {
  0% { translate: 0 8px; opacity: 0.45; }
  55% { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  100% { translate: 0; opacity: 1; }
}

@keyframes pulse-node {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}

@media (max-width: 960px) {
  .hero-grid,
  .course-summary,
  .section-heading {
    grid-template-columns: 1fr;
  }

  .network-visual {
    max-width: 680px;
    margin-inline: auto;
  }

  .lecture-card,
  .lecture-card:nth-child(4),
  .lecture-card:nth-child(5) {
    grid-column: span 6;
  }

  .lecture-card:last-child {
    grid-column: 4 / span 6;
  }

  .page-shell {
    grid-template-columns: 1fr;
  }

  .lecture-toc {
    position: static;
    order: -1;
  }

  .lecture-toc ol {
    display: flex;
    overflow-x: auto;
    gap: 0.3rem;
    padding-block-end: 0.25rem;
  }

  .lecture-toc li {
    flex: 0 0 auto;
  }

  .lecture-toc li + li {
    margin: 0;
  }

  .card-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }

  .container {
    width: min(calc(100% - 1.15rem), var(--content));
  }

  .header-inner {
    min-height: 64px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-link {
    padding-inline: 0.65rem;
    font-size: 0.82rem;
  }

  .hero-grid {
    gap: 2rem;
  }

  .network-svg {
    min-height: 250px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .lecture-card,
  .lecture-card:nth-child(4),
  .lecture-card:nth-child(5),
  .lecture-card:last-child {
    grid-column: 1 / -1;
    min-height: 0;
  }

  .coverage-banner,
  .footer-inner {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .coverage-ring {
    width: 110px;
  }

  .coverage-ring::before {
    width: 80px;
  }

  .card-grid,
  .card-grid.three,
  .lecture-pager {
    grid-template-columns: 1fr;
  }

  .node-diagram {
    grid-template-columns: 1fr;
  }

  .arrow-line {
    width: 3px;
    height: 55px;
    margin-inline: auto;
  }

  .arrow-line::after {
    inset-block-start: auto;
    inset-block-end: -1px;
    inset-inline-end: 50%;
    rotate: 135deg;
    translate: 50% 0;
  }

  .moving-packet {
    inset-block-start: 0;
    inset-inline-start: 50%;
    translate: -50% 0;
    animation-name: packet-move-vertical;
  }

  .content-section {
    border-radius: 20px;
  }

  .slide-map {
    columns: 1;
  }
}

@keyframes packet-move-vertical {
  0%, 12% { inset-block-start: 0; opacity: 0; }
  22% { opacity: 1; }
  78% { opacity: 1; }
  88%, 100% { inset-block-start: calc(100% - 15px); opacity: 0; }
}

@media print {
  :root {
    --paper: #fff;
    --surface: #fff;
    --ink: #111;
    --muted: #333;
    --line: #bbb;
  }

  body::before,
  .site-header,
  .reading-progress,
  .lecture-toc,
  .back-to-top,
  .play-button,
  .lecture-pager,
  .site-footer {
    display: none !important;
  }

  .page-shell {
    display: block;
  }

  .content-section,
  .diagram-card,
  .table-wrap {
    break-inside: avoid;
    box-shadow: none;
  }

  .js [data-reveal] {
    opacity: 1 !important;
    translate: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .js [data-reveal] {
    opacity: 1;
    translate: none;
  }

  .moving-packet,
  svg .packet,
  svg animateMotion,
  svg animateTransform {
    display: none !important;
  }
}
