/* ==========================================================================
   فهيم — Base + Components (RTL-first, logical properties throughout)
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  font-weight: var(--w-regular);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: var(--w-semibold); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { display: block; }
ul { list-style: none; margin: 0; padding: 0; }

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

.container { max-width: var(--page-max); margin-inline: auto; padding-inline: var(--gutter); }

/* ---- Type helpers ---- */
.t-display { font-size: var(--text-display); line-height: var(--lh-display); font-weight: var(--w-display); }
.t-h2 { font-size: var(--text-h2); line-height: var(--lh-h2); font-weight: var(--w-display); }
.t-h3 { font-size: var(--text-h3); line-height: var(--lh-h3); font-weight: var(--w-semibold); }
.t-sub { font-size: var(--text-sub); line-height: var(--lh-sub); color: var(--ink-2); }
.t-body { color: var(--ink-2); font-size: 16px; line-height: 1.75; }
.t-sm { font-size: var(--text-sm); line-height: var(--lh-sm); }
.t-caption { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--muted); }

/* Highlighter: a rectangular marker wash behind a word or two (JS-free; .reveal parents animate it) */
.hl-word { position: relative; isolation: isolate; font-style: normal; color: inherit; white-space: nowrap; }
/* headlines carry no marker: the words do the emphasis (the marker stays for words inside running text) */
:is(h1, h2, h3, .lp-title) .hl-word::before { display: none; }
.hl-word::before {
  content: ""; position: absolute; z-index: -1;
  inset-inline: -0.18em; bottom: 0.12em; height: 0.55em;   /* overhangs a little so Arabic tails stay inside */
  background: var(--hl-color, var(--highlight)); border-radius: 3px;
}

/* Eyebrow / tagline badge: yellow pill with a tiny icon */
.tagline { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--highlight); color: var(--ink); font-size: var(--text-sm); font-weight: var(--w-medium); }
.tagline .icon { width: 14px; height: 14px; fill: var(--ink); stroke: none; }

/* English micro-labels (section numbers, timers, tags) */
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; direction: ltr; unicode-bidi: isolate; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-8);
  min-height: 44px; padding: 10px 24px;
  font-size: var(--text-body); font-weight: var(--w-semibold); line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-button);
  font-weight: var(--w-medium);
  position: relative; top: 0;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), top .15s var(--ease);
  white-space: nowrap;
}
.btn:active { top: 1px; }

.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); }

.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--lilac); }

/* Arrow glyph that leads the eye forward (left, in RTL); nudges on hover */
.btn--arrow::before { content: "←"; position: relative; left: 0; font-family: system-ui, sans-serif; font-weight: 400; transition: left var(--dur) var(--ease-out); }
.btn--arrow:hover::before { left: -4px; }
[dir="ltr"] .btn--arrow::before { content: "→"; }
[dir="ltr"] .btn--arrow:hover::before { left: 4px; }

.btn--utility { background: var(--surface); color: var(--ink); border-color: var(--border-strong); font-weight: var(--w-medium); min-height: 40px; padding: 8px 16px; font-size: var(--text-sm); }
.btn--utility:hover { border-color: var(--faint); }

.btn--sm { min-height: 38px; padding: 8px 16px; font-size: var(--text-sm); }
.btn--lg { min-height: 54px; padding: 16px 34px; font-size: 16px; }

.link { color: var(--ink); font-weight: var(--w-medium); text-decoration: underline; text-decoration-color: var(--highlight); text-decoration-thickness: 4px; text-underline-offset: 2px; text-decoration-skip-ink: none; transition: text-decoration-color var(--dur-fast); }
.link:hover { text-decoration-color: var(--ink); }

