/* =====================================================================
   درسي — الهوية الفاخرة «زمرّد وذهب على عاج»
   عاجي دافئ #FAF9F6 · زمرّدي ملكي #0F5132 · ذهب هادئ #C59B27
   تُحمَّل بعد styles.css وتعيد تعريف الرموز (tokens) فتتبعها كل المكوّنات.
   وضع ليلي فاخر بزجاج ناعم، ظلال متعددة الطبقات، حركات 60fps (transform/opacity فقط).
   ===================================================================== */
:root {
  /* فاتح فاخر (الهوية الأساسية): أبيض عاجي ناصع، كحلي عميق، لمسة زمردية — هدوء ودقة بأسلوب Linear/Notion */
  --paper: #FAFAFA; --surface: #FFFFFF; --surface-2: #F4F4F5; --line: #E8E8EC; --line-2: #D8D8DE;
  --ink: #0B1B33; --ink-2: #3A4459; --muted: #6B7280;
  --primary: #14284B; --primary-2: #1F3A68; --primary-soft: #EEF2F8; --on-primary: #FFFFFF;
  --gold: #0F7A55; --gold-2: #13946A; --gold-soft: #EAF6F0; --gold-ink: #0B5C40;   /* «اللمسة» زمردية */
  --emerald: #0F7A55; --navy: #14284B;
  --ok: #0F7A55; --ok-soft: #EAF6F0; --bad: #B42318; --bad-soft: #FDECEA;
  --radius: 14px; --radius-sm: 10px;
  --glass: rgba(255, 255, 255, .82); --glass-line: rgba(232, 232, 236, .9); --blur: 12px;
  --shadow: 0 1px 2px rgba(11, 27, 51, .04), 0 1px 1px rgba(11, 27, 51, .02);
  --shadow-lg: 0 1px 2px rgba(11, 27, 51, .04), 0 8px 24px rgba(11, 27, 51, .07);
  --ring: 0 0 0 3px rgba(31, 58, 104, .18);
  --font: "IBM Plex Sans Arabic", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Amiri", "IBM Plex Sans Arabic", serif;
  --font-academic: "Amiri", "Noto Naskh Arabic", serif;
  --font-read: "IBM Plex Sans Arabic", "Noto Naskh Arabic", sans-serif;
  --font-brand: "Amiri", "IBM Plex Sans Arabic", serif;
  --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.4, .64, 1);
  --bg-art: linear-gradient(transparent, transparent);
  color-scheme: light;
}
/* ---------- الوضع الليلي: أخضر ليلي عميق + زجاج ---------- */
html[data-theme="dark"] {
  --paper: #0B1220; --surface: #111A2B; --surface-2: #172238; --line: #22304A; --line-2: #2D3D5C;
  --ink: #EAF2EE; --ink-2: #C3D2CA; --muted: #8DA299;
  --primary: #3B6BC2; --primary-2: #5A86D6; --primary-soft: rgba(90, 134, 214, .14); --on-primary: #FFFFFF;
  --gold: #34B07A; --gold-2: #4CC38A; --gold-soft: rgba(52, 176, 122, .13); --gold-ink: #7FD8AE;
  --ok: #4CC38A; --ok-soft: rgba(76, 195, 138, .14); --bad: #F08A73; --bad-soft: rgba(240, 138, 115, .13);
  --glass: rgba(17, 29, 24, .62); --glass-line: rgba(255, 255, 255, .07);
  --shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 6px 16px rgba(0, 0, 0, .28), 0 18px 40px rgba(0, 0, 0, .22);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45), 0 30px 70px rgba(0, 0, 0, .35);
  --bg-art: radial-gradient(900px 500px at 105% -10%, rgba(59, 107, 194, .16), transparent 60%);
  color-scheme: dark;
}

/* ---------- الأساس والطباعة ---------- */
html { font-size: calc(16.5px * var(--scale, 1) * var(--age, 1)); }
body { font-family: var(--font); background-color: var(--paper); background-image: var(--bg-art); background-attachment: fixed; color: var(--ink); line-height: 1.85;
  font-feature-settings: "kern" 1; -webkit-font-smoothing: antialiased; transition: background-color .3s var(--ease), color .3s var(--ease); }
h1, h2 { font-family: var(--font-display); font-weight: 700; color: var(--ink); line-height: 1.45; }
h1 { font-size: 1.62rem; letter-spacing: 0; }
h2 { font-size: 1.18rem; }
h3 { font-weight: 600; }
p, li { text-wrap: pretty; }
.muted { color: var(--muted); }
a { color: var(--primary-2); }
::selection { background: rgba(197, 155, 39, .3); }
:focus-visible { outline: none; box-shadow: var(--ring); }
.katex { font-size: 1.07em; }   /* KaTeX بخطوطه الخاصة: لا نغيّر عائلته */

/* ---------- أسطح زجاجية وظلال ---------- */
.topbar { background: var(--glass); backdrop-filter: saturate(160%) blur(var(--blur)); -webkit-backdrop-filter: saturate(160%) blur(var(--blur));
  border-bottom: 1px solid var(--glass-line); box-shadow: 0 1px 0 var(--line); }
.bottomnav { background: var(--glass); backdrop-filter: saturate(160%) blur(var(--blur)); -webkit-backdrop-filter: saturate(160%) blur(var(--blur));
  border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(16, 42, 31, .06); }
.bottomnav a.on { background: var(--primary-soft); color: var(--primary); }
.bottomnav a.on .ic { transform: translateY(-2px) scale(1.08); }
.bottomnav a .ic { transition: transform .25s var(--spring); }
.card, .chapter, .subject-card, .task-card, .tool, .composer-box, .stat, .check { box-shadow: var(--shadow); border-color: var(--line); }
html[data-theme="dark"] .card, html[data-theme="dark"] .chapter, html[data-theme="dark"] .subject-card, html[data-theme="dark"] .task-card,
html[data-theme="dark"] .tool, html[data-theme="dark"] .stat, html[data-theme="dark"] .composer-box, html[data-theme="dark"] .pane-book,
html[data-theme="dark"] .pane-tools {
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border-color: var(--glass-line); }
.card.soft { background: var(--primary-soft); }

/* ---------- الشعار ---------- */
.brand { color: var(--primary); letter-spacing: 0; }
html[data-theme="dark"] .brand { color: var(--ink); }
.logo-mark { background: linear-gradient(145deg, var(--primary) 0%, #0B3D26 100%); box-shadow: inset 0 -3px 0 var(--gold), 0 4px 10px rgba(15, 81, 50, .25);
  border-radius: 11px; position: relative; overflow: hidden; }
.logo-mark::after { content: ""; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .45) 50%, transparent 60%);
  transform: translateX(-120%); animation: shine 5s var(--ease) 1.2s infinite; }
@keyframes shine { 0%, 70% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.theme-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; font-size: 1rem; transition: transform .2s var(--spring), background .2s; flex: none; }
.theme-btn:hover { transform: rotate(-12deg) scale(1.06); }

/* ---------- أزرار وحقول بلمسة فاخرة ---------- */
.btn { background: linear-gradient(180deg, var(--primary-2), var(--primary)); border-color: transparent; color: var(--on-primary);
  border-radius: 13px; font-weight: 600; box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 14px rgba(15, 81, 50, .22);
  position: relative; overflow: hidden; isolation: isolate; }
