/* ===== اشرح لي — ExplainMate ===== */
:root {
  --navy: #1B2559; --navy-deep: #111735; --night: #0C1129; --royal: #2C3A7A;
  --gold: #F7AB29; --gold-bright: #FFC24D;
  --paper: #FCFBF8; --canvas: #F4F3EF; --card: #fff;
  --ink: #1B2559; --body: #33395C; --muted: #6B7391; --faint: #8A93B2;
  --line: #E7E4DA; --line-strong: #D9D5C9; --success: #16A34A; --danger: #EF4444;
  --glass: rgba(255,255,255,.07); --glass-line: rgba(255,255,255,.12);
  --ui: 'Tajawal', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --board: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  --display: 'Noto Kufi Arabic', 'IBM Plex Sans Arabic', sans-serif;
  --nav-h: 70px; --r: 22px;
  --shadow: 0 1px 2px rgba(17,23,53,.06), 0 10px 30px rgba(17,23,53,.08);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.25), 0 30px 80px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--canvas); color: var(--body); font-family: var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; }
h1, h2 { color: var(--ink); font-family: var(--display); letter-spacing: -.2px; }
.hidden { display: none !important; }
.screen { display: none; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }
svg { flex: none; }

/* ===== رمز المعلّم (الكرة) ===== */
.orb { position: relative; width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 32% 28%, #4a5db8, var(--navy) 58%, var(--navy-deep)); box-shadow: 0 0 0 1px rgba(255,255,255,.15) inset, 0 8px 22px rgba(27,37,89,.45); }
.orb > svg { width: 54%; height: 54%; color: #fff; }
.orb i { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--gold); opacity: 0; }
.orb.speaking i, .orb.big i, .orb.thinking i { animation: ring 2s ease-out infinite; }
.orb i:nth-of-type(2) { animation-delay: .65s !important; } .orb i:nth-of-type(3) { animation-delay: 1.3s !important; }
@keyframes ring { 0% { transform: scale(.92); opacity: .75; } 100% { transform: scale(1.75); opacity: 0; } }
.orb.tiny { width: 28px; height: 28px; } .orb.big { width: 104px; height: 104px; margin: 0 auto 18px; }
.orb.speaking > svg, .orb.big > svg { animation: swing .9s ease-in-out infinite alternate; transform-origin: 50% 10%; }
.orb.speaking > svg { animation-duration: .32s; }
@keyframes swing { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }

/* ===== الهيكل والتبويبات ===== */
#shell { position: relative; background:
  radial-gradient(1200px 520px at 50% -180px, #2a3a8a 0%, rgba(27,37,89,0) 70%), linear-gradient(180deg, var(--navy-deep) 0, var(--navy-deep) 540px, var(--canvas) 660px); }
.app-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; position: sticky; top: 0; z-index: 3;
  background: rgba(17,23,53,.72); backdrop-filter: blur(14px); border-bottom: 1px solid var(--glass-line); }
.logo { height: 36px; filter: brightness(0) invert(1); opacity: .95; }
.stats { display: flex; gap: 8px; }
.pill { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; font-weight: 800; padding: 7px 13px; border-radius: 99px; background: var(--glass); color: #fff; border: 1px solid var(--glass-line); }
.pill svg { width: 16px; height: 16px; color: var(--gold); }
.pill.streak svg { color: #FB923C; }
.pill.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.25); } }
.tab { display: none; flex: 1; overflow-y: auto; padding: 8px 20px calc(var(--nav-h) + 34px); width: min(820px, 100%); margin: 0 auto; }
.tab.active { display: block; }
.tab h2 { font-size: 17px; margin: 30px 0 14px; }
.tab-title { font-size: 26px; margin: 18px 0 8px; color: #fff; }
.tab-sub { color: #C9CEE6; margin: 0 0 18px; line-height: 1.8; }
.tabbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 24px)); height: var(--nav-h);
  display: flex; background: rgba(17,23,53,.92); backdrop-filter: blur(16px); border: 1px solid var(--glass-line); border-radius: 24px; z-index: 5; box-shadow: var(--shadow-lg); padding: 6px; }
.tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #8A93B2; font-size: 12px; font-weight: 700; position: relative; border-radius: 18px; transition: .2s; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: #fff; background: rgba(255,255,255,.09); }
.tabbar button.active svg { color: var(--gold); }
.badge-dot { position: absolute; top: 8px; left: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(17,23,53,.9); }

/* ===== الرئيسية ===== */
.hero { text-align: center; padding: 34px 0 26px; color: #fff; }
.greet { display: inline-block; font-size: 13px; color: var(--gold-bright); font-weight: 700; margin-bottom: 10px; padding: 5px 12px; border-radius: 99px; background: rgba(247,171,41,.12); border: 1px solid rgba(247,171,41,.25); }
.hero h1 { font-size: clamp(30px, 6.5vw, 46px); margin: 0 0 10px; color: #fff; font-weight: 800; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--gold-bright), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0 auto; color: #C9CEE6; font-size: 16px; line-height: 1.9; max-width: 520px; }
.styles { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; margin: 14px 0 0; font-size: 13px; color: #9AA3C7; }
.styles button:not(.on) { background: var(--glass); color: #DDE2F5; border-color: var(--glass-line); }
.styles button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 7px 14px; font-size: 13px; color: var(--body); font-weight: 600; transition: .15s; }
.styles button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.today { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.today-card { border: 0; border-radius: var(--r); padding: 18px; display: flex; gap: 14px; align-items: center; text-align: right; box-shadow: var(--shadow); transition: transform .15s; }
.today-card:hover { transform: translateY(-2px); }
.today-card svg { width: 30px; height: 30px; padding: 9px; box-sizing: content-box; border-radius: 14px; }
.today-card b { display: block; font-size: 16px; font-family: var(--display); }
.today-card small { font-size: 13px; opacity: .8; }
.today-card.challenge { background: linear-gradient(135deg, var(--navy), var(--royal)); color: #fff; }
.today-card.challenge svg { color: var(--gold); background: rgba(255,255,255,.1); }
.today-card.review { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.today-card.review svg { color: var(--navy); background: #FFF4DC; }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.subject { border: 1px solid var(--line); background: #fff; border-radius: var(--r); padding: 18px 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--ink); transition: .18s; box-shadow: var(--shadow); }
.subject:hover { transform: translateY(-3px); border-color: var(--gold); }
.subject svg { width: 50px; height: 50px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 9px 16px; font-size: 14px; color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.chip:hover { border-color: var(--gold); }
.ai-note { margin-top: 24px; font-size: 12px; color: var(--muted); text-align: center; }
.ai-note.on { color: var(--success); }

/* ===== سبوراتي / البطاقات / التحدي ===== */
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px; margin: 10px 0 18px; box-shadow: var(--shadow); }
.search svg { width: 20px; height: 20px; color: var(--faint); }
.search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 11px 0; background: none; color: var(--ink); }
.saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.empty { color: var(--muted); font-size: 15px; line-height: 1.8; padding: 28px; text-align: center; background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--r); grid-column: 1 / -1; }
.card { position: relative; text-align: right; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; font: inherit; box-shadow: var(--shadow); transition: .15s; }
.card:hover { border-color: var(--gold); transform: translateY(-2px); }
.card b { display: block; font-family: var(--display); font-size: 17px; color: var(--navy); margin-bottom: 8px; }
.card small { color: var(--muted); }
.card .del { position: absolute; top: 10px; left: 12px; color: var(--faint); font-size: 18px; }
.btn { border: 0; border-radius: 16px; padding: 14px 18px; font-size: 15px; font-weight: 800; }
.btn.primary { background: var(--navy); color: #fff; box-shadow: 0 8px 20px rgba(27,37,89,.25); }
.btn.primary:disabled { background: var(--line-strong); color: var(--muted); box-shadow: none; }
.btn.gold { background: var(--gold); color: var(--navy-deep); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.decks { display: grid; gap: 10px; margin-top: 16px; }
.deck { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.deck .info { flex: 1; min-width: 0; }
.deck b { display: block; color: var(--ink); font-size: 16px; font-family: var(--display); }
.deck small { color: var(--muted); }
.deck .due { background: #FFF4DC; color: #8A5A00; font-weight: 800; border-radius: 99px; padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.deck .go { border: 0; background: var(--navy); color: #fff; border-radius: 12px; padding: 9px 16px; font-weight: 700; }
.deck .x { border: 0; background: none; color: var(--faint); font-size: 18px; }
.mastery { height: 6px; border-radius: 99px; background: var(--line); margin-top: 10px; overflow: hidden; }
.mastery i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--success)); border-radius: 99px; }
#reviewScreen { background: var(--canvas); }
.progress { height: 5px; background: var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.review-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; }
.flash { position: relative; width: min(540px, 100%); height: min(340px, 52vh); perspective: 1200px; cursor: pointer; outline: none; }
.face { position: absolute; inset: 0; border-radius: 28px; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px;
  backface-visibility: hidden; transition: transform .55s cubic-bezier(.3,1.25,.5,1); box-shadow: var(--shadow-lg); }
.face small { position: absolute; top: 18px; right: 22px; font-weight: 700; font-size: 12px; letter-spacing: .3px; }
.face > div { font-family: var(--board); font-weight: 600; font-size: clamp(22px, 4.6vw, 30px); line-height: 1.7; }
.front { background: #fff; color: var(--navy); }
.front small { color: var(--faint); }
.back { background: linear-gradient(135deg, var(--navy), var(--royal)); color: #fff; transform: rotateY(180deg); }
.back small { color: var(--gold-bright); }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0); }
.hint { position: absolute; bottom: 18px; font-size: 13px; color: var(--faint); }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(540px, 100%); }
.rate button { border: 0; border-radius: 14px; padding: 13px 4px; font-size: 14px; font-weight: 800; }
.rate .again { background: #FEE2E2; color: #991B1B; } .rate .hard { background: #FFF4DC; color: #8A5A00; }
.rate .good { background: #DCFCE7; color: #166534; } .rate .easy { background: var(--navy); color: #fff; }
.done-box { text-align: center; }
.done-box h2 { font-size: 24px; margin: 10px 0; }
.challenge-box { background: #fff; border: 1px solid var(--line); border-radius: 26px; padding: 24px; margin-top: 12px; box-shadow: var(--shadow-lg); }
.challenge-box .subj { display: inline-block; background: var(--navy); color: #fff; border-radius: 99px; padding: 4px 12px; font-size: 12px; font-weight: 700; }
.challenge-box .q { font-size: 21px; font-weight: 800; color: var(--ink); margin: 16px 0 18px; line-height: 1.7; font-family: var(--display); }
.challenge-box .opts { display: grid; gap: 10px; }
.challenge-box .opts button, .quiz .opts button { border: 1.5px solid var(--line); background: var(--paper); border-radius: 16px; padding: 13px; font-size: 16px; font-weight: 700; color: var(--ink); text-align: center; transition: .12s; }
.challenge-box .opts button:hover, .quiz .opts button:hover { border-color: var(--gold); transform: translateY(-1px); }
.opts .right { background: #DCFCE7 !important; border-color: var(--success) !important; color: #166534 !important; }
.opts .wrong { background: #FEE2E2 !important; border-color: var(--danger) !important; color: #991B1B !important; animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.challenge-box .explain { margin-top: 14px; line-height: 1.8; color: var(--body); }
.challenge-box .explain:empty { display: none; }
.challenge-box .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.week { display: flex; justify-content: space-between; gap: 6px; margin-top: 20px; }
.week span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.week span i { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto 4px; border-radius: 50%; background: var(--line); color: #fff; font-style: normal; }
.week span.on i { background: var(--gold); }
.week span.today i { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ===== شريط السؤال ===== */
.ask-bar { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 7px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.ask-bar .field { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ask-bar input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 11px 6px; background: transparent; color: var(--ink); }
.thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 10px; cursor: pointer; }
.ib { width: 42px; height: 42px; border-radius: 14px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; transition: .15s; }
.ib:hover { background: #F1EFE8; color: var(--navy); }
.ib.dark { color: #C9CEE6; } .ib.dark:hover { background: rgba(255,255,255,.08); color: #fff; }
.ib svg, .send svg { width: 21px; height: 21px; }
.ib.rec { color: #fff; background: var(--danger); animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.send { width: 46px; height: 46px; border-radius: 16px; border: 0; background: linear-gradient(135deg, var(--gold-bright), var(--gold)); color: var(--navy-deep); display: grid; place-items: center; flex: none; box-shadow: 0 6px 16px rgba(247,171,41,.4); }

/* ===== شاشة السبورة ===== */
#boardScreen { position: relative; background: radial-gradient(900px 400px at 70% -120px, #26357e 0%, rgba(17,23,53,0) 70%), var(--night); color: #fff; }
.board-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; z-index: 5; border-bottom: 1px solid var(--glass-line); }
.tutor { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; justify-content: center; }
.tutor-txt { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.tutor-txt.center { align-items: center; flex: 1; }
.tutor-txt b { font-size: 16px; color: #fff; font-family: var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tutor-txt small { color: #9AA3C7; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.live { width: 7px; height: 7px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: live 1.8s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(52,211,153,0); } }
.top-actions { display: flex; gap: 6px; }
.tool { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--glass-line); background: var(--glass); color: #DDE2F5; border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 700; transition: .15s; }
.tool svg { width: 17px; height: 17px; }
.tool:hover { background: rgba(255,255,255,.13); color: #fff; }
.stage { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 16px 18px 0; }
.rail { width: 248px; flex: none; display: flex; flex-direction: column; background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--r); padding: 16px; backdrop-filter: blur(10px); }
.rail-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; color: #9AA3C7; letter-spacing: .4px; margin-bottom: 12px; }
.rail-head b { background: rgba(247,171,41,.15); color: var(--gold-bright); border-radius: 99px; padding: 2px 9px; font-size: 12px; }
.steps { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; color: #9AA3C7; cursor: pointer; transition: .15s; animation: in .35s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.steps li:hover { background: rgba(255,255,255,.05); color: #fff; }
.steps li i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #4A557F; flex: none; margin-top: 3px; position: relative; }
.steps li.done { color: #C9CEE6; }
.steps li.done i { background: var(--gold); border-color: var(--gold); }
.steps li.done i::after { content: ''; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px; border: solid var(--navy-deep); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.steps li.now { background: rgba(255,255,255,.08); color: #fff; font-weight: 700; }
.steps li.now i { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(247,171,41,.18); }
.rail-foot { padding-top: 12px; border-top: 1px solid var(--glass-line); text-align: center; }
.rail-foot img { height: 26px; filter: brightness(0) invert(1); opacity: .55; }
.canvas-wrap { position: relative; flex: 1; min-width: 0; border-radius: 26px 26px 0 0; overflow: hidden; background: var(--paper); box-shadow: var(--shadow-lg); }
.scroller { position: absolute; inset: 0; overflow: auto; direction: ltr; cursor: grab; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.scroller.grabbing { cursor: grabbing; user-select: none; }
#board { display: block; width: 100%; min-width: 720px; user-select: none; padding-bottom: 150px;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(27,37,89,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(27,37,89,.045) 1px, transparent 1px);
  background-size: 28px 28px; }
#board .hand { font-family: 'Aref Ruqaa', var(--board); } /* خط يدوي عربي مثل كتابة المعلّم على السبورة */
#board .ui-text { font-family: var(--ui); }
#board .note { filter: drop-shadow(0 6px 14px rgba(27,37,89,.08)); }
#board .art-card { fill: none; stroke: none; }
#board .ph-box { fill: #F1EFE8; stroke: #E2DED2; stroke-width: 1.5; stroke-dasharray: 8 8; animation: phase 1.4s ease-in-out infinite alternate; }
#board .ph-text { font-size: 20px; fill: var(--faint); font-weight: 700; }
@keyframes phase { from { fill-opacity: .55; } to { fill-opacity: 1; } }
.pen { pointer-events: none; filter: drop-shadow(0 4px 6px rgba(17,23,53,.28)); }
.pen .pen-body { transform: rotate(30deg); transition: transform .14s ease; }
.pen.lift .pen-body { transform: translate(4px, -10px) rotate(24deg); }
.loading { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); padding: 9px 18px; border-radius: 99px; box-shadow: var(--shadow); z-index: 6; font-weight: 700; font-size: 14px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.caption { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 40px)); text-align: center;
  font-size: 16px; line-height: 1.7; color: #fff; background: rgba(12,17,41,.86); backdrop-filter: blur(10px); padding: 10px 18px; border-radius: 16px; z-index: 4; pointer-events: none; font-weight: 500; }
.caption:empty { display: none; }
.follow { position: absolute; bottom: 82px; left: 50%; transform: translateX(-50%); z-index: 6; border: 0; background: var(--navy); color: #fff;
  padding: 10px 18px; border-radius: 99px; font-weight: 700; box-shadow: 0 10px 24px rgba(27,37,89,.35); }
.dock-wrap { padding: 0 18px 14px; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 6; }
.dock-wrap::before { content: ''; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px; background: var(--glass-line); }
.player { display: flex; align-items: center; gap: 12px; padding: 10px 6px 0; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: var(--navy); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.play svg { width: 18px; height: 18px; }
.track { flex: 1; height: 6px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.track i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); transition: width .6s ease; }
.speed { border: 1px solid var(--glass-line); background: var(--glass); color: #fff; border-radius: 12px; padding: 0 12px; height: 36px; font-weight: 800; font-size: 13px; }
.speed:hover { border-color: var(--gold); }
.dock { width: 100%; max-width: none; }
.quiz { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); width: min(580px, calc(100% - 28px)); background: #fff; color: var(--body); border-radius: 26px; padding: 20px; z-index: 7;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: rise .35s cubic-bezier(.2,1.3,.4,1); }
@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }
.quiz-head { font-weight: 800; color: var(--navy); display: flex; justify-content: space-between; align-items: center; font-family: var(--display); font-size: 15px; }
.quiz-head small { color: #8A5A00; background: #FFF4DC; border-radius: 99px; padding: 2px 9px; margin-inline-start: 6px; font-family: var(--ui); }
.quiz .q { font-size: 18px; font-weight: 700; color: var(--ink); margin: 12px 0 14px; line-height: 1.7; }
.quiz .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz .opts button { font-size: 15px; padding: 12px; }
.quiz .explain { margin-top: 12px; font-size: 15px; line-height: 1.7; }
.quiz .explain:empty { display: none; }
.quiz .close { border: 0; background: #F1EFE8; color: var(--muted); width: 30px; height: 30px; border-radius: 50%; }
.followups, .followups-in { display: flex; gap: 8px; flex-wrap: wrap; }
.followups { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); justify-content: center; width: min(760px, calc(100% - 28px)); z-index: 5; }
.followups-in { margin-top: 14px; }
.followups button, .followups-in button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 9px 14px; font-size: 13.5px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow); transition: .15s; }
.followups button:hover, .followups-in button:hover { border-color: var(--gold); transform: translateY(-1px); }
#boardScreen.with-quiz #board { padding-bottom: 400px; }

.toast { position: fixed; top: 18px; left: 50%; transform: translate(-50%, -150%); opacity: 0; background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 14px; transition: transform .3s, opacity .3s; z-index: 50; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow-lg); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.xp-float { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--gold-bright), var(--gold)); color: var(--navy-deep); font-weight: 800; padding: 9px 18px; border-radius: 99px; z-index: 30; animation: floatUp 1.6s ease-out forwards; box-shadow: 0 10px 24px rgba(247,171,41,.45); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

@media (max-width: 1000px) { .rail { display: none; } .stage { padding: 10px 10px 0; } .dock-wrap { padding: 0 10px 10px; } }
@media (max-width: 560px) {
  .quiz .opts { grid-template-columns: 1fr; } .tool span { display: none; } .tutor-txt small { display: none; }
  .today { grid-template-columns: 1fr; } .logo { height: 30px; } .board-top { padding: 10px; }
}
@media print {
  .board-top, .ask-bar, .caption, .follow, .loading, .toast, .pen, .quiz, .followups, .rail, .dock-wrap { display: none !important; }
  .screen { height: auto; } .scroller { position: static; overflow: visible; } #board { min-width: 0; } #boardScreen { background: #fff; }
  .canvas-wrap { box-shadow: none; border-radius: 0; }
}

/* ===== صفحات التعريف (Onboarding) ===== */
.ob-screen { align-items: center; justify-content: center; padding: 20px; color: #fff;
  background: radial-gradient(900px 500px at 50% -120px, #2c3d92 0%, rgba(17,23,53,0) 70%), var(--night); }
.ob-screen.active { display: flex; }
.ob-card { width: min(520px, 100%); background: rgba(255,255,255,.06); border: 1px solid var(--glass-line); border-radius: 30px; padding: 26px 26px 22px; backdrop-filter: blur(16px); box-shadow: var(--shadow-lg); animation: rise .4s ease-out; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); transition: .25s; }
.ob-dots i.on { width: 26px; background: var(--gold); } .ob-dots i.done { background: rgba(247,171,41,.55); }
.ob-body { text-align: center; }
.ob-body h1 { color: #fff; font-size: clamp(24px, 5.5vw, 32px); margin: 6px 0 10px; line-height: 1.4; }
.ob-sub-en { font-size: .6em; color: #9AA3C7; font-family: 'Inter', var(--ui); font-weight: 600; }
.ob-p { color: #C9CEE6; line-height: 1.8; margin: 0 auto 18px; max-width: 400px; }
.ob-hero .orb.big { margin-bottom: 10px; }
.ob-choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0 6px; }
.ob-choices.two { display: grid; grid-template-columns: 1fr 1fr; }
.ob-choice { border: 1.5px solid var(--glass-line); background: var(--glass); color: #fff; border-radius: 20px; padding: 18px 12px; display: flex; flex-direction: column; gap: 6px; transition: .15s; }
.ob-choice b { font-size: 20px; } .ob-choice small { color: #9AA3C7; font-size: 12.5px; }
.ob-choice.on, .ob-chip.on, .ob-age.on { border-color: var(--gold); background: rgba(247,171,41,.14); box-shadow: 0 0 0 4px rgba(247,171,41,.12); }
.ob-chip { border: 1.5px solid var(--glass-line); background: var(--glass); color: #fff; border-radius: 99px; padding: 10px 16px; font-size: 15px; font-weight: 700; }
.ob-ages { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 10px 0; }
.ob-age { aspect-ratio: 1; border: 1.5px solid var(--glass-line); background: var(--glass); color: #fff; border-radius: 16px; font-size: 18px; font-weight: 800; }
.ob-label { color: #9AA3C7; font-size: 13px; margin: 14px 0 0; font-weight: 700; }
.ob-input { width: 100%; border: 1.5px solid var(--glass-line); background: rgba(255,255,255,.08); color: #fff; border-radius: 16px; padding: 15px 16px; font: inherit; font-size: 18px; text-align: center; outline: none; margin: 6px 0 4px; }
.ob-input:focus { border-color: var(--gold); }
.ob-feats { display: grid; gap: 10px; margin: 10px 0 6px; text-align: start; }
.ob-feats div { display: flex; align-items: center; gap: 12px; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px; padding: 12px 14px; color: #DDE2F5; font-weight: 600; }
.ob-feats svg { width: 22px; height: 22px; color: var(--gold); }
.ob-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 14px; }
.ob-summary div { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px; padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.ob-summary small { color: #9AA3C7; font-size: 12px; } .ob-summary b { color: #fff; font-size: 15px; }
.ob-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; }
.ob-back { border: 0; background: none; color: #9AA3C7; font-weight: 700; padding: 12px; }
.ob-next { border: 0; border-radius: 16px; padding: 14px 26px; font-size: 16px; font-weight: 800; color: var(--navy-deep); background: linear-gradient(135deg, var(--gold-bright), var(--gold)); box-shadow: 0 8px 22px rgba(247,171,41,.35); margin-inline-start: auto; }
.profile-pill { cursor: pointer; } .profile-pill b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .ob-ages { grid-template-columns: repeat(5, 1fr); } .ob-summary { grid-template-columns: 1fr; } }

/* ===== الإنجليزية ===== */
body.lang-en .ar-only { display: none !important; }
#board .hand { font-family: 'Patrick Hand', 'Aref Ruqaa', var(--board); } /* اللاتيني بخط يد إنجليزي، والعربي بالرقعة */
html[dir="ltr"] body { font-family: 'Inter', var(--ui); }
html[dir="ltr"] .send svg, html[dir="ltr"] .ob-next svg { transform: scaleX(-1); }

/* موافقة ولي الأمر */
.ob-age-input { font-size: 34px; font-weight: 800; letter-spacing: 2px; max-width: 200px; margin-inline: auto; display: block; }
.ob-code { font-size: 30px; letter-spacing: 10px; font-weight: 800; }
.ob-badge { display: inline-block; font-size: 12px; font-weight: 800; color: var(--gold-bright); background: rgba(247,171,41,.12); border: 1px solid rgba(247,171,41,.3); border-radius: 99px; padding: 4px 12px; margin-bottom: 8px; }
.ob-ok { display: inline-block; font-size: 13px; font-weight: 800; color: #34D399; background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3); border-radius: 99px; padding: 5px 12px; margin-bottom: 8px; }
.ob-agree { display: grid; gap: 8px; margin: 14px 0 4px; text-align: start; }
.ob-check { display: flex; gap: 10px; align-items: flex-start; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 14px; padding: 11px 12px; color: #DDE2F5; font-size: 13.5px; line-height: 1.7; cursor: pointer; }
.ob-check input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; margin-top: 3px; }
.ob-err { color: #FCA5A5; font-size: 14px; font-weight: 700; margin: 10px 0 0; }
.ob-dev { color: #FDE68A; font-size: 12.5px; background: rgba(253,230,138,.08); border: 1px dashed rgba(253,230,138,.35); border-radius: 12px; padding: 8px 10px; }
.ob-next:disabled { opacity: .6; }

/* =====================================================================
   هوية «اشرح لي / ExplainMate» — ثيم فاتح حسب دليل الهوية
   60% أبيض وسطوح، 30% نصوص، 10% نيلي، والأصفر لمسات فقط
   ===================================================================== */
:root {
  --navy: #4F46E5; --navy-deep: #1E1B4B; --royal: #4338CA; --night: #F5F5FF;
  --gold: #FACC15; --gold-bright: #FDE047;
  --paper: #FFFFFF; --canvas: #F5F5FF; --tint: #EEF0FF; --card: #fff;
  --ink: #1E1B4B; --body: #1E1B4B; --muted: #4B4A6B; --faint: #8584A6;
  --line: #E0E0F5; --line-strong: #CFCFEA; --success: #15803D; --danger: #DC2626;
  --glass: #FFFFFF; --glass-line: #E0E0F5;
  --ui: 'IBM Plex Sans Arabic', 'Rubik', system-ui, sans-serif;
  --display: 'Rubik', 'IBM Plex Sans Arabic', sans-serif;
  --r: 24px;
  --shadow: 0 1px 2px rgba(30,27,75,.05), 0 8px 24px rgba(30,27,75,.06);
  --shadow-lg: 0 2px 6px rgba(30,27,75,.06), 0 24px 60px rgba(30,27,75,.12);
}
html, body { background: var(--canvas); color: var(--ink); }
html[dir="ltr"] body { font-family: 'Rubik', var(--ui); }

/* الكرة: رمز الهوية على النيلي */
.orb { background: var(--navy); box-shadow: 0 8px 22px rgba(79,70,229,.35); color: #fff; }
.orb i { border-color: var(--navy); }
.orb > svg { width: 62%; height: 62%; }

/* الهيكل */
#shell { background: var(--canvas); }
.app-top { background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); }
.logo { filter: none; height: 34px; opacity: 1; }
.pill { background: var(--tint); color: var(--ink); border-color: var(--line); }
.pill svg { color: var(--navy); } .pill.streak svg { color: #EA580C; }
.tab-title { color: var(--ink); } .tab-sub { color: var(--muted); }
.tabbar { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.tabbar button { color: var(--faint); }
.tabbar button.active { color: var(--navy); background: var(--tint); }
.tabbar button.active svg { color: var(--navy); }
.badge-dot { box-shadow: 0 0 0 3px #fff; }

/* الرئيسية */
.hero { color: var(--ink); }
.hero h1 { color: var(--ink); }
.hero h1 em { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: var(--navy); }
.hero p { color: var(--muted); }
.greet { color: var(--navy); background: var(--tint); border-color: transparent; }
.styles { color: var(--muted); }
.styles button:not(.on) { background: #fff; color: var(--ink); border-color: var(--line); }
.styles button.on { background: var(--navy); border-color: var(--navy); }
.today-card.challenge { background: var(--navy); }
.today-card.challenge svg { color: var(--gold); background: rgba(255,255,255,.14); }
.today-card.review svg { color: var(--navy); background: var(--tint); }
.send { background: var(--navy); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.35); border-radius: 14px; }
.ask-bar { box-shadow: var(--shadow-lg); border-radius: 24px; }
.btn.primary { background: var(--navy); box-shadow: 0 8px 20px rgba(79,70,229,.25); }
.btn.gold { background: var(--gold); color: var(--ink); }
.subject:hover, .chip:hover, .card:hover { border-color: var(--navy); }
.card b, .deck b { color: var(--ink); }
.deck .go { background: var(--navy); }
.mastery i { background: linear-gradient(90deg, var(--navy), var(--success)); }
.week span.on i { background: var(--navy); } .week span.today i { outline-color: var(--gold); }
.back { background: var(--navy); } .rate .easy { background: var(--navy); }
.challenge-box .subj { background: var(--navy); }
.progress i { background: var(--navy); }

/* شاشة الشرح: هادئة، بيضاء، والنيلي للأزرار والأرقام */
#boardScreen { background: var(--canvas); color: var(--ink); }
.board-top { background: #fff; border-bottom: 1px solid var(--line); }
.tutor-txt b { color: var(--ink); } .tutor-txt small { color: var(--muted); }
.tool { background: #fff; color: var(--ink); border-color: var(--line); }
.tool:hover { background: var(--tint); color: var(--navy); }
.ib.dark { color: var(--muted); } .ib.dark:hover { background: var(--tint); color: var(--navy); }
.rail { background: #fff; border-color: var(--line); backdrop-filter: none; box-shadow: var(--shadow); }
.rail-head { color: var(--muted); }
.rail-head b { background: var(--tint); color: var(--navy); }
.steps li { color: var(--muted); }
.steps li:hover { background: var(--canvas); color: var(--ink); }
.steps li i { border-color: var(--line-strong); }
.steps li.done { color: var(--ink); }
.steps li.done i { background: var(--navy); border-color: var(--navy); }
.steps li.done i::after { border-color: #fff; }
.steps li.now { background: var(--tint); color: var(--ink); }
.steps li.now i { border-color: var(--navy); box-shadow: 0 0 0 4px rgba(79,70,229,.15); }
.rail-foot { border-top-color: var(--line); }
.rail-foot img { filter: none; opacity: .8; height: 24px; }
.canvas-wrap { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 24px 24px 0 0; }
#board { background-color: #fff; background-image: linear-gradient(rgba(79,70,229,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(79,70,229,.05) 1px, transparent 1px); }
.dock-wrap::before { background: var(--line); }
.play { background: var(--navy); color: #fff; box-shadow: 0 6px 18px rgba(79,70,229,.35); }
.track { background: var(--line); }
.track i { background: var(--navy); }
.speed { background: #fff; color: var(--ink); border-color: var(--line); }
.speed:hover { border-color: var(--navy); }
.caption { background: rgba(30,27,75,.88); }
.follow { background: var(--navy); }
.dots i { background: var(--navy); }
.quiz-head { color: var(--ink); }
.quiz-head small { background: var(--gold); color: var(--ink); }
.followups button:hover, .followups-in button:hover, .challenge-box .opts button:hover, .quiz .opts button:hover { border-color: var(--navy); }
.toast { background: var(--ink); }
.xp-float { background: var(--gold); color: var(--ink); box-shadow: 0 10px 24px rgba(250,204,21,.4); }
#board .ph-box { fill: var(--canvas); stroke: var(--line-strong); }

/* صفحات البداية */
.ob-screen { background: var(--canvas); color: var(--ink); }
.ob-card { background: #fff; border-color: var(--line); backdrop-filter: none; box-shadow: var(--shadow-lg); }
.ob-dots i { background: var(--line); } .ob-dots i.on { background: var(--navy); } .ob-dots i.done { background: rgba(79,70,229,.4); }
.ob-body h1 { color: var(--ink); font-family: var(--display); }
.ob-sub-en, .ob-p, .ob-label, .ob-back, .ob-summary small, .ob-choice small { color: var(--muted); }
.ob-choice, .ob-chip, .ob-age, .ob-feats div, .ob-summary div, .ob-check { background: #fff; color: var(--ink); border-color: var(--line); }
.ob-choice.on, .ob-chip.on, .ob-age.on { border-color: var(--navy); background: var(--tint); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.ob-summary b { color: var(--ink); }
.ob-feats svg { color: var(--navy); }
.ob-input { background: #fff; color: var(--ink); border-color: var(--line); }
.ob-input:focus { border-color: var(--navy); }
.ob-next { background: var(--navy); color: #fff; box-shadow: 0 8px 22px rgba(79,70,229,.3); border-radius: 14px; }
.ob-badge { color: var(--navy); background: var(--tint); border-color: transparent; }
.ob-ok { color: var(--success); background: #E9F7EE; border-color: #BFE5CC; }
.ob-check input { accent-color: var(--navy); }
.ob-err { color: var(--danger); }
.ob-dev { color: #8A5A00; background: #FFF8DB; border-color: #F5DC7A; }
/* إصلاحات التخطيط */
.tab { width: 100%; padding-inline: max(20px, calc((100% - 820px) / 2)); }
.ob-hero { margin-top: 22px; }
.hero .orb.big { margin-bottom: 22px; }
.greet { margin-top: 4px; }
