/* ============================================================
   مِسبار — التمارين · lesson.css — the full-focus LESSON player (engine.js v3).
   Scoped to #ex .ls (uses the live #ex tokens, dark default + html.light).
   Layout: fixed full-viewport grid → top bar · scrolling body · bottom answer bar.
   RTL: start edge = right (× sits there), end edge = left (hearts, «…», «كمّل»).
   ============================================================ */

/* the lesson owns the whole screen: hide the site chrome while it is mounted */
html.ex-lesson, html.ex-lesson body { overflow: hidden !important; }
html.ex-lesson #ex-sidebar, html.ex-lesson #ex-topbar, html.ex-lesson #ex-mtop, html.ex-lesson #mobile-menu,
html.ex-lesson .ex-guestbar, html.ex-lesson .to-top { display: none !important; }

#ex .ls {
  --ls-top: 68px;
  --ls-col: 620px;
  --ls-paper: #FFFFFF;
  --ls-paper-line: rgba(17,17,20,.10);
  --ls-ok: var(--ex-ok); --ls-okbg: color-mix(in srgb, var(--ex-ok) 13%, var(--ex-bg));
  --ls-bad: var(--ex-danger); --ls-badbg: color-mix(in srgb, var(--ex-danger) 13%, var(--ex-bg));
  --ls-heart: #F87171;
  position: fixed; inset: 0; z-index: 150;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--ex-bg); color: var(--ex-ink);
  font-family: inherit;
}
html.light #ex .ls { --ls-paper-line: rgba(46,16,101,.10); --ls-heart: #E0464A; }

/* ---------------- top bar ---------------- */
#ex .ls-top {
  height: var(--ls-top); display: flex; align-items: center; gap: 18px;
  padding: 0 clamp(14px, 3vw, 40px);
  max-width: 1280px; width: 100%; margin: 0 auto; box-sizing: border-box;
}
#ex .ls-ib {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px;
  border: 0; background: transparent; color: var(--ex-mut); cursor: pointer;
  transition: background .15s, color .15s;
}
#ex .ls-ib:hover { background: var(--ex-s2); color: var(--ex-ink); }
#ex .ls-prog { flex: 1; height: 8px; border-radius: 99px; background: var(--ex-s3); overflow: hidden; }
#ex .ls-prog > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ex-vio); transition: width .5s var(--ex-ease); }
#ex .ls-hearts { display: flex; gap: 4px; flex: none; color: var(--ls-heart); }
#ex .ls-heart { display: grid; place-items: center; width: 26px; height: 26px; }
#ex .ls-heart.is-off { color: var(--ex-line2); }
#ex .ls-heart.is-lost { animation: ls-heart-lose .6s var(--ex-ease); }
@keyframes ls-heart-lose { 0% { transform: scale(1); color: var(--ls-heart); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
#ex .ls-menuw { position: relative; flex: none; }
#ex .ls-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 5;
  min-width: 220px; padding: 6px; border-radius: 14px;
  background: var(--ex-s); border: 1px solid var(--ex-line2); box-shadow: var(--ex-sh2);
  display: grid; gap: 2px;
}
#ex .ls-menu[hidden] { display: none; }
#ex .ls-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ex-ink); font: inherit; font-size: 14.5px; font-weight: 600; text-align: start; cursor: pointer;
}
#ex .ls-menu button:hover, #ex .ls-menu button:focus-visible { background: var(--ex-s2); }
#ex .ls-menu button svg { color: var(--ex-mut); flex: none; }

/* ---------------- body ---------------- */
#ex .ls-body { overflow-y: auto; overflow-x: hidden; outline: none; padding: 8px clamp(16px, 3vw, 40px) 40px; scrollbar-gutter: stable; }
#ex .ls-body:focus-visible { outline: none; }

/* paper = the real screenshot sits on a white sheet, like a printed reference */
#ex .ls-paper { position: relative; display: block; background: var(--ls-paper); border-radius: 16px; padding: 10px; box-shadow: 0 0 0 1px var(--ls-paper-line), 0 10px 30px rgba(0,0,0,.18); }
html.light #ex .ls-paper { box-shadow: 0 0 0 1px var(--ls-paper-line), 0 10px 26px rgba(46,16,101,.08); }
#ex .ls-pic {
  --ph: 420px;
  position: relative; display: block; overflow: hidden; border-radius: 8px;
  aspect-ratio: var(--ar);
  width: min(100%, calc(var(--ph) * var(--ar)));
  margin-inline: auto; background: #F4F4F7;
}
#ex .ls-pic img { position: absolute; max-width: none; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
#ex .ls-pic.is-missing { display: grid; place-items: center; aspect-ratio: 16/9; color: #6B6B76; }
#ex .ls-mark { position: absolute; border: 2.5px solid #7C3AED; border-radius: 6px; box-shadow: 0 0 0 2px rgba(255,255,255,.85); pointer-events: none; }
#ex .ls-mark > i {
  position: absolute; top: -12px; left: -12px; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 900; line-height: 1;
  background: #7C3AED; color: #fff; box-shadow: 0 0 0 2px #fff;
}
#ex .ls-zoom {
  position: absolute; top: 18px; left: 18px; z-index: 3; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; cursor: zoom-in;
  border: 1px solid rgba(17,17,20,.14); background: rgba(255,255,255,.94); color: #111114;
  box-shadow: 0 2px 10px rgba(0,0,0,.16); opacity: .0; transition: opacity .15s;
}
#ex .ls-paper:hover .ls-zoom, #ex .ls-cardw:hover .ls-zoom, #ex .ls-zoom:focus-visible { opacity: 1; }
@media (hover: none) { #ex .ls-zoom { opacity: 1; } }

/* ---------------- step ---------------- */
#ex .ls-step { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: clamp(4px, 2vh, 24px); }
#ex .ls-count { margin: 0; font-size: 13px; font-weight: 700; color: var(--ex-faint); letter-spacing: .01em; }
#ex .ls-q {
  margin: -14px 0 0; max-width: 820px; text-align: center; text-wrap: balance;
  font-size: clamp(21px, 2.1vw, 28px); line-height: 1.4; font-weight: 800; color: var(--ex-ink); outline: none;
}