.store-badge {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--black); color: #fff; border-radius: var(--r-input);
  padding: 8px 16px; min-height: 48px; direction: ltr;
}
.store-badge svg { width: 22px; height: 22px; fill: #fff; }
.store-badge small { display: block; font-size: 10px; line-height: 1.2; opacity: .8; }
.store-badge strong { display: block; font-size: 15px; line-height: 1.2; font-weight: var(--w-semibold); font-family: -apple-system, "Segoe UI", system-ui, sans-serif; }

/* ==========================================================================
   Nav
   ========================================================================== */
/* Floating pill nav: a bordered cream bar with a soft highlighter glow */
.nav { position: sticky; top: 12px; z-index: 50; padding-inline: var(--gutter); margin-top: 12px; }
.nav__inner {
  display: flex; align-items: center; gap: var(--s-16); height: 60px;
  max-width: calc(var(--page-max) - 2 * var(--gutter)); margin-inline: auto; padding-inline: 12px 16px;
  background: var(--canvas);   /* solid: a backdrop blur re-renders every frame while content animates beneath it */
  border: 1px solid var(--border-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-glow);
}
.nav__inner.container { padding-inline: 12px 16px; }

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
/* إحراز logo: the ح/e monogram on an ink tile + the drawn Arabic wordmark (assets/brand/) */
.logo__mark { width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--ink); display: grid; place-items: center; }
.logo__mark svg { width: 36px; height: 36px; fill: var(--on-accent); }
.logo__word { display: block; height: 30px; width: auto; fill: currentColor; }

.nav__menu { display: flex; gap: var(--s-4); }
.nav__item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: var(--r-input); background: none; border: 0;
  font-size: var(--text-sm); font-weight: var(--w-medium); color: var(--ink);
}
.nav__item:hover { background: var(--canvas); }

.search {
  flex: 1; max-width: 460px; margin-inline: auto;
  display: flex; align-items: center; gap: var(--s-8);
  background: var(--surface); border-radius: var(--r-button); padding: 0 14px; height: 40px;
  color: var(--muted); border: 1px solid var(--border);
}
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: inherit; font-size: var(--text-sm); color: var(--ink); }
.search input::placeholder { color: var(--faint); }

.nav__actions { display: flex; align-items: center; gap: var(--s-8); }
.nav__burger { display: none; background: none; border: 0; padding: 8px; border-radius: var(--r-input); }

@media (max-width: 1000px) {
  .nav__menu { display: none; }
}
@media (max-width: 720px) {
  .search, .nav__create { display: none; }
  .nav__actions { margin-inline-start: auto; }
  .nav__burger { display: inline-flex; }
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card);
  padding: var(--s-16);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), top .2s var(--ease);
}
a.card { position: relative; top: 0; }
a.card:hover { border-color: var(--ink); top: -2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--canvas); color: var(--muted);
  font-size: var(--text-caption); line-height: 20px; font-weight: var(--w-regular);
}
.badge--accent { background: var(--highlight); color: var(--ink); font-weight: var(--w-medium); }

.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: var(--w-semibold); color: var(--ink); background: var(--highlight);
  box-shadow: inset 0 0 0 1px rgba(23, 25, 23, .15);
}

.arrow-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.arrow-btn:hover { border-color: var(--ink); }
.arrow-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* Progress bar */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--lilac); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* Section shells */
.section { padding-block: var(--section-gap); }
/* one continuous cream page: sections are separated by space, not colored bands */
.section--white, .section--lilac { background: transparent; }

/* ==========================================================================
   Motion
   RULE — text never animates. Only shapes do: doodle strokes, the highlighter
   marker, progress bars, the score ring, ticks, dots, the waveform, hover lifts.
   (Safari drops Arabic marks — ّ ي ٔ ً — from text while any fade/slide/clip
   effect is applied to it, and they pop back in when it ends.)
   ========================================================================== */
/* .reveal is now only a TRIGGER: JS adds .is-in when a block scrolls into view, which starts the
   text-free shape animations inside it (marker sweep, bars, ring, ticks, doodle strokes).
   The block itself — and any text — never fades, slides or clips in: Safari drops Arabic marks
   (ّ ي ٔ ً) from text while an effect is applied, so text is always simply there. */
:where(.js) :where(.reveal) { position: relative; }   /* for paint-only hover lifts (top); zero specificity */
.reveal.is-done {
  transition: top var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}

/* Hand-drawn doodles & squiggles draw themselves stroke by stroke when they come into view.
   JS measures each shape (--len) so one dash covers the whole stroke and slides into place. */
:where(.js) .draw-me :is(path, rect, circle, ellipse, line, polyline) {
  stroke-dasharray: calc(var(--len, 2000) * 1px); stroke-dashoffset: calc(var(--len, 2000) * 1px);
}
/* the transition lives only on the drawing state, so measuring (--len) never animates */
:where(.js) .draw-me.is-in :is(path, rect, circle, ellipse, line, polyline) {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.4s cubic-bezier(.45, .05, .25, 1);
  transition-delay: calc(var(--d, 0) * 1s);
}
:where(.js) .draw-me :is(text, [stroke="none"]) { opacity: 0; transition: opacity .6s ease-out; transition-delay: calc(var(--d, 0) * 1s + .9s); }
:where(.js) .draw-me.is-in :is(text, [stroke="none"]) { opacity: 1; }
.no-anim, .no-anim * { transition: none !important; }

