/* ADR 0040 — the classroom (/learn/{slug}). Prefix lx-.
   Three panes: course contents | lesson | tools (on this page · resources · notes). Layout state lives in
   data-* attributes on .lx that js/learn.js owns and remembers per browser:
     data-width = standard | wide | full      data-toc / data-side = open | closed
     data-fs    = 0..3 (text size)            data-focus = on (both rails closed)
   Palette roles (theme-medax.css): ONE orange action per view (Complete & continue), royal for structure
   and "you are here", verified green for done, slate for "not yet". Every colour is a token, so the dark
   mirror comes free. */

/* MainLayout caps <main> at 1120px with 40px padding - that cap is why the old classroom felt narrow.
   The classroom owns its width (standard = the site shell, wide, full), like the dashboard does. */
.mx-app > .mx-main:has(> .lx) { max-width: none; padding: 0; }

.lx {
  --lx-top: 3.6rem;                 /* sticky offset under the site header; learn.js measures it */
  --lx-toc-w: 17rem;
  --lx-side-w: 19rem;
  --lx-strip-w: 3.25rem;
  --lx-gap: 1.25rem;
  --lx-fs: 1.0625rem;
  --lx-ink: var(--bs-heading-color);
  --lx-muted: var(--bs-secondary-color);
  --lx-line: var(--bs-border-color);
  --lx-card: var(--bs-card-bg, var(--bs-body-bg));
  --lx-royal: var(--mx-nav-signal);
  --lx-royal-tint: var(--mx-nav-signal-tint);
  --lx-done: var(--mx-teal, #0f9c7c);
  --lx-done-ink: var(--mx-nav-verified);
  --lx-action: var(--mx-nav-action);
  --lx-on-action: var(--mx-nav-on-action);
  --lx-radius: 14px;
  width: 100%;
  max-width: var(--mx-shell, 1240px);
  margin: 0 auto;
  padding: 0 clamp(.75rem, 2vw, 1.5rem) 3rem;
  color: var(--bs-body-color);
}
.lx[data-width="wide"] { max-width: 1640px; }
.lx[data-width="full"] { max-width: none; }
.lx[data-fs="0"] { --lx-fs: .98rem; }
.lx[data-fs="2"] { --lx-fs: 1.17rem; }
.lx[data-fs="3"] { --lx-fs: 1.3rem; }

.lx-svg { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }
.lx-hint { color: var(--lx-muted); font-size: .8rem; }
.lx-eyebrow { font-family: var(--mx-font-sans); font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--lx-muted); }
.lx-count { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .2rem; border-radius: 999px; font-size: .7rem; font-weight: 700; line-height: 1.25rem; text-align: center; background: var(--bs-tertiary-bg); color: var(--lx-muted); }

/* ── buttons ── */
.lx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.5rem; padding: .5rem 1.05rem; border-radius: 999px;
  font-weight: 700; font-size: .9rem; line-height: 1.1; text-decoration: none; white-space: nowrap;
  border: 1.5px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.lx-btn:active:not(:disabled) { transform: translateY(1px); }
.lx-btn--sm { min-height: 2rem; padding: .3rem .8rem; font-size: .8rem; }
.lx-btn--block { width: 100%; }
.lx-btn--primary { background: var(--lx-action); color: var(--lx-on-action); }
.lx-btn--primary:hover:not(:disabled) { background: var(--mx-nav-action-hover); color: var(--lx-on-action); }
.lx-btn--ghost { background: transparent; color: var(--lx-ink); border-color: var(--mx-nav-hairline-strong); }
.lx-btn--ghost:hover:not(:disabled) { border-color: var(--lx-royal); color: var(--lx-royal); }
.lx-btn--done { background: color-mix(in srgb, var(--lx-done) 14%, transparent); color: var(--lx-done-ink); border-color: color-mix(in srgb, var(--lx-done) 40%, transparent); }
.lx-btn--done:hover { background: transparent; }
/* The opening grace (ADR 0040 D2): the button fills left→right over --grace instead of sitting greyed out. */
.lx-btn--grace {
  position: relative; overflow: hidden; isolation: isolate; cursor: progress;
  background: var(--mx-nav-disabled); color: var(--mx-nav-on-disabled); border-color: transparent;
}
.lx-btn--grace::before {
  content: ""; position: absolute; inset: 0; z-index: -1; transform-origin: left;
  background: var(--mx-nav-action-tint); animation: lx-grace var(--grace, 10s) linear forwards;
}
@keyframes lx-grace { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.lx-btn:disabled { opacity: 1; }
.lx-btn--primary:disabled { opacity: .55; cursor: not-allowed; }
.lx-link { background: none; border: 0; padding: 0; color: var(--lx-royal); font-weight: 600; font-size: .8rem; cursor: pointer; text-decoration: none; }
.lx-link:hover { text-decoration: underline; }
.lx-link--danger { color: var(--mx-nav-error); }
.lx-icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem;
  border-radius: 10px; border: 0; background: transparent; color: var(--lx-muted); cursor: pointer; font-weight: 700;
  transition: background .15s, color .15s;
}
.lx-icon-btn:hover { background: var(--bs-tertiary-bg); color: var(--lx-ink); }
.lx-icon-btn:focus-visible, .lx-btn:focus-visible, .lx-lesson:focus-visible, .lx-mod-head:focus-visible, .lx-seg-btn:focus-visible { outline: 2px solid var(--lx-royal); outline-offset: 2px; }
.lx-badge { position: absolute; top: .1rem; right: .05rem; min-width: 1rem; height: 1rem; padding: 0 .25rem; border-radius: 999px; background: var(--lx-royal); color: var(--mx-nav-on-signal); font-size: .6rem; font-weight: 800; line-height: 1rem; }