/* reference screenshot above text options */
#ex .ls-refs { width: 100%; max-width: 900px; display: grid; gap: 12px; }
#ex .ls-ref { margin: 0; }
#ex .ls-ref .ls-pic { --ph: clamp(190px, calc(100vh - 560px), 440px); }
#ex .ls-refs.is-multi .ls-paper { padding: 8px; }
#ex .ls-pic.is-strip { width: 100%; }

/* image options: big cards side by side */
#ex .ls-cards { width: 100%; display: grid; gap: clamp(16px, 2.4vw, 36px); justify-content: center; }
#ex .ls-cards[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 620px)); }
#ex .ls-cards[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 400px)); }
#ex .ls-cardw { position: relative; min-width: 0; }
#ex .ls-card {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: center;
}
#ex .ls-card .ls-paper { width: 100%; box-sizing: border-box; transition: box-shadow .18s, transform .18s var(--ex-ease), opacity .2s; }
#ex .ls-card .ls-pic { --ph: clamp(200px, calc(100vh - 380px), 640px); }
#ex .ls-cards[data-n="3"] .ls-card .ls-pic { --ph: clamp(140px, calc(100vh - 420px), 460px); }
#ex .ls-card:hover:not([aria-disabled]) .ls-paper { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--ex-vio), 0 16px 36px rgba(0,0,0,.22); }
#ex .ls-card:focus-visible { outline: none; }
#ex .ls-card:focus-visible .ls-paper { box-shadow: 0 0 0 3px var(--ex-vio), 0 0 0 6px var(--ex-t2); }
#ex .ls-num {
  flex: none; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 9px; box-sizing: border-box;
  display: inline-grid; place-items: center; font-size: 14px; font-weight: 800;
  border: 1.5px solid var(--ex-line2); color: var(--ex-mut); background: var(--ex-s);
}
#ex .ls-card-l { margin-top: -6px; font-size: 14px; font-weight: 700; color: var(--ex-mut); }
#ex .ls-card.is-ok .ls-paper { box-shadow: 0 0 0 4px var(--ls-ok), 0 16px 36px rgba(0,0,0,.2); }
#ex .ls-card.is-bad .ls-paper { box-shadow: 0 0 0 4px var(--ls-bad), 0 16px 36px rgba(0,0,0,.2); }
#ex .ls-card.is-ok .ls-num { background: var(--ls-ok); border-color: var(--ls-ok); color: var(--ex-ok-on); }
#ex .ls-card.is-bad .ls-num { background: var(--ls-bad); border-color: var(--ls-bad); color: #fff; }
#ex .ls-card.is-dim .ls-paper, #ex .ls-row.is-dim { opacity: .42; }
#ex .ls-card.is-dim.is-answer .ls-paper { opacity: 1; box-shadow: 0 0 0 3px var(--ls-ok); }
#ex .ls-card[aria-disabled] { cursor: default; }

/* text options: narrow centred column */
#ex .ls-list { width: 100%; max-width: 540px; display: grid; gap: 10px; }
#ex .ls-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 12px 16px 12px 12px; box-sizing: border-box;
  border-radius: 14px; border: 1.5px solid var(--ex-line2); background: var(--ex-s); color: var(--ex-ink);
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1.55; text-align: start; cursor: pointer;
  transition: border-color .15s, background .15s, opacity .2s, transform .15s;
}
#ex .ls-row-t { flex: 1; min-width: 0; }
#ex .ls-row:hover:not([aria-disabled]) { border-color: var(--ex-vio); background: var(--ex-s2); }
#ex .ls-row:active:not([aria-disabled]) { transform: scale(.99); }
#ex .ls-row:focus-visible { outline: 2px solid var(--ex-vio); outline-offset: 3px; }
#ex .ls-row[aria-disabled] { cursor: default; }
#ex .ls-row.is-ok { border-color: var(--ls-ok); background: var(--ls-okbg); }
#ex .ls-row.is-bad { border-color: var(--ls-bad); background: var(--ls-badbg); }
#ex .ls-row.is-ok .ls-num { background: var(--ls-ok); border-color: var(--ls-ok); color: var(--ex-ok-on); }
#ex .ls-row.is-bad .ls-num { background: var(--ls-bad); border-color: var(--ls-bad); color: #fff; }
#ex .ls-row.is-dim.is-answer { opacity: 1; border-color: var(--ls-ok); border-style: dashed; }
#ex .ls-step.is-txt .ls-refs + .ls-list { margin-top: 2px; }

/* credit line (truth rule: product · date · source on every screenshot) */
#ex .ls-credit { margin: 4px 0 0; max-width: 820px; display: flex; gap: 6px; align-items: flex-start; justify-content: center; text-align: center; font-size: 12.5px; line-height: 1.7; color: var(--ex-faint); }
#ex .ls-credit svg { flex: none; margin-top: 4px; }
#ex .ls-credit a { color: var(--ex-mut); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ex-line2); }
#ex .ls-credit a:hover { color: var(--ex-ink); }
#ex .ls-credit small { font-size: 12px; color: var(--ex-faint); }

/* ---------------- theory ---------------- */
#ex .ls-theory { max-width: var(--ls-col); margin: 0 auto; padding-top: clamp(6px, 3vh, 32px); }
#ex .ls-eyebrow { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--ex-vio); flex-wrap: wrap; }
#ex .ls-eyebrow span { color: var(--ex-faint); font-weight: 600; }
#ex .ls-th-title { margin: 0 0 12px; font-size: clamp(28px, 3.2vw, 38px); line-height: 1.25; font-weight: 900; outline: none; text-wrap: balance; }
#ex .ls-lead { margin: 0 0 26px; font-size: 17.5px; line-height: 1.85; color: var(--ex-body); }
#ex .ls-pair { display: grid; gap: 26px; margin: 0 0 30px; }
#ex .ls-ex { margin: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; align-items: start; }
#ex .ls-mk { width: 32px; height: 32px; border-radius: 99px; display: grid; place-items: center; margin-top: 14px; color: #fff; }
#ex .ls-ex.is-do .ls-mk { background: var(--ls-ok); color: var(--ex-ok-on); }
#ex .ls-ex.is-dont .ls-mk { background: var(--ls-bad); color: #fff; }
#ex .ls-ex .ls-pic { --ph: 520px; }
#ex .ls-ex.is-do .ls-paper { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ls-ok) 55%, transparent), 0 10px 30px rgba(0,0,0,.16); }
#ex .ls-ex.is-dont .ls-paper { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ls-bad) 55%, transparent), 0 10px 30px rgba(0,0,0,.16); }
#ex .ls-ex figcaption { margin-top: 10px; font-size: 15px; line-height: 1.75; color: var(--ex-body); }
#ex .ls-ex figcaption small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ex-faint); }
#ex .ls-illus-tag { display: inline-block; margin-bottom: 8px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; background: var(--ex-closebg); color: var(--ex-close); }
#ex .ls-p { margin: 0 0 16px; font-size: 16.5px; line-height: 1.9; color: var(--ex-body); }
#ex .ls-ul { margin: 0 0 28px; padding: 0; list-style: none; display: grid; gap: 10px; }
#ex .ls-ul li { position: relative; padding-inline-start: 22px; font-size: 16px; line-height: 1.8; color: var(--ex-body); }
#ex .ls-ul li::before { content: ""; position: absolute; inset-inline-start: 4px; top: .78em; width: 7px; height: 7px; border-radius: 99px; background: var(--ex-vio); }
#ex .ls-src { border-top: 1px solid var(--ex-line); padding-top: 18px; }
#ex .ls-src h2 { display: flex; align-items: center; gap: 7px; margin: 0 0 12px; font-size: 14px; font-weight: 800; color: var(--ex-mut); }
#ex .ls-src ul { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 12px; }
#ex .ls-src li { display: grid; gap: 3px; font-size: 13.5px; line-height: 1.65; }
#ex .ls-src q { color: var(--ex-body); font-style: italic; text-align: left; }
#ex .ls-src a { color: var(--ex-vio); text-align: left; word-break: break-all; font-size: 12.5px; }
#ex .ls-src .ls-credit { justify-content: flex-start; text-align: start; }

/* ---------------- completion ---------------- */
#ex .ls-done { max-width: 560px; margin: 0 auto; padding-top: clamp(8px, 4vh, 48px); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
#ex .ls-done-ring { position: relative; width: 132px; height: 132px; margin-bottom: 10px; }
#ex .ls-done-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#ex .ls-done-ring circle { fill: none; stroke-width: 9; }
#ex .ls-done-ring .tr { stroke: var(--ex-s3); }
#ex .ls-done-ring .fg { stroke: var(--ls-ok); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ex-ease); }
#ex .ls-done-ring > span { position: absolute; inset: 0; display: grid; place-content: center; gap: 0; }
#ex .ls-done-ring b { font-size: 34px; font-weight: 900; line-height: 1.1; }
#ex .ls-done-ring b small { font-size: 18px; color: var(--ex-faint); font-weight: 800; }
#ex .ls-done-ring em { font-style: normal; font-size: 13px; color: var(--ex-mut); font-weight: 700; }
#ex .ls-done-t { margin: 0; font-size: clamp(26px, 3vw, 34px); line-height: 1.3; font-weight: 900; outline: none; }
#ex .ls-done .ls-lead { margin: 0 0 14px; font-size: 16px; color: var(--ex-mut); }
#ex .ls-done-stats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; border: 1px solid var(--ex-line); border-radius: 16px; overflow: hidden; }
#ex .ls-done-stats li { padding: 14px 8px; display: grid; gap: 2px; }
#ex .ls-done-stats li + li { border-inline-start: 1px solid var(--ex-line); }
#ex .ls-done-stats b { font-size: 22px; font-weight: 900; }
#ex .ls-done-stats span { font-size: 12.5px; color: var(--ex-mut); }
#ex .ls-mut { color: var(--ex-mut); font-size: 14px; margin: 0 0 10px; }
#ex .ls-lv { width: 100%; margin: 4px 0 16px; text-align: start; }
#ex .ls-lv-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--ex-mut); margin-bottom: 8px; }
#ex .ls-lv-row > b { color: var(--ex-ink); }
#ex .ls-lv-bar { height: 8px; border-radius: 99px; background: var(--ex-s3); overflow: hidden; }
#ex .ls-lv-bar i { display: block; height: 100%; background: var(--ex-vio); border-radius: inherit; }
#ex .ls-orbit { width: 100%; margin-bottom: 14px; text-align: start; }
#ex .ls-next {
  width: 100%; display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 10px; border-radius: 16px; border: 1px solid var(--ex-line2); background: var(--ex-s); color: var(--ex-ink);
  font: inherit; text-align: start; cursor: pointer; transition: border-color .15s, background .15s;
}
#ex .ls-next:hover { border-color: var(--ex-vio); background: var(--ex-s2); }
#ex .ls-next:focus-visible { outline: 2px solid var(--ex-vio); outline-offset: 3px; }
#ex .ls-next-art { display: block; border-radius: 10px; overflow: hidden; background: #fff; }
#ex .ls-next-art .ls-pic { --ph: 70px; border-radius: 0; }
#ex .ls-next-tx { display: grid; gap: 2px; min-width: 0; }
#ex .ls-next-tx small { font-size: 12px; color: var(--ex-vio); font-weight: 800; }
#ex .ls-next-tx b { font-size: 16px; line-height: 1.5; }
#ex .ls-next-tx > span { font-size: 12.5px; color: var(--ex-mut); }
#ex .ls-next > svg { color: var(--ex-mut); margin-inline-end: 6px; }
#ex .ls-state { max-width: 520px; margin: 10vh auto 0; text-align: center; display: grid; justify-items: center; gap: 10px; color: var(--ex-mut); }