/* Progress bars fill from the inline-start edge */
.bar > span { transform-origin: right center; transition: transform 1.1s var(--ease-out) .25s; }
[dir="ltr"] .bar > span { transform-origin: left center; }
:where(.js) .reveal:not(.is-in) .bar > span { transform: scaleX(0); }

/* Highlighter words: the marker sweeps across once the block lands */
/* paint-only clip wipe, right-to-left (where an Arabic word starts), as the headline finishes */
.reveal .hl-word::before { clip-path: inset(0); transition: clip-path .7s cubic-bezier(.65, 0, .35, 1) .5s; }
:where(.js) .reveal:not(.is-in) .hl-word::before { clip-path: inset(0 0 0 100%); }
[dir="ltr"] :where(.js) .reveal:not(.is-in) .hl-word::before { clip-path: inset(0 100% 0 0); }

/* Site-wide, shapes only and cheap: bars grow in, icons spring on hover, the next lesson breathes.
   Only empty bars, svg icons and an empty ring move (transform/opacity on the compositor), never text.
   `scale` is its own property, so icons that already rotate (chevrons) keep their transform. */
@keyframes bar-grow { from { transform: scaleX(0); } }
.is-loaded :is([class*="bar"], [class*="prog"]) > i[style*="width"] {
  transform-origin: right center; animation: bar-grow .9s var(--ease-out) .15s both;
}
[dir="ltr"] :is([class*="bar"], [class*="prog"]) > i[style*="width"] { transform-origin: left center; }

svg.icon { transition: scale .25s var(--ease-spring); }
@media (hover: hover) {
  :is(a, button, label, summary):hover > svg.icon,
  :is(a, button, label):hover > :is([class*="__ic"], [class*="__icon"], [class*="__n"]) > svg.icon { scale: 1.12; }
}

@keyframes next-ping { 0% { transform: scale(.9); opacity: .7; } 70%, 100% { transform: scale(1.45); opacity: 0; } }
.rll-item.is-next .rll-item__n { position: relative; }
.rll-item.is-next .rll-item__n::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--highlight);
  animation: next-ping 2.4s var(--ease-out) infinite; pointer-events: none;
}

/* Buttons: soft lift */
.btn:where(:not(:disabled)):hover { top: -2px; }
.btn:active { top: 1px; transition-duration: 80ms; }

/* Every other button with no motion of its own (boot.js marks it [data-anim]: no transition, in normal flow) gets
   the same lift and press — with `top`, never transform, since buttons hold Arabic text. A button with a fill or an
   outline ("box") also casts a soft shadow while lifted. An underlined link ("line") doesn't jump inside its sentence:
   its underline grows and takes the text's colour. All :where() but that hover, so any rule a page sets wins. */
:where([data-anim="box"], [data-anim="text"]) {
  position: relative; top: 0;
  transition: top var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
    background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
:where([data-anim="line"]) { transition: text-decoration-color var(--dur-fast) var(--ease), text-decoration-thickness var(--dur) var(--ease-out), color var(--dur-fast) var(--ease); }
@media (hover: hover) {
  :where([data-anim="box"], [data-anim="text"]):where(:hover:not(:disabled, [aria-disabled="true"])) { top: -2px; }
  :where([data-anim="box"]):where(:hover:not(:disabled, [aria-disabled="true"])) { box-shadow: 0 10px 20px -14px rgba(20, 20, 30, .45); }
  /* not :where: a link's own rule sets its underline at rest, and the hover has to win over that */
  [data-anim="line"][data-anim]:hover { text-decoration-color: currentColor; text-decoration-thickness: calc(var(--ul, 1px) + 2px); }
}
:where([data-anim="box"], [data-anim="text"]):where(:active:not(:disabled, [aria-disabled="true"])) { top: 1px; box-shadow: none; transition-duration: 80ms; }

/* Big cards on the signed-in pages (boot.js marks them [data-card="lift"]): a very small lift and a faint shadow,
   slower than a button's. `top` again, since cards hold Arabic text. */
:where([data-card="lift"]) { position: relative; top: 0; transition: top 450ms var(--ease-out), box-shadow 450ms var(--ease-out); }
@media (hover: hover) {
  :where([data-card="lift"]):hover { top: -2px; box-shadow: 0 16px 32px -26px rgba(20, 20, 30, .3); }
}

/* Nav: flat at top, shadow once the page scrolls */
.nav { transition: box-shadow var(--dur) var(--ease-out); }
.nav__inner { transition: box-shadow var(--dur) var(--ease-out), background-color var(--dur); }
.nav.is-scrolled .nav__inner { background: color-mix(in srgb, var(--canvas) 94%, transparent); }

.arrow-btn { transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur) var(--ease-spring), opacity var(--dur); }
.arrow-btn:not(:disabled):hover { transform: scale(1.08); }
.arrow-btn:not(:disabled):active { transform: scale(0.94); }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes pulse-ring { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.06, 0.97) rotate(-2deg); }
  50% { transform: scale(0.97, 1.05) rotate(1.5deg); }
  75% { transform: scale(1.04, 0.98) rotate(-1deg); }
}
@keyframes float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; transition-delay: 0s !important;
  }
}

