/* قدرات — تصميم نظيف حديث، الجوال أولًا */
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2190-22FF; }
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2190-22FF; }

:root {
  --bg: #faf9ff;
  --bg2: #f3f0ff;
  --surface: #ffffff;
  --text: #17142b;
  --muted: #6b6785;
  --line: #e7e3f5;
  --a1: #7c3aed;
  --a2: #ec4899;
  --accent: #6d28d9;
  --accent-soft: #ede9fe;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --bad: #e11d48;
  --bad-soft: #ffe4e6;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgb(23 20 43 / 4%), 0 8px 24px rgb(23 20 43 / 6%);
  --radius: 20px;
  --tabbar: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c0a14; --bg2: #141022; --surface: #17132a; --text: #f3f1ff; --muted: #a29dbd; --line: #2a2445;
    --accent: #a78bfa; --accent-soft: #261d45; --ok: #4ade80; --ok-soft: #12301f; --bad: #fb7185; --bad-soft: #3a1420; --warn-soft: #33270c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 28px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0c0a14; --bg2: #141022; --surface: #17132a; --text: #f3f1ff; --muted: #a29dbd; --line: #2a2445;
  --accent: #a78bfa; --accent-soft: #261d45; --ok: #4ade80; --ok-soft: #12301f; --bad: #fb7185; --bad-soft: #3a1420; --warn-soft: #33270c;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 28px rgb(0 0 0 / 35%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 17px/1.75 'Plex Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--a1); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.skip { position: absolute; inset-inline-start: -999px; }
.skip:focus { inset-inline-start: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 10px; }
.grad { background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== الشريط العلوي والتنقل ===== */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.15rem; }
.brand img { border-radius: 9px; }
.chip { display: flex; gap: 6px; }
.chip-item { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.chip-level { background: linear-gradient(90deg, var(--a1), var(--a2)); color: #fff; border: 0; }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 500; }
.tab-icon { font-size: 1.35rem; line-height: 1; filter: grayscale(1); opacity: .7; transition: transform .2s; }
.tab.active { color: var(--accent); font-weight: 700; }
.tab.active .tab-icon { filter: none; opacity: 1; transform: translateY(-2px) scale(1.1); }
body[data-route='quiz'] .tabbar, body[data-route='welcome'] .tabbar, body[data-route='welcome'] .chip { display: none; }
body[data-route='quiz'], body[data-route='welcome'] { padding-bottom: env(safe-area-inset-bottom); }
body[data-route='quiz'] .topbar { display: none; }

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-inline-start: 232px; }
  .tabbar { inset-inline: 0 auto; inset-inline-start: 0; top: 0; bottom: 0; width: 232px; height: auto; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 84px 14px 14px; border-top: 0; border-inline-end: 1px solid var(--line); }
  .tab { flex: 0; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 14px; border-radius: 14px; font-size: .98rem; }
  .tab.active { background: var(--accent-soft); }
  .topbar { position: fixed; inset-inline-start: 0; width: 232px; z-index: 31; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; flex-direction: column; align-items: flex-start; gap: 10px; }
  .chip { position: fixed; top: 16px; inset-inline-end: 24px; }
  body[data-route='quiz'] { padding-inline-start: 0; }
}

/* ===== الصفحة ===== */
main { outline: none; }
.page { max-width: 760px; margin: 0 auto; padding: 8px 16px 32px; animation: fade .3s ease; }
@media (min-width: 900px) { .page { padding-top: 32px; } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.enter { animation: pop .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.page-head { margin: 8px 0 20px; }
.display { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 700; margin: 0 0 4px; }
.display-sm { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 700; }
.kicker { color: var(--muted); font-weight: 500; margin: 0; }
.lead { font-size: 1.08rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.stack > * + * { margin-top: 10px; }
.boot { min-height: 60vh; display: grid; place-items: center; }
.boot-dot { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--a1), var(--a2)); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { transform: scale(.7); opacity: .5; } }
.back { display: inline-block; margin: 6px 0 12px; color: var(--muted); font-weight: 500; }
.pill { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.bar { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--a1), var(--a2)); border-radius: inherit; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar.thin { height: 6px; max-width: 120px; }
.mini-bar { height: 4px; width: 100%; background: var(--bg2); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--a1), var(--a2)); }
.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; }

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px;
  padding: 12px 20px; font-weight: 700; font-size: 1rem; text-align: center; transition: transform .08s, box-shadow .08s, filter .2s; user-select: none;
}
.btn:active { transform: translateY(3px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; box-shadow: 0 4px 0 #5b21b6, 0 10px 24px rgb(124 58 237 / 25%); }
.btn-primary:active { box-shadow: 0 1px 0 #5b21b6; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); color: var(--text); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn-ghost:active { box-shadow: none; }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-lg { padding: 15px 24px; font-size: 1.08rem; border-radius: 18px; }
.btn-sm { padding: 7px 14px; font-size: .9rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--muted); font-size: 1.2rem; background: transparent; border: 0; }
.icon-btn:hover { background: var(--bg2); }

/* ===== الترحيب ===== */
.welcome { min-height: 90dvh; display: grid; place-items: center; }
.welcome-card { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.welcome-hero { font-size: 4.5rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-4deg); } }
.label { font-weight: 700; text-align: start; margin-top: 10px; }
.input { width: 100%; font: inherit; font-size: 1.1rem; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); color: var(--text); }
.input:focus { border-color: var(--a1); outline: none; }
.goal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.goal { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); transition: .15s; }
.goal small { color: var(--muted); font-size: .72rem; line-height: 1.4; }
.goal-icon { font-size: 1.6rem; }
.goal.selected { border-color: var(--a1); background: var(--accent-soft); transform: translateY(-2px); }

