/* Learning surface. Two rooms in one page: the film stage is the reading
   room (true black; the lesson IS the image), the rail and the caption are
   slate (read in ambient light). Tokens mirror DESIGN.md by role. */
@font-face {
  font-family: Vazirmatn;
  src: url(assets/fonts/Vazirmatn-Regular.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url(assets/fonts/Vazirmatn-SemiBold.woff2) format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  /* reading room */
  --room: #0e0f11;
  --room-2: #17181c;
  --room-3: #1f2026;
  --room-line: rgba(255,255,255,.12);
  --room-text: #f3f2ee;
  --room-muted: #b8b6b0;
  --room-low: #8a8890;
  --room-accent: #3fb8d4;
  --room-on-accent: #06222c;
  /* slate */
  --ink: #e9edf1;
  --ink-2: #f7f9fb;
  --rule: #cfd7de;
  --rule-2: #dbe1e7;
  --text: #151a21;
  --dim: #3f4954;
  --faint: #5b6672;
  --cyan: #0a7389;
  --cyan-hover: #086274;
  --cyan-ink: #fff;
  --cyan-tint: #15a9c7;
  --cyan-soft: #daeff5;
  /* dark band */
  --deep: #1b242e;
  --deep-text: #f4f6f8;
  --deep-muted: #c2cbd4;
  --deep-subtle: #9aa6b2;
  --accent-on-dark: #45c2de;
  --on-accent-dark: #06222c;
  /* landmark tones */
  --mark-new: #3fb8d4;
  --mark-known: rgba(243,242,238,.55);
  --mark-air: #9aa6b2;
  --mark-fluid: #f4f6f8;
  --mark-bone: #fbbf24;
  --mark-muted: rgba(243,242,238,.38);
  --mark-line: rgba(255,255,255,.55);
  /* lesson tones (final "whole film" step): the read's structure, by colour.
     Class names are lt-<lesson id>; keep in sync with learn-content.js. */
  --tone-first-look: #9aa6b2;
  --tone-airway: #3fb8d4;
  --tone-breathing: #34d399;
  --tone-circulation: #f472b6;
  --tone-bones: #fbbf24;
  --tone-lateral: #fb923c;
  --tone-review-areas: #a78bfa;
  --pad: 20px;
  --maxw: 1440px;
  --sans: Vazirmatn, "Segoe UI", Inter, system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: dark;
}
[lang="en"], :root[lang="en"] {
  --sans: Inter, Vazirmatn, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--room); }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 15px; line-height: 1.6;
  color: var(--room-text);
  background: var(--room);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
body.is-home { min-height: 100dvh; }
body.is-module { height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
::selection { background: rgba(63,184,212,.35); color: #fff; }
:focus-visible { outline: 2px solid var(--room-accent); outline-offset: 2px; border-radius: 6px; }

.skip {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50;
  padding: 8px 14px; background: var(--ink-2); color: var(--text); text-decoration: none; border-radius: 8px;
  transition: top .15s var(--ease);
}
.skip:focus { top: 12px; }

/* ---------- top bar (dark band) ---------- */
.top { background: var(--deep); color: var(--deep-text); flex: none; }
.top-in {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad);
  height: 56px; display: flex; align-items: center; gap: 14px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--deep-text); }