/* ?noanim — diagnostic switch: no transitions or animations anywhere */
html.noanim *, html.noanim *::before, html.noanim *::after { transition: none !important; animation: none !important; }

/* «حركة أقل» in settings.html (boot.js sets html.calm): the same as the system's reduced-motion setting above —
   everything lands in its final state at once (not animation: none, which would leave reveals at their start) */
html.calm *, html.calm *::before, html.calm *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important; transition-delay: 0s !important;
}
html.calm, html.noanim { scroll-behavior: auto !important; }

/* «حجم الخط» in settings.html (boot.js sets html[data-text]): the signed-in pages are drawn larger as a whole —
   every size on the site is in px, so zoom keeps each page's proportions (the landing and sign-in pages stay as they are) */
html[data-text="large"] body.dash-body { zoom: 1.1; }
html[data-text="larger"] body.dash-body { zoom: 1.2; }

/* ---------- Owner blocks (inserted with the page editor, ?edit → «+ عنصر») ----------
   Same sketchbook look as the rest of the site. Text inside never animates. */
.blk { margin-block: var(--s-24); }
.blk-sticky, .blk-callout { display: grid; gap: 8px; padding: 20px 22px; border: 1px solid var(--border-strong); border-radius: var(--r-panel); color: var(--ink); }
.blk-sticky { background: var(--tint, var(--tint-cyan)); box-shadow: none; }
.blk-callout { background: var(--highlight-soft); }
.blk-sticky h3, .blk-callout h3 { font-size: 19px; font-weight: var(--w-display); line-height: 1.5; }
.blk-sticky p, .blk-callout p, .blk-tip p { font-size: 16px; line-height: 1.85; }
.blk-tip { padding: 14px 18px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-card); background: var(--surface); }
.blk-figure { display: grid; gap: 8px; }
.blk-figure img { width: 100%; height: auto; border: 1px solid var(--border-strong); border-radius: var(--r-card); background: #fff; }
.blk-figure figcaption { font-size: 13.5px; color: var(--muted); text-align: center; }
.blk-example { padding: 14px 18px; border-radius: var(--r-card); border: 1px solid var(--border-strong); background: var(--lilac); text-align: left; font-size: 16px; line-height: 1.8; }
.blk-pill { margin-block: var(--s-12); }

/* ---------- AI helper (Claude): one look on every page — teal ✦ button, intro banner, feedback card ---------- */
.ai-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill); background: var(--tint-cyan); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: var(--w-semibold); line-height: 1.3; cursor: pointer; text-decoration: none; }
.ai-btn::before { content: "✦"; font-size: 13px; }
.ai-btn:hover { box-shadow: none; }
.ai-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ai-btn:disabled { opacity: .65; cursor: progress; box-shadow: none; }
.ai-btn--sm { min-height: 34px; padding: 5px 14px; font-size: 13px; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--tint-cyan);
  color: var(--ink); font-size: 12px; font-weight: var(--w-semibold); white-space: nowrap; }
.ai-badge::before { content: "✦"; }
/* the banner that tells students the AI helper is here and what it does */
.ai-intro { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border: 1.5px solid var(--border-strong);
  border-radius: var(--r-card); background: var(--surface); }