.lx-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--bs-tertiary-bg); }
.lx-seg-btn { border: 0; background: transparent; color: var(--lx-muted); border-radius: 999px; padding: .3rem .7rem; font-size: .78rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; }
.lx-seg-btn.is-on, .lx-seg-btn[data-on] { background: var(--lx-card); color: var(--lx-ink); box-shadow: 0 1px 3px rgba(10, 26, 47, .12); }
.lx-seg--icons .lx-seg-btn { padding: .25rem .5rem; }
.lx-fs-btn small { font-size: .7em; margin-left: 1px; }
.lx-chip { border: 1px solid var(--lx-line); background: transparent; color: var(--lx-muted); border-radius: 999px; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; cursor: pointer; }
.lx-chip.is-on { background: var(--mx-nav-action-tint); border-color: transparent; color: var(--mx-nav-action-ink); }

/* progress ring: set --p (0-100) inline */
.lx-ring {
  --size: 1.6rem; --thick: 3.5px;
  display: inline-grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%;
  background: conic-gradient(var(--lx-done) calc(var(--p, 0) * 1%), var(--bs-tertiary-bg) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + .5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + .5px));
}
.lx-ring--lg { --size: 2.4rem; --thick: 4px; -webkit-mask: none; mask: none; position: relative; }
.lx-ring--lg::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--lx-card); }
.lx-ring--lg > span { position: relative; font-size: .68rem; font-weight: 800; color: var(--lx-ink); }