/* ===== الرئيسية ===== */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 8px 0 18px; }
.hero-text { min-width: 0; }
.goal-ring { position: relative; width: 88px; height: 88px; flex: none; color: var(--text); }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--bg2); }
.ring-fg { stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.goal-ring-text { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 28px; }
.goal-ring-text strong { font-size: 1.3rem; }
.goal-ring-text small { color: var(--muted); font-size: .75rem; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stats-row.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .stats-row.four { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; align-items: center; text-align: center; box-shadow: var(--shadow); }
.stat strong { font-size: 1.35rem; line-height: 1.2; }
.stat small { color: var(--muted); font-size: .78rem; }
.stat-icon { font-size: 1.3rem; }
.continue {
  display: flex; align-items: center; gap: 14px; padding: 18px; margin-bottom: 16px; border-radius: 24px; color: #fff;
  background: linear-gradient(135deg, var(--c, var(--a1)), color-mix(in srgb, var(--c, var(--a1)) 55%, var(--a2)));
  box-shadow: 0 5px 0 color-mix(in srgb, var(--c, var(--a1)) 70%, #000), 0 16px 32px color-mix(in srgb, var(--c, var(--a1)) 30%, transparent);
  transition: transform .1s;
}
.continue:active { transform: translateY(3px); }
.continue.done { --c: #ca8a04; }
.continue-icon { width: 56px; height: 56px; flex: none; display: grid; place-items: center; font-size: 1.8rem; border-radius: 18px; background: rgb(255 255 255 / 20%); }
.continue-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.continue-body small { opacity: .85; font-size: .82rem; }
.continue-body strong { font-size: 1.2rem; line-height: 1.4; }
.continue-body .muted { color: rgb(255 255 255 / 80%); font-size: .85rem; }
.continue-go { font-size: 1.6rem; font-weight: 700; }
.bento { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); text-align: start; transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile small { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.tile-icon { font-size: 1.7rem; margin-bottom: 4px; }
.tile-speed { background: linear-gradient(160deg, color-mix(in srgb, #f97316 14%, var(--surface)), var(--surface)); }
.tile-exam { background: linear-gradient(160deg, color-mix(in srgb, #0891b2 14%, var(--surface)), var(--surface)); }
.tile-mistakes { background: linear-gradient(160deg, color-mix(in srgb, #e11d48 12%, var(--surface)), var(--surface)); }
.tile-path { background: linear-gradient(160deg, color-mix(in srgb, #7c3aed 14%, var(--surface)), var(--surface)); }
.tile-fact, .tile-install { grid-column: 1 / -1; }
.tile-fact { background: linear-gradient(160deg, var(--warn-soft), var(--surface)); }
.tile-fact p { margin: 4px 0 0; color: var(--text); font-size: .95rem; }
.tile-install { border: 2px dashed var(--a1); }
@media (min-width: 700px) { .bento { grid-template-columns: repeat(4, 1fr); } }

/* ===== شجرة المنهج ===== */
.tree, .nodes { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.stage.locked { opacity: .6; }
.stage-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.stage-badge { width: 52px; height: 52px; flex: none; display: grid; place-items: center; font-size: 1.6rem; border-radius: 16px; background: color-mix(in srgb, var(--c) 15%, var(--surface)); }
.stage.passed .stage-badge { box-shadow: 0 0 0 3px var(--c); }
.stage-info { flex: 1; min-width: 0; }
.stage-info small { color: var(--c); font-weight: 700; font-size: .78rem; }
.stage-info h2 { margin: 0; font-size: 1.15rem; }
.stage-info p { margin: 0; font-size: .88rem; }
.nodes { position: relative; padding-inline-start: 26px; }
.nodes::before { content: ''; position: absolute; inset-inline-start: 17px; top: 18px; bottom: 18px; width: 3px; background: var(--line); border-radius: 3px; }
.node { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; color: var(--text); margin-inline-start: -26px; }
.node:hover { background: var(--bg2); }
.node-dot { position: relative; z-index: 1; width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: .95rem; background: var(--surface); border: 3px solid var(--line); color: var(--muted); }
.node.open .node-dot { border-color: var(--c); color: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 18%, transparent); animation: glow 2s infinite; }
.node.done .node-dot { background: var(--c); border-color: var(--c); color: #fff; }
.node.locked { color: var(--muted); cursor: not-allowed; }
.node.locked .node-dot { font-size: .8rem; }
.node-title { flex: 1; font-weight: 500; }
.node-meta { color: var(--muted); font-size: .8rem; }
.node-test .node-title { font-weight: 700; }
@keyframes glow { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--c) 8%, transparent); } }

/* ===== الدرس ===== */
.lesson-head { margin-bottom: 18px; }
.chip-stage { display: inline-block; font-size: .82rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--c); margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .9rem; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { position: relative; padding-inline-start: 30px; margin-bottom: 6px; }
.checks li::before { content: '✓'; position: absolute; inset-inline-start: 0; top: 2px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: .75rem; font-weight: 700; }
.prose h2 { display: flex; align-items: center; gap: 10px; }
.num { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--c); font-size: .9rem; }
.prose ul, .prose ol, .card ul { padding-inline-start: 1.3em; margin: 0 0 .75em; }
.prose li { margin-bottom: .3em; }
.prose strong, .prose b { color: var(--c, var(--accent)); }
.prose table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: start; }
.prose th { background: var(--bg2); }
.prose code, .ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.prose code { background: var(--bg2); padding: 0 6px; border-radius: 6px; font-family: inherit; }
.examples > h2, .videos > h2 { margin: 22px 0 10px; }
.example { padding: 0; overflow: hidden; }
.example summary { list-style: none; cursor: pointer; padding: 16px 20px; display: flex; gap: 10px; align-items: flex-start; }
.example summary::-webkit-details-marker { display: none; }
.example summary::after { content: '＋'; margin-inline-start: auto; color: var(--muted); font-weight: 700; }
.example[open] summary::after { content: '－'; }
.example .prose { padding: 0 20px 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.ex-tag { flex: none; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-top: 3px; }
.ex-q { font-weight: 500; }
.two-col { display: grid; gap: 14px; margin-top: 8px; }
@media (min-width: 700px) { .two-col { grid-template-columns: 1fr 1fr; } .two-col .card { margin: 0; } }
.tips { background: linear-gradient(160deg, var(--ok-soft), var(--surface) 60%); }
.warn { background: linear-gradient(160deg, var(--bad-soft), var(--surface) 60%); }
.fact { background: linear-gradient(160deg, var(--warn-soft), var(--surface) 70%); margin-top: 14px; }
.sources { margin: 18px 0; font-size: .9rem; }
.sources ul { padding-inline-start: 1.2em; }
.video-card { margin: 0 0 14px; }
.video { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; border-radius: 18px; overflow: hidden; background: #000; }
.video img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.video iframe { width: 100%; height: 100%; border: 0; }
.video-play { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: rgb(255 255 255 / 92%); color: #e11d48; font-size: 1.8rem; padding-inline-start: 6px; box-shadow: 0 8px 30px rgb(0 0 0 / 40%); transition: transform .2s; }
.video:hover .video-play { transform: scale(1.08); }
.video-card figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 8px 4px 0; font-size: .9rem; }
.video-search { display: block; font-weight: 700; color: var(--accent); }
.sticky-cta { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 10px); display: flex; gap: 10px; margin-top: 18px; z-index: 5; }
.sticky-cta .btn-ghost { flex: none; }
@media (min-width: 900px) { .sticky-cta { bottom: 16px; } }

/* ===== الأسئلة ===== */
.quiz { max-width: 680px; padding-top: calc(8px + env(safe-area-inset-top)); }
.quiz-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 0; background: var(--bg); }
.top-title { flex: 1; }
.combo { min-width: 52px; text-align: center; font-weight: 700; font-size: .95rem; color: var(--muted); }
.combo.hot { color: #f97316; animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.25); } }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 4px 12px; border-radius: 999px; background: var(--bg2); }
.timer.big { font-size: 1.4rem; flex: 1; text-align: center; background: none; }
.timer.low { color: var(--bad); background: var(--bad-soft); animation: bump .5s infinite; }
.q-card { padding: 8px 0; }
.q-label { color: var(--muted); font-weight: 500; font-size: .85rem; }
.q-prompt { font-size: clamp(1.2rem, 4.5vw, 1.45rem); font-weight: 700; line-height: 1.7; margin: 8px 0 18px; }
.passage { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin: 10px 0; font-size: .98rem; }
.passage summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.passage p { margin: 8px 0 0; max-height: 40vh; overflow-y: auto; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 18px; }
.compare .col { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line); text-align: center; }
.compare small { color: var(--muted); font-weight: 700; }
.compare strong { font-size: 1.35rem; }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; padding: 14px 16px; border-radius: 18px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); font-size: 1.08rem; font-weight: 500;
  transition: transform .08s, box-shadow .08s, border-color .15s, background .15s;
}
.choice:hover { border-color: color-mix(in srgb, var(--a1) 40%, var(--line)); }
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.choice[disabled] { cursor: default; }
.letter { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 2px solid var(--line); font-weight: 700; font-size: .9rem; color: var(--muted); }
.choice-text { flex: 1; }
.choice.selected { border-color: var(--a1); background: var(--accent-soft); box-shadow: 0 4px 0 var(--a1); }
.choice.selected .letter { background: var(--a1); border-color: var(--a1); color: #fff; }
.choice.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 4px 0 var(--ok); animation: bump .3s; }
.choice.right .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 4px 0 var(--bad); animation: shake .35s; }
.choice.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
@keyframes shake { 25% { transform: translateX(6px); } 75% { transform: translateX(-6px); } }
.feedback { display: none; margin-top: 16px; padding: 18px; border-radius: 22px; }
.feedback.show { display: block; animation: pop .3s; }
.feedback.is-ok { background: var(--ok-soft); }
.feedback.is-bad { background: var(--bad-soft); }
.fb-head { font-size: 1.15rem; margin-bottom: 6px; }
.is-ok .fb-head { color: var(--ok); }
.is-bad .fb-head { color: var(--bad); }
.xp-pop { font-size: .9rem; color: #f59e0b; }
.fb-exp { white-space: pre-line; color: var(--text); }
.test-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.test-nav .btn { flex: 1; }
.qmap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; justify-content: center; }
.qdot { width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-size: .85rem; font-weight: 700; color: var(--muted); }
.qdot.filled { background: var(--accent-soft); border-color: var(--a1); color: var(--accent); }
.qdot.current { outline: 3px solid var(--a2); outline-offset: 1px; }
.intro { text-align: center; padding: 20px 0; }
.intro .back { display: block; text-align: start; }
.intro-list { list-style: none; padding: 0; margin: 16px auto 22px; display: grid; gap: 8px; max-width: 340px; text-align: start; }
.intro-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.result { text-align: center; padding: 24px 0 8px; }
.result-emoji { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.result-pct { font-size: 3.4rem; font-weight: 700; line-height: 1.1; background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.stars { font-size: 2.2rem; letter-spacing: 4px; color: var(--line); }
.stars .on { color: #f59e0b; display: inline-block; animation: pop .4s backwards; }
.stars .on:nth-child(2) { animation-delay: .12s; }
.stars .on:nth-child(3) { animation-delay: .24s; }
.split { display: flex; justify-content: center; gap: 12px; margin: 10px 0; }
.split > div { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 22px; display: flex; flex-direction: column; }
.split strong { font-size: 1.4rem; }
.review { margin-top: 28px; text-align: start; }
.review-item { padding: 0; overflow: hidden; }
.review-item > *:not(summary) { margin-inline: 18px; }
.review-item > :last-child { margin-bottom: 16px; }
.review-item summary { cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item .q-prompt { font-size: 1.05rem; margin: 4px 0 10px; }
.review-item .compare strong { font-size: 1.1rem; }
.rv-mark { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: .85rem; color: #fff; }
.is-ok .rv-mark { background: var(--ok); }
.is-bad .rv-mark { background: var(--bad); }
.clip { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== الإنجاز ===== */
.level-card { display: flex; align-items: center; gap: 16px; }
.level-num { width: 64px; height: 64px; flex: none; display: grid; place-items: center; border-radius: 20px; background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; font-size: 1.8rem; font-weight: 700; }
.level-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.chart .col i { display: block; width: 100%; min-height: 3px; border-radius: 6px 6px 3px 3px; background: linear-gradient(0deg, var(--a1), var(--a2)); opacity: .85; }
.chart .col.today i { opacity: 1; box-shadow: 0 0 0 2px var(--a2); }
.chart small { font-size: .7rem; color: var(--muted); }
.stage-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.stage-row .bar i { background: var(--c); }
.stage-row small { width: 52px; text-align: end; color: var(--muted); font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 14px 8px; border-radius: 18px; background: var(--bg2); filter: grayscale(1); opacity: .5; }
.badge.got { filter: none; opacity: 1; background: linear-gradient(160deg, var(--accent-soft), var(--surface)); border: 1px solid var(--line); }
.badge-icon { font-size: 2rem; }
.badge strong { font-size: .92rem; }
.badge small { color: var(--muted); font-size: .74rem; line-height: 1.4; }
.attempts { list-style: none; padding: 0; margin: 0; }
.attempts li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.attempts li:last-child { border: 0; }

/* ===== الإعدادات ===== */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border: 0; }
.set-row > div { display: flex; flex-direction: column; }
.set-row small { font-size: .84rem; }
.switch { width: 52px; height: 30px; flex: none; border-radius: 999px; border: 0; background: var(--line); position: relative; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: inset-inline-start .2s; }
.switch.on { background: linear-gradient(90deg, var(--a1), var(--a2)); }
.switch.on::after { inset-inline-start: 25px; }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 3px; flex: none; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: .88rem; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 700; }

/* ===== النوافذ والإشعارات ===== */
.modal-back { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(12 10 20 / 50%); backdrop-filter: blur(4px); animation: fade .2s; }
.modal-back.out { opacity: 0; transition: opacity .18s; }
.modal { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; padding: 22px; box-shadow: 0 24px 60px rgb(0 0 0 / 30%); animation: pop .25s; }
.modal-body { margin-bottom: 16px; color: var(--muted); }
.modal-body .input { margin-top: 6px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
#toasts { position: fixed; z-index: 120; top: calc(12px + env(safe-area-inset-top)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; max-width: 420px; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 16px; font-weight: 700; font-size: .95rem; box-shadow: 0 10px 30px rgb(0 0 0 / 25%); animation: drop .3s cubic-bezier(.2, .9, .3, 1.3); }
.toast-xp { background: linear-gradient(90deg, var(--a1), var(--a2)); color: #fff; }
.toast-bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes drop { from { opacity: 0; transform: translateY(-20px) scale(.9); } }
.update-banner { position: fixed; z-index: 110; inset-inline: 16px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); max-width: 420px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 12px 12px; padding-inline-start: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 12px 40px rgb(0 0 0 / 20%); font-weight: 700; animation: pop .3s; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 200; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.pill-sa { background: #dcfce7; color: #166534; }
.m { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }
