:root {
  --terracotta: #D95D39; --cedar: #1B4332; --azure: #0077B6; --sand: #F8F4E3; --slate: #1E293B;
  --card: #ffffff; --line: #e4dcc3; --muted: #64748b; --ok: #1f8a4c; --bad: #c0392b;
  --blue: #0077B6; --amber: #e0a526; --emerald: #1f9d6b; --rose: #d6487a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* App shell: the window never scrolls. Header and nav are fixed rows; #view is the only scroll container. */
body { font-family: Inter, system-ui, sans-serif; background: var(--sand); color: var(--slate); line-height: 1.45; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
h1, h2, h3, h4 { margin: .4em 0; font-family: Cairo, Inter, sans-serif; color: var(--cedar); }
a { color: var(--azure); text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.ar, .big-ar { font-family: Cairo, 'Noto Sans Arabic', sans-serif; direction: rtl; }
.ar { font-size: 1.15em; }

#hdr { flex: none; position: relative; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--cedar); color: #fff; }
.logo { color: #fff; display: flex; gap: 10px; align-items: baseline; font-weight: 700; }
.logo-ar { font-family: Cairo, sans-serif; font-size: 1.3rem; color: #ffd9c9; }
.stats { display: flex; gap: 10px; font-size: .85rem; flex-wrap: wrap; justify-content: flex-end; }
.stat { background: rgba(255,255,255,.12); padding: 3px 9px; border-radius: 999px; }

#view { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px max(16px, calc((100% - 820px) / 2)) 90px; }
.badge { position: absolute; top: 0; right: 0; background: var(--terracotta); color: #fff; border-radius: 999px; font-style: normal; font-size: .62rem; padding: 1px 5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgba(30,41,59,.05); }
a.card.link { display: block; color: inherit; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--slate); border-radius: 10px; padding: 10px 14px; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--azure); }
.btn.primary { background: var(--terracotta); border-color: var(--terracotta); color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; }
.btn.opt { display: block; width: 100%; text-align: left; margin: 6px 0; }
.btn.right, .btn.opt.right { background: #e6f6ec; border-color: var(--ok); }
.btn.wrong, .btn.opt.wrong { background: #fdeaea; border-color: var(--bad); }
.btn:disabled { opacity: .7; cursor: default; }
.chip { font: inherit; font-size: .8rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: #fff; padding: 8px 12px; cursor: pointer; }
.seg button.on { background: var(--cedar); color: #fff; }
.inp { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin: 6px 0; }
.field { display: block; margin: 8px 0; } .field span { display: block; font-size: .85rem; color: var(--muted); }
.check { display: block; margin: 6px 0; }
.bar { height: 8px; background: #efe8cf; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--terracotta), var(--azure)); }
.fb { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.fb.ok { background: #e6f6ec; color: #14532d; } .fb.bad { background: #fdeaea; color: #7f1d1d; }
.rule { font-size: .88rem; color: var(--cedar); background: #eef5ef; border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.culture { background: #fff3e6; border-radius: 10px; padding: 4px 12px; margin: 10px 0; }
.prompt { font-size: 1.3rem; font-weight: 600; margin: 8px 0 12px; }
.crumb { font-size: .9rem; }

.audio { border: 0; background: var(--azure); color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.05rem; flex: none; }
.audio.small { width: 30px; height: 30px; font-size: .85rem; }
.audio.playing { background: var(--terracotta); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* text blocks */
.tx { display: flex; flex-direction: column; gap: 2px; }
.tx .chat { font-weight: 600; font-size: 1.05rem; }
.tx.big .chat { font-size: 1.6rem; } .tx.big .ar { font-size: 1.7rem; }
.tx .ar { color: var(--slate); }
.w { cursor: pointer; border-bottom: 1px dotted var(--muted); }
.w:hover { background: #fff0cc; }
.phrases { display: grid; gap: 10px; }
.phrase { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid #f0ead6; }
.en { color: var(--muted); font-size: .92rem; }

/* sheet (x-ray) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: min(560px, 100%); border-radius: 18px 18px 0 0; padding: 16px; max-height: 80vh; overflow: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.x { border: 0; background: none; font-size: 1.2rem; cursor: pointer; }
.xr-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1ecd8; }
.xr-k { flex: 0 0 150px; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.sheet-foot { display: flex; gap: 10px; align-items: center; margin-top: 10px; }

/* map */
.hero { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 20px; }
.hero-stats b { font-size: 1.2rem; color: var(--terracotta); }
.wave-on { margin-top: 8px; }
.tier { margin-top: 22px; color: var(--terracotta); font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; }
.unit { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; overflow: hidden; }
.unit-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.station { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--azure); color: #fff; display: grid; place-items: center; font-weight: 700; border: 4px solid #cfe9f7; }
.station.complete { background: var(--ok); border-color: #c9efd8; }
.unit-main { flex: 1; min-width: 0; } .unit-title { font-weight: 600; }
.unit-set { padding: 0 14px; margin: 0 0 8px; }
.subs { border-top: 1px solid #f0ead6; }
.sub { display: flex; gap: 10px; padding: 9px 14px; color: var(--slate); border-bottom: 1px solid #f7f2e0; align-items: center; min-height: 44px; }
.sub:hover { background: #fffaf0; }
.sub-n { flex: none; width: 38px; color: var(--muted); font-size: .85rem; }
.sub-t { flex: 1; font-size: .92rem; }
.sub.pending { color: #94a3b8; } .sub.done .sub-s { color: var(--ok); font-weight: 700; } .sub:not(.pending):not(.done) .sub-s { color: var(--terracotta); }

/* chat story */
.wa { background: #e7dfc9; border-radius: var(--radius); padding: 10px; }
.wa-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.wa-thread { display: flex; flex-direction: column; gap: 8px; max-height: 58vh; overflow: auto; padding: 4px; }
.bubble { max-width: 86%; padding: 8px 12px; border-radius: 12px; background: #fff; position: relative; }
.bubble.me { align-self: flex-end; background: #d9f2c6; }
.bubble.them { align-self: flex-start; }
.who { font-size: .72rem; font-weight: 700; color: var(--terracotta); }
.bub-foot { text-align: right; margin-top: 2px; }
.wa-ctl { margin-top: 10px; }
.check-q { margin: 6px 0; }

.shorty-lines .sh-line { padding: 8px 10px; border-radius: 10px; margin: 6px 0; cursor: pointer; border-left: 4px solid transparent; }
.sh-line.active { background: #fff0cc; border-left-color: var(--terracotta); }

/* tiles */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tile { font: inherit; border: 2px solid; border-radius: 10px; padding: 8px 14px; background: #fff; cursor: pointer; font-weight: 600; min-height: 44px; }
.legend .tile { font-size: .75rem; min-height: 0; padding: 3px 8px; cursor: default; }
.k-p { color: var(--blue); border-color: var(--blue); background: #e6f3fb; }
.k-s { color: #8a5e00; border-color: var(--amber); background: #fff6dc; }
.k-x { color: #0d6b47; border-color: var(--emerald); background: #e2f6ee; }
.k-c { color: #a02456; border-color: var(--rose); background: #fde9f1; }
.k-w { color: var(--slate); border-color: #cbd5e1; background: #f1f5f9; }
.tb-answer, .tb-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-radius: 12px; margin: 10px 0; min-height: 64px; align-items: center; }
.tb-answer { border: 2px dashed var(--line); background: #fffdf5; }
.segs { display: inline-flex; gap: 2px; }
.seg-t { padding: 2px 8px; border-radius: 8px; border: 2px solid; font-weight: 700; font-size: 1.1rem; }

/* anticipation */
.radial { width: 150px; height: 150px; transform: rotate(-90deg); }
.radial .rbg { fill: none; stroke: #efe8cf; stroke-width: 9; }
.radial .rfg { fill: none; stroke: var(--terracotta); stroke-width: 9; stroke-linecap: round; }
.radial .rtxt { transform: rotate(90deg); transform-origin: 50px 50px; font-size: 22px; font-weight: 700; fill: var(--cedar); font-family: Cairo, sans-serif; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.hands { float: right; font-size: .85rem; color: var(--muted); }

/* labs */
.slider-row { display: grid; grid-template-columns: 70px 1fr 150px; gap: 10px; align-items: center; margin: 10px 0; }
.slider-row input[type=range] { width: 100%; accent-color: var(--terracotta); min-height: 32px; }
.lab-out { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.lab-form { font-size: 1.4rem; }
.lab-pron { color: var(--muted); font-size: 1rem; }
.lab-label { font-size: .85rem; color: var(--cedar); font-weight: 600; }
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.letter { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; }
.big-ar { font-size: 2.6rem; line-height: 1.2; color: var(--cedar); }
.lt-chat { font-weight: 700; color: var(--terracotta); } .lt-ex { font-size: .85rem; margin-top: 6px; }
.marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.mark { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; display: flex; flex-direction: column; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0; }
.pair-w { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pair-focus { font-weight: 700; color: var(--terracotta); }

/* review grades */
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.grades .btn { text-align: center; padding: 8px 4px; } .grades small { display: block; color: var(--muted); }
.g1 { border-color: var(--bad); } .g2 { border-color: var(--amber); } .g3 { border-color: var(--ok); } .g4 { border-color: var(--azure); }
.btn.sug { box-shadow: 0 0 0 3px rgba(217,93,57,.35); }

/* phases */
.phases { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.phase { font: inherit; font-size: .72rem; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.phase b { font-size: 1rem; } .phase.on { background: var(--cedar); color: #fff; } .phase.past { background: #e6f6ec; }

/* roots */
.verb-list { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.verb { display: grid; grid-template-columns: 90px 1fr 1fr auto; gap: 8px; align-items: center; text-align: left; font: inherit; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.verb.on { border-color: var(--terracotta); background: #fff6f2; }
.forms { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.formcell { background: #f8f4e3; border-radius: 10px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; }
.scroll-x { overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; font-size: .9rem; }
.matrix th, .matrix td { border: 1px solid #efe8cf; padding: 4px 6px; text-align: left; white-space: nowrap; cursor: pointer; }
.matrix .seg-t { font-size: .85rem; padding: 0 4px; border-width: 1px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--slate); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 80; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .slider-row { grid-template-columns: 1fr; }
  .verb { grid-template-columns: 70px 1fr; } .verb .chip { display: none; }
  .pair { grid-template-columns: 1fr; }
  .logo span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { .audio.playing { animation: none; } }

/* ── gamification ── */
.stats { color: inherit; align-items: center; }
.stat.goal { display: inline-flex; gap: 6px; align-items: center; padding: 2px 10px 2px 4px; }
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .rbg { fill: none; stroke: rgba(120,120,120,.22); stroke-width: 4; }
.ring .rfg { fill: none; stroke: var(--terracotta); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .6s; }
.stat .ring .rbg { stroke: rgba(255,255,255,.25); } .stat .ring .rfg { stroke: #ffd27a; }
.ring span { position: relative; font-size: .8rem; }
.hero { align-items: center; justify-content: flex-start; gap: 16px; }
.hero-main { flex: 1; min-width: 160px; } .hero-main h2 { margin: 0 0 2px; }
.week { display: flex; justify-content: space-between; margin: 14px 0 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .7rem; color: var(--muted); }
.wd i { width: 32px; height: 32px; border-radius: 50%; background: #efe8cf; display: grid; place-items: center; font-style: normal; font-size: 1rem; }
.wd.on i { background: #ffe3cf; } .wd.today i { box-shadow: 0 0 0 2px var(--terracotta); }
.quests { display: grid; gap: 6px; margin-top: 8px; }
.quest { display: flex; gap: 8px; align-items: center; font-size: .92rem; } .quest span:nth-child(2) { flex: 1; } .quest small { color: var(--muted); }
.quest.done span:nth-child(2) { text-decoration: line-through; color: var(--muted); }
.stars { font-size: 3rem; letter-spacing: 6px; color: #d9d2bb; } .stars .on { color: #f1b020; animation: pop .5s both; } .stars span:nth-child(2) { animation-delay: .15s; } .stars span:nth-child(3) { animation-delay: .3s; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.35); } 100% { transform: scale(1); } }
.xp-float { position: fixed; left: 50%; top: 38%; transform: translateX(-50%); z-index: 90; font-weight: 800; font-size: 1.4rem; color: var(--terracotta); text-shadow: 0 1px 0 #fff, 0 0 12px #fff; pointer-events: none; animation: floatup 1.3s ease-out forwards; }
.xp-float.big { font-size: 1.9rem; color: var(--cedar); } .xp-float.combo { top: 30%; color: var(--azure); }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -90px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; animation: fall 2.2s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
.celebrate { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 92; display: grid; place-items: center; padding: 20px; }
.cel-card { background: #fff; border-radius: 20px; padding: 24px; text-align: center; max-width: 340px; animation: pop .45s both; }
.cel-emoji { font-size: 4rem; }
.rank { display: flex; gap: 14px; align-items: center; } .rank > div:last-child { flex: 1; } .rank-ic { font-size: 3rem; }
.stat-row { display: flex; justify-content: space-around; text-align: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.big-stat b { display: block; font-size: 1.5rem; color: var(--terracotta); } .big-stat span { font-size: .78rem; color: var(--muted); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.badge-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; opacity: .55; }
.badge-card.got { opacity: 1; background: #fff8e6; border-color: var(--amber); }
.badge-card small { color: var(--muted); } .b-ic { font-size: 2rem; }

/* ── Audio Lab ── */
.al-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.al-row { border-top: 1px solid var(--line); padding: 10px 0; }
.al-row.playing { background: #fff6e6; }
.al-main { display: flex; align-items: center; gap: 10px; }
.al-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.al-rate { display: flex; gap: 6px; align-items: center; margin-top: 6px; padding-left: 46px; }
.al-note { flex: 1; min-width: 0; padding: 6px 8px; font-size: .85rem; }
.chip.on { background: #e3f4ea; border-color: var(--ok); }
.chip.on.bad { background: #fbe5e2; border-color: var(--bad); }
pre.code { background: #f3efe0; padding: 10px; border-radius: 8px; overflow-x: auto; }

/* ══════════ V2: nav ══════════ */

/* ══════════ The Road ══════════ */
.road-hero { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.rh-main { flex: 1; min-width: 0; }
.rh-top { display: flex; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.rh-rank { color: var(--cedar); }
.btn.big-cta { width: 100%; font-size: 1.05rem; padding: 14px 16px; border-radius: 16px; box-shadow: 0 4px 0 #a8432a; }
.btn.big-cta:active { transform: translateY(3px); box-shadow: 0 1px 0 #a8432a; }
.btn.big-cta[disabled] { opacity: .45; box-shadow: none; }
.road { display: flex; flex-direction: column; align-items: center; padding: 8px 0 120px; }
.station-banner { align-self: stretch; display: flex; gap: 12px; align-items: center; margin: 22px 0 14px; padding: 12px 14px; border-radius: 16px; color: #fff; background: var(--azure); scroll-margin-top: 70px; }
.station-banner.tier-2 { background: var(--terracotta); }
.station-banner.tier-3 { background: var(--cedar); }
.station-banner .muted { color: rgba(255,255,255,.8); }
.station-banner .bar { background: rgba(255,255,255,.25); }
.station-banner .bar .fill { background: #fff; }
.sb-n { flex: none; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.sb-main { flex: 1; min-width: 0; }
.sb-place { font: 700 1.05rem Cairo, Inter, sans-serif; }
.sb-place .ar { font-size: .95rem; opacity: .85; }
.sb-title { font-size: .85rem; opacity: .95; }
.rnode { position: relative; display: flex; flex-direction: column; align-items: center; margin: 6px 0; }
.rn-btn { width: 66px; height: 62px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.6rem; background: #e6dfc8; color: #8a8f98; box-shadow: 0 6px 0 #cbbf9c; transition: transform .1s; }
.rn-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #cbbf9c; }
.rnode.big .rn-btn { width: 80px; height: 74px; font-size: 2rem; }
.rnode.done .rn-btn { background: #f1c84b; color: #6b4e00; box-shadow: 0 6px 0 #c99a17; font-weight: 800; }
.rnode.open .rn-btn { background: #fff; color: var(--slate); box-shadow: 0 6px 0 #cbbf9c; }
.rnode.current .rn-btn { background: var(--terracotta); color: #fff; box-shadow: 0 6px 0 #a8432a, 0 0 0 8px rgba(217,93,57,.18); animation: nodeglow 1.6s ease-in-out infinite; }
.rnode.t-boss.current .rn-btn, .rnode.t-boss.open .rn-btn { background: #7b3f61; color: #fff; box-shadow: 0 6px 0 #4f2740; }
.rnode.t-shorty.current .rn-btn, .rnode.t-shorty.open .rn-btn { background: var(--azure); color: #fff; box-shadow: 0 6px 0 #005484; }
@keyframes nodeglow { 50% { box-shadow: 0 6px 0 #a8432a, 0 0 0 14px rgba(217,93,57,.08); } }
.rn-label { font-size: .7rem; color: var(--muted); margin-top: 8px; max-width: 120px; text-align: center; }
.rnode.current .rn-label { color: var(--terracotta); font-weight: 700; }
.start-tag { position: absolute; top: -30px; background: #fff; border: 2px solid var(--terracotta); color: var(--terracotta); font-weight: 800; font-size: .72rem; letter-spacing: .08em; padding: 3px 10px; border-radius: 10px; animation: bob 1.2s ease-in-out infinite; z-index: 1; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.road-pending { margin: 10px 0 0; }
.warmup-tag { background: #fff6e0; border: 1px dashed #e0a526; border-radius: 12px; padding: 10px 12px; margin: 10px 0; }

/* ══════════ The Gym ══════════ */
.gym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.gym-tile { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; color: inherit; box-shadow: 0 3px 0 var(--line); }
.gym-tile.hot { border-color: var(--terracotta); box-shadow: 0 3px 0 #f0b8a6; }
.gt-ic { font-size: 1.9rem; width: 48px; height: 48px; display: grid; place-items: center; background: var(--sand); border-radius: 12px; flex: none; }

/* ══════════ My Diwan ══════════ */
.diwan-hero { display: flex; gap: 14px; align-items: center; }
.diwan-cat { width: 120px; flex: none; }
.diwan-cat .cat { width: 100%; height: auto; }
.wallet { margin-top: 8px; font-size: 1.05rem; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.shop-item.on { border-color: var(--ok); background: #f1faf4; }
.shop-item.locked { opacity: .6; }
.si-ic { font-size: 1.8rem; }
.si-lock { color: var(--muted); }
.postcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.postcard { border: 2px dashed #d8cfb6; border-radius: 12px; padding: 12px; background: #fffdf6; }
.postcard.got { border-style: solid; border-color: #e0a526; background: linear-gradient(135deg, #fffaf0, #fdf1d8); }
.ladder { display: flex; flex-direction: column; gap: 6px; }
.rung { display: flex; gap: 12px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; }
.rung.past { opacity: .6; }
.rung.cur { background: #fff1ea; border: 1px solid var(--terracotta); }
.rg-xp { width: 70px; flex: none; padding-top: 2px; }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cast-card { display: flex; gap: 10px; align-items: flex-start; }
.prof-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.prof-row .inp { max-width: 60%; }

/* ══════════ Characters ══════════ */
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; }
.avatar.sm { width: 34px; height: 34px; }
.avatar.lg { width: 60px; height: 60px; }
.avatar .face { width: 100%; height: 100%; display: block; }
.avatar.cat-av { background: #fdf0c8; overflow: hidden; } .avatar.cat-av .cat { width: 100%; height: 100%; display: block; }
.face .m-open { opacity: 0; transform-box: fill-box; transform-origin: center; }
.talking .face .m-open { animation: talk .22s ease-in-out infinite alternate; }
.talking .face .m-closed { opacity: 0; }
.talking { filter: drop-shadow(0 0 6px rgba(0,119,182,.55)); }
@keyframes talk { from { opacity: 1; transform: scaleY(.25); } to { opacity: 1; transform: scaleY(1); } }
.bub-row { display: flex; gap: 8px; align-items: flex-end; margin: 6px 0; }
.bub-row.me { flex-direction: row-reverse; }
.bub-row .bubble { margin: 0; }
.sh-line { display: flex; gap: 10px; align-items: flex-start; }
.sh-body { flex: 1; min-width: 0; }

/* ══════════ Za3tar the cat ══════════ */
.mascot { position: fixed; right: 10px; bottom: 78px; z-index: 30; width: 74px; height: 74px; padding: 0; border: 0; background: none; cursor: pointer; filter: drop-shadow(0 3px 4px rgba(30,41,59,.25)); }
.mascot .cat { width: 100%; height: 100%; overflow: visible; }
.cat .tail { transform-origin: 68px 74px; animation: tail 2.4s ease-in-out infinite; }
@keyframes tail { 50% { transform: rotate(-12deg); } }
.cat .cat-eyes { transform-origin: 50px 40px; animation: blink 4.5s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.cat .cat-x { display: none; }
.cat .cup { display: none; }
.cat .cup[data-gold] { display: inline; }
.cat .ear { transition: transform .2s; }
.mascot.listen .ear-l { transform: translate(-1px, -3px) rotate(-6deg); transform-origin: 37px 24px; }
.mascot.listen .ear-r { transform: translate(1px, -3px) rotate(6deg); transform-origin: 63px 24px; }
.mascot.think .cup { display: inline; }
.mascot.think .head { transform: rotate(-6deg); transform-origin: 50px 60px; transition: transform .3s; }
.mascot.think .steam { animation: steam 1.2s ease-in-out infinite; }
@keyframes steam { 50% { opacity: .3; transform: translateY(-2px); } }
.mascot.happy .cat { animation: hop .45s ease-out 2; }
.mascot.party .cat { animation: dabkeh .5s ease-in-out infinite; }
@keyframes hop { 40% { transform: translateY(-14px); } }
@keyframes dabkeh { 25% { transform: translateY(-10px) rotate(-8deg); } 50% { transform: translateY(0); } 75% { transform: translateY(-10px) rotate(8deg); } }
.mascot.sad .cat { transform: rotate(-80deg) translate(-10px, 14px); transition: transform .35s; }
.mascot.sad .cat-eyes { display: none; }
.mascot.sad .cat-x { display: inline; }
.mascot-bubble { position: fixed; right: 88px; bottom: 150px; z-index: 31; max-width: 220px; background: #fff; border: 2px solid var(--cedar); border-radius: 14px 14px 2px 14px; padding: 8px 12px; font-size: .9rem; box-shadow: 0 4px 10px rgba(30,41,59,.15); opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .2s, transform .2s; }
.mascot-bubble.show { opacity: 1; transform: none; }
.mascot-bubble small { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .cat .tail, .cat .cat-eyes, .mascot.party .cat, .mascot.happy .cat, .rnode.current .rn-btn, .start-tag { animation: none !important; } }

/* ══════════ Combo meter & fire ══════════ */
#combo-meter { position: fixed; top: 62px; left: 50%; transform: translateX(-50%) scale(.6); z-index: 25; background: var(--slate); color: #fff; font-weight: 800; letter-spacing: .04em; padding: 6px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#combo-meter.show { opacity: 1; transform: translateX(-50%) scale(1); }
#combo-meter.x3 { background: linear-gradient(90deg, #d95d39, #e0a526); }
#combo-meter.x5 { background: linear-gradient(90deg, #c0272d, #d95d39, #e0a526); animation: pulse .6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.08); } }
#view.on-fire .card { box-shadow: 0 0 0 2px #e0a526, 0 0 18px rgba(217,93,57,.45); transition: box-shadow .3s; }
.xp-float.combo.x3, .xp-float.combo.x5 { color: #c0272d; }
.tile.snap { animation: snap .18s ease-out; }
@keyframes snap { from { transform: scale(1.25); } to { transform: scale(1); } }

/* ══════════ Onboarding ══════════ */
.onboard { position: fixed; inset: 0; z-index: 60; background: rgba(27,67,50,.92); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.ob-panel { background: var(--sand); border-radius: 22px; max-width: 460px; width: 100%; padding: 22px 18px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.ob-panel h4 { margin: 14px 0 6px; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: #d8cfb6; }
.ob-dots i.on { background: var(--terracotta); width: 22px; border-radius: 4px; }
.ob-dots i.past { background: var(--cedar); }
.ob-cat { width: 130px; margin: 0 auto; }
.ob-cat .cat { width: 100%; height: auto; }
.ob-cat.wave .cat { animation: hop .6s ease-out 2; }
.ob-cat.happy .cat { animation: dabkeh .6s ease-in-out 3; }
.ob-choices { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip.big { font-size: .95rem; padding: 9px 14px; }
.ob-sounds { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.ob-sound { display: flex; gap: 12px; align-items: center; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; font: inherit; }
.ob-sound.heard { border-color: var(--ok); background: #f1faf4; }
.obs-d { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--terracotta); color: #fff; font: 800 1.6rem Inter, sans-serif; display: grid; place-items: center; }
.ob-sound.heard .obs-d { background: var(--ok); }
.ob-demo { background: #fff; border-radius: 14px; padding: 16px; margin: 12px 0; }
.ob-ranks { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.ob-rank { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.ob-rank.on { border-color: var(--terracotta); background: #fff1ea; }
.ob-rank small { color: var(--muted); }
@media (max-width: 420px) { .diwan-hero { flex-direction: column; text-align: center; } }
/* lessons: leave room under the content for Za3tar */

/* ══════════ Gold checkpoints on the Road (Shorty / Boss) ══════════ */
.rnode.t-shorty.current .rn-btn, .rnode.t-shorty.open .rn-btn, .rnode.t-boss.current .rn-btn, .rnode.t-boss.open .rn-btn { background: linear-gradient(160deg, #f7d774, #e0a526); color: #5a3d00; box-shadow: 0 6px 0 #b07d10; }
.rnode.t-shorty.current .rn-btn, .rnode.t-boss.current .rn-btn { box-shadow: 0 6px 0 #b07d10, 0 0 0 10px rgba(224,165,38,.25); }
.rnode.t-shorty .rn-label, .rnode.t-boss .rn-label { color: #9a6b00; font-weight: 700; }

/* ══════════ 5-Beat Episode ══════════ */
.beat-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 6px 0 12px; }
.beat { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .62rem; color: var(--muted); text-align: center; }
.beat b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #e6dfc8; color: #8a8f98; font-size: .75rem; }
.beat.past b { background: var(--ok); color: #fff; }
.beat.on b { background: var(--terracotta); color: #fff; box-shadow: 0 0 0 4px rgba(217,93,57,.2); }
.beat.on span { color: var(--terracotta); font-weight: 700; }
.ep-setting { margin: 2px 0 0; }
.literal { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 2px; }
.lit { font: 500 .68rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f3efe0; color: #6b6150; border-radius: 6px; padding: 1px 5px; }
.bubble.me .lit { background: rgba(255,255,255,.6); }
.note-ref { color: var(--terracotta); font-weight: 800; font-size: .7rem; cursor: pointer; margin-left: 1px; }
.note-ref:hover { text-decoration: underline; }
.za-notes { display: flex; gap: 12px; align-items: center; }
.za-cat { width: 70px; flex: none; }
.za-cat .cat, .ring-tip-cat .cat { width: 100%; height: auto; }
.za-note { display: flex; gap: 10px; align-items: flex-start; border-top: 1px solid var(--line); padding: 10px 0; }
.za-num { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--terracotta); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: .85rem; }
.za-note p { margin: 2px 0; }
.sub-prog { font-size: .8rem; font-weight: 700; color: var(--terracotta); letter-spacing: .03em; margin: 4px 0; }
.cloze-ctx { color: var(--muted); margin: 6px 0; }
.cloze-line { font-size: 1.1rem; margin: 6px 0; }

/* Character Ring */
.ring-modes { margin: 4px 0 10px; flex-wrap: wrap; }
.flip-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 48px; align-items: center; margin: 8px 0; perspective: 600px; }
.flip-tiles .tile { font-size: 1.15rem; padding: 8px 12px; cursor: default; }
.tile.fused { margin-left: -6px; border-top-left-radius: 2px; border-bottom-left-radius: 2px; }
.tile-flip-anim { animation: morphFlip .45s cubic-bezier(.2,.8,.3,1.2), morphGlow 1s ease-out; transform-origin: center; backface-visibility: hidden; }
@keyframes morphFlip { from { transform: rotateX(90deg); } to { transform: rotateX(0deg); } }
@keyframes morphGlow { 0% { box-shadow: 0 0 0 0 rgba(224,165,38,.9); } 100% { box-shadow: 0 0 0 12px rgba(224,165,38,0); } }
.ring-said { text-align: center; min-height: 60px; }
.ring-circle { position: relative; width: min(100%, 340px); aspect-ratio: 1; margin: 6px auto; border-radius: 50%; background: radial-gradient(circle, #fff7e6 0 38%, transparent 39%), repeating-conic-gradient(#f6efdc 0 10deg, #fbf6e9 10deg 20deg); border: 2px dashed #e4d6ad; }
.ring-person { position: absolute; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; cursor: pointer; padding: 0; font: inherit; }
.ring-person .ring-av { width: 56px; height: 56px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(30,41,59,.2); background: #fff; transition: transform .15s; }
.ring-person.seen .ring-av { border-color: #c9efd8; }
.ring-person.on .ring-av { border-color: var(--terracotta); transform: scale(1.15); box-shadow: 0 0 0 4px rgba(217,93,57,.25); }
.ring-person .rp-label { font-size: .64rem; line-height: 1.15; background: rgba(255,255,255,.9); border-radius: 6px; padding: 1px 4px; text-align: center; }
.ring-av .face { width: 100%; height: 100%; display: block; border-radius: 50%; }
.ring-av.multi { display: flex; overflow: hidden; }
.ring-av.multi .face { width: 50%; height: 100%; border-radius: 0; object-fit: cover; }
.ring-av.multi.three .face { width: 33.4%; }
.ring-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; font-size: 1.8rem; color: var(--muted); }
.ring-center small { font-size: .65rem; }
.ring-tip { display: flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; margin: 8px 0; }
.ring-tip-cat { width: 44px; flex: none; }
.ring-count { margin: 6px 0; }

/* Beat 5 */
.chain-steps { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.chain-step { display: flex; gap: 10px; align-items: center; text-align: left; font: inherit; font-size: 1.05rem; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.chain-step.next { border-color: var(--terracotta); box-shadow: 0 0 0 4px rgba(217,93,57,.15); }
.chain-step.heard { border-color: var(--ok); background: #f1faf4; }
.chain-step.later { opacity: .45; }
.cs-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--sand); display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.reflex-head { display: flex; gap: 12px; align-items: center; }
.reflex-say { margin: 10px 0; }
.reflex-clock { display: flex; gap: 12px; align-items: center; margin: 10px 0; }
.radial-wrap { width: 84px; flex: none; }
.radial-wrap .radial { width: 100%; height: auto; }
.radial-wrap.out .rfg { stroke: var(--bad); }
.aw-en { font-size: 1.15rem; font-style: italic; }

/* ══════════ Chat screens: the dialogue frame fills the view, its thread scrolls, controls stay visible ══════════ */
#view.chat-mode { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 8px; }
#view.chat-mode > * { flex: none; }
#view.chat-mode .chat-fill { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#view.chat-mode .chat-fill > * { flex: none; }
#view.chat-mode .chat-fill > .chat-fill, #view.chat-mode .chat-fill > .chat-frame { flex: 1 1 auto; min-height: 0; }
#view.chat-mode .chat-frame { display: flex; flex-direction: column; min-height: 0; margin: 0; }
#view.chat-mode .chat-frame .wa-thread { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
#view.chat-mode .chat-frame .wa-ctl { flex: none; padding-right: 80px; } /* keep the buttons clear of Za3tar */
#view.chat-mode h2 { font-size: 1.1rem; margin: .2em 0; }
#view.chat-mode .crumb { font-size: .8rem; }

/* ══════════ Workout & mic ══════════ */
.big-listen { font-size: 1.2rem; padding: 18px 22px; margin: 10px 0; }
.big-inp { font-size: 1.15rem; padding: 12px; width: 100%; }
.rule { margin-top: 6px; font-size: .9rem; color: var(--slate); background: #fff8e8; border-radius: 8px; padding: 6px 8px; }
.chain-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chain-row .chain-step { flex: 1; min-width: 0; }
.mic-wrap { display: flex; flex-direction: column; gap: 4px; }
.mic-wrap.big { flex: 1; }
.btn.mic.on { background: var(--bad); color: #fff; animation: pulse-mic 1s ease-in-out infinite; }
@keyframes pulse-mic { 50% { box-shadow: 0 0 0 8px rgba(192,57,43,.2); } }
.mic-score { font-weight: 700; border-radius: 10px; padding: 4px 8px; display: inline-block; }
.mic-score.great { background: #e3f4ea; color: var(--ok); }
.mic-score.close { background: #fff3d6; color: #9a6b00; }
.mic-score.again { background: #fbe5e2; color: var(--bad); }
.mic-words { font-family: Cairo, 'Noto Sans Arabic', sans-serif; font-size: 1.05rem; }
.mic-words .hit { color: var(--ok); font-weight: 700; }
.mic-words .miss { color: var(--muted); }
.radial-wrap.listening .rfg { stroke: var(--azure); }

/* mic: one fixed-height result line, so nothing around it moves */
.mic-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chain-row .mic-wrap { flex: 0 0 auto; width: 46%; }
.mic-result { height: 1.5em; line-height: 1.5em; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.mic-result b { font-weight: 700; }
.mic-result.great b { color: var(--ok); }
.mic-result.close b { color: #9a6b00; }
.mic-result.again, .mic-result.again b { color: var(--bad); }
.mic-result.listening { color: var(--azure); }
.mic-result .heard { font-family: Cairo, 'Noto Sans Arabic', sans-serif; }
.reflex-clock .mic-wrap.big { flex: 1; }
.how-to { margin: 4px 0 10px; padding-left: 20px; color: var(--muted); }
.how-to li { margin: 2px 0; }

/* one pronunciation-feedback row between header and content (in the layout: never covers anything) */
.mic-bar { display: none; flex: none; padding: 6px max(12px, calc((100% - 820px) / 2)); background: #fff; border-bottom: 3px solid var(--line); height: 68px; overflow: hidden; box-sizing: border-box; } /* fixed height: idle, listening and results never resize it */
.mic-bar.show { display: flex; align-items: center; }
.mic-bar .mb-body { flex: 1; min-width: 0; }
.mic-bar .mb-main { font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mic-bar .mb-line { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mic-bar .mb-line span { font-family: Cairo, 'Noto Sans Arabic', sans-serif; }
.mic-bar.idle .mb-main { font-weight: 600; color: var(--muted); }
.mic-bar.listening { border-color: var(--azure); } .mic-bar.listening .mb-main { color: var(--azure); }
.mic-bar.great { border-color: var(--ok); } .mic-bar.great .mb-main { color: var(--ok); }
.mic-bar.close { border-color: #e0a526; } .mic-bar.close .mb-main { color: #9a6b00; }
.mic-bar.again { border-color: var(--bad); } .mic-bar.again .mb-main { color: var(--bad); }
.chain-row .mic-wrap { width: auto; }

/* ══════════ V3.8: header (no bottom tab bar) ══════════ */
#hdr { gap: 8px; padding: 8px 12px; }
.brand { display: flex; flex-direction: column; color: #fff; line-height: 1.1; min-width: 0; }
.brand-title { font: 800 1.05rem Cairo, Inter, sans-serif; white-space: nowrap; }
.brand-title .logo-ar { font-size: .95rem; color: #ffd9c9; }
.brand-sub { display: inline-block; margin-top: 3px; font-size: .62rem; font-weight: 700; letter-spacing: .03em; background: rgba(255,255,255,.14); color: #e9f5ee; border-radius: 999px; padding: 1px 7px; white-space: nowrap; align-self: flex-start; }
.hdr-right { display: flex; align-items: center; gap: 6px; flex: none; }
.hdr-btn { position: relative; display: inline-flex; align-items: center; gap: 2px; color: #fff; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); padding: 5px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: box-shadow .15s, background .15s; }
.hdr-btn:hover, .hdr-btn:focus-visible { background: rgba(255,255,255,.24); box-shadow: 0 0 0 3px rgba(255,217,201,.35); }
.hdr-btn.rank { background: #fff3c9; color: var(--cedar); border-color: #ffe08a; }
.hdr-btn .badge { top: -6px; right: -6px; }
.stat .goal-n { margin-left: 3px; }
@media (max-width: 480px) { .hb-label, .stat .goal-n, .brand-title .logo-ar { display: none; } .brand-sub { font-size: .58rem; } }
.back-link { display: inline-block; margin: 2px 0 6px; font-weight: 700; }
.khatt-head h2 { margin-bottom: 0; }
.khatt-head .kh-dash { font-size: .8em; color: var(--muted); font-weight: 600; }
.mascot { bottom: 16px; }
.mascot-bubble { bottom: 96px; }

/* ══════════ Exercise frame: kicker / hero / body / action dock ══════════ */
.card.exercise { padding: 0; overflow: visible; }
.card.exercise > .test-bar, .card.exercise > .ex-kicker, .card.exercise > .ex-hero, .card.exercise > .ex-body { margin-left: 16px; margin-right: 16px; }
.ex-kicker { padding-top: 14px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ex-hero { margin-top: 6px; margin-bottom: 12px; padding: 14px 16px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; font-size: 22px; font-weight: 800; color: #0F172A; line-height: 1.3; }
.ex-hero .hero-ctx { font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.ex-hero .hero-en { font-size: .9rem; font-weight: 500; color: var(--muted); margin-top: 4px; }
.ex-hero .big-listen { font-size: 1.1rem; margin: 0; }
.ex-hero .reflex-say { font-size: 1rem; font-weight: 600; }
.ex-body { padding-bottom: 14px; }
.ex-body .opts { margin-top: 0; }
.opts.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.exercise-action-dock { position: sticky; bottom: 0; z-index: 6; min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; background: #fff; border-top: 2px solid var(--line); border-radius: 0 0 16px 16px; transition: background-color .2s ease, border-color .2s ease; }
.exercise-action-dock.is-correct { background: #ECFDF5; border-top-color: #10B981; }
.exercise-action-dock.is-wrong { background: #FEF2F2; border-top-color: #F87171; }
.dock-msg { flex: 1; min-width: 0; font-size: .9rem; color: var(--muted); }
.is-correct .dock-msg b { color: #047857; } .is-wrong .dock-msg b { color: #B91C1C; }
.dock-why { font-size: .82rem; color: var(--slate); margin-top: 2px; max-height: 3.9em; overflow: auto; }
.dock-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.dock-btn { min-width: 132px; }
.legend-wrap { position: relative; }
.legend-q { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; padding: 0; line-height: 16px; }
.legend-pop { position: absolute; top: 22px; left: 0; z-index: 8; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 6px 16px rgba(30,41,59,.15); width: 240px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.legend-pop .legend { flex-wrap: wrap; }

/* test-mode jumpers */
.test-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 10px; padding: 6px 8px; border: 1px dashed #a78bfa; background: #f5f3ff; border-radius: 10px; font-size: .75rem; font-weight: 700; color: #6d28d9; }
.test-bar button { border: 1px solid #c4b5fd; background: #fff; border-radius: 6px; padding: 2px 7px; font: inherit; cursor: pointer; color: #5b21b6; }
.test-bar button.on { background: #7c3aed; color: #fff; }
.beat-bar.jump .beat { cursor: pointer; border: 0; background: none; font: inherit; padding: 0; }
.beat-bar.jump .beat:hover b { box-shadow: 0 0 0 3px rgba(124,58,237,.3); }

/* ══════════ Grammar tips vs Word X-Ray ══════════ */
.grammar-tip-pill { display: inline-block; vertical-align: middle; margin: 0 2px; border: 0; cursor: pointer; background: linear-gradient(135deg, #F59E0B, #D97706); color: #FFF; font-weight: 800; font-size: 11px; padding: 2px 8px; border-radius: 999px; box-shadow: 0 2px 6px rgba(217,119,6,.35); line-height: 1.5; }
.grammar-tip-pill:hover { filter: brightness(1.08); }
.xray-hint { font-size: .75rem; color: var(--muted); background: rgba(255,255,255,.6); border-radius: 999px; padding: 2px 10px; align-self: flex-start; margin: 2px 0 6px; }
.chat .w { text-decoration: none; border-radius: 6px; padding: 0 2px; transition: background .15s; cursor: pointer; }
.chat .w:hover, .chat .w:focus { background: rgba(0,119,182,.12); }
.spotlight { flex: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin: 6px 0; padding: 8px; border: 2px solid #F59E0B; border-radius: 12px; background: #FFFBEB; max-height: 140px; overflow-y: auto; }
.spot-empty { font-size: .8rem; color: #92400E; }
.spot-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid #FCD34D; background: #fff; border-radius: 999px; padding: 3px 10px 3px 4px; font: inherit; font-size: .8rem; cursor: pointer; color: #78350F; }
.spot-chip::first-letter { }
.spot-chip.on { background: #F59E0B; color: #fff; border-color: #D97706; }
.spot-chip span { font-weight: 600; }
.spot-text { flex-basis: 100%; font-size: .85rem; color: #451a03; }
.spot-text p { margin: 2px 0; }
.pulse { animation: tipPulse .8s ease-out; }
@keyframes tipPulse { from { box-shadow: 0 0 0 0 rgba(245,158,11,.6); } to { box-shadow: 0 0 0 12px rgba(245,158,11,0); } }
.sheet.xray .sheet-head { align-items: center; }
.xray-badge { background: #0F172A; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; }
.xray-word { display: flex; gap: 12px; align-items: center; margin: 10px 0; }
.xw-chat { font-size: 1.4rem; font-weight: 800; }
.xw-ar { font-size: 1.3rem; }

/* ══════════ Pattern Stage / Call & Response ══════════ */
.ring-title { font-weight: 700; color: var(--slate); }
.living-sentence { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 10px; margin: 8px 0; text-align: center; }
.tile.still { opacity: .95; }
.ring-diff { min-height: 1.6em; font-size: .85rem; color: var(--slate); margin-top: 6px; }
.ring-diff .d-from { color: var(--bad); } .ring-diff .d-to { color: var(--ok); }
.ring-groups { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
.rg { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 2px solid; }
.rg.grp-speak { border-color: #e0a526; color: #8a5a00; } .rg.grp-to { border-color: var(--azure); color: #005484; } .rg.grp-about { border-color: #7b3f61; color: #7b3f61; }
.ring-person.grp-speak .ring-av { border-color: #f3d27a; } .ring-person.grp-to .ring-av { border-color: #9fd0ec; } .ring-person.grp-about .ring-av { border-color: #d8b4c8; }
.ring-person.on .ring-av { border-color: var(--terracotta); }
.cr-line { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cr-tag { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cr-arrow { font-size: 1.3rem; color: var(--terracotta); margin: 2px 0; }
/* fixed dock height: the button keeps exactly the same coordinates whatever the feedback says */
.exercise-action-dock { height: 96px; min-height: 96px; box-sizing: border-box; }
.exercise-action-dock .dock-msg { max-height: 68px; overflow-y: auto; }
.exercise-action-dock .dock-why { max-height: none; }
/* exercise screens: the bottom belongs to the action dock, so Za3tar moves to the top right (still reacting) */

/* ══════════ V3.9 polish ══════════ */
/* the dock sits at the end of its card (after the content), not floating mid-screen */
.exercise-action-dock { position: static; }
.exercise-action-dock.is-great { background: #ECFDF5; border-top-color: #10B981; }
.exercise-action-dock.is-close { background: #FFFBEB; border-top-color: #F59E0B; }
.exercise-action-dock.is-again { background: #FEF2F2; border-top-color: #F87171; }
.exercise-action-dock.is-info { background: #EFF6FF; border-top-color: #60A5FA; }
.is-great .dock-msg b { color: #047857; } .is-close .dock-msg b { color: #92400E; } .is-again .dock-msg b { color: #B91C1C; } .is-info .dock-msg b { color: #1D4ED8; }
.dock-msg.flash { animation: dockIn .28s ease-out; }
@keyframes dockIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dock-why .heard { font-family: Cairo, 'Noto Sans Arabic', sans-serif; }
@media (prefers-reduced-motion: reduce) { .dock-msg.flash { animation: none; } }
/* two CTAs side by side always get a gap */
.wa-ctl, .toolbar, .dock-actions, .stage-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn + .btn { margin-left: 0; }
/* header */
.brand-title .logo-ar { margin-left: 8px; }
/* cloze as a mini dialogue */
.ex-hero.hero-chat { background: #e7dfc9; padding: 10px; font-size: 1rem; }
.ex-hero.hero-chat .hero-line { font-size: 1.25rem; font-weight: 800; color: #0F172A; }
.ex-hero.hero-chat .bub-row { margin: 4px 0; }
.ex-hero .hero-ctx { font-weight: 700; }
/* tips beside the bubble */
.tip-col { display: flex; flex-direction: column; gap: 4px; align-self: center; flex: none; }
.tip-col .grammar-tip-pill { font-size: 12px; padding: 3px 8px; }
.za-num { font-size: .85rem; }
/* Pattern Stage: vertical person bar + Living Sentence beside it */
.stage-grid { display: grid; grid-template-columns: 116px 1fr; gap: 10px; align-items: start; margin-top: 8px; }
.ring-bar { display: flex; flex-direction: column; gap: 6px; }
.rb-group { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 4px; }
.rb-group.grp-speak { color: #8a5a00; } .rb-group.grp-to { color: #005484; } .rb-group.grp-about { color: #7b3f61; }
.ring-bar .ring-person { position: static; width: auto; flex-direction: row; gap: 6px; align-items: center; text-align: left; padding: 4px 6px 4px 4px; border-radius: 12px; background: #fff; border: 2px solid var(--line); }
.ring-bar .ring-person .ring-av { width: 36px; height: 36px; flex: none; border-width: 2px; box-shadow: none; }
.ring-bar .ring-person .rp-label { font-size: .7rem; background: none; padding: 0; text-align: left; }
.ring-bar .ring-person.grp-speak { border-color: #f3d27a; } .ring-bar .ring-person.grp-to { border-color: #9fd0ec; } .ring-bar .ring-person.grp-about { border-color: #d8b4c8; }
.ring-bar .ring-person.seen { background: #f6fbf8; }
.ring-bar .ring-person.on { border-color: var(--terracotta); background: #fff1ea; box-shadow: 0 0 0 3px rgba(217,93,57,.18); }
.stage-main { position: sticky; top: 0; min-width: 0; }
.stage-main .living-sentence { margin-top: 0; }
.stage-main .ring-said .tx.big { font-size: 1.15rem; }
@media (max-width: 360px) { .stage-grid { grid-template-columns: 96px 1fr; } }

/* any two buttons in a row get a gap; flex containers already use gap */
.btn + .btn { margin-left: 8px; }
.toolbar > .btn + .btn, .wa-ctl > .btn + .btn, .dock-actions > .btn + .btn, .dock-side > .btn + .btn, .opts > .btn + .btn, .stage-foot > .btn + .btn, .finish-actions > .btn + .btn { margin-left: 0; }
.finish-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

/* Pattern Stage: horizontal person strip on phones, vertical bar from 600px up */
@media (max-width: 599px) {
  .stage-grid { grid-template-columns: 1fr; }
  .ring-bar { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .ring-bar .rb-group { display: none; }
  .ring-bar .ring-person { flex: 0 0 auto; flex-direction: column; gap: 2px; padding: 6px 8px; min-width: 76px; scroll-snap-align: start; text-align: center; }
  .ring-bar .ring-person .rp-label { text-align: center; white-space: nowrap; }
  .stage-main { position: static; }
}
.stage-card .ex-hero { font-size: 18px; }
.to-whom { font-size: .8rem; color: var(--muted); font-weight: 600; }
.to-whom b { color: var(--terracotta); }
.hero-setup { font-size: 1.05rem; font-weight: 800; color: #0F172A; }
.warmup-tag { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Shared dock under chat threads (stories, episode scenes): same bar as the exercise cards */
.dock-side { display: flex; gap: 8px; align-items: center; }
.dock-side:empty { display: none; }
.wa-ctl.docked { display: block; margin-top: 8px; }
#view.chat-mode .chat-frame .wa-ctl.docked { padding-right: 0; }
.wa-ctl.docked .exercise-action-dock { border-radius: 12px; border: 1px solid var(--line); border-top-width: 2px; }
.wa-ask:empty { display: none; }
.wa-ask .opts { margin: 6px 0 8px; }
.ex-q { margin: 4px 0 10px; font-weight: 600; }
.ant-stage { min-height: 60px; }
.ant-stage .inp { width: 100%; margin-top: 8px; }
.exercise .hands { float: none; display: flex; justify-content: flex-end; gap: 4px; margin: -4px 0 6px; font-size: .8rem; color: var(--muted); }
@media (max-width: 480px) {
  .exercise-action-dock { padding: 12px; gap: 10px; }
  .exercise-action-dock .dock-msg:empty { display: none; }
  .exercise-action-dock .dock-actions { margin-left: auto; }
}

/* Za3tar: same size and place on every screen (bottom right). The content always keeps room below it, so the
   cat never sits on top of a button: #view has 90px of bottom padding, chat screens reserve the same on phones. */
.mascot { right: 12px; bottom: 12px; width: 74px; height: 74px; }
.mascot-bubble { right: 92px; bottom: 70px; }
@media (min-width: 760px) { .mascot { right: 32px; bottom: 16px; } .mascot-bubble { right: 114px; bottom: 74px; } }
#view.chat-mode { padding-bottom: 92px; }
@media (min-width: 1040px) { #view.chat-mode { padding-bottom: 16px; } } /* wide: the cat sits in the side margin */

/* Speaking prompts as a chat: their line, then your (empty or English) bubble */
.reflex-chat { display: flex; flex-direction: column; gap: 8px; }
.reflex-lead { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 800; color: #0F172A; }
.reflex-setup:empty { display: none; }
.reflex-setup { font-size: .85rem; color: var(--muted); font-weight: 600; }
.reflex-chat .bub-row { margin: 0; }
.bubble.mine { border: 2px dashed #9fd0ec; background: #f5fbff; min-width: 140px; }
.bubble.mine.filled { border-style: solid; border-color: #10B981; background: #ECFDF5; }
.bubble.mine .mine-text { font-size: 1.15rem; font-weight: 700; }
.bubble.mine .mine-en { color: #0F172A; }
.ex-hero .reflex-chat .bubble { font-size: 1rem; }
.reflex-opts { margin-top: 6px; }
.link-btn { background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-weight: 700; color: #0369a1; text-decoration: underline; cursor: pointer; }
.chain-step.heard .cs-n { color: #047857; }
/* phones: a dock with two buttons stacks (message on top, buttons right-aligned underneath) */
@media (max-width: 480px) {
  .exercise-action-dock:has(.dock-side:not(:empty)) { flex-wrap: wrap; height: auto; min-height: 96px; row-gap: 8px; }
  .exercise-action-dock:has(.dock-side:not(:empty)) .dock-msg { flex: 1 1 100%; max-height: none; }
}
/* keyboard: the focused answer is obvious */
.btn.opt:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }

/* Typing helper: chat digits one tap away */
.arabizi-input .inp { width: 100%; }
.digit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.digit-chip { font: inherit; font-size: .8rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; min-height: 30px; cursor: pointer; color: var(--muted); }
.digit-chip b { color: var(--slate); }
.digit-chip:active { transform: scale(.95); }
/* Context pills: who is talking / to whom */
.en-ctx { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ctx-pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .01em; padding: 3px 9px; border-radius: 999px; background: #e0f2fe; color: #075985; white-space: nowrap; vertical-align: middle; }
.ex-hero .ctx-pill { font-size: .78rem; }
.exercise-action-dock .mic-words { display: flex; flex-wrap: wrap; gap: 2px 8px; font-family: inherit; font-size: .95rem; margin-top: 2px; }
.mic-words .miss { color: #B91C1C; text-decoration: underline wavy rgba(185,28,28,.4); }
.show-choices { display: block; margin: 8px auto 0; font-size: .9rem; }
.reflex-opts[hidden], .show-choices[hidden] { display: none; }
.quests-box { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.quests-box summary { cursor: pointer; font-weight: 700; font-size: .9rem; list-style: none; }
.quests-box summary::-webkit-details-marker { display: none; }
.quests-box summary::after { content: ' ▾'; color: var(--muted); }
.quests-box:not([open]) summary::after { content: ' ▸'; }

/* Side trips (YL.DETOURS) */
.detours { display: grid; gap: 8px; }
.detour-card { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 2px dashed #e0a526; border-radius: 12px; background: #fffbeb; color: inherit; text-decoration: none; }
.detour-card b { color: var(--slate); }
.detour-card.locked { opacity: .65; border-color: var(--line); background: #f8fafc; }
.dc-ic { font-size: 1.4rem; }
.road-detour { margin: 8px 0 14px; }
.rd-tag { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .04em; color: #92400E; margin-bottom: 4px; text-transform: uppercase; }