/* ── top bar ── */
.lx-bar {
  position: sticky; top: var(--lx-top); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem .5rem; margin: 0 calc(-1 * clamp(.75rem, 2vw, 1.5rem)) 1rem;
  padding-inline: clamp(.75rem, 2vw, 1.5rem);
  background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(10px); backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--lx-line);
}
.lx-bar-l, .lx-bar-r { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.lx-bar-back { display: inline-flex; align-items: center; gap: .15rem; color: var(--lx-muted); font-size: .85rem; font-weight: 600; text-decoration: none; }
.lx-bar-back:hover { color: var(--lx-royal); }
.lx-bar-sep { color: var(--lx-line); }
.lx-bar-course { font-weight: 800; color: var(--lx-ink); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lx-bar-progress { display: inline-flex; align-items: center; gap: .4rem; margin-right: .35rem; font-size: .8rem; font-weight: 800; color: var(--lx-ink); }

/* ── grid ── */
.lx-grid {
  display: grid; gap: var(--lx-gap); align-items: start;
  grid-template-columns: var(--lx-toc-w) minmax(0, 1fr) var(--lx-strip-w);
  /* No transition on the columns: an interpolated grid is caught half-collapsed whenever the tab isn't
     painting (background tab, screenshots) and reflows the lesson text every frame anyway. */
}
.lx[data-side="open"] .lx-grid { grid-template-columns: var(--lx-toc-w) minmax(0, 1fr) var(--lx-side-w); }
.lx[data-toc="closed"] .lx-grid { grid-template-columns: var(--lx-strip-w) minmax(0, 1fr) var(--lx-strip-w); }
.lx[data-toc="closed"][data-side="open"] .lx-grid { grid-template-columns: var(--lx-strip-w) minmax(0, 1fr) var(--lx-side-w); }

.lx-toc, .lx-side {
  position: sticky; top: calc(var(--lx-top) + 3.9rem); align-self: start;
  max-height: calc(100vh - var(--lx-top) - 4.9rem); display: flex; flex-direction: column; min-width: 0;
}
.lx-rail { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--mx-nav-hairline-strong) transparent; padding: .1rem .25rem 1rem .1rem; min-height: 0; }
.lx-strip { display: none; flex-direction: column; align-items: center; gap: .55rem; padding-top: .25rem; }
.lx-strip-num { font-size: .72rem; font-weight: 800; color: var(--lx-ink); writing-mode: horizontal-tb; }
.lx-strip-num small { color: var(--lx-muted); font-weight: 600; }
.lx[data-toc="closed"] .lx-toc .lx-rail, .lx:not([data-side="open"]) .lx-side .lx-rail { display: none; }
.lx[data-toc="closed"] .lx-toc .lx-strip, .lx:not([data-side="open"]) .lx-side .lx-strip { display: flex; }

/* ── contents rail ── */
.lx-summary { padding: .9rem .9rem .8rem; border: 1px solid var(--lx-line); border-radius: var(--lx-radius); background: var(--lx-card); margin-bottom: .75rem; }
.lx-summary-bar, .lx-mod-bar { height: .4rem; border-radius: 999px; background: var(--bs-tertiary-bg); overflow: hidden; }
.lx-summary-bar span, .lx-mod-bar span { display: block; height: 100%; background: var(--lx-done); border-radius: inherit; transition: width .4s ease; }
.lx-summary-row { margin-top: .45rem; font-size: .82rem; color: var(--lx-ink); }
.lx-summary-row.lx-hint { margin-top: .15rem; color: var(--lx-muted); }
/* "Test yourself": the course's stations or mocks, a quiet tinted link under the progress (never a second orange button). */
.lx-practice { display: flex; flex-direction: column; gap: .1rem; margin-top: .7rem; padding: .5rem .65rem; border-radius: .55rem;
  background: var(--lx-royal-tint); color: var(--lx-royal); text-decoration: none; transition: filter .15s; }
.lx-practice:hover { filter: brightness(.97); color: var(--lx-royal); }
.lx-practice-lbl { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lx-muted); }
.lx-practice-go { font-size: .86rem; font-weight: 650; }
.lx-find { position: relative; margin-bottom: .5rem; }
.lx-find-ico { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--lx-muted); display: inline-flex; }
.lx-find-input { width: 100%; border: 1px solid var(--lx-line); background: var(--lx-card); color: var(--bs-body-color); border-radius: 10px; padding: .45rem .7rem .45rem 2.1rem; font-size: .85rem; }
.lx-find-input:focus { outline: 2px solid var(--lx-royal-tint); border-color: var(--lx-royal); }
.lx-toc-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-bottom: .6rem; padding: 0 .1rem; }
.lx-toc-tools .lx-chip { padding: .15rem .5rem; font-size: .72rem; white-space: nowrap; }
.lx-toc-tools .lx-link { white-space: nowrap; font-size: .75rem; margin-left: auto; }
.lx-toc-tools-sp { display: none; }   /* the link's auto margin does the pushing, and doesn't wrap on its own */
.lx-toc-tools-sp { flex: 1; }