.btn:hover { background: linear-gradient(180deg, #1A7D53, var(--primary-2)); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 10px 22px rgba(15, 81, 50, .28); }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); box-shadow: none; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.quiet { background: var(--surface-2); color: var(--ink); box-shadow: none; border: 1px solid transparent; }
.btn.quiet:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--line)); }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2B1F00; box-shadow: 0 8px 18px rgba(197, 155, 39, .3); }
html[data-theme="dark"] .btn.ghost { color: var(--primary-2); }
input, select, textarea { background: var(--surface); color: var(--ink); border-color: var(--line-2); border-radius: 13px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.opt { background: var(--surface); }
.opt:hover { border-color: var(--primary-2); }
.chip { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.chip.strong { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.tag.accent, .chapter .num { color: var(--gold-ink); }
.card.warn, .note { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--gold-ink); }
.ref-card { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.cite { border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.ai-note .cand { background: var(--surface); }
dialog { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
#toast { background: color-mix(in srgb, var(--ink) 92%, transparent); color: var(--paper); backdrop-filter: blur(8px); border-radius: 14px;
  transform: translateY(8px); transition: opacity .2s, transform .3s var(--spring); }
#toast.show { transform: none; }
table.t { border-collapse: collapse; width: 100%; } table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: start; }
.ai-avatar { background: radial-gradient(circle at 30% 30%, #1E8A5B, var(--primary) 70%); color: var(--gold-soft); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--gold); }
html[data-theme="dark"] .ai-avatar { color: #FBF4DF; }
.msg.user .body { background: linear-gradient(180deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 70%, var(--surface))); }
.ring > span { background: var(--primary-soft); color: var(--primary); }
html[data-theme="dark"] .ring > span { color: var(--ink); }
.big-ic, .tool span { background: var(--primary-soft); }

/* ---------- تموّج اللمس (micro-interaction) ---------- */
.rpl { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .35; background: currentColor;
  animation: rpl .55s var(--ease) forwards; z-index: -1; }
@keyframes rpl { to { transform: scale(2.6); opacity: 0; } }
.btn, .chip, .tool, .choice, .subject-card, .task-card, .stat-tile, .role-tab { position: relative; overflow: hidden; }
.btn:active, .chip:active, .tool:active, .choice:active { transform: scale(.965); }
@media (hover: hover) {
  .subject-card, .task-card, a.card, .tool, .stat-tile { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s; }
  .subject-card:hover, .task-card:hover, a.card:hover, .tool:hover, .stat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
}

/* ---------- دخول متدرّج أنعم ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
main .card, main .tool, main .subject-card, main .task-card, main .qcard, main .stat, main .stat-tile, main .chapter, main .choice {
  animation: enter .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
main > h1, main .hero { animation: enter .55s var(--ease) both; }

/* ---------- كتابة «مِداد» الحيّة أثناء البث ---------- */
.msg.streaming .body p:last-child::after, .typing-caret::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em; margin-inline-start: 3px; vertical-align: -0.15em;
  background: var(--gold); border-radius: 2px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.msg.streaming .body .tk { animation: tk .35s var(--ease) both; }
@keyframes tk { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.msg.settled .body { animation: settle .35s var(--ease); }
@keyframes settle { from { opacity: .75; } to { opacity: 1; } }
.typing .dots i { background: var(--gold); }

/* ---------- عدادات وأرقام ---------- */
.stat .big, .stat-tile .num { font-variant-numeric: tabular-nums; }

/* =====================================================================
   صفحة الدخول والتسجيل
   ===================================================================== */
body.auth-mode { padding-bottom: 0; }
body.auth-mode .bottomnav { display: none; }
body.auth-mode main { max-width: 1080px; }
.auth { display: grid; gap: 22px; align-items: stretch; min-height: calc(100vh - 120px); padding: 8px 0 24px; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.05fr 1fr; } }
.auth-hero { position: relative; overflow: hidden; border-radius: 28px; padding: 34px 30px; color: #F6F1E1; min-height: 260px;
  background: radial-gradient(500px 300px at 85% 10%, rgba(226, 190, 85, .28), transparent 60%), linear-gradient(150deg, #0F5132 0%, #0A3B24 55%, #072A1A 100%);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; justify-content: space-between; animation: enter .6s var(--ease) both; }
.auth-hero::before { content: ""; position: absolute; inset: 0; opacity: .16; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23E2BE55' stroke-width='1'%3E%3Cpath d='M36 6l9 21 21 9-21 9-9 21-9-21-21-9 21-9z'/%3E%3Crect x='21' y='21' width='30' height='30' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 72px 72px; mask-image: linear-gradient(200deg, #000 20%, transparent 85%); -webkit-mask-image: linear-gradient(200deg, #000 20%, transparent 85%); }
.auth-hero > * { position: relative; }
.auth-hero .brand-xl { font-family: var(--font-display); font-size: 2.6rem; line-height: 1.1; display: flex; align-items: center; gap: 12px; color: #FFF; }
.auth-hero .brand-xl .logo-mark { width: 54px; height: 54px; font-size: 1.7rem; border-radius: 16px; background: linear-gradient(145deg, #1A7D53, #0B3D26); }
.auth-hero h2 { font-family: var(--font-academic); font-size: 1.5rem; color: #FBF4DF; margin: 18px 0 6px; font-weight: 700; }
.auth-hero p { color: rgba(246, 241, 225, .82); }
.auth-points { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.auth-points li { display: flex; gap: 10px; align-items: center; animation: enter .5s var(--ease) both; animation-delay: calc(.25s + var(--i, 0) * 90ms); }
.auth-points li b { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); border: 1px solid rgba(226, 190, 85, .35); flex: none; }
.auth-card { background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 28px;
  padding: 26px 24px; box-shadow: var(--shadow-lg); animation: enter .6s var(--ease) .08s both; align-self: center; width: 100%; }
.auth-card h1 { margin-top: 0; }
.role-tabs { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 16px; padding: 4px; margin: 6px 0 14px; }
.role-tab { border: 0; background: none; font: inherit; padding: 9px 6px; border-radius: 12px; cursor: pointer; color: var(--ink-2); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.3; transition: color .25s; }
.role-tab .ri { font-size: 1.25rem; transition: transform .35s var(--spring); }
.role-tab[aria-selected="true"] { color: var(--primary); font-weight: 700; }
html[data-theme="dark"] .role-tab[aria-selected="true"] { color: var(--ink); }
.role-tab[aria-selected="true"] .ri { transform: scale(1.18) translateY(-1px); }
.role-ind { position: absolute; top: 4px; bottom: 4px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  transition: inset-inline-start .35s var(--spring), width .35s var(--spring); }
.role-hint { min-height: 1.6em; color: var(--muted); font-size: .9rem; animation: enter .3s var(--ease); }
.pw-wrap { position: relative; } .pw-wrap button { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 1rem; color: var(--muted); }
.demo-fill { border: 1px dashed var(--line-2); background: none; color: var(--muted); border-radius: 10px; padding: 4px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.demo-fill:hover { color: var(--primary); border-color: var(--primary-2); }
.auth-ok { text-align: center; padding: 10px 0; } .auth-ok .big { font-size: 3rem; animation: pop .5s var(--spring) both; }

/* =====================================================================
   مركز قيادة المدير ولوحة المدرس
   ===================================================================== */
.cmd-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.cmd-head h1 { margin: 0; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(30, 122, 76, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(30, 122, 76, 0); } 100% { box-shadow: 0 0 0 0 rgba(30, 122, 76, 0); } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 12px 0; }
.stat-tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 16px 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.stat-tile .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.15rem; margin-bottom: 6px; }
.stat-tile .num { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.15; color: var(--ink); }
.stat-tile .lbl { color: var(--muted); font-size: .88rem; }
.stat-tile.gold { background: linear-gradient(160deg, var(--gold-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); }
.stat-tile.gold .ic { background: color-mix(in srgb, var(--gold) 22%, transparent); }
.stat-tile.alert .num { color: var(--bad); }
.stat-tile.emerald { background: linear-gradient(155deg, #0F5132, #0A3B24); color: #F6F1E1; border-color: transparent; }
.stat-tile.emerald .num, .stat-tile.emerald .lbl { color: #F6F1E1; } .stat-tile.emerald .ic { background: rgba(255, 255, 255, .12); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 36px; margin-top: 6px; }
.spark i { flex: 1; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-radius: 3px 3px 0 0; min-height: 2px;
  transform-origin: bottom; animation: grow .7s var(--ease) both; animation-delay: calc(var(--i) * 40ms); }
@keyframes grow { from { transform: scaleY(0); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
html[data-theme="dark"] .panel { background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(var(--blur)); }
.panel > h2 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.panel > h2 .count { font-family: var(--font); font-size: .8rem; background: var(--gold-soft); color: var(--gold-ink); border-radius: 999px; padding: 0 10px; }
.cmd-grid { display: grid; gap: 12px; } @media (min-width: 1100px) { .cmd-grid { grid-template-columns: 1fr 1fr; } }
.req { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.req:first-of-type { border-top: 0; }
.req .who { flex: 1; min-width: 200px; }
.req.leaving { animation: leave .35s var(--ease) forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(-24px); height: 0; padding: 0; margin: 0; } }
.utable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.utable th { text-align: start; color: var(--muted); font-weight: 500; font-size: .82rem; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.utable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.utable tr { transition: background .2s; } .utable tbody tr:hover { background: var(--surface-2); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); border: 0; cursor: pointer; transition: background .25s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: inset-inline-start .3s var(--spring); }
.switch[aria-checked="true"] { background: var(--ok); } .switch[aria-checked="true"]::after { inset-inline-start: 21px; }
.pill { display: inline-block; font-size: .75rem; padding: 1px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.wait { background: var(--gold-soft); color: var(--gold-ink); } .pill.off { background: var(--bad-soft); color: var(--bad); }
.book-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.book-row .bar { grid-column: 1 / -1; height: 6px; }
.book-row .bar > i { background: linear-gradient(90deg, var(--primary-2), var(--gold)); transform-origin: right; animation: grow-x .8s var(--ease) both; }
@keyframes grow-x { from { transform: scaleX(0); } }
.seg-filter { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg-filter button { border: 0; background: none; font: inherit; font-size: .88rem; padding: 4px 12px; border-radius: 9px; cursor: pointer; color: var(--ink-2); }
.seg-filter button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }

/* =====================================================================
   التكيّف حسب الفئة
   ===================================================================== */
/* الأول–الثالث الابتدائي: مرح ومشرق، بطاقات كبيرة جدًا، خط النسخ للقراءة */
html[data-level="primary_lower"] {
  --primary: #1769C2; --primary-2: #2A86E8; --primary-soft: #E6F1FD; --gold: #F59E0B; --gold-2: #FBBF24; --gold-soft: #FFF4D6; --gold-ink: #8A5300;
  --paper: #FFFBF2; --radius: 28px; --font-read: "Noto Naskh Arabic", "IBM Plex Sans Arabic", serif;
  --bg-art: radial-gradient(600px 400px at 100% 0, rgba(42, 134, 232, .12), transparent 60%), radial-gradient(600px 400px at 0 100%, rgba(245, 158, 11, .14), transparent 60%),
            radial-gradient(400px 300px at 50% 50%, rgba(52, 211, 153, .08), transparent 70%); }
html[data-level="primary_lower"] .btn { background: linear-gradient(180deg, var(--primary-2), var(--primary)); box-shadow: 0 6px 0 #0F4F95, 0 10px 18px rgba(23, 105, 194, .25); border-radius: 999px; }
html[data-level="primary_lower"] .btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0F4F95; }
html[data-level="primary_lower"] .subjects { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
html[data-level="primary_lower"] .subject-card { flex-direction: column; text-align: center; padding: 22px 14px; border-width: 2px; }
html[data-level="primary_lower"] .subject-card:nth-child(4n+1) { background: #EAF4FF; } html[data-level="primary_lower"] .subject-card:nth-child(4n+2) { background: #FFF3DA; }
html[data-level="primary_lower"] .subject-card:nth-child(4n+3) { background: #E8FAF1; } html[data-level="primary_lower"] .subject-card:nth-child(4n) { background: #FCEBF5; }
html[data-level="primary_lower"] .ring { width: 84px; height: 84px; } html[data-level="primary_lower"] .ring > span { width: 68px; height: 68px; font-size: 2rem; }
html[data-level="primary_lower"] .tool { padding: 18px; border-width: 2px; } html[data-level="primary_lower"] .tool span { width: 56px; height: 56px; font-size: 2rem; }
html[data-level="primary_lower"] .msg .body, html[data-level="primary_lower"] .stem { font-family: var(--font-read); }
html[data-level="primary_lower"] h1 { font-size: 2rem; }
html[data-level="primary_lower"][data-theme="dark"] .subject-card { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; }
/* الرابع–السادس: مشجّع، شارات وتحديات */
html[data-level="primary_upper"] { --primary: #0E7A6B; --primary-2: #14A08B; --primary-soft: #E2F6F2; --gold: #F2A51A; --gold-2: #FFC24B; --gold-soft: #FFF3D9; --radius: 22px; }
html[data-level="primary_upper"] .btn { border-radius: 999px; }
/* المتوسط: شبابي عصري — تدرجات حيوية وأمثلة عراقية بارزة */
html[data-level="intermediate"] { --radius: 20px; }
html[data-level="intermediate"] .hero h1 { background: linear-gradient(90deg, var(--primary), #1A9E68 55%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-level="intermediate"] .msg:not(.user) .body strong { color: var(--primary); }
html[data-level="intermediate"][data-theme="dark"] .msg:not(.user) .body strong { color: var(--gold-2); }
/* الإعدادي (الوزاري): أكاديمي هادئ — عناوين أميري، مشتتات أقل، الإجابة النموذجية والملاحظات الوزارية بارزة */
html[data-level="preparatory"] { --font-display: var(--font-academic); --radius: 14px; --bg-art: linear-gradient(transparent, transparent); }
html[data-level="preparatory"] h1 { font-size: 1.75rem; }
html[data-level="preparatory"] main .card, html[data-level="preparatory"] main .tool { animation-duration: .35s; animation-delay: calc(var(--i, 0) * 25ms); filter: none; }
html[data-level="preparatory"] .logo-mark::after { animation: none; }
html[data-level="preparatory"] .chip[data-i="model_answer"], html[data-level="preparatory"] .chip[data-ministerial] {
  background: linear-gradient(180deg, var(--gold-soft), var(--surface)); border: 1.5px solid var(--gold); color: var(--gold-ink); font-weight: 700; }
html[data-level="preparatory"] .tool[data-model], html[data-level="preparatory"] .tool[data-ministerial] { border: 1.5px solid var(--gold); background: linear-gradient(180deg, var(--gold-soft), var(--surface)); }
.chip[data-ministerial] { display: none; } html[data-level="preparatory"] .chip[data-ministerial], html[data-level="intermediate"] .chip[data-ministerial] { display: inline-flex; }
.tool[data-ministerial] { display: none; } html[data-level="preparatory"] .tool[data-ministerial], html[data-level="intermediate"] .tool[data-ministerial] { display: grid; }
/* المدرس والمدير: لوحات تقارير أنيقة وأوسع */
html[data-role="teacher"], html[data-role="admin"] { --radius: 16px; }
html[data-role="teacher"] main:not(.wide), html[data-role="admin"] main:not(.wide) { max-width: 1100px; }

/* ---------- شارات الإنجاز والتحدي (الابتدائي العلوي ويظهر للجميع بهدوء) ---------- */
.badges { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.badge { flex: none; width: 96px; text-align: center; font-size: .78rem; color: var(--muted); }
.badge .medal { width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; position: relative; overflow: hidden;
  background: radial-gradient(circle at 30% 25%, #FFF6D6, var(--gold-2) 45%, var(--gold) 80%); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--gold) 60%, transparent), 0 8px 16px rgba(197, 155, 39, .3);
  animation: pop .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 120ms); }
.badge .medal::after { content: ""; position: absolute; inset: -30%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .7) 50%, transparent 60%); transform: translateX(-120%);
  animation: shine 3.5s var(--ease) calc(1s + var(--i, 0) * .3s) infinite; }
.badge.locked .medal { background: var(--surface-2); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--line); filter: grayscale(1); opacity: .55; animation: none; }
.badge.locked .medal::after { display: none; }
.badge b { display: block; color: var(--ink); font-size: .82rem; }
.challenge { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: linear-gradient(120deg, var(--primary-soft), var(--gold-soft)); border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line)); box-shadow: var(--shadow); }
.challenge .big { font-size: 2rem; animation: wiggle 2.4s var(--ease) 1s infinite; }
.challenge .prog { height: 8px; border-radius: 99px; background: var(--surface); overflow: hidden; margin-top: 6px; }
.challenge .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-2), var(--gold)); border-radius: 99px; transform-origin: right; animation: grow-x 1s var(--ease) .3s both; }
html[data-level="preparatory"] .badges, html[data-level="preparatory"] .challenge { display: none; }

/* ---------- تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print { body { background: #fff !important; color: #000; } .theme-btn { display: none; } }

/* main يأخذ التركيز برمجيًا بعد كل انتقال (لقارئ الشاشة) — بلا إطار مرئي */
main:focus, main:focus-visible { outline: none; box-shadow: none; }
/* الدخول على الموبايل: النموذج أولًا، والواجهة التعريفية شريط مختصر */
@media (max-width: 899px) {
  .auth { min-height: 0; gap: 14px; }
  .auth-card { order: -1; padding: 22px 18px; }
  .auth-hero { min-height: 0; padding: 18px 20px; border-radius: 22px; }
  .auth-hero .brand-xl { font-size: 1.9rem; } .auth-hero .brand-xl .logo-mark { width: 42px; height: 42px; font-size: 1.3rem; }
  .auth-hero h2 { font-size: 1.15rem; margin: 10px 0 2px; }
  .auth-hero p { display: none; }
  .auth-points { grid-template-columns: 1fr 1fr; gap: 6px; font-size: .85rem; }
}
a.card, a.stat-tile, a.challenge, a.task-card, a.subject-card { text-decoration: none; color: var(--ink); }
a.card strong { color: var(--primary); } html[data-theme="dark"] a.card strong { color: var(--ink); }
/* صفحة الكتاب: ورق دافئ نهارًا، وورق ليلي هادئ ليلًا */
.page { background: #FFFEFA; border-color: var(--line); box-shadow: var(--shadow); }
.page .chunk.hl { background: var(--gold-soft); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gold) 70%, transparent); }
.mm .node, .skip { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .page { background: #14231C; color: var(--ink); }
html[data-theme="dark"] .recite-words .w.wrong, html[data-theme="dark"] .score.mid { background: var(--gold-soft); color: var(--gold-ink); }
html[data-theme="dark"] .paper { box-shadow: var(--shadow-lg); }   /* ورقة الامتحان تبقى بيضاء كالمطبوعة */


/* =====================================================================
   v2 — فاتح فاخر هادئ (Linear/Notion): خطوط رفيعة، ظلال شبه معدومة، كحلي وزمردي، أيقونات خطية
   ===================================================================== */
svg.i { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; display: inline-block; }
.btn svg.i, .chip svg.i { width: 1.05em; height: 1.05em; }
h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.22rem; }
body { background-image: none; }
html[data-theme="dark"] body { background-image: var(--bg-art); }
.topbar { background: rgba(250, 250, 250, .85); box-shadow: none; border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .topbar { background: rgba(11, 18, 32, .78); }
.brand { font-family: var(--font-brand); font-size: 1.45rem; color: var(--navy); }
.logo-mark { background: var(--navy); box-shadow: inset 0 -2.5px 0 var(--emerald); border-radius: 9px; font-family: var(--font-brand); }
.logo-mark::after { display: none; }
.btn { background: var(--primary); border: 1px solid var(--primary); border-radius: 10px; font-weight: 600; box-shadow: 0 1px 2px rgba(11, 27, 51, .12); }
.btn:hover { background: var(--primary-2); box-shadow: 0 2px 6px rgba(11, 27, 51, .14); }
.btn.gold, .btn.accent { background: var(--emerald); border-color: var(--emerald); color: #fff; box-shadow: 0 1px 2px rgba(15, 122, 85, .2); }
.btn.quiet { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); }
.btn.quiet:hover { background: var(--surface-2); }
.btn.ghost { border-color: var(--line-2); color: var(--primary); background: var(--surface); }
input, select, textarea { border-radius: 10px; border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: var(--ring); }
.card, .chapter, .subject-card, .task-card, .tool, .stat, .panel, .stat-tile, .composer-box { border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
@media (hover: hover) {
  .subject-card:hover, .task-card:hover, a.card:hover, .tool:hover, .stat-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
}
.chip { border-radius: 8px; border-color: var(--line-2); font-size: .88rem; }
.chip.strong { background: var(--gold-soft); border-color: color-mix(in srgb, var(--emerald) 45%, transparent); color: var(--gold-ink); }
.tag, .pill { border-radius: 6px; }
.tool span, .big-ic, .stat-tile .ic { background: var(--surface-2); color: var(--primary); border: 1px solid var(--line); }
.tool span svg.i { width: 1.25em; height: 1.25em; }
.stat-tile .ic svg.i, .big-ic svg.i { width: 1.3em; height: 1.3em; }
.ring { background: conic-gradient(var(--emerald) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > span { background: var(--surface); color: var(--primary); border: 1px solid var(--line); }
.ring > span svg.i { width: 1.4em; height: 1.4em; }
.ai-avatar { background: var(--navy); color: #fff; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--emerald); font-family: var(--font-brand); }
.msg.user .body { background: var(--surface-2); border: 1px solid var(--line); }
.stat-tile.emerald { background: var(--navy); }
.stat-tile.gold { background: linear-gradient(160deg, var(--gold-soft), var(--surface) 70%); }
.spark i { background: var(--emerald); }
.book-row .bar > i { background: linear-gradient(90deg, var(--primary-2), var(--emerald)); }
.bottomnav { background: rgba(255, 255, 255, .9); box-shadow: 0 -1px 0 var(--line); }
html[data-theme="dark"] .bottomnav { background: rgba(17, 26, 43, .86); }
.bottomnav a .ic svg.i { width: 1.35rem; height: 1.35rem; }
.topnav a .ic svg.i { width: 1.05rem; height: 1.05rem; }
.theme-btn { border-radius: 9px; color: var(--ink-2); }
.theme-btn svg.i { width: 1.1rem; height: 1.1rem; }
.badge .medal { background: var(--surface); color: var(--emerald); box-shadow: 0 0 0 1px var(--line), 0 0 0 4px var(--gold-soft); }
.badge .medal svg.i { width: 1.7rem; height: 1.7rem; }
.badge .medal::after { background: linear-gradient(115deg, transparent 40%, rgba(15, 122, 85, .12) 50%, transparent 60%); }
.challenge { background: var(--surface); border: 1px solid var(--line); }
.challenge .big svg.i { width: 1.9rem; height: 1.9rem; color: var(--emerald); }
.challenge .prog { background: var(--surface-2); }
.auth-hero { background: radial-gradient(500px 300px at 85% 10%, rgba(19, 148, 106, .22), transparent 60%), linear-gradient(150deg, #14284B 0%, #0E1D38 60%, #0A1529 100%); }
.auth-hero::before { opacity: .1; }
.auth-hero .brand-xl .logo-mark { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); }
.auth-points li b { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.auth-points li b svg.i { width: 1.1em; height: 1.1em; }
.auth-card { background: var(--surface); backdrop-filter: none; box-shadow: var(--shadow-lg); border-radius: 18px; }
.role-tab .ri svg.i { width: 1.3rem; height: 1.3rem; }
.flag-btn svg.i { width: 1rem; height: 1rem; }
.cite svg.i { width: .95em; height: .95em; }
.note svg.i, .tag svg.i { width: 1em; height: 1em; }
html[data-level="intermediate"] .hero h1 { background: none; color: var(--ink); }
html[data-level="intermediate"] .msg:not(.user) .body strong { color: var(--primary); }
@media (prefers-reduced-motion: no-preference) {
  main .card, main .tool, main .subject-card, main .task-card, main .stat-tile, main .chapter { animation-duration: .38s; }
}

/* =====================================================================
   رحلة الترحيب: الأستاذ مِداد (روبوت) ← الصف ← الباقات
   ===================================================================== */
body.welcome-mode .topbar { display: none; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--emerald); font-weight: 600; letter-spacing: 0; }
.center { text-align: center; }
.wl-top { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 4px; }
.wl-top .brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-brand); font-weight: 700; font-size: 1.45rem; color: var(--navy); }
.wl-top .logo-mark { width: 32px; height: 32px; display: inline-grid; place-items: center; color: #fff; font-size: 1.05rem; }
.welcome { max-width: 980px; margin: 0 auto; }
.wl-stage { display: grid; gap: 18px; align-items: center; justify-items: center; padding: 18px 0 6px; }
@media (min-width: 820px) { .wl-stage { grid-template-columns: 300px 1fr; justify-items: start; padding-top: 40px; } }
.wl-robot { width: min(260px, 64vw); animation: floaty 6s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-6px); } }
.robot { width: 100%; height: auto; overflow: visible; }
.robot .rb-head, .robot .rb-face { transform-box: view-box; transform-origin: 110px 110px; will-change: transform; }
.robot .rb-ant { animation: ant 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ant { 50% { opacity: .45; transform: scale(.82); } }
.robot.talking .rb-mouth { animation: talk .22s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes talk { to { transform: scaleY(2.2); } }
.robot .rb-shadow { animation: shadowp 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes shadowp { 50% { transform: scaleX(.88); opacity: .05; } }
.wl-speech { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 22px; box-shadow: var(--shadow-lg); position: relative; max-width: 560px; }
.wl-speech::before { content: ""; position: absolute; top: 34px; inset-inline-end: -8px; width: 16px; height: 16px; background: var(--surface);
  border-inline-end: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(-45deg); }
html[dir="rtl"] .wl-speech::before { transform: rotate(45deg); }
@media (max-width: 819px) { .wl-speech::before { top: -8px; inset-inline-end: auto; inset-inline-start: calc(50% - 8px); transform: rotate(-45deg); } }
.wl-name { font-family: var(--font-display); font-weight: 700; color: var(--navy); font-size: 1.15rem; margin: 0 0 4px; }
.wl-say { font-size: 1.08rem; line-height: 1.95; color: var(--ink); min-height: 3.9em; margin: 0; }
.wl-q { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--emerald); margin: 10px 0 0; }
.wl-grades { margin: 22px 0 30px; display: grid; gap: 14px; }
.wl-stage-row { animation: enter .45s var(--ease) both; animation-delay: calc(var(--i) * 90ms); }
.wl-stage-row h3 { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.wl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wl-grade { border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--ink);
  cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, transform .15s var(--ease), box-shadow .15s; min-height: 46px; }
.wl-grade:hover { border-color: var(--primary-2); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.wl-grade.on { border-color: var(--emerald); background: var(--gold-soft); color: var(--gold-ink); }
.wl-branch { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; animation: enter .35s var(--ease) both; }
.wl-branch p { margin: 0 0 8px; font-weight: 600; }

/* الباقات */
.plans-page { max-width: 1080px; margin: 0 auto; padding-bottom: 24px; }
.plans-head { text-align: center; margin: 18px 0 22px; }
.plans-head h1 { font-size: 2rem; margin: 4px 0; }
.plans { display: grid; gap: 14px; align-items: stretch; }
@media (min-width: 860px) { .plans { grid-template-columns: repeat(3, 1fr); } }
.plan { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: enter .5s var(--ease) both; animation-delay: calc(var(--i) * 80ms); }
.plan h2 { margin: 0; font-size: 1.35rem; }
.plan.featured { border: 1.5px solid var(--emerald); box-shadow: 0 1px 2px rgba(11, 27, 51, .05), 0 18px 40px rgba(15, 122, 85, .12); }
@media (min-width: 860px) { .plan.featured { transform: translateY(-6px); } }
.plan.current { border-color: var(--primary-2); }
.plan-badge { position: absolute; top: -12px; inset-inline-start: 18px; background: var(--emerald); color: #fff; font-size: .78rem; font-weight: 600; padding: 3px 12px; border-radius: 999px; }
.price { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--navy); margin: 14px 0 6px; line-height: 1.2; }
.price small { font-family: var(--font); font-size: .85rem; font-weight: 500; color: var(--muted); }
html[data-theme="dark"] .price { color: var(--ink); }
.plan ul { list-style: none; padding: 0; margin: 8px 0 18px; display: grid; gap: 9px; flex: 1; }
.plan li { display: flex; gap: 8px; align-items: flex-start; font-size: .95rem; }
.plan li svg.i { color: var(--emerald); margin-top: .3em; flex: none; }
.signup { margin-top: 18px; animation: enter .4s var(--ease) both; }
.signup h2 { display: flex; align-items: center; gap: 8px; margin-top: 0; }
.signup-grid { display: grid; gap: 4px 14px; } @media (min-width: 760px) { .signup-grid { grid-template-columns: repeat(3, 1fr); } .signup-grid .full { grid-column: 1 / -1; } }
.upsell { border: 1px solid color-mix(in srgb, var(--emerald) 35%, var(--line)); background: var(--gold-soft); border-radius: 12px; padding: 10px 14px; }
.upsell p { margin: 0 0 8px; color: var(--gold-ink); display: flex; gap: 8px; align-items: flex-start; }
.upsell svg.i { margin-top: .3em; }
.plan-card .plan-name { font-family: var(--font-display); font-size: 1.35rem; color: var(--navy); }
html[data-theme="dark"] .plan-card .plan-name { color: var(--ink); }
.usage { display: grid; gap: 10px; margin-top: 12px; }
.u-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: .92rem; }
.u-row .bar { grid-column: 1 / -1; height: 6px; } .u-row .bar > i { background: var(--emerald); }

/* =====================================================================
   بيئة الدراسة: الكتاب بجانب طاولة الأستاذ
   ===================================================================== */
.pane-book .pane-head { gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.pane-book .pane-head strong { font-family: var(--font-display); font-size: 1.2rem; }
.desk-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px; flex-wrap: wrap; position: sticky; top: 64px; z-index: 6; }
.desk-head > .grow { min-width: 0; }
.desk-head strong { display: block; font-family: var(--font-display); font-size: 1.1rem; white-space: nowrap; }
.desk-head .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk-tools { flex-basis: 100%; order: 3; padding-top: 8px; border-top: 1px solid var(--line); }
.desk-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.dt { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 9px;
  padding: 5px 9px; font: inherit; font-size: .82rem; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.dt:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--primary); }
.dt.more { border-color: color-mix(in srgb, var(--emerald) 40%, var(--line)); color: var(--emerald); }
@media (max-width: 999px) { .dt span { display: none; } .desk-head { position: static; } }
.desk .msg.assistant .body { font-size: 1.02rem; line-height: 1.95; }
.desk .msg.assistant { border-inline-start: 2px solid color-mix(in srgb, var(--emerald) 30%, transparent); padding-inline-start: 10px; }
.hw-thumb { max-width: 220px; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-bottom: 4px; }
.composer-row .photo svg.i, .composer-row .mic svg.i { width: 1.15rem; height: 1.15rem; }
.send svg.i { width: 1.15rem; height: 1.15rem; }
.send { display: grid; place-items: center; background: var(--primary); }
@media (min-width: 1000px) {
  .workspace { grid-template-columns: minmax(330px, 1fr) minmax(460px, 1.25fr) !important; }
  .workspace .pane-tools { position: fixed !important; top: 70px; bottom: 16px; inset-inline-end: 16px; width: 360px; max-height: none !important; z-index: 30;
    transform: translateX(-18px); opacity: 0; visibility: hidden; pointer-events: none;
    transition: transform .3s var(--ease), opacity .22s, visibility 0s linear .3s; box-shadow: var(--shadow-lg); }
  body.tools-open .workspace .pane-tools { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition: transform .3s var(--ease), opacity .22s; }
}
.close-tools { display: none; } @media (min-width: 1000px) { .close-tools { display: inline-flex; } }

html, body { overflow-x: clip; }
.stat-tile .num, .stat .big { font-family: var(--font); font-weight: 600; letter-spacing: -.01em; }

/* =====================================================================
   هوية آيفِندي (AiEfendi): كحلي البدلة · زمرّدي الذكاء · أسود السِّدارة · عاجي الورق · نحاسي للأوسمة فقط
   ===================================================================== */
:root { --sidara: #0B1220; --brass: #B8893B; --brass-soft: #F6EEDC; }
html[data-theme="dark"] { --brass: #D4A957; --brass-soft: rgba(212, 169, 87, .14); }
/* الشعار بالشريط العلوي */
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.brand .efendi { flex: none; }
.brand-word { font-family: var(--font-brand); font-weight: 700; font-size: 1.4rem; color: var(--navy); line-height: 1; }
html[data-theme="dark"] .brand-word { color: var(--ink); }
.logo-mark { display: none; }
svg.efendi { display: block; overflow: visible; }
svg.efendi .ef-head { transform-box: view-box; transform-origin: 100px 120px; }
svg.efendi .ef-lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); }
svg.efendi .ef-dot { animation: efDot 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes efDot { 50% { opacity: .45; transform: scale(.8); } }
svg.efendi.pose-think .ef-bub { animation: efBub 1.4s ease-in-out infinite alternate; }
@keyframes efBub { to { opacity: .15; } }
/* الزر الأساسي: «شريط السِّدارة» الزمردي أسفله — علامة الهوية */
.btn:not(.quiet):not(.ghost):not(.accent):not(.gold) { background: var(--navy); border-color: var(--navy); border-radius: 12px;
  box-shadow: inset 0 -3px 0 var(--emerald), 0 1px 2px rgba(11, 27, 51, .15); }
.btn:not(.quiet):not(.ghost):not(.accent):not(.gold):hover { background: #1B3460; }
html[data-theme="dark"] .btn:not(.quiet):not(.ghost):not(.accent):not(.gold) { background: #24427A; border-color: #24427A; }
.send { background: var(--navy) !important; box-shadow: inset 0 -3px 0 var(--emerald); border-radius: 12px !important; }
.chip[data-ministerial] { border: 1.5px solid var(--brass) !important; background: var(--surface) !important; color: var(--navy) !important; }
.tool[data-ministerial] { border-color: var(--brass) !important; }
/* الأوسمة: النحاسي يظهر هنا فقط */
.badge .medal { border: 2px solid var(--brass); box-shadow: 0 0 0 4px var(--brass-soft); background: var(--surface); color: var(--emerald); }
.badge.locked .medal { border-color: var(--line-2); box-shadow: 0 0 0 4px var(--surface-2); }
.plan-badge { background: var(--emerald); }
/* صورة الأستاذ في المحادثة */
.ai-avatar.ef-avatar { background: none !important; box-shadow: none !important; width: 40px; height: 40px; padding: 0; border-radius: 0; flex: none; }
.ai-avatar.ef-avatar svg { width: 40px; height: 40px; }
.msg.typing .ef-avatar svg .ef-head { animation: efNod 1.2s ease-in-out infinite; }
@keyframes efNod { 50% { transform: rotate(-4deg) translateY(-1px); } }
/* الدخول والترحيب */
.auth-hero .brand-xl { gap: 14px; }
.auth-hero .brand-xl > span { display: flex; flex-direction: column; font-family: var(--font-brand); line-height: 1.05; }
.auth-hero .brand-xl small { font-family: var(--font); font-size: 1rem; font-weight: 600; color: rgba(255,255,255,.75); }
.auth-hero .brand-xl small b { color: #4CC38A; }
.auth-hero .brand-xl .efendi { background: #fff; border-radius: 18px; padding: 4px; }
.wl-top .brand { font-family: var(--font-brand); }
.wl-robot .efendi { width: 100%; height: auto; }

/* ---------- الأستاذ المرافق (يظهر بكل صفحة) ---------- */
.ef-dock { position: fixed; z-index: 45; inset-inline-end: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
@media (max-width: 899px) { .ef-dock { bottom: calc(84px + env(safe-area-inset-bottom)); inset-inline-end: 10px; } }
body.auth-mode .ef-dock, html[data-role="admin"] .ef-dock, body.chat-mode .ef-dock .ef-bubble.menu { display: none; }
body.chat-mode .ef-dock { bottom: calc(150px + env(safe-area-inset-bottom)); }
.ef-btn { pointer-events: auto; width: 66px; height: 66px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg);
  display: grid; place-items: center; cursor: pointer; padding: 0; animation: efFloat 5s ease-in-out infinite; transition: transform .2s var(--spring); }
.ef-btn:hover { transform: translateY(-2px) scale(1.04); }
.ef-btn:focus-visible { box-shadow: var(--ring), var(--shadow-lg); }
@keyframes efFloat { 50% { translate: 0 -4px; } }
.ef-dock[data-pose="alert"] .ef-btn { border-color: var(--brass); box-shadow: 0 0 0 4px var(--brass-soft), var(--shadow-lg); }
.ef-dock[data-pose="proud"] .ef-btn { border-color: var(--emerald); box-shadow: 0 0 0 4px var(--gold-soft), var(--shadow-lg); }
.ef-bubble { pointer-events: auto; position: relative; width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px 12px; box-shadow: var(--shadow-lg); animation: efIn .32s var(--spring) both; transform-origin: bottom left; }
html[dir="rtl"] .ef-bubble { transform-origin: bottom left; }
.ef-bubble::after { content: ""; position: absolute; bottom: -7px; inset-inline-end: 26px; width: 12px; height: 12px; background: var(--surface);
  border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
@keyframes efIn { from { opacity: 0; transform: translateY(8px) scale(.94); } }
.ef-name { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--navy); }
html[data-theme="dark"] .ef-name { color: var(--ink); }
.ef-text { margin: 2px 0 0; font-size: .95rem; line-height: 1.8; }
.ef-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ef-actions:empty { display: none; }
.ef-x { position: absolute; top: 6px; inset-inline-end: 6px; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.ef-x:hover { background: var(--surface-2); }
@media print { .ef-dock { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .ef-btn { animation: none; } }
body.ef-top .ef-dock { top: 74px; bottom: auto; flex-direction: column-reverse; }
body.ef-top .ef-btn { width: 54px; height: 54px; border-radius: 18px; }
body.ef-top .ef-btn svg { width: 46px; height: 46px; }
body.ef-top .ef-bubble::after { bottom: auto; top: -7px; transform: rotate(225deg); }
body.ef-top .ef-bubble { transform-origin: top left; }
@media (min-width: 1000px) { body.ef-top.tools-open .ef-dock { inset-inline-end: 392px; } }

/* الفم: خط الابتسامة وقت السكوت، وفك ينفتح ويسكّر مع الحروف وقت الكلام */
svg.efendi .ef-jaw { display: none; transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(var(--mo, .1)); transition: transform .075s ease-out; }
svg.efendi.lips .ef-jaw { display: inline; }
svg.efendi.lips .ef-mouth { opacity: 0; }
.wl-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wl-voice { font-size: .78rem; padding: 4px 10px; min-height: 0; }
.ef-set h2 { display: flex; align-items: center; gap: 8px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; font-weight: 500; }
.switch-row input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 42px !important; height: 24px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch-row input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .2s; }
.switch-row input[type="checkbox"]:checked { background: var(--emerald); }
.switch-row input[type="checkbox"]:checked::after { inset-inline-start: 21px; }
.switch-row input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }

/* ===================== الصفحة المرتّبة ===================== */
.ly-switch { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.ly-switch button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.ly-switch button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 -2px 0 var(--emerald); }
.ly-switch button:disabled { opacity: .5; cursor: progress; }
.ly { line-height: 1.95; }
.ly .ly-h { font-family: var(--font-display); color: var(--navy); margin: 1.1em 0 .4em; line-height: 1.4; }
html[data-theme="dark"] .ly .ly-h { color: var(--ink); }
.ly h2.ly-h { font-size: 1.35rem; border-bottom: 2px solid var(--emerald); padding-bottom: 4px; display: inline-block; }
.ly h3.ly-h { font-size: 1.15rem; } .ly h4.ly-h { font-size: 1.02rem; }
.ly-list { padding-inline-start: 1.4em; margin: .4em 0 .8em; } .ly-list li { margin: .25em 0; }
.ly-box { position: relative; border: 1px solid var(--line); border-inline-start: 4px solid var(--emerald); background: color-mix(in srgb, var(--emerald) 5%, var(--surface));
  border-radius: 12px; padding: 22px 16px 10px; margin: 16px 0; }
.ly-box .ly-tag { position: absolute; top: -11px; inset-inline-start: 12px; background: var(--emerald); color: #fff; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.ly-law { border-inline-start-color: var(--navy); background: color-mix(in srgb, var(--navy) 5%, var(--surface)); } .ly-law .ly-tag { background: var(--navy); }
.ly-note { border-inline-start-color: var(--brass); background: color-mix(in srgb, var(--brass) 7%, var(--surface)); } .ly-note .ly-tag { background: var(--brass); }
.ly-q .ly-tag, .ly-act .ly-tag { background: #5B6B86; } .ly-q, .ly-act { border-inline-start-color: #5B6B86; background: var(--surface); }
.ly-fig { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px dashed var(--emerald); background: transparent; color: var(--ink); border-radius: 12px; padding: 10px 14px; margin: 10px 0; font: inherit; cursor: pointer; text-align: start; }
.ly-fig span { flex: 1; font-weight: 600; } .ly-fig small { color: var(--emerald); font-weight: 600; }
.ly-fig:hover { background: color-mix(in srgb, var(--emerald) 6%, transparent); }

/* ===================== المسرح (ملء الشاشة) ===================== */
body.stage-open { overflow: hidden; }
body.stage-open .ef-dock { display: none; }
.stage-ov { position: fixed; inset: 0; z-index: 1200; background: rgba(11, 18, 32, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; animation: stIn .18s ease; }
@keyframes stIn { from { opacity: 0; } }
.stage-card { width: min(1180px, 100%); height: min(860px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.stage-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.stage-head strong { font-family: var(--font-display); font-size: 1.05rem; }
.stage-body { flex: 1; overflow: auto; padding: 14px; }
@media (max-width: 700px) { .stage-ov { padding: 0; } .stage-card { border-radius: 0; height: 100%; } }

/* ===================== رسوم الكتاب ===================== */
.figs-head h3 { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; }
.figs-wait { display: flex; gap: 14px; align-items: center; padding: 18px; border: 1px dashed var(--line); border-radius: 14px; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.fig-card { display: flex; flex-direction: column; gap: 6px; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; cursor: pointer; font: inherit; color: var(--ink); transition: transform .15s var(--ease), box-shadow .15s; }
.fig-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.fig-thumb { aspect-ratio: 4/3; border-radius: 10px; background: #F4F6F9; display: grid; place-items: center; overflow: hidden; }
.fig-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fig-cap { font-weight: 600; font-size: .92rem; line-height: 1.5; }
.fig-view { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto 1fr; gap: 12px 16px; height: 100%; }
.fig-modes { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.fig-modes button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 7px 14px; font: inherit; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.fig-modes button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 -3px 0 var(--emerald); }
.fig-modes button:disabled { opacity: .45; cursor: not-allowed; }
.fig-stage { position: relative; overflow: hidden; border-radius: 16px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; min-height: 300px; height: 100%; }
.fig-view { min-height: 0; } .fig-view > * { min-height: 0; }
.fig-zoom { position: relative; transition: transform .9s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.fig-zoom img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.fig-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tour-line { stroke: var(--emerald); stroke-width: .5; stroke-dasharray: 60; stroke-dashoffset: 60; animation: tourLine .7s .2s forwards; vector-effect: non-scaling-stroke; stroke-width: 2.5; }
@keyframes tourLine { to { stroke-dashoffset: 0; } }
.fig-marks { position: absolute; inset: 0; }
.fig-mark { position: absolute; border-radius: 6px; border: 2px solid transparent; transition: all .2s; }
.fig-mark.on { border-color: var(--emerald); background: color-mix(in srgb, var(--emerald) 14%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--emerald) 18%, transparent); }
.tour-ring { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid var(--brass); box-shadow: 0 0 0 0 rgba(184,137,59,.6); animation: ring 1.4s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(184,137,59,.55); } 100% { box-shadow: 0 0 0 18px rgba(184,137,59,0); } }
.fig-side { overflow: auto; }
.fig-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.fig-labels .chip { cursor: pointer; }
.tour-now { padding: 14px; border-radius: 14px; background: color-mix(in srgb, var(--emerald) 7%, var(--surface)); border: 1px solid var(--line); margin-bottom: 10px; min-height: 84px; }
.tour-n { display: block; color: var(--muted); font-size: .8rem; }
.tour-t { font-family: var(--font-display); font-size: 1.5rem; color: var(--navy); line-height: 1.5; }
html[data-theme="dark"] .tour-t { color: var(--ink); }
.tour-ctl { gap: 6px; flex-wrap: wrap; }
.fig-zoom.quiz .fig-blank { position: absolute; display: grid; place-items: center; min-width: 34px; min-height: 22px; border-radius: 7px; border: 2px dashed var(--navy);
  background: #fff; color: var(--navy); font: 700 .78rem var(--font); cursor: pointer; padding: 0 4px; overflow: hidden; white-space: nowrap; }
.fig-blank.ok { border-style: solid; border-color: var(--emerald); background: #EAF6F0; color: var(--emerald); cursor: default; animation: pop .3s; }
.fig-blank.bad { animation: shake .35s; border-color: #C0392B; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.bank .chip.strong { background: var(--navy); color: #fff; }
.quiz-score { margin-top: 12px; }
@media (max-width: 860px) { .fig-view { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; } .fig-stage { min-height: 0; height: 52vh; } }
@media (prefers-reduced-motion: reduce) { .fig-zoom { transition: none; } .tour-ring, .tour-line { animation: none; stroke-dashoffset: 0; } }

/* ===================== السبورة ===================== */
.board { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.bd-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.bd-color { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.bd-color.on { box-shadow: 0 0 0 2px var(--c); }
.bd-size { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.bd-size i { display: block; border-radius: 50%; background: var(--ink); }
.bd-size.on, .bd-tool.on { background: var(--navy); border-color: var(--navy); color: #fff; } .bd-size.on i { background: #fff; }
.bd-tool { width: 34px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.bd-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.bd-q { width: 100%; }
.bd-wrap { position: relative; flex: 1; min-height: 340px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: inset 0 0 0 6px #F4F1EA; }
.bd-canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.bd-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #9AA4B5; pointer-events: none; margin: 0; font-size: 1.05rem; }
.bd-actions { gap: 8px; flex-wrap: wrap; }
.btn.loading { opacity: .7; pointer-events: none; }
.bd-say { display: flex; gap: 10px; align-items: center; font-weight: 600; background: color-mix(in srgb, var(--emerald) 7%, var(--surface)); border-radius: 12px; padding: 8px 12px; }
.bd-result { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.bd-result h4 { margin: 0 0 6px; font-family: var(--font-display); }
.bd-result.v-correct { border-color: var(--emerald); } .bd-result.v-correct h4 { color: var(--emerald); }
.bd-result.v-wrong h4, .bd-result.v-partial h4 { color: #B03A2E; }
.bd-steps { padding-inline-start: 1.6em; } .bd-steps li { margin: 6px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.bd-steps li .i { flex: none; } .bd-steps .s-ok .i { color: var(--emerald); } .bd-steps .s-wrong .i { color: #C0392B; } .bd-steps .s-unclear .i { color: var(--muted); }
.bd-steps .s-wrong .tx { text-decoration: underline wavy #C0392B; text-underline-offset: 5px; }
.bd-steps .nt { flex-basis: 100%; color: #B03A2E; font-size: .9rem; }
.bd-steps .tx p { margin: 0; }
.bd-score { float: inline-end; text-align: center; } .bd-score b { font-size: 2rem; color: var(--emerald); font-family: var(--font-display); }
.bd-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bd-compare figure { margin: 0; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; }
.bd-compare img { width: 100%; display: block; } .bd-compare figcaption { text-align: center; font-size: .85rem; color: var(--muted); }
.board-host { height: 100%; }
.bd-hint[hidden], .ly-switch[hidden], .ly-ordered[hidden], .ly-original[hidden] { display: none !important; }

/* ===================== المختبر التفاعلي ===================== */
.lab-wrap { display: flex; flex-direction: column; gap: 12px; height: 100%; }
.lab-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.lab-tabs button { flex: none; display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.lab-tabs button small { background: var(--brass); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .7rem; }
.lab-tabs button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 -3px 0 var(--emerald); }
.lab-host { flex: 1; min-height: 0; }
.lab { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 16px; height: 100%; }
.lab-stage { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); display: grid; place-items: center; padding: 8px; color: var(--ink); min-height: 280px; }
.lab-svg { width: 100%; height: 100%; max-height: 520px; }
.lab-panel { display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.lab-panel.wide { grid-column: 1 / -1; }
.lab-sl { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
.lab-sl-t b { color: var(--emerald); font-variant-numeric: tabular-nums; }
.lab-sl input[type="range"] { width: 100%; accent-color: var(--emerald); direction: ltr; }
.lab-seg { display: inline-flex; gap: 4px; background: color-mix(in srgb, var(--navy) 6%, transparent); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.lab-seg button { border: 0; background: transparent; color: var(--ink); padding: 6px 12px; border-radius: 9px; font: inherit; cursor: pointer; }
.lab-seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; color: var(--navy); }
.lab-out { border-top: 1px dashed var(--line); padding-top: 8px; overflow-x: auto; }
.lab-out .katex-display { margin: .4em 0; }
.lab-res { margin: .3em 0; } .lab-res.ok { color: var(--emerald); }
.lab-flow { animation: labFlow linear infinite; } @keyframes labFlow { to { stroke-dashoffset: -34; } }
.lab-orbit { transform-origin: 300px 150px; animation: labSpin linear infinite; } @keyframes labSpin { to { transform: rotate(360deg); } }
.lab-chem .lab-eqs button { direction: ltr; font-family: var(--font); }
.lab-eq { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; font-size: 1.35rem; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.lab-sp { display: inline-flex; align-items: center; gap: 4px; }
.lab-sp input { width: 52px; text-align: center; font-size: 1.1rem; padding: 4px; border-radius: 10px; border: 2px solid var(--line); }
.lab-sp input:focus { border-color: var(--emerald); outline: none; }
.lab-eq .arr { color: var(--emerald); margin: 0 6px; }
.lab-atoms table { width: 100%; max-width: 420px; margin: 0 auto; text-align: center; }
.lab-atoms tr.eq td { color: var(--emerald); } .lab-atoms tr.neq td { color: #B03A2E; font-weight: 700; }
.lab-row { gap: 8px; justify-content: center; }
@media (max-width: 860px) { .lab { grid-template-columns: 1fr; height: auto; } .lab-stage { min-height: 220px; } }
@media (prefers-reduced-motion: reduce) { .lab-flow, .lab-orbit { animation: none; } }
.lab-svg { direction: ltr; }

/* ===================== الأسئلة الوزارية ===================== */
.mq-subs, .mq-pp { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.mq-subs button, .mq-pp button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; cursor: pointer; }
.mq-subs button small, .mq-pp button small { color: var(--muted); margin-inline-start: 4px; }
.mq-subs button[aria-selected="true"], .mq-pp button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 -3px 0 var(--emerald); }
.mq-subs button[aria-selected="true"] small, .mq-pp button[aria-pressed="true"] small { color: #cfe; }
.mq-subs button:disabled { opacity: .45; cursor: default; }
.mq { margin: 12px 0; }
.mq-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.mq-no { font-family: var(--font-display); font-weight: 700; color: var(--navy); font-size: 1.1rem; }
html[data-theme="dark"] .mq-no { color: var(--ink); }
.mq-l { margin-inline-start: auto; display: inline-flex; gap: 4px; align-items: center; }
.mq-opts { margin: 6px 0; padding-inline-start: 1.6em; }
.mq-act { gap: 8px; margin-top: 8px; }
.mq-sol { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.mq-final { background: color-mix(in srgb, var(--emerald) 8%, var(--surface)); border-radius: 10px; padding: 8px 12px; }
.mq-timer { position: sticky; top: 76px; z-index: 5; display: flex; justify-content: space-between; align-items: center; }
.mq-exam { gap: 10px; align-items: center; margin: 8px 0; }
.empty { display: flex; gap: 14px; align-items: center; }

/* رف أدوات الدرس تحت ترحيب الأستاذ */
.tool-shelf { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.shelf-btn { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .88rem; cursor: pointer; transition: transform .12s var(--ease), border-color .12s; }
.shelf-btn:hover { border-color: var(--emerald); transform: translateY(-1px); }
.shelf-btn.hot { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: inset 0 -3px 0 var(--emerald); }
.lab-page { padding: 14px; min-height: 560px; }
/* بالموبايل داخل الدرس: آيفِندي ما يغطي التبويبات والأدوات (موجود برأس المحادثة ورف الأدوات) */
@media (max-width: 860px) { body.ef-top .ef-dock { display: none; } }
.lab-ask[hidden] { display: none !important; } .tool-shelf { margin: 4px 0 14px; border-top: 0; padding-top: 0; }

/* ---------- v1.47: الدفع، الامتحان الأونلاين، خطة الوزاري ---------- */
.prog { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-2, var(--emerald)), var(--gold)); border-radius: 99px; }
.ok-card { border-color: color-mix(in srgb, var(--emerald) 45%, var(--line)); background: color-mix(in srgb, var(--emerald) 7%, var(--surface)); }
.pay-pending, .pl-late { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.pay-box { margin-top: 16px; } .pay-box h2 { margin-top: 0; }
.pay-step { padding: 12px 0; border-top: 1px solid var(--line); } .pay-step:first-of-type { border-top: 0; } .pay-step > b { display: block; margin-bottom: 8px; }
.pay-total { margin: 8px 0 0; font-size: 1.05rem; } .pay-total b { font-size: 1.35rem; color: var(--navy); }
html[data-theme="dark"] .pay-total b { color: var(--ink); }
.pay-methods { display: grid; gap: 8px; } @media (min-width: 760px) { .pay-methods { grid-template-columns: repeat(3, 1fr); } }
.pay-method { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-2); border-radius: 14px; cursor: pointer; background: var(--surface); }
.pay-method:has(input:checked) { border-color: var(--emerald); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 18%, transparent); }
.pay-method input { width: auto; margin-top: 4px; } .pay-method span { display: grid; gap: 2px; }
.pay-accounts { display: grid; gap: 8px; margin: 8px 0; } @media (min-width: 760px) { .pay-accounts { grid-template-columns: repeat(2, 1fr); } }
.pay-acc { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px dashed var(--gold); border-radius: 12px; background: color-mix(in srgb, var(--gold) 6%, var(--surface)); flex-wrap: wrap; }
.pay-acc b { font-size: 1.15rem; letter-spacing: .04em; flex: 1; }
.pay-form { display: grid; gap: 4px 14px; } @media (min-width: 760px) { .pay-form { grid-template-columns: repeat(3, 1fr); } .pay-form .full { grid-column: 1 / -1; } }
.pay-history { margin-top: 14px; } .pay-req .who { flex: 1; min-width: 220px; }
.plan-set { gap: 6px; flex-wrap: nowrap; } .plan-set select, .plan-set input { min-height: 34px; padding: 4px 8px; width: auto; }
/* امتحان أونلاين */
.pub-grid { display: grid; gap: 4px 14px; } @media (min-width: 760px) { .pub-grid { grid-template-columns: repeat(3, 1fr); } .pub-grid .full { grid-column: 1 / -1; } }
.publish-box { margin-top: 16px; border-color: color-mix(in srgb, var(--emerald) 35%, var(--line)); }
.online-row, .exam-card { align-items: center; gap: 12px; margin: 8px 0; text-decoration: none; color: var(--ink); }
.online-num { display: grid; text-align: center; min-width: 64px; } .online-num b { font-size: 1.3rem; }
.exam-card.live { border-color: color-mix(in srgb, var(--emerald) 45%, var(--line)); }
.exam-card > svg, .plan-link > svg { width: 26px; height: 26px; color: var(--emerald); flex: none; }
.plan-link { align-items: center; gap: 12px; text-decoration: none; color: var(--ink); margin: 10px 0; }
.exam-bar { position: sticky; top: 64px; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 10px 14px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.exam-timer { font: 700 1.35rem/1 ui-monospace, monospace; direction: ltr; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); }
.exam-timer.low { background: #FDECEC; color: #B42318; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.exam-paper .ex-q { margin: 12px 0 18px; } .exam-paper textarea { width: 100%; margin-top: 8px; }
.ex-opts { display: grid; gap: 6px; margin-top: 8px; } .ex-opts.tf { grid-template-columns: repeat(2, minmax(0, 160px)); }
.ex-opt { display: flex; gap: 8px; align-items: center; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; background: var(--surface); }
.ex-opt input { width: auto; } .ex-opt:has(input:checked) { border-color: var(--navy); background: color-mix(in srgb, var(--navy) 6%, var(--surface)); }
.exam-intro, .exam-result { text-align: center; max-width: 560px; margin: 20px auto; }
.big-ring { width: 120px !important; height: 120px !important; margin: 10px auto; } .big-ring > span { width: 100px !important; height: 100px !important; display: grid; align-content: center; }
.big-ring b { font-size: 1.8rem; line-height: 1; } .big-ring small { font-size: .78rem; color: var(--muted); font-weight: 500; }
.att-item { border: 1px solid var(--line); border-inline-start: 4px solid var(--line-2); border-radius: 12px; padding: 10px 14px; margin: 10px 0; background: var(--surface); }
.att-item.ok { border-inline-start-color: var(--emerald); } .att-item.part { border-inline-start-color: var(--gold); } .att-item.bad { border-inline-start-color: #C2410C; }
.att-item p { margin: 4px 0; }
.q-stat { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.q-bar { width: 120px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; flex: none; } .q-bar i { display: block; height: 100%; background: var(--emerald); }
/* خطة الوزاري */
.pl-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pl-task { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin: 8px 0; flex-wrap: wrap; }
.pl-task.done { opacity: .6; } .pl-task.done strong { text-decoration: line-through; }
.pl-task.k-review { border-inline-start: 4px solid var(--gold); } .pl-task.k-ministerial { border-inline-start: 4px solid var(--navy); } .pl-task.k-study { border-inline-start: 4px solid var(--emerald); }
.pl-check { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.pl-check[aria-pressed="true"] { color: var(--emerald); border-color: var(--emerald); }
.pl-task .grow { min-width: 0; flex: 1 1 200px; }
.pl-day h3 { margin: 16px 0 4px; font-size: 1rem; }
.pl-phases { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.pl-phase { display: grid; gap: 2px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.pl-phase small { color: var(--muted); font-weight: 400; }
.pl-home .pl-mini { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pl-home .pl-mini.done { opacity: .55; text-decoration: line-through; }
.pl-form h2 { font-size: 1.15rem; }
@media print { .exam-bar { display: none; } }
.rl { margin: 4px 0; } .rl p { display: inline; margin: 0; } .rl .katex-display { display: inline-block; margin: 0; }

/* ---------- v1.48: التنبيهات والامتحان التجريبي ---------- */
.bell-btn { position: relative; display: grid; place-items: center; text-decoration: none; color: var(--ink); }
.bell-n { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: #C2410C; color: #fff;
  font: 700 .7rem/18px system-ui, sans-serif; text-align: center; }
.notif { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin: 8px 0; text-decoration: none; color: var(--ink); }
.notif > svg { width: 22px; height: 22px; color: var(--emerald); flex: none; margin-top: 2px; }
.notif.new { border-inline-start: 4px solid var(--emerald); background: color-mix(in srgb, var(--emerald) 5%, var(--surface)); }
.notif-set { margin-top: 18px; } .set-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; } .set-row svg { width: 18px; height: 18px; vertical-align: -3px; }
.wa-form { display: grid; gap: 8px; margin-top: 8px; max-width: 420px; } .wa-form input[type="text"], .wa-form #wap { max-width: 220px; }
.mock-subs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin: 14px 0; }
.mock-sub { display: grid; gap: 6px; justify-items: center; text-align: center; cursor: pointer; font: inherit; color: var(--ink); padding: 18px 12px; }
.mock-sub:hover { border-color: var(--emerald); } .mock-sub > span:first-child, .mock-sub > svg { font-size: 1.6rem; }
.past-tag { background: color-mix(in srgb, var(--gold) 14%, var(--surface)); color: #7A5A1E; border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); }
html[data-theme="dark"] .past-tag { color: var(--gold); }
.weak-row, .mock-res + .panel .q-stat { text-decoration: none; color: var(--ink); }
.mock-res p { max-width: 460px; margin-inline: auto; }
.set-row > .grow { flex: 1 1 240px; min-width: 0; }
.wa-form label, .set-row > label { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 500; margin: 0; }
.wa-form label input, .set-row > label input { margin-top: 3px; flex: none; }
.wa-form label, .set-row > label { flex-wrap: nowrap !important; } .wa-form label > span, .set-row > label > span { flex: 1; }

/* ---------- v1.49: لوحة درجاتي (ألوان متحقق منها: فاتح #0F7A55/#B8893B، ليلي #33A87A/#A97E33) ---------- */
.sc-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.sc-range { font-size: 1.15rem; margin: 0 0 6px; }
.sc-grid-wrap { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); margin: 14px 0; }
.sc-card h2 { font-size: 1.1rem; } .sc-card h2 svg { width: 20px; height: 20px; vertical-align: -4px; }
.sc-predv { font: 700 1.5rem/1 system-ui, sans-serif; color: var(--ink); } .sc-predv small { font-size: .7rem; color: var(--muted); font-weight: 500; margin-inline-start: 3px; }
.sc-svg { width: 100%; height: auto; display: block; margin: 6px 0 8px; --sc-line: #0F7A55; --sc-pred: #B8893B; }
html[data-theme="dark"] .sc-svg { --sc-line: #33A87A; --sc-pred: #A97E33; }
.sc-grid { stroke: var(--line); stroke-width: 1; }
.sc-ax { fill: var(--muted); font: 10px system-ui, sans-serif; }
.sc-line { fill: none; stroke: var(--sc-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sc-dot { fill: var(--sc-line); stroke: var(--surface); stroke-width: 2; }
.sc-hit { fill: transparent; cursor: pointer; }
.sc-pt:hover .sc-dot, .sc-pt:focus .sc-dot { r: 6; }
.sc-pt:focus { outline: none; }
.sc-pred-line { stroke: var(--sc-pred); stroke-width: 2; stroke-dasharray: 4 4; }
.sc-pred { fill: var(--surface); stroke: var(--sc-pred); stroke-width: 2.5; }
.sc-band { fill: color-mix(in srgb, var(--sc-pred) 22%, transparent); }
.sc-lbl { fill: var(--ink); font: 600 11px system-ui, sans-serif; } .sc-lbl.pred { fill: var(--ink); }
.sc-table { margin-inline-start: auto; } .sc-table table { margin-top: 6px; font-size: .85rem; }

/* رسوم الدرس: بحث ظاهر للطالب (صفحات تنفحص وخط مسح يتحرك) */
.figs-wait.scan { align-items: flex-start; }
.sc-pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.sc-page { position: relative; width: 34px; height: 44px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--card, #fff);
  overflow: hidden; display: grid; place-items: center; color: var(--emerald, #0F7A55); }
.sc-page::before { content: ""; position: absolute; inset: 8px 6px auto 6px; height: 2px; background: var(--line);
  box-shadow: 0 6px 0 var(--line), 0 12px 0 var(--line), 0 18px 0 var(--line); }
.sc-page.done { border-color: var(--emerald, #0F7A55); background: color-mix(in srgb, var(--emerald, #0F7A55) 10%, transparent); }
.sc-page.done::before { display: none; }
.sc-page.now { border-color: var(--brass, #B8893B); }
.sc-page.now::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: var(--brass, #B8893B);
  box-shadow: 0 0 8px var(--brass, #B8893B); animation: sc-line 1.4s ease-in-out infinite; }
@keyframes sc-line { 0% { top: 2px; } 50% { top: calc(100% - 5px); } 100% { top: 2px; } }
.sc-prog i { transition: width .6s ease; background: linear-gradient(90deg, var(--emerald, #0F7A55), var(--brass, #B8893B)); }
.sc-step { animation: sc-fade 3.5s ease infinite; }
@keyframes sc-fade { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sc-page.now::after, .sc-step { animation: none; } }
.bd-q-show { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .95rem; line-height: 1.7; }
/* تأكيد الحساب بكود + زر Google */
.otp { text-align: center; } .otp .big { font-size: 2.6rem; color: var(--emerald, #0F7A55); }
.otp form { text-align: start; max-width: 340px; margin: 14px auto 0; }
.otp-in { font-size: 1.7rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding: 10px 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--emerald, #0F7A55); text-decoration: underline; cursor: pointer; font: inherit; }
.linkish:disabled { color: var(--muted, #888); text-decoration: none; cursor: default; }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted, #888); font-size: .85rem; margin: 14px 0 10px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