/* ---------------- bottom bar ---------------- */
#ex .ls-bar { border-top: 1px solid var(--ex-line); background: var(--ex-bg); transition: background .25s, border-color .25s; padding-bottom: env(safe-area-inset-bottom); }
#ex .ls-bar.is-ok { background: var(--ls-okbg); border-top-color: color-mix(in srgb, var(--ls-ok) 45%, transparent); }
#ex .ls-bar.is-bad { background: var(--ls-badbg); border-top-color: color-mix(in srgb, var(--ls-bad) 45%, transparent); }
#ex .ls-bar-in { max-width: 1280px; margin: 0 auto; min-height: 88px; box-sizing: border-box; padding: 14px clamp(14px, 3vw, 40px); display: flex; align-items: center; gap: 16px; }
#ex .ls-bar-s { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; }
#ex .ls-bar-e { flex: none; display: flex; align-items: center; gap: 10px; }
#ex .ls-bar-note { font-size: 14px; color: var(--ex-faint); display: inline-flex; align-items: center; gap: 8px; }
#ex .ls-pill { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 14px; border-radius: 99px; font-size: 16px; }
#ex .ls-pill b { font-weight: 900; }
#ex .ls-bar.is-ok .ls-pill { background: var(--ls-ok); color: var(--ex-ok-on); }
#ex .ls-bar.is-bad .ls-pill { background: var(--ls-bad); color: #fff; }
html.light #ex .ls-bar.is-bad .ls-pill { color: #fff; }
/* the explanation is never truncated (there is no other place to read it in the correct state); a very long one scrolls */
#ex .ls-bar-why { margin: 0; min-width: 0; font-size: 14px; line-height: 1.65; color: var(--ex-body); max-height: 30vh; overflow-y: auto; }
#ex .ls-bar-why.is-soft { color: var(--ex-mut); }
#ex .ls-btn {
  height: 48px; padding: 0 20px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15.5px; font-weight: 800; cursor: pointer; white-space: nowrap;
  border: 1.5px solid transparent; transition: background .15s, border-color .15s, color .15s, transform .1s, opacity .15s;
}
#ex .ls-btn:active:not(:disabled) { transform: translateY(1px); }
#ex .ls-btn:focus-visible { outline: 2px solid var(--ex-vio); outline-offset: 3px; }
#ex .ls-btn.is-primary { background: var(--ex-vio); color: var(--ex-on); min-width: 132px; }
#ex .ls-btn.is-primary:hover:not(:disabled) { background: var(--ex-vio2); }
#ex .ls-btn:disabled { background: var(--ex-s3); color: var(--ex-faint); cursor: not-allowed; }
#ex .ls-btn.is-ok { background: var(--ls-ok); color: var(--ex-ok-on); min-width: 132px; }
#ex .ls-btn.is-bad { background: var(--ls-bad); color: #fff; min-width: 132px; }
#ex .ls-btn.is-ok:hover, #ex .ls-btn.is-bad:hover { filter: brightness(1.06); }
#ex .ls-btn.is-ghost { background: transparent; color: var(--ex-ink); border-color: var(--ex-line2); }
#ex .ls-btn.is-ghost:hover { background: var(--ex-s2); }
#ex .ls-bar.is-ok .ls-btn.is-ghost { border-color: color-mix(in srgb, var(--ls-ok) 50%, transparent); }
#ex .ls-bar.is-bad .ls-btn.is-ghost { border-color: color-mix(in srgb, var(--ls-bad) 50%, transparent); }
#ex .ls-btn.is-on svg { color: var(--ex-vio); }
#ex .ls-kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; box-sizing: border-box; border-radius: 6px;
  font: 700 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0;
  direction: ltr; unicode-bidi: isolate; /* «1–4» must not flip to «4–1» in RTL */
  background: color-mix(in srgb, currentColor 14%, transparent); border: 1px solid color-mix(in srgb, currentColor 22%, transparent); opacity: .85;
}
#ex .ls-btn:disabled .ls-kbd { opacity: .6; }
@media (hover: none), (pointer: coarse) { #ex .ls-kbd, #ex .ls-bar-keys { display: none; } }

/* ---------------- «ليش؟» / report sheet ---------------- */
#ex .ls-scrim { position: fixed; inset: 0; z-index: 160; background: var(--ex-scrim); }
#ex .ls-sheet {
  position: fixed; z-index: 161; inset-inline: 0; bottom: 0; margin: 0 auto; width: min(640px, 100%); box-sizing: border-box;
  max-height: min(78vh, 640px); overflow-y: auto;
  background: var(--ex-s); border: 1px solid var(--ex-line2); border-bottom: 0; border-radius: 22px 22px 0 0;
  box-shadow: var(--ex-sh2); padding: 26px clamp(18px, 4vw, 32px) calc(28px + env(safe-area-inset-bottom));
  transform: translateY(16px); opacity: 0; transition: transform .25s var(--ex-ease), opacity .2s;
}
#ex .ls-sheet.is-on { transform: none; opacity: 1; }
#ex .ls-sh-x { position: absolute; top: 12px; inset-inline-end: 12px; }
#ex .ls-sh-t { margin: 0 0 14px; font-size: 22px; font-weight: 900; outline: none; }
#ex .ls-sh-ans { margin: 0 0 14px; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--ls-okbg); border: 1px solid color-mix(in srgb, var(--ls-ok) 40%, transparent); }
#ex .ls-sh-ans span { font-size: 12.5px; font-weight: 800; color: var(--ls-ok); }
#ex .ls-sh-ans b { font-size: 16px; line-height: 1.6; }
#ex .ls-sh-why { margin: 0 0 12px; font-size: 16px; line-height: 1.9; color: var(--ex-body); }
#ex .ls-sh-note { margin: 0 0 12px; font-size: 14.5px; line-height: 1.8; color: var(--ex-mut); padding-inline-start: 12px; border-inline-start: 3px solid var(--ls-bad); }
#ex .ls-sheet.is-neutral .ls-sh-note { border-inline-start-color: var(--ex-line2); }
#ex .ls-sh-src { margin: 0; display: flex; gap: 7px; align-items: flex-start; font-size: 13px; color: var(--ex-faint); }
#ex .ls-sh-src svg { flex: none; margin-top: 3px; }
#ex .ls-sh-src a { color: var(--ex-vio); text-align: left; }
#ex .ls-sh-lbl { display: block; font-size: 13px; font-weight: 800; color: var(--ex-mut); margin-bottom: 6px; }
#ex .ls-sh-ta { width: 100%; box-sizing: border-box; border-radius: 12px; border: 1.5px solid var(--ex-line2); background: var(--ex-bg); color: var(--ex-ink); font: inherit; font-size: 15px; line-height: 1.7; padding: 10px 12px; margin-bottom: 12px; resize: vertical; }
#ex .ls-sh-ta:focus-visible { outline: 2px solid var(--ex-vio); outline-offset: 2px; }
#ex .ls-sh-acts { display: flex; align-items: center; gap: 12px; }
#ex .ls-sh-ok { font-size: 13.5px; color: var(--ls-ok); font-weight: 700; }

/* ---------------- tablet / mobile ---------------- */
@media (max-width: 1023px) {
  #ex .ls-cards[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  #ex .ls { --ls-top: 58px; }
  #ex .ls-top { gap: 10px; }
  #ex .ls-ib { width: 40px; height: 40px; }
  #ex .ls-heart { width: 22px; height: 22px; }
  #ex .ls-heart svg { width: 19px; height: 19px; }
  #ex .ls-body { padding: 4px 16px 28px; }
  #ex .ls-step { gap: 18px; }
  #ex .ls-q { font-size: 20px; margin-top: -10px; }
  /* image cards stack vertically on phones */
  #ex .ls-cards[data-n] { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  #ex .ls-card .ls-pic, #ex .ls-cards[data-n="3"] .ls-card .ls-pic { --ph: 46vh; }
  #ex .ls-ref .ls-pic { --ph: 36vh; }
  #ex .ls-paper { padding: 7px; border-radius: 14px; }
  #ex .ls-zoom { opacity: 1; top: 13px; left: 13px; }
  #ex .ls-row { min-height: 54px; font-size: 15.5px; }
  #ex .ls-ex { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  #ex .ls-mk { width: 28px; height: 28px; }
  #ex .ls-lead { font-size: 16.5px; }
  #ex .ls-bar-in { min-height: 76px; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  #ex .ls-bar.is-ok .ls-bar-s, #ex .ls-bar.is-bad .ls-bar-s { flex-basis: 100%; }
  #ex .ls-bar.is-ok .ls-bar-e, #ex .ls-bar.is-bad .ls-bar-e, #ex .ls-bar.is-theory .ls-bar-e { flex: 1; justify-content: flex-end; }
  #ex .ls-bar.is-ok .ls-bar-e .ls-btn:last-child, #ex .ls-bar.is-bad .ls-bar-e .ls-btn:last-child { flex: 1; }
  #ex .ls-bar.is-idle .ls-bar-e, #ex .ls-bar.is-theory0 .ls-bar-e, #ex .ls-bar.is-done .ls-bar-e { flex: 1; justify-content: flex-end; }
  #ex .ls-bar.is-idle .ls-bar-s { display: none; }
  #ex .ls-bar.is-idle .ls-btn.is-primary { flex: 1; }
  #ex .ls-btn { height: 48px; padding: 0 16px; }
  #ex .ls-pill { height: 34px; font-size: 15px; }
  #ex .ls-bar-why { font-size: 13.5px; }
  #ex .ls-next { grid-template-columns: 84px minmax(0, 1fr) auto; }
  #ex .ls-sheet { max-height: 84vh; }
}
@media (max-width: 380px) {
  #ex .ls-bar.is-theory .ls-btn.is-ghost[data-save] span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #ex .ls-prog > i, #ex .ls-card .ls-paper, #ex .ls-sheet, #ex .ls-done-ring .fg { transition: none; }
  #ex .ls-heart.is-lost { animation: none; }
}