.lx-part-head { margin: .9rem .5rem .15rem; font-size: .72rem; font-weight: 800; letter-spacing: .02em; color: var(--lx-ink); }
.lx-part-hint { margin: 0 .5rem .35rem; font-size: .72rem; line-height: 1.35; color: var(--lx-muted); }
.lx-mod { border-radius: 12px; margin-bottom: .25rem; }
.lx-mod.is-open { background: color-mix(in srgb, var(--lx-card) 70%, transparent); }
.lx-mod-head {
  width: 100%; display: flex; align-items: center; gap: .55rem; padding: .55rem .5rem;
  border: 0; background: transparent; border-radius: 10px; text-align: left; cursor: pointer; color: var(--lx-ink);
}
.lx-mod-head:hover { background: var(--bs-tertiary-bg); }
.lx-mod-n { flex: 0 0 auto; width: 1.55rem; height: 1.55rem; display: grid; place-items: center; border-radius: 8px; font-size: .72rem; font-weight: 800; background: var(--bs-tertiary-bg); color: var(--lx-muted); }
.lx-mod.is-here .lx-mod-n { background: var(--lx-royal); color: var(--mx-nav-on-signal); }
.lx-mod.is-done .lx-mod-n { background: color-mix(in srgb, var(--lx-done) 18%, transparent); color: var(--lx-done-ink); }
.lx-mod-title { flex: 1; font-size: .8rem; font-weight: 700; letter-spacing: .01em; line-height: 1.25; }
.lx-mod-count { font-size: .7rem; font-weight: 700; color: var(--lx-muted); font-variant-numeric: tabular-nums; }
.lx-mod-chev { color: var(--lx-muted); display: inline-flex; transition: transform .2s ease; }
.lx-mod.is-open .lx-mod-chev { transform: rotate(180deg); }
.lx-mod-bar { height: 3px; margin: 0 .55rem .2rem 2.6rem; }
.lx-mod:not(.is-open) .lx-mod-bar { opacity: .7; }
.lx-lessons { list-style: none; margin: .15rem 0 .4rem; padding: 0; }
.lx-lesson {
  width: 100%; display: flex; align-items: center; gap: .55rem; padding: .42rem .5rem .42rem .55rem;
  border: 0; background: transparent; border-radius: 9px; text-align: left; cursor: pointer; color: var(--bs-body-color);
  font-size: .84rem; line-height: 1.3;
}
.lx-lesson:hover { background: var(--bs-tertiary-bg); }
.lx-lesson.is-current { background: var(--lx-royal-tint); color: var(--lx-royal); font-weight: 700; box-shadow: inset 3px 0 0 var(--lx-royal); }
.lx-lesson-state {
  flex: 0 0 auto; position: relative; width: 1.35rem; height: 1.35rem; border-radius: 50%; display: grid; place-items: center;
  font-size: .62rem; color: var(--lx-muted); background: var(--bs-tertiary-bg);
}
.lx-lesson.is-started .lx-lesson-state { background: conic-gradient(var(--lx-royal) calc(var(--p, 0) * 1%), var(--bs-tertiary-bg) 0); }
.lx-lesson.is-started .lx-lesson-state > span { position: absolute; inset: 2.5px; border-radius: 50%; display: grid; place-items: center; background: var(--lx-card); }
.lx-lesson.is-done .lx-lesson-state { background: var(--lx-done); color: #fff; font-size: .7rem; font-weight: 800; }
/* Completed quickly: still a tick (it IS complete), but hollow - a quiet "worth a revisit". */
.lx-lesson.is-quick .lx-lesson-state { background: transparent; color: var(--lx-done-ink); box-shadow: inset 0 0 0 1.5px var(--lx-done); }
/* Two lines before it's cut: "Drug calculations from first principles" was reading as "Drug calculations from fir…". */
.lx-lesson-title { flex: 1 1 auto; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; line-height: 1.3; }
.lx-lesson-meta { flex: 0 0 auto; display: inline-flex; gap: .3rem; align-items: center; font-size: .68rem; color: var(--lx-muted); font-weight: 500; }
.lx-star-mini { color: var(--lx-action); }
.lx-sessions { padding: .1rem .4rem .5rem; }

/* ── the lesson ── */
.lx-main { min-width: 0; }
.lx-card { position: relative; background: var(--lx-card); border: 1px solid var(--lx-line); border-radius: var(--lx-radius); box-shadow: var(--mx-nav-shadow); }
.lx-article { padding: clamp(1.25rem, 3vw, 2.4rem) clamp(1.1rem, 3.4vw, 2.75rem) 1.5rem; overflow: clip; }
.lx-welcome { padding: 3rem 2rem; text-align: center; }
/* A course with no lessons yet lists what it does include, each a way in. */
.lx-included { list-style: none; margin: 1.4rem auto 0; padding: 0; max-width: 30rem; text-align: left; display: grid; gap: .55rem; }
.lx-included li { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .9rem; border: 1px solid var(--lx-line); border-radius: 10px; background: var(--bs-card-bg); }
.lx-included a { font-weight: 650; text-decoration: none; }
.lx-included a:hover { text-decoration: underline; }
.lx-readbar { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: transparent; border-radius: var(--lx-radius) var(--lx-radius) 0 0; overflow: hidden; }
.lx-readbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lx-royal), var(--mx-nav-ramp-2)); transition: width .15s linear; }

.lx-lesson-head { margin-bottom: 1.25rem; }
.lx-crumbs { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .5rem; }
.lx-crumbs-n { font-size: .75rem; color: var(--lx-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.lx-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lx-title { font-family: var(--mx-font-quote); font-weight: 700; font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1.15; letter-spacing: -.01em; color: var(--lx-ink); margin: 0; flex: 1 1 18rem; }
.lx-title-acts { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.lx-star { font-size: 1.25rem; color: var(--lx-muted); }
.lx-star.is-on { color: var(--lx-action); }
.lx-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.lx-tag { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; background: var(--bs-tertiary-bg); color: var(--lx-muted); font-size: .74rem; font-weight: 600; }
.lx-tag .lx-svg { width: .9rem; height: .9rem; }
.lx-tag--done { background: color-mix(in srgb, var(--lx-done) 15%, transparent); color: var(--lx-done-ink); }
.lx-tag--prog { background: var(--lx-royal-tint); color: var(--lx-royal); }
.lx-resumed { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: -.35rem 0 1rem; padding: .5rem .8rem; border-radius: 10px; background: var(--lx-royal-tint); color: var(--lx-royal); font-size: .82rem; font-weight: 600; }
.lx-resumed span { display: inline-flex; align-items: center; gap: .35rem; }

.lx-video { position: relative; border-radius: 12px; overflow: hidden; background: #000; margin: 0 0 1.5rem; }
.lx-video--embed { padding-top: 56.25%; }
.lx-video--embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lx-callout { padding: 1rem 1.1rem; border-radius: 12px; background: var(--lx-royal-tint); margin-bottom: 1.25rem; }
.lx-download { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; margin-bottom: 1.5rem; border: 1px solid var(--lx-line); border-radius: 12px; text-decoration: none; color: var(--lx-ink); background: var(--mx-nav-inset); }
.lx-download:hover { border-color: var(--lx-royal); }
.lx-download-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lx-download-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-download-go { font-weight: 700; color: var(--lx-royal); font-size: .85rem; }

.lx-body { font-size: var(--lx-fs); line-height: 1.75; }
.lx-body .mkt-prose { font-size: inherit; max-width: none; }
.lx-body .mkt-prose h2 { font-family: var(--mx-font-quote); font-size: 1.55em; margin-top: 1.8em; scroll-margin-top: calc(var(--lx-top) + 5rem); }
.lx-body .mkt-prose h3 { font-size: 1.15em; margin-top: 1.5em; scroll-margin-top: calc(var(--lx-top) + 5rem); }
.lx-body .mkt-prose h2:first-child { margin-top: .4em; }
/* pictures in a lesson's text (the OSCE book's figures): fit the reading column, never wider than drawn */
.lx-body .mkt-prose img { display: block; max-width: 100%; height: auto; margin: 1.2em auto; border-radius: 6px; cursor: zoom-in; }
.lx-body .mkt-prose img:focus-visible { outline: 3px solid var(--lx-royal); outline-offset: 3px; }

/* picture viewer (learn.js): the picture fitted to the screen, or at full size to scroll around */
.lx-viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgb(8 12 24 / .94); color: #fff; display: none; flex-direction: column; }
.lx-viewer[open] { display: flex; }
.lx-viewer::backdrop { background: rgb(8 12 24 / .6); }
html.lx-viewer-open { overflow: hidden; }
.lx-viewer-bar { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .6rem max(.75rem, env(safe-area-inset-right)) .6rem .75rem; flex: none; }
.lx-viewer-count { margin-right: auto; font-size: .9rem; opacity: .85; }
.lx-viewer-btn { appearance: none; border: 1px solid rgb(255 255 255 / .35); background: rgb(255 255 255 / .08); color: #fff;
  border-radius: 999px; min-height: 2.5rem; min-width: 2.5rem; padding: 0 .9rem; font: inherit; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; }
.lx-viewer-btn:hover { background: rgb(255 255 255 / .18); color: #fff; }
.lx-viewer-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.lx-viewer-btn[hidden] { display: none; }
.lx-viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 0 .75rem .75rem; }
.lx-viewer-stage img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 4px; cursor: zoom-in; }
.lx-viewer.is-full .lx-viewer-stage img { max-width: none; max-height: none; cursor: zoom-out; }
@media (max-width: 575.98px) { .lx-viewer-btn[data-v="tab"] { display: none; } }
.lx-body ::selection { background: color-mix(in srgb, var(--lx-action) 30%, transparent); }
.lx-end { height: 1px; }

/* quick check */
.lx-check { margin: 2.25rem 0 .5rem; padding: 1.35rem clamp(1rem, 2.5vw, 1.6rem); border-radius: var(--lx-radius); border: 1px solid var(--lx-line); background: var(--mx-nav-inset); scroll-margin-top: calc(var(--lx-top) + 5rem); }
.lx-check-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lx-check-title { font-family: var(--mx-font-quote); font-size: 1.35rem; font-weight: 700; margin: .15rem 0 .2rem; color: var(--lx-ink); }
.lx-check-sub { margin: 0; color: var(--lx-muted); font-size: .88rem; }
.lx-check-score { display: flex; flex-direction: column; align-items: center; padding: .45rem .9rem; border-radius: 12px; min-width: 6rem; }
.lx-check-score.is-pass { background: color-mix(in srgb, var(--lx-done) 15%, transparent); color: var(--lx-done-ink); }
.lx-check-score.is-retry { background: var(--mx-nav-action-tint); color: var(--mx-nav-action-ink); }
.lx-check-score-n { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.lx-check-score-l { font-size: .72rem; font-weight: 700; }
.lx-check-list { list-style: none; counter-reset: q; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.lx-check-q { counter-increment: q; }
.lx-check-prompt { font-weight: 700; color: var(--lx-ink); margin: 0 0 .55rem; font-size: calc(var(--lx-fs) * .95); }
.lx-check-prompt::before { content: counter(q) ". "; color: var(--lx-muted); }
.lx-check-opts { display: grid; gap: .4rem; }
.lx-check-opt {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; padding: .6rem .8rem; border-radius: 10px;
  border: 1.5px solid var(--lx-line); background: var(--lx-card); color: var(--bs-body-color); cursor: pointer; font-size: .92rem;
  transition: border-color .15s, background .15s;
}
.lx-check-opt:hover:not(:disabled) { border-color: var(--lx-royal); }
.lx-check-opt:disabled { cursor: default; }
.lx-check-letter { flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 800; background: var(--bs-tertiary-bg); color: var(--lx-muted); }
.lx-check-text { flex: 1; }
.lx-check-mark { font-weight: 800; }
.lx-check-opt.is-chosen { border-color: var(--lx-royal); background: var(--lx-royal-tint); }
.lx-check-opt.is-chosen .lx-check-letter { background: var(--lx-royal); color: var(--mx-nav-on-signal); }
.lx-check-opt.is-correct { border-color: var(--lx-done); background: color-mix(in srgb, var(--lx-done) 12%, var(--lx-card)); }
.lx-check-opt.is-correct .lx-check-letter { background: var(--lx-done); color: #fff; }
.lx-check-opt.is-correct .lx-check-mark { color: var(--lx-done-ink); }
.lx-check-opt.is-wrong { border-color: var(--mx-nav-error); background: color-mix(in srgb, var(--mx-nav-error) 8%, var(--lx-card)); }
.lx-check-opt.is-wrong .lx-check-mark { color: var(--mx-nav-error); }
.lx-check-opt.is-dim { opacity: .6; }
.lx-check-why { margin: .55rem 0 0; padding: .55rem .75rem; border-left: 3px solid var(--lx-line); color: var(--bs-body-color); font-size: .88rem; background: var(--lx-card); border-radius: 0 8px 8px 0; }
.lx-check-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: 1.2rem; }
.lx-check-hint { font-size: .8rem; color: var(--lx-muted); }

/* lesson foot */
.lx-foot { margin-top: 2rem; padding-top: 1.1rem; border-top: 1px solid var(--lx-line); }
.lx-foot-status { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .85rem; color: var(--lx-muted); margin-bottom: .8rem; }
.lx-foot-status::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--mx-nav-wait-fill); align-self: center; }
.lx-foot-status.is-ready { color: var(--lx-royal); font-weight: 600; }
.lx-foot-status.is-ready::before { background: var(--lx-action); box-shadow: 0 0 0 4px var(--mx-nav-action-tint); }
.lx-foot-status.is-done { color: var(--lx-done-ink); font-weight: 600; }
.lx-foot-status.is-done::before { background: var(--lx-done); }
.lx-foot-notice { color: var(--mx-nav-action-ink); font-weight: 600; }
.lx-foot-nav { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.lx-foot-sp { flex: 1; }

/* ── tools rail ── */
.lx-side .lx-rail { border: 1px solid var(--lx-line); border-radius: var(--lx-radius); background: var(--lx-card); padding: 0; display: flex; flex-direction: column; }
.lx-tabs { display: flex; gap: .15rem; padding: .4rem; border-bottom: 1px solid var(--lx-line); position: sticky; top: 0; background: var(--lx-card); z-index: 1; border-radius: var(--lx-radius) var(--lx-radius) 0 0; }
.lx-tab { flex: 1; border: 0; background: transparent; padding: .45rem .35rem; border-radius: 8px; font-size: .76rem; font-weight: 700; color: var(--lx-muted); cursor: pointer; white-space: nowrap; }
.lx-tab:hover { color: var(--lx-ink); background: var(--bs-tertiary-bg); }
.lx-tab.is-on { color: var(--lx-royal); background: var(--lx-royal-tint); }
.lx-panel { padding: .85rem .9rem 1rem; }
.lx-strip-tab { color: var(--lx-muted); }

.lx-outline { list-style: none; margin: 0 0 1rem; padding: 0; border-left: 2px solid var(--lx-line); }
.lx-outline li { margin: 0; }
.lx-outline-link { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .32rem .7rem; margin-left: -2px; border-left: 2px solid transparent; color: var(--lx-muted); font-size: .82rem; line-height: 1.35; cursor: pointer; }
.lx-outline-l3 .lx-outline-link { padding-left: 1.4rem; font-size: .78rem; }
.lx-outline-link:hover { color: var(--lx-ink); }
.lx-outline-link[data-active] { color: var(--lx-royal); border-left-color: var(--lx-royal); font-weight: 700; }
.lx-facts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 0; }
.lx-facts > div { padding: .55rem .65rem; border-radius: 10px; background: var(--mx-nav-inset); }
.lx-facts dt { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--lx-muted); }
.lx-facts dd { margin: .1rem 0 0; font-weight: 800; color: var(--lx-ink); font-size: .9rem; }

.lx-res-group { font-family: var(--mx-font-mono); font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--lx-muted); margin: .9rem 0 .45rem; }
.lx-res-group:first-child { margin-top: 0; }
.lx-res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.lx-res-list li { display: flex; align-items: stretch; gap: .25rem; }
.lx-res { flex: 1; min-width: 0; display: flex; gap: .65rem; align-items: flex-start; padding: .55rem .6rem; border: 1px solid var(--lx-line); border-radius: 10px; text-decoration: none; color: inherit; transition: border-color .15s, background .15s; }
.lx-res:hover { border-color: var(--lx-royal); background: var(--lx-royal-tint); }
.lx-res-main { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.lx-res-title { font-weight: 700; font-size: .84rem; color: var(--lx-ink); line-height: 1.3; }
.lx-res-desc { font-size: .76rem; color: var(--bs-body-color); line-height: 1.35; }
.lx-res-meta { font-size: .7rem; color: var(--lx-muted); }
.lx-res-dl { display: grid; place-items: center; width: 2.1rem; border: 1px solid var(--lx-line); border-radius: 10px; color: var(--lx-muted); }
.lx-res-dl:hover { color: var(--lx-royal); border-color: var(--lx-royal); }
.lx-res-ico { flex: 0 0 auto; width: 2.1rem; height: 2.1rem; border-radius: 8px; display: grid; place-items: center; font-size: .58rem; font-weight: 800; letter-spacing: .03em; background: var(--bs-tertiary-bg); color: var(--lx-muted); }
.lx-res-ico--pdf { background: color-mix(in srgb, var(--mx-nav-error) 13%, transparent); color: var(--mx-nav-error); }
.lx-res-ico--doc { background: color-mix(in srgb, #2b6cd4 14%, transparent); color: #2b6cd4; }
.lx-res-ico--slides { background: var(--mx-nav-action-tint); color: var(--mx-nav-action-ink); }
.lx-res-ico--sheet { background: color-mix(in srgb, var(--lx-done) 15%, transparent); color: var(--lx-done-ink); }
.lx-res-ico--video { background: var(--lx-royal-tint); color: var(--lx-royal); font-size: .8rem; }
.lx-res-ico--link { background: var(--lx-royal-tint); color: var(--lx-royal); font-size: .95rem; }
.lx-empty-mini { padding: 1rem .8rem; border-radius: 10px; background: var(--mx-nav-inset); text-align: center; }
.lx-empty-mini p { margin: 0 0 .25rem; font-size: .85rem; }

/* notes */
.lx-notes { display: flex; flex-direction: column; gap: .75rem; }
.lx-notes .lx-seg { align-self: flex-start; }
.lx-note-composer { border: 1px solid var(--lx-line); border-radius: 12px; padding: .5rem; background: var(--mx-nav-inset); }
.lx-note-input { width: 100%; border: 0; background: transparent; color: var(--bs-body-color); resize: vertical; font-size: .88rem; line-height: 1.5; padding: .25rem .35rem; min-height: 4.5rem; }
.lx-note-input:focus { outline: none; }
.lx-note-composer:focus-within { border-color: var(--lx-royal); box-shadow: 0 0 0 3px var(--lx-royal-tint); }
.lx-note-composer-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .25rem; }
.lx-note-quote { position: relative; margin: 0 0 .4rem; padding: .45rem 1.6rem .45rem .7rem; border-left: 3px solid var(--lx-action); background: var(--mx-nav-action-tint); border-radius: 0 8px 8px 0; font-size: .82rem; font-style: italic; color: var(--bs-body-color); }
.lx-note-quote-x { position: absolute; top: .15rem; right: .3rem; border: 0; background: none; color: var(--lx-muted); font-size: 1rem; cursor: pointer; }
.lx-note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.lx-note { padding: .65rem .75rem; border: 1px solid var(--lx-line); border-radius: 12px; background: var(--lx-card); }
.lx-note-body p { margin: 0 0 .35rem; font-size: .86rem; white-space: pre-wrap; line-height: 1.5; }
.lx-note-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.lx-note-acts { display: inline-flex; gap: .7rem; }
.lx-note-src { border: 0; background: none; padding: 0; margin-bottom: .3rem; font-size: .72rem; font-weight: 700; color: var(--lx-royal); cursor: pointer; }
.lx-notes-all { font-size: .8rem; font-weight: 700; color: var(--lx-royal); text-decoration: none; }

/* ── overlays ── */
.lx-selpop { position: fixed; z-index: 1100; transform: translate(-50%, calc(-100% - 10px)); }
.lx-selpop button { display: inline-flex; align-items: center; gap: .35rem; border: 0; border-radius: 999px; padding: .4rem .8rem; background: var(--mx-nav-ink); color: #fff; font-size: .8rem; font-weight: 700; box-shadow: 0 10px 24px -8px rgba(10, 26, 47, .55); cursor: pointer; }
.lx-selpop button::after { content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%) rotate(45deg); width: 10px; height: 10px; background: var(--mx-nav-ink); }
.lx-toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 1150; transform: translateX(-50%);
  display: flex; align-items: center; gap: .75rem; max-width: min(92vw, 34rem);
  padding: .75rem .9rem .75rem 1rem; border-radius: 14px; background: var(--mx-nav-ink); color: #fff;
  box-shadow: 0 20px 44px -18px rgba(10, 26, 47, .7); animation: lx-rise .35s cubic-bezier(.2, .9, .3, 1.3);
}
.lx-toast.is-big { padding: 1rem 1.1rem; }
.lx-toast-emoji { font-size: 1.5rem; }
.lx-toast-text { font-size: .88rem; line-height: 1.35; }
.lx-toast-x { border: 0; background: none; color: inherit; opacity: .7; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.lx-toast-x:hover { opacity: 1; }
@keyframes lx-rise { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

.lx-help { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; background: rgba(10, 26, 47, .45); padding: 1rem; }
.lx-help[hidden] { display: none; }
.lx-help-card { width: min(100%, 26rem); background: var(--lx-card); border-radius: 16px; padding: 1.1rem 1.25rem 1.25rem; box-shadow: var(--mx-nav-shadow); }
.lx-help-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.lx-help-head h2 { font-size: 1.05rem; font-weight: 800; margin: 0; }
.lx-help-head .lx-toast-x { color: var(--lx-muted); }
.lx-keys { margin: 0; display: grid; gap: .35rem; }
.lx-keys > div { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; }
.lx-keys dd { margin: 0; color: var(--lx-muted); }
.lx-keys kbd { display: inline-block; min-width: 1.5rem; padding: .05rem .35rem; border-radius: 6px; border: 1px solid var(--lx-line); border-bottom-width: 2px; background: var(--bs-tertiary-bg); color: var(--lx-ink); font-family: var(--mx-font-mono); font-size: .75rem; text-align: center; }

.lx-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1140; overflow: hidden; }
.lx-confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: .95; animation: lx-fall linear forwards; }
@keyframes lx-fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); opacity: .9; } }