.ai-intro__text { flex: 1 1 260px; display: grid; gap: 4px; min-width: 0; }
.ai-intro__text b { font-size: 15px; font-weight: var(--w-semibold); color: var(--ink); }
.ai-intro__text p { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }
@media (max-width: 560px) { .ai-intro .ai-btn { width: 100%; } }
.ai-box { margin-top: 10px; padding: 12px 14px; border-radius: var(--r-card); background: var(--lilac); border-inline-start: 3px solid var(--ink);
  display: grid; gap: 8px; font-size: 14px; line-height: 1.85; color: var(--ink-2); }
.ai-box__head { font-size: 12.5px; font-weight: var(--w-semibold); color: var(--muted); }
.ai-box__en { direction: ltr; text-align: left; font-size: 14.5px; line-height: 1.7; color: var(--ink); }
.ai-box__en mark { background: var(--highlight); color: var(--ink); padding: 0 2px; border-radius: 2px; }
.ai-box__tip { font-size: 13px; color: var(--ink); }
.ai-box__tip b { font-weight: var(--w-semibold); }
.ai-box__verdict { display: inline-block; justify-self: start; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: var(--w-semibold); background: var(--tint-violet); color: var(--ink); }
.ai-box__verdict.is-almost { background: var(--highlight); }
.ai-box__verdict.is-wrong { background: var(--tint-peach); }
.ai-box__fixes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ai-box__fixes li { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; background: var(--surface); }
.ai-box__fixes .ai-fix { direction: ltr; text-align: left; font-size: 14px; }
.ai-box__fixes s { color: var(--terracotta); }
.ai-box__fixes ins { text-decoration: none; background: var(--tint-violet); color: var(--ink); padding: 0 3px; border-radius: 3px; }
.ai-box > .ai-badge { justify-self: start; }
.ai-box__note { font-size: 11.5px; color: var(--muted); }
.ai-box.is-error { border-inline-start-color: var(--terracotta); }
/* where the AI helper can't answer (html.ai-off, set by assets/api.js): its optional buttons and banners are not offered,
   and exercises built around it show a plain note and a self-review instead */
.ai-off button.ai-btn, .ai-off .ai-intro:not(.ai-intro--self):not(.pp-link) { display: none !important; }   /* paraphrase works without it (self-review) */
.ai-off-note { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px dashed var(--border-strong);
  font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.ai-badge--self { background: var(--highlight); }
.ai-badge--self::before { content: "✓"; }
.ai-self { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; font-size: 13.5px; }
/* while Claude is working: the ✦ turns and pulses, and a placeholder card shimmers where the answer will appear.
   Only the star and the bars move — text never animates (Safari drops Arabic marks under effects). */
.ai-btn.is-thinking, .ai-btn.is-thinking:disabled { opacity: 1; cursor: progress; }
.ai-btn.is-thinking::before, .ai-wait .ai-badge::before { animation: ai-star 1.1s ease-in-out infinite; }
.ai-wait { gap: 10px; }
.ai-wait__label { font-size: 13px; color: var(--muted); }
.ai-wait__bar { display: block; width: 92%; height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, var(--border-strong) 20%, var(--surface) 50%, var(--border-strong) 80%);
  background-size: 300% 100%; animation: ai-shimmer 1.4s linear infinite; }
.ai-wait__bar + .ai-wait__bar { width: 72%; animation-delay: .15s; }
.ai-wait__bar + .ai-wait__bar + .ai-wait__bar { width: 46%; animation-delay: .3s; }
@keyframes ai-star { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.4); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes ai-shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .ai-btn.is-thinking::before, .ai-wait .ai-badge::before, .ai-wait__bar { animation: none; }
}

/* ==========================================================================
   «تحليل أدائك» on the Listening and Speaking pages (the tabs themselves are .rtabs in reading.css)
   ========================================================================== */
.an { display: grid; gap: var(--s-24); align-content: start; }
.an .grid-2 { align-items: start; }
.an-kicker { font-size: 13px; color: var(--ink-2); font-weight: var(--w-semibold); }
.an-empty { display: grid; gap: 8px; justify-items: start; }
.an-empty b { font-size: 18px; font-weight: var(--w-display); }
.an-empty p { color: var(--muted); font-size: var(--text-sm); line-height: 1.8; max-width: 60ch; }

/* the headline: one number, what it is based on, and the counts beside it */
.an .an-level { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px;
  background: var(--highlight); border-color: var(--border-strong); }