/* completion: level-up line + new badges (calm list, replaces the orbit card inside the lesson) */
#ex .ls-lvup { margin: 0 0 12px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px; background: var(--ex-t); color: var(--ex-vio); font-size: 14px; }
#ex .ls-lvup b { color: var(--ex-ink); }
#ex .ls-badges { list-style: none; margin: 0 0 16px; padding: 0; width: 100%; display: grid; gap: 8px; text-align: start; }
#ex .ls-badges li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--ex-line); background: var(--ex-s); }
#ex .ls-badges li > span:last-child { display: grid; gap: 1px; }
#ex .ls-badges b { font-size: 14.5px; }
#ex .ls-badges small { font-size: 12.5px; color: var(--ex-mut); }
#ex .ls-badges .ex-badge-art { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--ex-t); color: var(--ex-vio); }

/* zoom sits bottom-start so it never covers the top of a screenshot (where the marks usually are) */
#ex .ls-zoom { top: auto; bottom: 18px; }
@media (max-width: 720px) {
  #ex .ls-zoom { width: 30px; height: 30px; bottom: 12px; left: 12px; }
  #ex .ls-kbd, #ex .ls-bar-keys { display: none; }
}

/* wide image options: one per row, number + label at the end edge */
#ex .ls-cards.is-wide[data-n] { grid-template-columns: minmax(0, 1fr); max-width: 1040px; gap: 18px; }
#ex .ls-cards.is-wide .ls-card { flex-direction: row; align-items: center; gap: 18px; }
#ex .ls-cards.is-wide .ls-card .ls-paper { flex: 1; min-width: 0; }
#ex .ls-cards.is-wide .ls-card .ls-pic { --ph: calc((100vh - 400px) / var(--n, 2)); }
#ex .ls-cards.is-wide .ls-card-l { margin: 0; width: 110px; flex: none; text-align: start; }
#ex .ls-cards.is-wide[data-n="3"] { --n: 3; }
@media (max-width: 720px) {
  #ex .ls-cards.is-wide .ls-card { flex-direction: column; gap: 10px; }
  #ex .ls-cards.is-wide .ls-card .ls-pic { --ph: 40vh; }
  #ex .ls-cards.is-wide .ls-card-l { width: auto; text-align: center; }
}

/* text options + a reference screenshot on wide screens: screenshot on the start side, options beside it */
@media (min-width: 1100px) {
  #ex .ls-step.is-txt.has-ref {
    display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); column-gap: clamp(24px, 3vw, 48px); row-gap: 18px;
    align-items: center; max-width: 1240px;
  }
  #ex .ls-step.is-txt.has-ref > .ls-count, #ex .ls-step.is-txt.has-ref > .ls-q, #ex .ls-step.is-txt.has-ref > .ls-credit { grid-column: 1 / -1; justify-self: center; }
  #ex .ls-step.is-txt.has-ref > .ls-refs { grid-column: 1; max-width: none; }
  #ex .ls-step.is-txt.has-ref > .ls-list { grid-column: 2; max-width: 460px; margin: 0; }
  #ex .ls-step.is-txt.has-ref .ls-ref .ls-pic { --ph: clamp(240px, calc(100vh - 340px), 640px); }
  #ex .ls-step.is-txt.has-ref .ls-refs.is-multi .ls-pic { --ph: 200px; }
}

/* the crop is clipped by .ls-clip so the mark badges (outside the box corners) stay visible */
#ex .ls-pic { overflow: visible; }
#ex .ls-clip { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
#ex .ls-mark > i { top: -11px; left: -11px; }
/* card zoom: top corner on the paper's start side (paper comes first in the card) */
#ex .ls-cardw > .ls-zoom { top: 18px; bottom: auto; left: auto; inset-inline-start: 18px; }
@media (max-width: 720px) {
  #ex .ls-cardw > .ls-zoom { top: 12px; inset-inline-start: 12px; left: auto; }
  #ex .ls-refs.is-multi .ls-zoom { display: none; }
}
#ex .ls-pic.is-strip .ls-mark > i { min-width: 18px; height: 18px; font-size: 11px; top: -9px; left: -9px; }
@media (max-width: 720px) {
  #ex .ls-mark { border-width: 2px; }
  #ex .ls-mark > i { min-width: 20px; height: 20px; font-size: 11.5px; top: -10px; left: -10px; }
  #ex .ls-pic.is-strip .ls-mark > i { min-width: 15px; height: 15px; font-size: 9.5px; top: -7px; left: -7px; }
}

/* text on the red fill: dark ink in dark mode (white on #F87171 measured 2.77:1), white in light mode (#B42318) */
#ex .ls { --ls-bad-on: #2B0707; }
html.light #ex .ls { --ls-bad-on: #FFFFFF; }
#ex .ls-bar.is-bad .ls-pill, html.light #ex .ls-bar.is-bad .ls-pill,
#ex .ls-btn.is-bad, #ex .ls-card.is-bad .ls-num, #ex .ls-row.is-bad .ls-num, #ex .ls-ex.is-dont .ls-mk { color: var(--ls-bad-on); }

/* ============================================================
   Orbit layer in the lesson player (2026-11-24): bar spring, completion orbit.
   ============================================================ */
/* completion: the learner's orbit system, one column so nothing truncates */
#ex .ls-done-orb { width: 100%; margin: 6px 0 16px; text-align: start; }
#ex .ls-done .orb { grid-template-columns: minmax(0, 1fr); gap: 14px; }
#ex .ls-done .orb-stage { max-width: min(360px, calc(100vh - 380px)); min-width: min(260px, 100%); width: 100%; }
#ex .ls-done .orb-side { gap: 8px; }
#ex .ls-done .orb-count { text-align: center; }
#ex .ls-done .orb-chip-tx b { white-space: normal; overflow: visible; }
#ex .ls-done .orb-tip { inset-inline-start: 50%; transform: translate(50%, 4px); }
#ex .ls-done .orb-chip.is-hot .orb-tip, #ex .ls-done .orb-chip:hover .orb-tip, #ex .ls-done .orb-chip:focus-visible .orb-tip { transform: translate(50%, 0); }
#ex .ls-newp { margin: 0 0 12px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 16px; background: var(--ex-t); color: var(--ex-vio); font-size: 14px; line-height: 1.6; text-align: start; }
#ex .ls-newp b { color: var(--ex-ink); }
#ex .ls-done-stats b[data-xp-count] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: no-preference) {
  /* bottom bar slides up with a spring after an answer */
  #ex .ls-bar.is-ok .ls-bar-in { animation: ls-bar-spring .55s cubic-bezier(.2, 1.45, .4, 1) both; }
  #ex .ls-bar.is-bad .ls-bar-in { animation: ls-bar-up .32s cubic-bezier(.2, .8, .2, 1) both; }
  #ex .ls-bar.is-ok .ls-pill { animation: ls-pill-pop .5s cubic-bezier(.2, 1.6, .4, 1) .08s both; }
  /* progress fills with a soft overshoot */
  #ex .ls-prog > i { transition: width .7s cubic-bezier(.2, 1.15, .35, 1); }
  #ex .ls-done .ls-lvup, #ex .ls-done .ls-newp { animation: orb-lv-in .6s cubic-bezier(.2, .9, .25, 1) 1.3s both; }
  #ex .ls-done-stats { animation: orb-lv-in .5s cubic-bezier(.2, .9, .25, 1) .25s both; }
}
@media (prefers-reduced-motion: reduce) {
  #ex .ls-bar.is-ok .ls-bar-in, #ex .ls-bar.is-bad .ls-bar-in { animation: ls-fade .25s ease-out both; }
  #ex .ls-prog > i { transition: width .2s linear; }
}
@keyframes ls-bar-spring { 0% { transform: translateY(60%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ls-bar-up { 0% { transform: translateY(30%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ls-pill-pop { 0% { transform: scale(.4); } 100% { transform: none; } }
@keyframes ls-fade { from { opacity: 0; } to { opacity: 1; } }

/* tablet portrait (2026-11-25): side-by-side image cards were ~370px wide with half the screen empty → stack them, full column width */
@media (min-width: 721px) and (max-width: 1099px) and (orientation: portrait) {
  #ex .ls-cards[data-n]:not(.is-wide) { grid-template-columns: minmax(0, 1fr); max-width: 760px; gap: 22px; }
  #ex .ls-cards[data-n]:not(.is-wide) .ls-card .ls-pic { --ph: calc((100vh - 420px) / 2); }
  #ex .ls-cards[data-n="3"]:not(.is-wide) .ls-card .ls-pic { --ph: calc((100vh - 460px) / 3); }
}

/* zoom fallback when every picture corner holds a mark (engine.js placeZooms): sits under the picture, end edge */
#ex .ls .ls-zoom.is-flow { position: static; display: grid; opacity: 1; margin: 8px 0 0; margin-inline-start: auto; inset: auto; }
#ex .ls-credit .ls-lic { white-space: nowrap; }

/* ============================================================
   Deltas 2026-11-25 (docs/exercises/SPEC-v4-deltas.md): hearts only in tests, progress moves only on
   correct answers + combo pill, «ليش؟» theory sheet, review interstitial, test intro, end-screen sequence.
   ============================================================ */
#ex .ls-progw { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; height: 30px; }
#ex .ls-progw .ls-prog { flex: 1; }
#ex .ls-prog[data-combo="on"] > i { background: var(--ls-ok); }
#ex .ls-prog[data-combo="hot"] > i { background: var(--ex-close); }
#ex .ls-prog > i { transition: width .7s cubic-bezier(.2, 1.15, .35, 1), background-color .35s; }
/* the combo pill rides the leading edge of the fill (RTL: the fill grows from the right, its edge is on the left) */
#ex .ls-combo {
  position: absolute; top: 50%; z-index: 2;
  inset-inline-start: clamp(44px, calc(var(--p, 0) * 1%), calc(100% - 44px));
  transform: translate(50%, -50%);
  height: 24px; padding: 0 10px; border-radius: 99px; display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 900; white-space: nowrap; line-height: 1;
  background: var(--ls-ok); color: var(--ex-ok-on); box-shadow: 0 0 0 3px var(--ex-bg);
  transition: inset-inline-start .7s cubic-bezier(.2, 1.15, .35, 1), background-color .3s;
}
[dir="ltr"] #ex .ls-combo { transform: translate(-50%, -50%); }
#ex .ls-combo[data-lv="hot"] { background: var(--ex-close); color: var(--ex-close-on); }
#ex .ls-combo[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { #ex .ls-combo, #ex .ls-prog > i { transition: none; } }

#ex .ls-count.is-review { display: inline-flex; align-items: center; gap: 6px; color: var(--ex-vio); }

/* «ليش؟» / «الشرح» sheet: the step's theory section, wide enough for the DO/DON'T screenshots */
#ex .ls-sheet.is-theory { width: min(780px, 100%); max-height: 90vh; padding-top: 22px; }
#ex .ls-sheet.is-theory .ls-th-title { font-size: clamp(24px, 2.6vw, 30px); margin-bottom: 10px; outline: none; }
#ex .ls-sheet.is-theory .ls-lead { font-size: 16.5px; margin-bottom: 20px; }
#ex .ls-sheet.is-theory .ls-ex .ls-pic { --ph: 360px; }
#ex .ls-sheet.is-theory .ls-pair { gap: 20px; margin-bottom: 22px; }
#ex .ls-sheet.is-theory .ls-sh-acts { margin: 16px 0 0; }
#ex .ls-sheet.is-theory .ls-sh-src { margin-top: 12px; }
#ex .ls-sh-keys {
  position: sticky; bottom: calc(-28px - env(safe-area-inset-bottom)); z-index: 4; margin: 18px calc(-1 * clamp(18px, 4vw, 32px)) calc(-28px - env(safe-area-inset-bottom));
  padding: 12px clamp(18px, 4vw, 32px) calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center;
  background: var(--ex-s); border-top: 1px solid var(--ex-line); font-size: 13px; color: var(--ex-mut);
}
#ex .ls-sh-keys span { display: inline-flex; align-items: center; gap: 6px; }
@media (hover: none), (pointer: coarse), (max-width: 720px) { #ex .ls-sh-keys { display: none; } }
#ex .ls-src-h { display: flex; align-items: center; gap: 7px; margin: 0 0 12px; font-size: 14px; font-weight: 800; color: var(--ex-mut); }
#ex .ls-bar-keys { color: var(--ex-faint); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

/* review interstitial + test intro */
#ex .ls-intro { max-width: 560px; margin: 0 auto; padding-top: clamp(16px, 8vh, 90px); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
#ex .ls-intro-ic, #ex .ls-done-ic {
  width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; margin-bottom: 10px;
  background: var(--ex-t); color: var(--ex-vio);
}
#ex .ls-done-ic { background: var(--ls-okbg); color: var(--ls-ok); border-radius: 99px; }
#ex .ls-done-ic.is-flame { background: color-mix(in srgb, var(--ex-flame) 16%, transparent); color: var(--ex-flame); }
#ex .ls-done-ic.is-calm { background: var(--ex-s2); color: var(--ex-mut); }
#ex .ls-eyebrow.is-c { justify-content: center; margin: 0; }
#ex .ls-intro .ls-lead { margin: 4px 0 10px; }
#ex .ls-rules { list-style: none; margin: 0 0 12px; padding: 0; width: 100%; display: grid; gap: 8px; text-align: start; }
#ex .ls-rules li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--ex-line); background: var(--ex-s); font-size: 15px; line-height: 1.6; color: var(--ex-body); }
#ex .ls-rules li svg { flex: none; color: var(--ex-vio); }
#ex .ls-rules b { color: var(--ex-ink); }
#ex .ls-done.is-a, #ex .ls-done.is-b, #ex .ls-done.is-fail { padding-top: clamp(16px, 7vh, 80px); }
#ex .ls-done.is-a .ls-mut, #ex .ls-done.is-fail .ls-mut { display: inline-flex; align-items: center; gap: 6px; }
#ex .ls-done.is-b .ex-week { margin: 8px 0 14px; }
#ex .ls.is-test .ls-bar.is-bad .ls-bar-why.is-soft { color: var(--ex-body); }
@media (max-width: 720px) {
  #ex .ls-bar.is-bad .ls-bar-e .ls-btn { flex: 1; }
  #ex .ls-bar.is-review0 .ls-bar-e, #ex .ls-bar.is-test0 .ls-bar-e, #ex .ls-bar.is-done-a .ls-bar-e, #ex .ls-bar.is-done-b .ls-bar-e, #ex .ls-bar.is-done-c .ls-bar-e, #ex .ls-bar.is-fail .ls-bar-e { flex: 1; justify-content: flex-end; }
  #ex .ls-bar.is-review0 .ls-btn.is-primary, #ex .ls-bar.is-test0 .ls-btn.is-primary, #ex .ls-bar.is-done-a .ls-btn.is-primary, #ex .ls-bar.is-done-b .ls-btn.is-primary { flex: 1; }
  #ex .ls-combo { font-size: 11.5px; height: 22px; padding: 0 8px; }
  #ex .ls-intro-ic, #ex .ls-done-ic { width: 72px; height: 72px; }
  #ex .ls-sheet.is-theory .ls-ex .ls-pic { --ph: 260px; }
}
#ex .ls-bar-s:empty { display: none; }

/* ---- QA 2026-11-25: nothing the player adds may cover screenshot content ---- */
/* magnifier: a reserved strip under the picture (inside the white paper), always visible */
#ex .ls-paper.has-zoom { padding-bottom: 40px; }
#ex .ls .ls-zoom, #ex .ls-cardw > .ls-zoom { width: 28px; height: 28px; border-radius: 8px; opacity: 1; box-shadow: none; background: #F3F1F8; border-color: rgba(17,17,20,.12); color: #2A2A33; }
#ex .ls .ls-zoom:hover { background: #E9E4F7; }
@media (max-width: 720px) { #ex .ls-paper.has-zoom { padding-bottom: 36px; } #ex .ls .ls-zoom, #ex .ls-cardw > .ls-zoom { width: 26px; height: 26px; } }
/* number badges sit outside the mark's top-left corner, so they never cover the marked text */
#ex .ls-mark > i { top: auto; left: auto; bottom: calc(100% + 3px); right: calc(100% - 6px); min-width: 22px; height: 22px; font-size: 12px; }
#ex .ls-pic.is-strip .ls-mark > i { min-width: 18px; height: 18px; font-size: 11px; }
@media (max-width: 720px) { #ex .ls-mark > i { min-width: 18px; height: 18px; font-size: 11px; } }
#ex .ls-pic { overflow: visible; }
/* credits: each source is an isolated LTR chip */
#ex .ls-credit a.ls-cr-i { display: inline-block; unicode-bidi: isolate; direction: ltr; max-width: 100%; }
/* sheet: keep the breadcrumb clear of the close button */
#ex .ls-sheet .ls-eyebrow { padding-inline-end: 44px; }
#ex figcaption small.ls-cr-i { display: inline-block; unicode-bidi: isolate; direction: ltr; max-width: 100%; }