.lx-scrim { display: none; }

/* ── responsive: below 992px the rails become drawers over the lesson ── */
@media (max-width: 991.98px) {
  .lx .lx-grid, .lx[data-side="open"] .lx-grid, .lx[data-toc="closed"] .lx-grid, .lx[data-toc="closed"][data-side="open"] .lx-grid { grid-template-columns: minmax(0, 1fr); }
  .lx-hide-sm { display: none !important; }
  .lx-toc, .lx-side {
    position: fixed; top: 0; bottom: 0; z-index: 1060; width: min(88vw, 22rem); max-height: none;
    background: var(--bs-body-bg); padding: 1rem .75rem; box-shadow: 0 0 40px rgba(10, 26, 47, .3);
    transition: transform .25s ease; visibility: hidden;
  }
  .lx-toc { left: 0; transform: translateX(-105%); }
  .lx-side { right: 0; transform: translateX(105%); }
  .lx .lx-toc .lx-strip, .lx .lx-side .lx-strip { display: none; }
  .lx .lx-toc .lx-rail, .lx .lx-side .lx-rail { display: flex; flex-direction: column; }
  .lx .lx-toc .lx-rail { display: block; }
  .lx[data-drawer="toc"] .lx-toc, .lx[data-drawer="side"] .lx-side { transform: none; visibility: visible; }
  .lx[data-drawer] .lx-scrim { display: block; position: fixed; inset: 0; z-index: 1050; background: rgba(10, 26, 47, .4); }
  .lx-bar { top: var(--lx-top); }
  .lx-article { padding: 1.1rem 1rem 1.25rem; }
  .lx-foot-nav .lx-btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .lx-summary-bar span, .lx-mod-bar span, .lx-readbar span, .lx-toc, .lx-side { transition: none; }
  .lx-toast { animation: none; }
  .lx-btn--grace::before { animation: none; transform: scaleX(1); }
  .lx-confetti { display: none; }
}

@media print {
  .lx-bar, .lx-toc, .lx-side, .lx-foot, .lx-check-actions { display: none !important; }
  .lx .lx-grid { display: block; }
  .lx-card { border: 0; box-shadow: none; }
}

/* Resources rail: This lesson | All (every resource in the course, grouped by lesson). */
.lx-seg { display: flex; gap: .25rem; padding: .2rem; margin: 0 0 .85rem; border-radius: 9px; background: var(--bs-tertiary-bg); }
.lx-seg-btn { flex: 1; border: 0; border-radius: 7px; padding: .35rem .5rem; background: transparent; font-size: .76rem; font-weight: 700; color: var(--lx-muted); cursor: pointer; white-space: nowrap; }
.lx-seg-btn:hover { color: var(--lx-ink); }
.lx-seg-btn.is-on { background: var(--bs-body-bg); color: var(--lx-royal); box-shadow: 0 1px 2px rgba(10, 26, 47, .08); }
.lx-seg-btn:focus-visible, .lx-res-grouplink:focus-visible { outline: 2px solid var(--lx-royal); outline-offset: 2px; }
.lx-res-grouplink { border: 0; padding: 0; background: none; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--lx-royal); cursor: pointer; text-align: start; }
.lx-res-grouplink:hover { text-decoration: underline; text-underline-offset: 2px; }