.an .an-level--none { background: var(--surface); border-style: dashed; }
.an-level__band { display: block; font-size: 44px; line-height: 1.15; font-weight: var(--w-display); }
.an-level__none { display: block; font-size: 22px; line-height: 1.4; font-weight: var(--w-display); margin-top: 2px; }
.an-level__meta { font-size: 13.5px; line-height: 1.8; color: var(--ink-2); max-width: 56ch; }
.an-level__stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.an-level__stats > div { display: grid; gap: 0; padding: 8px 14px; border-radius: 12px; background: rgba(255, 255, 255, .6); border: 1px solid rgba(23, 25, 23, .2); min-width: 96px; }
.an-level__stats dt { font-size: 12px; color: var(--ink-2); }
.an-level__stats dd { margin: 0; font-size: 20px; font-weight: var(--w-display); }

.an-focus ol { display: grid; gap: 10px; margin: 10px 0 0; padding: 0; list-style: none; counter-reset: an; }
.an-focus li { position: relative; padding-inline-start: 34px; font-size: 14px; line-height: 1.85; color: var(--ink-2); counter-increment: an; }
.an-focus li::before { content: counter(an); position: absolute; inset-inline-start: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12.5px; font-weight: var(--w-display); background: var(--highlight); border: 1px solid var(--border-strong); color: var(--ink); }

/* bars: name · % · right/of, the bar under them */
.an-bars { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.an-bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 10px; align-items: baseline; }
.an-bars__name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; color: var(--ink-2); }
.an-bars__name small { font-size: 11px; color: var(--muted); }
.an-bars__pct { font-weight: var(--w-display); font-size: 15px; }
.an-bars__n { font-size: 12px; color: var(--muted); min-width: 4.5ch; text-align: end; }
.an-bars .bar { grid-column: 1 / -1; height: 10px; }
.an-bars .bar > span { background: var(--ink); }
.an-bars li.is-small .bar > span { background: var(--border-strong); }
.an-weak { font-style: normal; font-size: 11px; font-weight: var(--w-semibold); color: var(--terracotta); background: #fbe1d3; border-radius: var(--r-pill); padding: 1px 8px; }

.an-lost { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.an-lost li { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--canvas); border: 1px dashed var(--border-strong); }
.an-lost b { font-size: 22px; font-weight: var(--w-display); }
.an-lost span { font-size: 12.5px; color: var(--ink-2); }

/* every attempt / answer, newest first */
.an-hist { display: grid; margin: 0; padding: 0; list-style: none; }
.an-hist li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 16px; align-items: center; padding: 12px 2px; border-top: 1.5px dashed var(--border); }
.an-hist li:first-child { border-top: 0; }
.an-hist li > div { display: grid; gap: 2px; min-width: 0; }
.an-hist li > div b { font-size: 14.5px; font-weight: var(--w-semibold); text-align: start; }
.an-hist li > div span { font-size: 12px; color: var(--muted); }
.an-hist li > div small { font-size: 12px; color: var(--ink-2); line-height: 1.6; }
.an-hist__score { display: grid; justify-items: center; font-size: 12px; color: var(--muted); }
.an-hist__score b { font-size: 15px; color: var(--ink); font-weight: var(--w-display); }
.an-tag { font-size: 11.5px; font-weight: var(--w-semibold); white-space: nowrap; padding: 2px 10px; border-radius: var(--r-pill); border: 1px dashed var(--border-strong); color: var(--muted); }
.an-tag--on { background: var(--highlight); border: 1px solid var(--ink); color: var(--ink); }

.an-how { font-size: 13.5px; }
.an-how summary { cursor: pointer; font-weight: var(--w-semibold); }
.an-how ul { display: grid; gap: 8px; margin: 12px 0 0; padding-inline-start: 18px; color: var(--ink-2); line-height: 1.85; }

@media (max-width: 560px) {
  .an-level__band { font-size: 36px; }
  .an-level__stats { width: 100%; }
  .an-level__stats > div { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
  .an-level__stats dt { font-size: 11px; }
  .an-lost { grid-template-columns: minmax(0, 1fr); }
  .an-lost li { grid-template-columns: auto 1fr; align-items: baseline; gap: 10px; }
  .an-hist li { grid-template-columns: minmax(0, 1fr) auto; }
  .an-hist li > .an-tag { grid-column: 1 / -1; justify-self: start; }
}