.brand-mark { width: 22px; height: 22px; }
.brand-name { font-weight: 600; font-size: 17px; }
.crumb {
  margin-inline-start: 6px; text-decoration: none; color: var(--deep-muted);
  font-size: 13px; padding: 4px 0; border-bottom: 1px solid transparent;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.crumb:hover { color: var(--deep-text); border-color: var(--accent-on-dark); }
.top-tools { margin-inline-start: auto; display: flex; gap: 8px; }
.lang {
  background: transparent; border: 1px solid rgba(255,255,255,.18); color: var(--deep-text);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.lang:hover { border-color: var(--accent-on-dark); color: var(--accent-on-dark); }

/* ---------- home: the module list (slate) ---------- */
.home { flex: 1; background: var(--ink); color: var(--text); color-scheme: light; }
.home-in { max-width: 760px; margin: 0 auto; padding: 56px var(--pad) 80px; }
html[lang="en"] .home-in { max-width: 680px; }
.home-title { font-size: 32px; line-height: 1.15; margin: 0 0 10px; font-weight: 600; }
html[lang="en"] .home-title { letter-spacing: -.5px; }
.home-lead { color: var(--dim); margin: 0 0 32px; font-size: 16px; max-width: 56ch; }
.mods { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.mod-link {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 18px; align-items: center;
  padding: 18px 4px; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--text);
  transition: background .15s var(--ease);
}
.mod-link:hover { background: var(--ink-2); }
.mod-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #000; display: block; }
.mod-name { font-weight: 600; font-size: 17px; margin: 0; }
.mod-sub { color: var(--faint); font-size: 13px; margin: 4px 0 0; }
.mod-cta { display: inline-flex; align-items: center; gap: 6px; color: var(--cyan); font-size: 13px; font-weight: 600; }
[dir="rtl"] .mod-cta svg { transform: scaleX(-1); }
.mod-prog { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mod-prog-bar { width: 96px; height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.mod-prog-bar i { display: block; height: 100%; width: 100%; background: var(--cyan); border-radius: 2px; transform: scaleX(0); transform-origin: 0 50%; }
[dir="rtl"] .mod-prog-bar i { transform-origin: 100% 50%; }

/* ---------- module layout: the film dominates; the side column is fixed-width ---------- */
main.learn { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mod {
  flex: 1; display: grid; min-height: 0; overflow: hidden;
  grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 480px);
  grid-template-areas: "stage side";
  grid-template-rows: minmax(0, 1fr);
}
.side {
  grid-area: side; display: flex; flex-direction: column; min-height: 0;
  background: var(--ink); color: var(--text); border-inline-start: 1px solid var(--rule); color-scheme: light;
}
.rail {
  flex: 1 1 42%; min-height: 210px; background: var(--ink); color: var(--text);
  display: flex; flex-direction: column; overflow: hidden;
}
.stagewrap { grid-area: stage; background: var(--room); display: flex; flex-direction: column; min-height: 0; }
/* rail */
.rail-back {
  display: inline-flex; align-items: center; gap: 6px; margin: 14px var(--pad) 0;
  color: var(--faint); font-size: 13px; text-decoration: none;
}
.rail-back:hover { color: var(--cyan); }
[dir="rtl"] .rail-back svg { transform: scaleX(-1); }
.rail-title { font-size: 20px; font-weight: 600; margin: 10px var(--pad) 8px; line-height: 1.3; }
.lessons { list-style: none; margin: 0; padding: 0 0 8px; overflow: auto; flex: 1; min-height: 96px; }
.lesson { border-top: 1px solid var(--rule-2); }
.lesson:first-child { border-top: 0; }
.lesson-btn {
  width: 100%; background: none; border: 0; text-align: start; cursor: pointer;
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start;
  padding: 12px var(--pad);
}
.lesson-idx {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--faint);
  border: 1px solid var(--rule); margin-top: 1px; transition: all .15s var(--ease);
}
.lesson-name { font-weight: 600; font-size: 14px; margin: 0; color: var(--text); }
.lesson-goal { color: var(--faint); font-size: 12px; margin: 2px 0 0; }
.lesson-state { font-size: 11px; color: var(--faint); margin-top: 4px; }
.lesson.is-active .lesson-idx { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.lesson.is-active { background: var(--ink-2); }
.lesson.is-done .lesson-idx { background: var(--cyan-soft); border-color: var(--cyan-soft); color: var(--cyan); }
.lesson.is-done .lesson-state { color: var(--cyan); }
.steps { list-style: none; margin: 0; padding: 0 0 8px; display: none; }
.lesson.is-active .steps { display: block; }
.step-btn {
  width: 100%; text-align: start; background: none; border: 0; cursor: pointer;
  padding: 6px var(--pad); padding-inline-start: calc(var(--pad) + 38px);
  font-size: 13px; color: var(--dim);
  display: flex; align-items: center; gap: 8px;
}
.step-btn::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--rule);
  flex: none; transition: background .15s var(--ease), transform .15s var(--ease);
}
.step-btn.is-current { color: var(--cyan); font-weight: 600; }
.step-btn.is-current::before { background: var(--cyan); transform: scale(1.4); }
.step-btn.is-done::before { background: var(--cyan); }
.step-btn:hover { color: var(--text); }

.rail-foot { padding: 12px var(--pad) 16px; border-top: 1px solid var(--rule); }
.rail-progress { margin: 0 0 8px; font-size: 12px; color: var(--faint); }
.rail-bar { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.rail-bar i { display: block; height: 100%; width: 100%; background: var(--cyan); border-radius: 2px; transform: scaleX(0); transform-origin: 0 50%; transition: transform .32s var(--ease); }
[dir="rtl"] .rail-bar i { transform-origin: 100% 50%; }
.btn-viewer { width: 100%; background: transparent; color: var(--dim); border: 1px solid var(--rule); }
.btn-viewer:hover { color: var(--cyan); border-color: var(--cyan); }

/* stage: the film */
.stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: #000; touch-action: none; cursor: grab; user-select: none;
}
.stage.is-panning { cursor: grabbing; }
.film {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
  transform-origin: 0 0; will-change: transform;
  opacity: 0; transition: opacity .32s var(--ease);
}
.film.is-loaded { opacity: 1; }
.film:not(.is-loaded) ~ .marks, .film:not(.is-loaded) ~ .overlay-svg { visibility: hidden; }
.film.is-inverted { filter: invert(1) contrast(1.06); }
.overlay-svg {
  position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 1;
}
.overlay-svg svg { display: block; overflow: visible; position: absolute; left: 0; top: 0; }
.marks { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 2; }
.stage.is-marks-hidden .marks, .stage.is-marks-hidden .overlay-svg { opacity: 0; pointer-events: none; }
.stage.is-marks-hidden .mark { pointer-events: none; }
.stage.is-quiz { cursor: crosshair; }
.stage.is-review:not(.is-panning) { cursor: crosshair; }
.stage.is-review .marks, .stage.is-review .overlay-svg, .stage.is-review .stage-hint { visibility: hidden; }
.review-pin {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; border: 2px solid #fbbf24; background: rgba(251,191,36,.28);
  box-shadow: 0 0 0 2px rgba(0,0,0,.7); pointer-events: none; z-index: 3;
}
.review-bar {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  padding: 8px 14px; background: var(--room-2); border-bottom: 1px solid var(--room-accent);
  color: var(--room-text); font-size: 12px;
}
.review-line { display: flex; align-items: center; gap: 8px; }
#reviewCursor { min-width: 15ch; color: var(--room-accent); font-weight: 600; }
#reviewPoint { width: 17ch; font: inherit; font-weight: 600; padding: 3px 6px; color: #fbbf24; background: var(--room); border: 1px solid var(--room-line); border-radius: 4px; }
#reviewStatus { color: var(--room-muted); }
.tool-xy { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.stage-tools {
  position: absolute; inset-inline-end: 14px; top: 14px; display: flex; flex-direction: column; gap: 4px; z-index: 4;
  background: var(--room-2); border: 1px solid var(--room-line); border-radius: 10px; padding: 4px;
}
.tool-sep { height: 1px; background: var(--room-line); margin: 2px 4px; }
.tool {
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--room-muted);
  border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 18px; line-height: 1;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tool:hover { background: var(--room-3); color: var(--room-text); }
.tool[aria-pressed="true"] { background: rgba(63,184,212,.18); color: var(--room-accent); }
.stage-filmbar {
  flex: none; display: flex; justify-content: center; gap: 6px; padding: 8px 14px;
  background: var(--room); border-bottom: 1px solid var(--room-line);
}
.film-tab {
  border: 1px solid var(--room-line); background: var(--room-2); color: var(--room-muted); font-size: 12px; font-weight: 600;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.film-tab:hover { color: var(--room-text); background: var(--room-3); }
.film-tab.is-active { background: var(--room-accent); border-color: var(--room-accent); color: var(--room-on-accent); }
.stage-hint {
  position: absolute; inset-inline-start: 14px; bottom: 14px; margin: 0; max-width: 70%;
  font-size: 11px; color: var(--room-low); opacity: 0; transition: opacity .32s var(--ease);
  pointer-events: none; white-space: nowrap;
}
.stage.is-hinting .stage-hint { opacity: 1; }
.stagemsg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center; background: var(--room); z-index: 3;
}
.stagemsg-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--room-text); }
.stagemsg-msg { margin: 0 0 10px; font-size: 13px; color: var(--room-muted); max-width: 42ch; }

/* markers. .mark is a 0x0 button at the landmark; ring, dot, leader and chip
   hang off it. data-dir is the CHIP direction (l|r|u|d), resolved by the
   engine; it is independent of the anatomical side. */
.mark {
  position: absolute; left: 0; top: 0; width: 0; height: 0; padding: 0; border: 0; background: none;
  pointer-events: auto; cursor: pointer; will-change: transform;
}
/* a 0x0 point has no hit area and the focus ring would draw around nothing:
  the invisible disc gives touch and mouse a 40px target, the ring carries focus */
.mark::before {
  content: ""; position: absolute; left: -20px; top: -20px; width: 40px; height: 40px; border-radius: 50%;
}
.mark:focus-visible { outline: none; }
.mark:focus-visible .mark-ring {
  outline: 2px solid var(--room-accent); outline-offset: 3px; border-radius: 50%;
}
.stage.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; border: 2px solid var(--room-line); border-top-color: var(--room-accent);
  animation: spin .8s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mark-ring {
  position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--mark-line); box-shadow: 0 0 0 3px rgba(0,0,0,.45);
  transition: border-color .2s var(--ease), transform .2s var(--ease), opacity .2s var(--ease);
}
.mark-dot { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: #fff; opacity: .9; }
.mark.is-known .mark-ring {
  left: -5px; top: -5px; width: 10px; height: 10px;
  border-width: 1.5px; border-color: var(--mark-known); opacity: .55; box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}
.mark.is-known .mark-dot { display: none; }
.mark.is-new .mark-ring { border-color: var(--mark-new); animation: breathe 1.6s var(--ease) .1s 2; }
.mark.is-pinned .mark-ring { border-color: var(--mark-new); transform: scale(1.25); opacity: 1; }
.mark.is-pulse .mark-ring { animation: pulse .9s var(--ease) 1; }
@keyframes pulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(63,184,212,.7), 0 0 0 3px rgba(0,0,0,.45); } 40% { transform: scale(1.35); } 100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(63,184,212,0), 0 0 0 3px rgba(0,0,0,.45); } }
.mark.is-new { z-index: 2; }
.mark:hover, .mark:focus-visible, .mark.is-pinned { z-index: 5; }
.mark.tone-air .mark-ring { border-color: var(--mark-air); }
.mark.tone-fluid .mark-ring { border-color: var(--mark-fluid); }
.mark.tone-bone .mark-ring { border-color: var(--mark-bone); }
.mark.tone-muted .mark-ring { border-color: var(--mark-muted); }
.mark-chip {
  position: absolute; white-space: nowrap; font-size: 12px; line-height: 1;
  padding: 5px 8px; border-radius: 6px; background: rgba(14,15,17,.82);
  color: var(--room-text); border: 1px solid rgba(255,255,255,.14);
  opacity: 0; transition: opacity .22s var(--ease);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.mark.is-new .mark-chip, .mark.is-pinned .mark-chip, .mark:hover .mark-chip, .mark:focus-visible .mark-chip { opacity: 1; }
.mark.is-pinned .mark-chip { opacity: 1 !important; }
.mark-chip { display: inline-flex; align-items: baseline; gap: 7px; }
.mark-chip > bdi { display: inline-block; unicode-bidi: isolate; white-space: nowrap; }
.mark-chip .en { color: var(--room-muted); font-size: 11px; }
/* The chip's box and the leader's length/angle are computed by the engine
   (layout) and applied as a translate + rotate; CSS owns only the look and
   the reveal (opacity + a 3px rise). */
.mark-chip { left: 0; top: 0; right: auto; }
.mark[data-dir="l"] .mark-chip { text-align: end; }
.mark-leader {
  position: absolute; left: 0; top: 0; height: 1px; width: 0;
  background: rgba(255,255,255,.55); transform-origin: 0 0;
  opacity: 0; transition: opacity .22s var(--ease); pointer-events: none;
}
.mark.is-new .mark-leader, .mark.is-pinned .mark-leader, .mark:hover .mark-leader, .mark:focus-visible .mark-leader { opacity: 1; }
/* lesson tones: final whole-film step */
.mark.lt-first-look .mark-ring { border-color: var(--tone-first-look); }
.mark.lt-airway .mark-ring { border-color: var(--tone-airway); }
.mark.lt-breathing .mark-ring { border-color: var(--tone-breathing); }
.mark.lt-circulation .mark-ring { border-color: var(--tone-circulation); }
.mark.lt-bones .mark-ring { border-color: var(--tone-bones); }
.mark.lt-lateral .mark-ring { border-color: var(--tone-lateral); }
.mark.lt-review-areas .mark-ring { border-color: var(--tone-review-areas); }
.mark.is-dimmed { opacity: .18; pointer-events: none; }
@keyframes breathe {
  0% { box-shadow: 0 0 0 0 rgba(63,184,212,.6), 0 0 0 3px rgba(0,0,0,.45); }
  100% { box-shadow: 0 0 0 18px rgba(63,184,212,0), 0 0 0 3px rgba(0,0,0,.45); }
}

/* caption: the step's words, on slate */
/* the caption is capped so the lesson rail keeps a floor on a short laptop;
   inside it the text scrolls and the nav row stays pinned, so Next/Prev are
   reachable for every caption length at any viewport height */
.caption {
  flex: 0 1 auto; min-height: 0; max-height: 58%; display: flex; flex-direction: column;
  overflow-y: auto; background: var(--ink-2); color: var(--text); padding: 18px var(--pad) 0; border-top: 1px solid var(--rule); color-scheme: light;
}
.caption > * { flex: none; }
.cap-nav {
  position: sticky; bottom: 0; margin-top: 18px; padding: 12px 0 16px;
  background: var(--ink-2);
}
.cap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.cap-lesson { margin: 0; font-size: 12px; color: var(--cyan); font-weight: 600; }
.cap-step { margin: 0; font-size: 12px; color: var(--faint); }
.cap-title { margin: 0 0 8px; font-size: 20px; line-height: 1.3; font-weight: 600; }
html[lang="en"] .cap-title { letter-spacing: -.2px; }
.cap-text { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.75; max-width: 60ch; }
html[lang="en"] .cap-text { line-height: 1.6; }
.sr-sep { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cap-pearl {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 8px;
  background: var(--ink); border: 1px solid var(--rule-2);
}
.cap-pearl-label {
  display: block; font-size: 11px; font-weight: 600; color: var(--cyan); margin-bottom: 3px;
}
.cap-pearl-text { margin: 0; font-size: 13px; line-height: 1.65; color: var(--dim); }
.quiz-box {
  margin: 12px 0 0; padding: 12px; border-radius: 10px;
  background: var(--ink); border: 1px solid var(--cyan);
}
.quiz-prompt { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.quiz-feedback { margin: 0 0 8px; font-size: 13px; color: var(--dim); min-height: 1.4em; }
.quiz-feedback.is-ok { color: #0f7a5a; font-weight: 600; }
.quiz-feedback.is-miss { color: #b3364b; }
.quiz-actions { display: flex; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.terms { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.term, .terms li {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 6px; background: var(--ink);
  border: 1px solid var(--rule-2); color: var(--dim); display: inline-flex; align-items: baseline;
}
.term { cursor: pointer; }
.term:hover { border-color: var(--cyan); }
.term b, .terms li b { font-weight: 600; color: var(--text); }
.term { gap: 7px; }
.term > bdi { display: inline-block; unicode-bidi: isolate; white-space: nowrap; }
.term .sub, .terms li span { display: inline-block; unicode-bidi: isolate; color: var(--faint); }
.terms.is-legend { gap: 4px 10px; }
.terms.is-legend .legend-btn {
  background: transparent; border: 1px solid transparent; padding: 3px 8px; border-radius: 6px;
  font: inherit; font-size: 12px; color: var(--dim); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.terms.is-legend .legend-btn:hover { background: var(--ink); border-color: var(--rule-2); }
.terms.is-legend .legend-btn.is-active { background: var(--ink); border-color: var(--cyan); color: var(--text); font-weight: 600; }
.terms.is-legend .legend-btn::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--lt); flex: none; }
.terms.is-legend .legend-btn[data-lt="first-look"] { --lt: #6b7280; }
.terms.is-legend .legend-btn[data-lt="airway"] { --lt: #0e8fae; }
.terms.is-legend .legend-btn[data-lt="breathing"] { --lt: #0f9d6e; }
.terms.is-legend .legend-btn[data-lt="circulation"] { --lt: #d43f7f; }
.terms.is-legend .legend-btn[data-lt="bones"] { --lt: #b7791f; }
.terms.is-legend .legend-btn[data-lt="lateral"] { --lt: #ea580c; }
.terms.is-legend .legend-btn[data-lt="review-areas"] { --lt: #7c5cf0; }
.cap-nav { display: flex; justify-content: space-between; gap: 10px; }
.btn-primary.is-finish .next-ico { display: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.btn-ghost { background: transparent; color: var(--dim); border: 1px solid var(--rule); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }
.btn-ghost:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--cyan); color: var(--cyan-ink); }
.btn-primary:hover { background: var(--cyan-hover); }
[dir="rtl"] .next-ico { transform: scaleX(-1); }
.cap-enter { animation: capIn .32s var(--ease) both; }
@keyframes capIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- responsive: phone is a single column; stage on top, caption below, rail last ---------- */
@media (max-width: 960px) {
  body.is-module { height: auto; overflow: auto; }
  .mod { display: flex; flex-direction: column; overflow: visible; flex: none; }
  .stage { height: 50dvh; min-height: 300px; flex: none; }
  .side { border-inline-start: 0; border-top: 1px solid var(--rule); flex-direction: column-reverse; }
  .rail { flex: none; min-height: 0; }
  .caption { max-height: none; overflow: visible; }
  .lessons { max-height: 260px; }
}
@media (min-width: 961px) and (max-height: 700px) {
  .rail-back { margin-top: 10px; }
  .rail-title { font-size: 17px; margin: 6px var(--pad) 4px; }
  .rail-foot { padding: 8px var(--pad) 10px; }
  .rail-bar { margin-bottom: 8px; }
  .btn-viewer { padding: 7px 14px; font-size: 13px; }
}
@media (max-width: 640px) {
  :root { --pad: 16px; }
  .home-in { padding-top: 32px; }
  .home-title { font-size: 26px; }
  .mod-link { grid-template-columns: 56px 1fr auto; gap: 12px; padding: 14px 2px; }
  .mod-thumb { width: 56px; height: 56px; }
  .cap-title { font-size: 18px; }
  .cap-text { font-size: 14px; }
  .stage { height: 46dvh; min-height: 260px; }
  .stage-hint { display: none; }
  .mark-chip { flex-direction: column; align-items: flex-start; gap: 2px; padding: 4px 6px; font-size: 11px; }
  .mark-chip .en { font-size: 10px; }
  .mark[data-dir="l"] .mark-chip { align-items: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .stage { height: 70dvh; }
}
