/* ===== اشرح لي — 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: 0; 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: 34px; }
.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; }

/* ===== الدخول ===== */
.ob-social { display: grid; gap: 10px; justify-items: center; margin: 6px 0; }
.ob-gbtn { min-height: 44px; }
.ob-google { width: 300px; max-width: 100%; height: 44px; border: 1px solid #DADCE0; border-radius: 99px; background: #fff; color: #1F1F1F; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.ob-google .g-logo { width: 18px; height: 18px; }
.ob-apple { width: 300px; max-width: 100%; height: 44px; border: 0; border-radius: 99px; background: #000; color: #fff; font-weight: 700; font-size: 15px; }
.ob-or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 13px; margin: 12px 0 10px; }
.ob-or::before, .ob-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.ob-seg { display: inline-flex; background: var(--canvas); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 10px; }
.ob-seg button { border: 0; background: none; padding: 8px 18px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.ob-seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* ===== النوافذ السفلية (اشتراك/حساب) ===== */
.sheet-wrap { position: fixed; inset: 0; background: rgba(30,27,75,.35); backdrop-filter: blur(3px); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { position: relative; width: min(560px, 100%); max-height: 92dvh; overflow-y: auto; background: #fff; border-radius: 28px 28px 0 0; padding: 26px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: up .3s cubic-bezier(.2,1,.4,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 28px; } }
.sheet-x { position: absolute; top: 14px; inset-inline-start: 14px; border: 0; background: var(--canvas); width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }
.pw-head { text-align: center; } .pw-head .orb { margin: 0 auto 10px; width: 54px; height: 54px; }
.pw-head h2 { margin: 6px 0; font-size: 21px; } .pw-head p { color: var(--muted); margin: 0 0 16px; line-height: 1.7; }
.pw-plans { display: grid; gap: 10px; }
.pw-plan { position: relative; border: 1.5px solid var(--line); border-radius: 20px; padding: 16px; display: grid; gap: 6px; }
.pw-plan.best { border-color: var(--navy); background: var(--tint); }
.pw-plan i { position: absolute; top: -11px; inset-inline-end: 16px; background: var(--gold); color: var(--ink); font-style: normal; font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 99px; }
.pw-plan b { font-family: var(--display); font-size: 17px; }
.pw-price { font-family: var(--display); font-size: 26px; font-weight: 800; color: var(--navy); } .pw-price small { font-size: 13px; color: var(--muted); font-weight: 600; }
.pw-plan ul { margin: 0; padding-inline-start: 18px; color: var(--muted); line-height: 1.8; font-size: 14px; }
.pw-note { text-align: center; color: var(--faint); font-size: 12.5px; margin: 12px 0 0; }
.btn:disabled { opacity: .55; }
.st-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.st-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.st-head b { display: block; font-size: 18px; } .st-head small { color: var(--muted); }
.st-card { border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; display: grid; gap: 10px; margin-bottom: 12px; }
.st-row { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; } .st-row span { color: var(--muted); }
.st-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; } .st-bar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.st-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.st-del { border: 0; background: none; color: var(--danger); font-weight: 700; }
.sheet-x { inset-inline-start: auto; inset-inline-end: 14px; z-index: 2; } .st-head { padding-inline-end: 44px; }
/* الجوال: مساحات آمنة، وسبورة بعرض مريح يتبع القلم */
.ob-card .ob-hero { margin-top: 34px; }
.app-top, .board-top { padding-top: max(10px, env(safe-area-inset-top)); }
@media (max-width: 700px) {
  .stage { padding: 8px 8px 0; } .canvas-wrap { border-radius: 18px 18px 0 0; }
  .dock-wrap { padding: 0 8px max(8px, env(safe-area-inset-bottom)); gap: 6px; }
  .player { padding-top: 6px; } .hero { padding-top: 18px; }
  .caption { font-size: 14px; bottom: 10px; }
}

/* الأدوات ونقاط الضعف */
.modes { display: flex; gap: 6px; justify-content: center; margin: 0 0 10px; flex-wrap: wrap; }
.modes button { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 99px; padding: 8px 16px; font-weight: 700; font-size: 14px; }
.modes button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.weak h2 { margin: 26px 0 12px; }
.weak-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.weak-list button { text-align: start; border: 1px solid #FBD5D5; background: #FFF7F7; border-radius: 18px; padding: 14px; display: grid; gap: 4px; }
.weak-list b { color: var(--ink); font-size: 15px; } .weak-list small { color: var(--danger); } .weak-list span { color: var(--navy); font-weight: 700; font-size: 13px; }
.cp-next { margin-top: 12px; }

/* =====================================================================
   الإصدار الفاخر: سطوح ناعمة، عمق خفيف، وتدرّجات نيلية محسوبة
   ===================================================================== */
:root {
  --grad: linear-gradient(135deg, #4F46E5 0%, #6D5BF2 55%, #7C3AED 100%);
  --grad-soft: linear-gradient(135deg, #EEF0FF 0%, #F5F0FF 100%);
  --shadow-xl: 0 1px 1px rgba(30,27,75,.04), 0 12px 32px rgba(30,27,75,.08), 0 40px 80px -30px rgba(79,70,229,.25);
  --ring: 0 0 0 4px rgba(79,70,229,.12);
}
/* خلفية الرئيسية: هالة نيلية هادئة أعلى الصفحة */
#shell { background:
  radial-gradient(700px 360px at 85% -60px, rgba(124,58,237,.12), transparent 70%),
  radial-gradient(800px 420px at 10% -80px, rgba(79,70,229,.14), transparent 70%), var(--canvas); }
.app-top { background: rgba(255,255,255,.75); backdrop-filter: saturate(1.4) blur(18px); }
.pill { background: #fff; box-shadow: var(--shadow); border-color: transparent; }
.hero { padding: 30px 0 22px; }
.hero h1 { font-size: clamp(32px, 6.4vw, 50px); letter-spacing: -.5px; }
.hero h1 em { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.orb.big { background: var(--grad); box-shadow: 0 18px 40px -8px rgba(79,70,229,.55), inset 0 1px 0 rgba(255,255,255,.35); }
.greet { background: #fff; box-shadow: var(--shadow); }
/* الأوضاع: شريط مقسّم أنيق */
.modes { display: inline-flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 5px; box-shadow: var(--shadow); margin: 0 auto 14px; }
#shell .modes { display: flex; width: fit-content; }
.modes button { border: 0; border-radius: 13px; padding: 9px 18px; background: transparent; color: var(--muted); transition: .2s; }
.modes button.on { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -4px rgba(79,70,229,.5); }
.ask-bar { border: 1px solid rgba(79,70,229,.14); box-shadow: var(--shadow-xl); padding: 8px; border-radius: 26px; }
.ask-bar:focus-within { border-color: rgba(79,70,229,.45); box-shadow: var(--shadow-xl), var(--ring); }
.send { background: var(--grad); border-radius: 16px; }
.styles button { padding: 7px 15px; }
.styles button.on { background: var(--ink); border-color: var(--ink); }
/* بطاقات اليوم */
.today-card { border-radius: 26px; padding: 20px; box-shadow: var(--shadow-xl); position: relative; overflow: hidden; }
.today-card.challenge { background: var(--grad); }
.today-card.challenge::after { content: ''; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.1); inset-inline-end: -60px; top: -70px; }
.today-card.review { background: #fff; border: 1px solid var(--line); }
.today-card svg { border-radius: 16px; }
/* المواد */
.tab h2 { font-size: 18px; margin: 32px 0 14px; display: flex; align-items: center; gap: 8px; }
.tab h2::before { content: ''; width: 5px; height: 18px; border-radius: 9px; background: var(--grad); }
.subjects { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.subject { border-radius: 24px; padding: 20px 10px 16px; border-color: transparent; box-shadow: var(--shadow); background: linear-gradient(#fff, #fff) padding-box, linear-gradient(135deg, rgba(79,70,229,.14), rgba(124,58,237,.06)) border-box; border: 1px solid transparent; }
.subject:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); }
.subject svg { width: 54px; height: 54px; padding: 10px; border-radius: 18px; background: var(--grad-soft); box-sizing: content-box; }
.chip { border-color: transparent; }
/* شريط التنقل */
.tabbar { border-radius: 26px; background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(18px); border: 1px solid rgba(79,70,229,.1); box-shadow: 0 20px 50px -12px rgba(30,27,75,.25); }
.tabbar button.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -6px rgba(79,70,229,.6); }
.tabbar button.active svg { color: #fff; }

/* ===== سبوراتي: بطاقة كأنها سبورة صغيرة ===== */
.saved { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.bcard { padding: 0; overflow: hidden; border-radius: 24px; border: 1px solid var(--line); box-shadow: var(--shadow); text-align: start; }
.bcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); border-color: rgba(79,70,229,.3); }
.bc-paper { position: relative; height: 128px; padding: 18px 20px; background-color: #fff;
  background-image: linear-gradient(rgba(79,70,229,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(79,70,229,.07) 1px, transparent 1px); background-size: 18px 18px;
  border-bottom: 1px solid var(--line); overflow: hidden; }
.bc-paper::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(var(--c1), var(--c2)); }
.bc-hand { display: block; font-family: 'Aref Ruqaa', var(--ui); font-size: 26px; line-height: 1.35; color: var(--c1); max-height: 72px; overflow: hidden; }
html[dir="ltr"] .bc-hand { font-family: 'Patrick Hand', var(--ui); }
.bc-line { display: block; height: 4px; width: 62%; border-radius: 9px; background: var(--c2); opacity: .22; margin-top: 10px; }
.bc-line.s { width: 38%; opacity: .14; }
.bc-ink { position: absolute; bottom: 10px; inset-inline-end: 12px; width: 30px; height: 30px; border-radius: 50%; background: #FFF8D6; display: grid; place-items: center; color: #A16207; }
.bc-ink svg { width: 16px; height: 16px; }
.bc-meta { padding: 14px 18px 16px; }
.bc-meta b { font-size: 15.5px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcard .del { top: 10px; inset-inline-end: 12px; left: auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.9); box-shadow: var(--shadow); opacity: 0; transition: .15s; }
.bcard:hover .del { opacity: 1; }
@media (hover: none) { .bcard .del { opacity: 1; } }
.search { border-radius: 18px; border-color: transparent; box-shadow: var(--shadow); }

/* ===== البطاقات: مجموعات كأنها رزم ===== */
#reviewAll { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--grad); border-radius: 18px; padding: 16px; font-size: 16px; }
#reviewAll svg { width: 20px; height: 20px; color: var(--gold); }
#reviewAll:disabled { background: var(--line); color: var(--muted); }
.decks { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 20px; }
.deck2 { background: #fff; border-radius: 26px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; transition: .2s; }
.deck2:hover { box-shadow: var(--shadow-xl); transform: translateY(-3px); }
.deck-cover { position: relative; height: 150px; margin: 6px 8px 18px; cursor: pointer; }
.deck-cover > i { position: absolute; inset: 0; border-radius: 20px; background: linear-gradient(135deg, var(--c1), var(--c2)); opacity: .25; transform: rotate(-4deg) translateY(6px); }
.deck-cover > i + i { opacity: .45; transform: rotate(2.5deg) translateY(3px); }
.deck-face { position: absolute; inset: 0; border-radius: 20px; background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 14px 30px -10px var(--c1); overflow: hidden; }
.deck-face::after { content: ''; position: absolute; width: 140px; height: 140px; border-radius: 50%; border: 22px solid rgba(255,255,255,.1); inset-inline-end: -40px; bottom: -50px; }
.deck-face b { font-family: var(--display); font-size: 19px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.deck-face small { opacity: .85; font-weight: 700; }
.deck-info { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.deck-txt { flex: 1; display: grid; gap: 2px; } .deck-txt small { color: var(--muted); font-size: 12px; }
.deck-txt .due { color: #B45309; font-weight: 800; font-size: 13px; } .deck-txt .ok { color: var(--success); font-weight: 800; font-size: 13px; }
.deck2 .go { border: 0; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 18px; font-weight: 800; }
.deck2 .x { border: 0; background: none; color: var(--faint); font-size: 20px; }
.ring { --p: 0; width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: radial-gradient(closest-side, #fff 78%, transparent 80% 100%), conic-gradient(var(--navy) calc(var(--p) * 1%), var(--line) 0); }
.ring span { font-size: 12px; font-weight: 800; color: var(--ink); }
.ring.big { width: 130px; height: 130px; margin: 0 auto 6px; } .ring.big span { font-size: 30px; font-family: var(--display); }
.deck-empty { display: grid; justify-items: center; gap: 6px; padding: 36px 24px; }
.deck-empty b { color: var(--ink); font-size: 17px; }
.stack-art { position: relative; width: 120px; height: 86px; margin-bottom: 12px; }
.stack-art i { position: absolute; inset: 0; border-radius: 16px; background: var(--grad); opacity: .2; transform: rotate(-7deg); }
.stack-art i + i { opacity: .4; transform: rotate(4deg); } .stack-art i + i + i { opacity: 1; transform: none; }

/* ===== شاشة المراجعة ===== */
#reviewScreen { background: radial-gradient(900px 500px at 50% -10%, rgba(79,70,229,.12), transparent 70%), var(--canvas); }
.rv-top { display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 10px; }
.rv-title { flex: 1; display: grid; justify-items: center; gap: 2px; min-width: 0; }
.rv-title b { font-family: var(--display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rv-title small { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.rv-score { display: flex; gap: 6px; }
.rv-score span { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 99px; font-weight: 800; font-size: 13px; background: #fff; box-shadow: var(--shadow); }
.rv-score svg { width: 15px; height: 15px; } .rv-score .ok { color: var(--success); } .rv-score .no { color: #DC2626; }
#reviewScreen .progress { height: 6px; margin: 0 16px; border-radius: 9px; background: var(--line); overflow: hidden; }
#reviewScreen .progress i { background: var(--grad); border-radius: 9px; }
.flash-stack { position: relative; width: min(560px, 100%); }
.flash-stack::before, .flash-stack::after { content: ''; position: absolute; inset: 0; border-radius: 30px; background: #fff; box-shadow: var(--shadow); }
.flash-stack::before { transform: translateY(18px) scale(.92); opacity: .6; } .flash-stack::after { transform: translateY(9px) scale(.96); opacity: .85; }
.flash { --c1: #4F46E5; --c2: #7C3AED; width: 100%; height: min(380px, 54vh); z-index: 2; transition: transform .25s ease, opacity .25s; touch-action: pan-y; }
.flash.fly-right { transform: translateX(120%) rotate(14deg) !important; opacity: 0; }
.flash.fly-left { transform: translateX(-120%) rotate(-14deg) !important; opacity: 0; }
.face { border-radius: 30px; padding: 26px 28px; justify-content: center; box-shadow: var(--shadow-xl); }
.face-top { position: absolute; top: 18px; inset-inline: 20px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.face small { position: static; font-size: 12px; letter-spacing: .4px; text-transform: uppercase; }
.deck-chip { font-size: 12px; font-weight: 800; padding: 5px 11px; border-radius: 99px; background: color-mix(in srgb, var(--c1) 10%, #fff); color: var(--c1); max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-chip.light { background: rgba(255,255,255,.16); color: #fff; }
.face-text { font-family: var(--display) !important; font-weight: 700 !important; font-size: clamp(22px, 4.8vw, 31px) !important; line-height: 1.6 !important; max-height: 70%; overflow-y: auto; }
.front { background: #fff; color: var(--ink); border: 1px solid var(--line);
  background-image: radial-gradient(circle at 100% 0, color-mix(in srgb, var(--c1) 9%, transparent) 0 120px, transparent 121px); }
.front small { color: var(--faint); }
.back { background: linear-gradient(140deg, var(--c1), var(--c2)); color: #fff; overflow: hidden; }
.back::after { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; border: 30px solid rgba(255,255,255,.08); inset-inline-start: -70px; bottom: -90px; }
.back .face-text { font-family: var(--ui) !important; font-weight: 600 !important; }
.back small { color: rgba(255,255,255,.75); }
.hint { display: inline-flex; align-items: center; gap: 6px; bottom: 18px; font-weight: 700; color: var(--faint); }
.hint svg { width: 16px; height: 16px; color: var(--gold); }
.back .hint { color: rgba(255,255,255,.7); }
.flash[data-lean="right"] .back { box-shadow: 0 0 0 4px #22C55E, var(--shadow-xl); }
.flash[data-lean="left"] .back { box-shadow: 0 0 0 4px #F87171, var(--shadow-xl); }
.rate { width: min(560px, 100%); gap: 10px; margin-top: 18px; }
.rate button { display: grid; gap: 2px; padding: 12px 4px; border-radius: 18px; border: 1px solid transparent; box-shadow: var(--shadow); transition: .15s; }
.rate button:hover { transform: translateY(-2px); }
.rate button b { font-size: 14.5px; } .rate button small { font-size: 11.5px; font-weight: 700; opacity: .75; }
.rate .again { background: #FFF1F1; color: #B91C1C; border-color: #FBD5D5; }
.rate .hard { background: #FFF8E6; color: #92400E; border-color: #FDE7B0; }
.rate .good { background: #EEFBF2; color: #166534; border-color: #C7EED3; }
.rate .easy { background: var(--grad); color: #fff; }
#explainCard { display: inline-flex; align-items: center; gap: 8px; border-radius: 99px; padding: 11px 18px; box-shadow: var(--shadow); }
#explainCard svg { width: 18px; height: 18px; color: var(--navy); }
.done-box { background: #fff; border-radius: 30px; padding: 30px 26px; box-shadow: var(--shadow-xl); width: min(440px, 100%); }
.done-box p { color: var(--muted); line-height: 1.8; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 20px; }
.done-stats span { display: grid; gap: 2px; background: var(--canvas); border-radius: 16px; padding: 12px 6px; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.done-stats b { font-family: var(--display); font-size: 22px; color: var(--ink); } .done-stats .ok b { color: var(--success); } .done-stats .no b { color: #DC2626; }

/* ===== أدوات السبورة ===== */
.board-tools { position: absolute; top: 14px; left: 14px; z-index: 6; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 20px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border: 1px solid var(--line); box-shadow: var(--shadow-xl); }
html[dir="ltr"] .board-tools { left: auto; right: 14px; }
.board-tools > button { width: 40px; height: 40px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); display: grid; place-items: center; transition: .15s; }
.board-tools > button svg { width: 20px; height: 20px; }
.board-tools > button:hover { background: var(--tint); color: var(--navy); }
.board-tools > button.on { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -4px rgba(79,70,229,.6); }
.board-tools .sep { height: 1px; background: var(--line); margin: 2px 6px; }
.swatches { display: grid; gap: 6px; justify-items: center; padding: 4px 0 2px; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
#board.tool-on { cursor: crosshair; touch-action: none; }
#board[data-tool="erase"] { cursor: cell; }
#board .user-ink path { pointer-events: none; }
#board[data-tool="erase"] .user-ink path { pointer-events: stroke; }
#board .ink-hl { mix-blend-mode: multiply; }
#board .sel-rect { fill: rgba(79,70,229,.06); stroke: #4F46E5; stroke-width: 2.5; stroke-dasharray: 9 7; animation: march .8s linear infinite; }
@keyframes march { to { stroke-dashoffset: -16; } }
.sel-ask { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 8px; box-shadow: var(--shadow-xl); animation: rise .3s cubic-bezier(.2,1.3,.4,1); width: max-content; max-width: calc(100% - 90px); }
.sel-ask b { font-size: 13px; color: var(--muted); padding: 0 6px; }
.sel-ask button { border: 0; background: var(--tint); color: var(--navy); border-radius: 13px; padding: 9px 13px; font-weight: 800; font-size: 13.5px; }
.sel-ask button:first-of-type { background: var(--grad); color: #fff; }
.sel-ask .x { background: none; color: var(--faint); }
@media (max-width: 700px) {
  .board-tools { flex-direction: row; top: auto; bottom: 10px; left: 50% !important; right: auto !important; transform: translateX(-50%); padding: 5px; border-radius: 18px; }
  .board-tools .sep { width: 1px; height: auto; margin: 6px 2px; }
  .swatches { grid-auto-flow: column; padding: 0 4px; align-items: center; }
  .board-tools > button { width: 38px; height: 38px; }
  .caption { bottom: 64px; }
  .sel-ask { max-width: calc(100% - 20px); }
}

/* ===== الطباعة: ورقة شرح أنيقة ===== */
#printView { display: none; }
@page { size: A4; margin: 14mm 13mm 16mm;
  @bottom-center { content: "اشرح لي · explainmate.io — " counter(page) " / " counter(pages); font: 600 9pt 'IBM Plex Sans Arabic', sans-serif; color: #8584A6; } }
@media print {
  body > *:not(#printView) { display: none !important; }
  html, body { background: #fff !important; height: auto; }
  #printView { display: block; color: #1E1B4B; font-family: var(--ui); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pv-head { position: relative; border-radius: 18px; padding: 18px 22px 16px; margin-bottom: 14px; color: #1E1B4B;
    background: linear-gradient(135deg, #EEF0FF, #F6F1FF); border: 1px solid #E0E0F5; overflow: hidden; }
  .pv-head::after { content: ''; position: absolute; inset-inline-end: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%; border: 26px solid rgba(79,70,229,.08); }
  .pv-brand { display: flex; justify-content: space-between; align-items: center; }
  .pv-brand img { height: 26px; }
  .pv-brand span { font-size: 9.5pt; font-weight: 800; color: #4F46E5; background: #fff; border-radius: 99px; padding: 3px 10px; }
  .pv-head h1 { font-family: 'Rubik', var(--ui); font-size: 22pt; margin: 12px 0 10px; color: #1E1B4B; line-height: 1.35; }
  .pv-meta { display: flex; flex-wrap: wrap; gap: 8px; }
  .pv-meta span { background: #fff; border: 1px solid #E0E0F5; border-radius: 12px; padding: 5px 12px; display: grid; }
  .pv-meta small { font-size: 7.5pt; color: #8584A6; font-weight: 700; } .pv-meta b { font-size: 10pt; }
  .pv-path { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: st; }
  .pv-path li { counter-increment: st; font-size: 9pt; font-weight: 700; color: #4B4A6B; background: rgba(255,255,255,.7); border-radius: 99px; padding: 3px 10px 3px 4px; }
  .pv-path li::before { content: counter(st); display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #4F46E5; color: #fff; font-size: 8pt; margin-inline-end: 6px; }
  .pv-board { display: grid; gap: 4mm; }
  .pv-sec { display: block; width: 100%; height: auto; break-inside: avoid; page-break-inside: avoid; border-radius: 10px; }
  .pv-sec .hand { font-family: 'Aref Ruqaa', var(--board); }
  html[dir="ltr"] .pv-sec .hand { font-family: 'Patrick Hand', 'Aref Ruqaa', var(--board); }
  .pv-sec .ph-box, .pv-sec .ph-text { display: none; }
  .pv-quiz, .pv-notes { break-inside: avoid; border: 1px solid #E0E0F5; border-radius: 16px; padding: 14px 18px; margin-top: 6mm; }
  .pv-quiz h2, .pv-notes h2 { font-family: 'Rubik', var(--ui); font-size: 13pt; margin: 0 0 10px; color: #4F46E5; }
  .pv-q { margin-bottom: 10px; } .pv-q b { font-size: 11pt; }
  .pv-q ol { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
  .pv-q li { font-size: 10.5pt; display: flex; align-items: center; gap: 8px; }
  .pv-q li i { width: 12px; height: 12px; border: 1.5px solid #4F46E5; border-radius: 50%; flex: none; }
  .pv-key { font-size: 8.5pt; color: #8584A6; border-top: 1px dashed #E0E0F5; padding-top: 8px; margin: 6px 0 0; transform: rotate(180deg); text-align: center; }
  .pv-notes i { display: block; height: 9mm; border-bottom: 1px solid #E0E0F5; }
  .pv-foot { display: flex; align-items: center; gap: 8px; margin-top: 8mm; padding-top: 8px; border-top: 1px solid #E0E0F5; font-size: 9pt; color: #8584A6; }
  .pv-foot img { width: 18px; height: 18px; } .pv-foot b { margin-inline-start: auto; color: #4F46E5; }
}
.deck-txt .due, .deck-txt .ok { white-space: nowrap; }
.deck-info { flex-wrap: nowrap; } .deck-txt { min-width: 0; }
/* بلاغ الخطأ */
.tool.icon-only { padding: 8px 10px; }
.rp-label { font-weight: 800; font-size: 14px; margin: 16px 0 8px; color: var(--ink); }
.rp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-chips button { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 9px 14px; font-weight: 700; font-size: 14px; color: var(--ink); }
.rp-chips button.on { border-color: var(--navy); background: var(--tint); color: var(--navy); }
.rp-note { width: 100%; min-height: 90px; margin: 14px 0; border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; font: inherit; font-size: 15px; resize: vertical; outline: none; }
.rp-note:focus { border-color: var(--navy); }

/* ===== صور الكتاب المدرسي على السبورة ===== */
#board .bookfig .art-card { fill: #fff; stroke: #E0E7FF; stroke-width: 2; filter: drop-shadow(0 6px 14px rgba(79,70,229,.10)); }
#board .bookfig .cite { font-size: 19px; fill: #6366F1; font-weight: 600; }

/* ===== كتبي: مواد الصف ===== */
.subjects.books { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.book-subject { position: relative; overflow: hidden; gap: 6px !important; }
.book-subject::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: var(--c); }
.book-subject svg { background: color-mix(in srgb, var(--c) 14%, #fff) !important; }
.book-subject small { color: var(--muted); font-weight: 500; font-size: 12px; }
.book-subject .bar { display: block; width: 70%; height: 5px; border-radius: 9px; background: #EEF2FF; overflow: hidden; }
.book-subject .bar i { display: block; height: 100%; background: var(--c); border-radius: 9px; }

#subjectScreen { overflow-y: auto; background: #F7F7FF; padding-bottom: 40px; }
#subjectScreen .sj-top { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 16%, #fff), #fff); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
#subjectScreen .sj-top .back { color: var(--ink); background: #fff; box-shadow: var(--shadow); }
#subjectScreen .back svg { width: 22px; height: 22px; }
html[dir="ltr"] #subjectScreen .back svg { transform: none; }
html[dir="rtl"] #subjectScreen .back svg { transform: scaleX(-1); }
#subjectScreen .sj-id { display: flex; align-items: center; gap: 12px; }
#subjectScreen .sj-id > svg { width: 44px; height: 44px; padding: 8px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
#subjectScreen h1 { font-size: 22px; margin: 0; }
#subjectScreen .sj-id small { color: var(--muted); font-size: 13px; }
#subjectScreen .sj-parts { display: flex; gap: 6px; margin: 16px auto 4px; padding: 5px; background: #EEF2FF; border-radius: 16px; width: fit-content; }
#subjectScreen .sj-parts button { border: 0; background: transparent; font: inherit; font-weight: 700; color: var(--muted); padding: 9px 18px; border-radius: 12px; cursor: pointer; }
#subjectScreen .sj-parts button.on { background: #fff; color: var(--c); box-shadow: var(--shadow); }
#subjectScreen .sj-units { max-width: 860px; margin: 0 auto; padding: 0 16px; }
#subjectScreen .sj-unit h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 26px 0 12px; }
#subjectScreen .sj-unit h2 span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--c); color: #fff; font-size: 15px; flex: none; }
#subjectScreen .sj-lessons { display: grid; gap: 10px; }
#subjectScreen .sj-lesson { display: flex; align-items: center; gap: 14px; text-align: start; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 10px; font: inherit; color: var(--ink); cursor: pointer; box-shadow: 0 2px 10px rgba(30,27,75,.04); transition: .16s; }
#subjectScreen .sj-lesson:hover { transform: translateY(-2px); border-color: var(--c); box-shadow: var(--shadow); }
#subjectScreen .sj-thumb { width: 84px; height: 70px; border-radius: 14px; overflow: hidden; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 10%, #fff); }
#subjectScreen .sj-thumb img { width: 100%; height: 100%; object-fit: cover; }
#subjectScreen .sj-thumb svg { width: 40px; height: 40px; }
#subjectScreen .sj-txt { flex: 1; min-width: 0; }
#subjectScreen .sj-txt b { display: block; font-size: 16px; }
#subjectScreen .sj-txt p { margin: 2px 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; }
#subjectScreen .sj-txt small { font-size: 12px; color: color-mix(in srgb, var(--c) 80%, #000); font-weight: 600; }
#subjectScreen .sj-go { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; flex: none; }
#subjectScreen .sj-go svg { width: 18px; height: 18px; }
#subjectScreen .sj-lesson.done .sj-go { background: #10B981; }

/* ===== أسئلة بالصور للصغار ===== */
.quiz .opts.pics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.quiz .opts.pics button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 10px 10px; border-radius: 22px; background: #fff; }
.quiz .opts.pics button:hover { transform: translateY(-3px) scale(1.02); }
.opt-art { display: grid; place-items: center; width: 100%; height: 110px; border-radius: 16px; background: #F5F5FF; overflow: hidden; }
.opt-pic { max-width: 100%; max-height: 110px; object-fit: contain; }
.opt-svg { width: 100px; height: 100px; }
.opt-icons { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4px; padding: 6px; }
.opt-icons svg { width: 40px; height: 40px; }
.opt-icons.n1 svg { width: 84px; height: 84px; } .opt-icons.n2 svg { width: 64px; height: 64px; } .opt-icons.n3 svg, .opt-icons.n4 svg { width: 48px; height: 48px; }
.opt-icons.n7 svg, .opt-icons.n8 svg, .opt-icons.n9 svg, .opt-icons.n10 svg { width: 30px; height: 30px; }
.opt-txt { font-size: 17px; font-weight: 800; }

/* ===== ولد / بنت في صفحات البداية ===== */
.ob-gender .ob-choice { align-items: center; }
.ob-gender .g-ico { font-size: 40px; line-height: 1; }

/* ===== الإعدادات: الجنس وصوت المعلم ===== */
.st-seg { display: flex; gap: 4px; background: #EEF2FF; padding: 4px; border-radius: 12px; }
.st-seg button { border: 0; background: transparent; font: inherit; font-weight: 700; color: var(--muted); padding: 6px 16px; border-radius: 9px; cursor: pointer; }
.st-seg button.on { background: #fff; color: var(--navy, #4F46E5); box-shadow: var(--shadow); }
.st-voices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.st-voice { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 12px 14px; font: inherit; color: var(--ink); cursor: pointer; text-align: start; transition: .15s; }
.st-voice.on { border-color: #4F46E5; background: #EEF2FF; box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.st-voice i { font-style: normal; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.st-voice i.f { background: #FCE7F3; color: #BE185D; } .st-voice i.m { background: #E0F2FE; color: #0369A1; }
.st-voice b { font-size: 16px; }
.st-play { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #4F46E5; color: #fff; }
.st-play svg { width: 14px; height: 14px; }

/* تكبير السبورة: السبورة بعرض الشاشة دائمًا، والتكبير اختياري */
.zoombar { position: absolute; top: 12px; right: 12px; z-index: 6; display: flex; flex-direction: column; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 18px rgba(30,27,75,.10); overflow: hidden; backdrop-filter: blur(6px); }
.zoombar button { width: 38px; height: 38px; border: 0; background: none; color: var(--ink); font: 700 22px/1 var(--ui); cursor: pointer; }
.zoombar button + button { border-top: 1px solid var(--line); }
.zoombar button:disabled { opacity: .3; cursor: default; }
@media (max-width: 700px) { .zoombar { top: 8px; right: 8px; } .zoombar button { width: 34px; height: 34px; font-size: 20px; } }
@media print { .zoombar { display: none !important; } }

/* الترجيع والتقديم: الجزء الفاتح = ما شاهده الطالب ويقدر ينتقل له */
.track { position: relative; height: 8px; }
.track i { position: absolute; inset: 0 auto 0 0; }
[dir="rtl"] .track i { inset: 0 0 0 auto; }
.track i.seen { background: rgba(79,70,229,.22) !important; transition: width .3s; }
.track.seekable { cursor: pointer; }
.track.seekable:hover { transform: scaleY(1.4); }
.ib.seek { width: 36px; height: 36px; color: var(--navy); }
.ib.seek svg { width: 16px; height: 16px; }
[dir="rtl"] .ib.seek svg { transform: scaleX(-1); }
.ib.seek:disabled { opacity: .3; cursor: default; }

/* رفع الدرس: كاميرا / صور / PDF */
.pick-h { margin: 0 0 14px; font-size: 19px; color: var(--ink); }
.pick-opts { display: grid; gap: 10px; }
.pick-opts button { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: start; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; cursor: pointer; font: inherit; color: var(--ink); }
.pick-opts button:hover { border-color: var(--navy); background: #F7F7FF; }
.pick-i { grid-row: 1 / span 2; width: 48px; height: 48px; border-radius: 14px; background: #EEF2FF; color: var(--navy); display: grid; place-items: center; }
.pick-i svg { width: 24px; height: 24px; }
.pick-opts b { font-size: 16px; } .pick-opts small { color: var(--muted); font-size: 13px; }
.pick-p { color: var(--muted); line-height: 1.7; margin: 0 0 14px; }
.pick-range { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick-range label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.pick-range input { font: 700 20px var(--ui); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; text-align: center; color: var(--ink); }
.pick-note { margin: 12px 0 14px; font-size: 14px; color: var(--navy); font-weight: 600; } .pick-note.bad { color: var(--danger); }
[data-ask] .field { position: relative; }
[data-ask] .field[data-count]::after { content: attr(data-count); position: absolute; inset-inline-start: 28px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--navy); color: #fff; font: 700 12px/20px var(--ui); text-align: center; pointer-events: none; }
.st-hint { color: var(--muted); font-size: 12px; }

/* ===== رئيسية أكثر مرحًا ===== */
.hero { position: relative; isolation: isolate; }
.doodles { position: absolute; inset: 0 -10px; pointer-events: none; z-index: -1; }
.doodles .d { position: absolute; width: 34px; height: 34px; opacity: .85; animation: floaty 6s ease-in-out infinite; }
.doodles .d1 { top: 10px; right: 14%; width: 40px; height: 40px; }
.doodles .d2 { top: 112px; left: 9%; animation-delay: -1s; animation-duration: 7s; }
.doodles .d3 { top: 6px; left: 22%; animation-delay: -2s; }
.doodles .d4 { top: 140px; right: 6%; width: 24px; height: 24px; animation-delay: -3s; animation-duration: 8s; }
.doodles .d5 { top: 70px; right: 2%; width: 50px; height: 26px; animation-delay: -1.5s; }
.doodles .d6 { top: 120px; right: 24%; width: 20px; height: 20px; animation-delay: -4s; }
.doodles .d7 { top: 44px; left: 4%; width: 42px; height: 42px; animation: spinny 18s linear infinite; }
.doodles .d8 { top: 0; right: 30%; width: 34px; height: 34px; animation-delay: -2.5s; }
@media (min-width: 900px) { .doodles .d1 { right: 30%; } .doodles .d3 { left: 31%; } .doodles .d2 { left: 30%; } .doodles .d6 { right: 33%; } .doodles .d7 { left: 25%; } .doodles .d4 { right: 26%; } .doodles .d5 { right: 23%; } .doodles .d8 { right: 37%; } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-12px) rotate(8deg); } }
@keyframes spinny { to { transform: rotate(360deg); } }
.orb.big { cursor: pointer; }
.orb.boing { animation: boing .6s cubic-bezier(.3,1.8,.5,1); }
@keyframes boing { 0% { transform: scale(1); } 30% { transform: scale(.86, 1.12); } 60% { transform: scale(1.1, .92); } 100% { transform: scale(1); } }
.greet { background: #FEF9C3; border-color: #FDE68A; color: #854D0E; }

.fun-strip { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin: 20px 0 12px; }
.fun-card { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.fun-txt { display: grid; gap: 2px; min-width: 0; }
.fun-txt small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fun-txt b { font-family: var(--display); font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-badge { position: relative; flex: none; width: 46px; height: 46px; display: grid; place-items: center; }
.lvl-badge svg { position: absolute; inset: 0; width: 46px; height: 46px; color: var(--gold); fill: var(--gold); animation: twinkle 2.6s ease-in-out infinite; }
.lvl-badge b { position: relative; font: 800 15px var(--display); color: #713F12; }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.08) rotate(-6deg); } }
.lvl-bar { display: block; height: 6px; border-radius: 9px; background: #EEF2FF; overflow: hidden; margin: 3px 0 1px; }
.lvl-bar i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, #4F46E5, #8B5CF6); }
.goal { position: relative; }
.ring { width: 50px; height: 50px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: #EEF2FF; } .ring .fg { stroke: #10B981; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-n { position: absolute; inset-inline-start: 12px; width: 50px; text-align: center; font: 800 12px var(--display); color: var(--ink); }
.goal.done { background: linear-gradient(135deg, #ECFDF5, #fff); border-color: #A7F3D0; }
.flame { width: 46px; height: 46px; flex: none; border-radius: 16px; display: grid; place-items: center; background: #F1F5F9; color: #94A3B8; }
.flame svg { width: 26px; height: 26px; }
.fire.on .flame { background: linear-gradient(160deg, #FFEDD5, #FEF3C7); color: #F97316; }
.fire.on .flame svg { animation: flicker 1.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.12, 1.06) rotate(3deg); } }

.continue-card { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 12px; padding: 12px 14px; border: 0; border-radius: 20px; text-align: start; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(120deg, #4F46E5 0%, #7C3AED 60%, #EC4899 130%); box-shadow: 0 10px 26px rgba(79,70,229,.28); transition: transform .15s; }
.continue-card:hover { transform: translateY(-2px); }
.continue-card div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.continue-card small { opacity: .85; font-size: 12px; }
.continue-card b { font: 700 16px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-play { width: 44px; height: 44px; flex: none; border-radius: 50%; background: #fff; color: #4F46E5; display: grid; place-items: center; animation: pulse 2s ease-in-out infinite; }
.cc-play svg { width: 18px; height: 18px; }
.cc-go svg { width: 20px; height: 20px; opacity: .8; }
[dir="rtl"] .cc-go svg { transform: scaleX(-1); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.55); } 50% { box-shadow: 0 0 0 10px rgba(255,255,255,0); } }

.subject.book-subject { background: linear-gradient(170deg, color-mix(in srgb, var(--c) 12%, #fff) 0%, #fff 70%); transition: transform .2s cubic-bezier(.3,1.6,.5,1), box-shadow .2s; }
.subject.book-subject:nth-child(odd) { --tilt: -1.2deg; } .subject.book-subject:nth-child(even) { --tilt: 1.2deg; }
.subject.book-subject:hover { transform: translateY(-4px) rotate(var(--tilt)); box-shadow: 0 14px 30px color-mix(in srgb, var(--c) 25%, transparent); }
.subject.book-subject:hover > svg { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.08); } 75% { transform: rotate(8deg) scale(1.08); } }

.curious-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.curious-more { border: 1px solid var(--line); background: #fff; color: var(--navy); font: 700 13px var(--ui); padding: 7px 14px; border-radius: 99px; cursor: pointer; }
.curious-more:hover { background: #EEF2FF; }
.curious { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
.curious-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 20px; text-align: start; font: inherit; cursor: pointer; color: var(--ink);
  border: 2px dashed color-mix(in srgb, var(--c) 35%, transparent); background: color-mix(in srgb, var(--c) 7%, #fff); transform: rotate(var(--r)); transition: transform .2s cubic-bezier(.3,1.6,.5,1), background .2s; }
.curious-card:hover { transform: rotate(0) scale(1.03); background: color-mix(in srgb, var(--c) 13%, #fff); }
.curious-card b { font-size: 15px; line-height: 1.5; }
.cq-i { width: 48px; height: 48px; flex: none; border-radius: 16px; background: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 20%, transparent); }
.cq-i svg { width: 34px; height: 34px; }
@media (min-width: 640px) { .curious { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .fun-strip { grid-template-columns: 1fr 1fr; } .fun-card.lvl { grid-column: 1 / -1; } }
@media (prefers-reduced-motion: reduce) { .doodles .d, .lvl-badge svg, .fire.on .flame svg, .cc-play { animation: none !important; } }
/* الكلمة الملوّنة بتدرّج: مساحة تحت الحروف النازلة (ح، ع، ي) حتى لا ينقص ذيلها */
.hero h1 em { display: inline-block; padding: 0 .04em .28em; margin-bottom: -.28em; line-height: 1.25; }

/* ===== النجوم والمستويات والإنجازات ===== */
.fly-star { position: fixed; left: 0; top: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; z-index: 80; pointer-events: none; filter: drop-shadow(0 3px 6px rgba(234,179,8,.45)); }
.fly-star svg { width: 100%; height: 100%; }
.xp-float.gain { display: grid; gap: 4px; padding: 10px 16px; border-radius: 18px; text-align: start; font-size: 14px; animation: gainUp 2.6s ease-out forwards; }
.xp-float.gain div { white-space: nowrap; } .xp-float.gain b { font: 800 16px var(--display); }
.xp-float.gain div:nth-child(n+2) { animation: gainIn .4s ease-out both; } .xp-float.gain div:nth-child(2) { animation-delay: .2s; } .xp-float.gain div:nth-child(3) { animation-delay: .4s; } .xp-float.gain div:nth-child(4) { animation-delay: .6s; }
@keyframes gainUp { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.9); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1.04); } 16% { transform: translate(-50%, 0) scale(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -18px); } }
@keyframes gainIn { from { opacity: 0; transform: translateY(6px); } }
.fun-card.lvl { cursor: pointer; font: inherit; text-align: start; position: relative; }
.fun-card.lvl:hover { border-color: #C7D2FE; }
.lvl-badge > svg { fill: none; }
.lvl-xp { color: #A16207; font-weight: 700; } .lvl-xp b { font: inherit; color: inherit; }
.lvl-badges { margin-inline-start: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.lvl-badges span { width: 26px; height: 26px; border-radius: 50%; background: #FEF9C3; display: grid; place-items: center; margin-inline-start: -6px; border: 2px solid #fff; }
.lvl-badges span svg { width: 18px; height: 18px; }
.lvl-badges em { font: 700 11px var(--ui); color: var(--muted); font-style: normal; margin-inline-start: 4px; }
.badge-pop { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 14px; border-radius: 20px;
  background: linear-gradient(120deg, #1E1B4B, #4F46E5); color: #fff; box-shadow: 0 16px 40px rgba(30,27,75,.35); animation: popIn .5s cubic-bezier(.3,1.6,.5,1); }
.badge-pop.out { animation: popOut .4s ease-in forwards; }
.bp-i { width: 52px; height: 52px; border-radius: 16px; background: #FEF9C3; display: grid; place-items: center; animation: twinkle 1.2s ease-in-out infinite; }
.bp-i svg { width: 38px; height: 38px; }
.badge-pop div { display: grid; gap: 1px; } .badge-pop small { color: #FDE047; font-weight: 700; font-size: 12px; } .badge-pop b { font: 800 17px var(--display); } .badge-pop em { font-style: normal; font-size: 12px; opacity: .8; }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -30px) scale(.8); } }
@keyframes popOut { to { opacity: 0; transform: translate(-50%, -30px) scale(.9); } }
.lvl-up { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; background: rgba(30,27,75,.55); backdrop-filter: blur(4px); animation: fadeIn .25s; }
.lvl-up.out { animation: fadeOut .3s forwards; }
.lu-card { position: relative; overflow: hidden; width: min(360px, 100%); background: #fff; border-radius: 28px; padding: 30px 24px 22px; text-align: center; box-shadow: 0 30px 80px rgba(30,27,75,.4); animation: popCard .6s cubic-bezier(.3,1.6,.5,1); }
.lu-rays { position: absolute; inset: -60%; background: repeating-conic-gradient(from 0deg, rgba(250,204,21,.16) 0 10deg, transparent 10deg 20deg); animation: spinny 14s linear infinite; z-index: 0; }
.lu-card > *:not(.lu-rays) { position: relative; }
.lu-star { position: relative; width: 120px; height: 120px; margin: 0 auto 8px; display: grid; place-items: center; animation: twinkle 1.6s ease-in-out infinite; }
.lu-star svg { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 10px 20px rgba(234,179,8,.45)); }
.lu-star b { position: relative; font: 800 34px var(--display); color: #713F12; margin-top: 8px; }
.lu-card small { color: #A16207; font-weight: 800; letter-spacing: .5px; } .lu-card h2 { margin: 4px 0 8px; font: 800 28px var(--display); color: var(--ink); } .lu-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.7; }
@keyframes popCard { from { opacity: 0; transform: scale(.6) rotate(-6deg); } }
@keyframes fadeIn { from { opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }
.ach-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.ach-head > div:last-child { flex: 1; display: grid; gap: 3px; } .ach-head h2 { margin: 0; font: 800 22px var(--display); }
.lvl-badge.big { width: 76px; height: 76px; } .lvl-badge.big svg { width: 76px; height: 76px; } .lvl-badge.big b { font-size: 22px; margin-top: 4px; }
.ach-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.ach-stats div { background: #F5F5FF; border-radius: 16px; padding: 10px 4px; text-align: center; display: grid; gap: 2px; }
.ach-stats b { font: 800 20px var(--display); color: var(--navy); } .ach-stats small { font-size: 11px; color: var(--muted); }
.ach-h { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 10px; font-size: 17px; } .ach-h small { color: var(--muted); font-size: 13px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ach { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 14px 8px; border-radius: 18px; border: 1px solid var(--line); background: #FAFAFA; filter: grayscale(1); opacity: .55; }
.ach span { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #fff; }
.ach span svg { width: 38px; height: 38px; } .ach b { font-size: 14px; } .ach small { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.ach.on { filter: none; opacity: 1; background: linear-gradient(170deg, #FEF9C3, #fff 70%); border-color: #FDE68A; }
.ach.on span { box-shadow: 0 6px 16px rgba(234,179,8,.3); }
.ach-how { margin: 14px 0 0; font-size: 13px; color: var(--muted); line-height: 1.8; }
@media (prefers-reduced-motion: reduce) { .lu-rays, .lu-star, .bp-i { animation: none !important; } }
.curious-card > div { display: grid; gap: 3px; min-width: 0; }
.curious-card small { font-size: 12px; color: color-mix(in srgb, var(--c) 70%, #333); opacity: .85; }
.curious-card.pop { animation: cardPop .5s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes cardPop { from { opacity: 0; transform: rotate(var(--r)) scale(.85) translateY(10px); } }
.curious-card.skel { --c: #A5B4FC; --r: 0deg; min-height: 76px; cursor: default; animation: phase 1.2s ease-in-out infinite alternate; }
.curious-card.skel b { width: 70%; height: 14px; border-radius: 8px; background: #E0E7FF; }
.curious-head.hidden, .curious.hidden { display: none; }
/* بطاقات: زر الحذف على الغلاف، وسطر الإتقان لا يتزاحم مع الزر */
.decks { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.deck-cover .x { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.22); color: #fff; backdrop-filter: blur(4px); opacity: .85; transition: .15s; cursor: pointer; }
.deck-cover .x:hover { background: rgba(255,255,255,.38); opacity: 1; }
.deck-cover .x svg { width: 15px; height: 15px; }
.deck-face b { padding-inline-start: 36px; }
.deck-txt .due, .deck-txt .ok { white-space: normal; line-height: 1.35; }
.deck2 .go { flex: none; }
/* زر البطاقات وهو يجهّز */
#btnCards.busy { opacity: .9; cursor: progress; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; display: inline-block; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.row-btns { display: grid; gap: 10px; margin-top: 18px; }
/* ===== الميداليات بالدرجات ===== */
.medal { --m1: #E5E7EB; --m2: #CBD5E1; --mi: #fff; position: relative; width: 54px; height: 54px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--m1), var(--m2), var(--m1), var(--m2), var(--m1)); box-shadow: inset 0 0 0 3px rgba(255,255,255,.55), 0 6px 14px -6px rgba(30,27,75,.35); }
.medal > i { width: 72%; height: 72%; border-radius: 50%; background: var(--mi); display: grid; place-items: center; box-shadow: inset 0 2px 4px rgba(0,0,0,.08); }
.medal > i svg { width: 70%; height: 70%; }
.medal > em { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 8px; line-height: 1; letter-spacing: -1px; white-space: nowrap;
  padding: 2px 4px; border-radius: 99px; background: var(--m2); color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.15); }
.medal.t0 { filter: grayscale(1); opacity: .5; }
.medal.t1 { --m1: #F2C29B; --m2: #B87333; --mi: #FFF7ED; }
.medal.t2 { --m1: #F1F5F9; --m2: #94A3B8; --mi: #F8FAFC; }
.medal.t3 { --m1: #FDE68A; --m2: #EAB308; --mi: #FEFCE8; }
.medal.t4 { --m1: #E0F2FE; --m2: #38BDF8; --mi: #F0F9FF; }
.medal.t5 { --m1: #DDD6FE; --m2: #7C3AED; --mi: #F5F3FF; }
.medal.t6 { --m1: #FACC15; --m2: #4F46E5; --mi: #FFFBEB; animation: legendGlow 2.4s ease-in-out infinite; }
@keyframes legendGlow { 50% { box-shadow: inset 0 0 0 3px rgba(255,255,255,.55), 0 0 18px 2px rgba(250,204,21,.6); } }
/* داخل بطاقات الإنجازات */
.ach .medal { width: 58px; height: 58px; margin-bottom: 6px; }
.ach .ach-tier { font-size: 12px; font-weight: 800; color: var(--muted); }
.ach.on .ach-tier { color: #A16207; }
.ach .pips { display: flex; gap: 3px; margin: 2px 0; }
.ach .pips i { width: 14px; height: 5px; border-radius: 3px; background: #E5E7EB; }
.ach .pips i.t1 { background: #B87333; } .ach .pips i.t2 { background: #94A3B8; } .ach .pips i.t3 { background: #EAB308; }
.ach .pips i.t4 { background: #38BDF8; } .ach .pips i.t5 { background: #7C3AED; } .ach .pips i.t6 { background: linear-gradient(90deg, #FACC15, #4F46E5); }
.lvl-bar.sm { height: 5px; width: 80%; }
.ach small.top { color: #A16207; font-weight: 800; }
.ach { filter: none; opacity: 1; } .ach:not(.on) { background: #FAFAFC; } .ach:not(.on) b { color: var(--muted); }
.ach-next { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: 18px; background: linear-gradient(120deg, #EEF2FF, #FEF9C3); }
.ach-next > div { flex: 1; display: grid; gap: 3px; } .ach-next small { font-size: 12px; color: var(--muted); } .ach-next b { font: 800 15px var(--display); }
/* الرئيسية والتنبيه */
.lvl-badges .medal { width: 30px; height: 30px; margin-inline-start: -8px; box-shadow: 0 0 0 2px #fff; }
.lvl-badges .medal > em { display: none; }
.badge-pop .medal.bp-i { width: 56px; height: 56px; border-radius: 50%; }
.badge-pop.t6 { background: linear-gradient(120deg, #1E1B4B, #4F46E5 60%, #A16207); }
.ach span.medal, .lvl-badges span.medal, .badge-pop span.medal { background: conic-gradient(from 210deg, var(--m1), var(--m2), var(--m1), var(--m2), var(--m1)); border: 0; }
.ach span.medal { width: 58px; height: 58px; }
.lvl-badges span.medal { width: 30px; height: 30px; }
.ach span.ach-tier, .ach span.pips { width: auto; height: auto; border-radius: 0; background: none; box-shadow: none; }
.badge-pop { width: max-content; max-width: calc(100vw - 24px); }
.badge-pop small { white-space: nowrap; }
.continue-card .cc-bar { display: block; height: 5px; border-radius: 99px; background: rgba(255,255,255,.25); margin-top: 6px; overflow: hidden; }
.continue-card .cc-bar i { display: block; height: 100%; border-radius: inherit; background: #FACC15; }
/* ===== سبورتي: تصفية ومجموعات ===== */
.bfilters { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }
.bchips { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.bchips::-webkit-scrollbar { display: none; }
.bchips button { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 99px; padding: 7px 13px; font: 700 13px var(--ui); cursor: pointer; }
.bchips button small { color: var(--muted); font-weight: 700; font-size: 11px; }
.bchips button svg { width: 14px; height: 14px; color: #EAB308; }
.bchips button.on { background: var(--ink); border-color: var(--ink); color: #fff; } .bchips button.on small { color: #C7D2FE; }
.bsort select { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 7px 10px; font: 700 13px var(--ui); color: var(--ink); }
.bgroup { grid-column: 1 / -1; margin: 14px 2px 0; font: 800 14px var(--display); color: var(--muted); }
.bgroup:first-child { margin-top: 4px; }
.bmore { grid-column: 1 / -1; margin-top: 6px; }
.bc-subj { position: absolute; bottom: 12px; inset-inline-start: 18px; font: 800 11.5px var(--ui); color: var(--c1); background: color-mix(in srgb, var(--c1) 10%, #fff); border-radius: 99px; padding: 3px 10px; }
.bc-prog { display: grid; gap: 4px; margin-top: 8px; }
.bc-prog > i { display: block; height: 5px; border-radius: 99px; background: #EEF2FF; overflow: hidden; }
.bc-prog > i > i { display: block; height: 100%; background: linear-gradient(90deg, var(--c1), var(--c2)); border-radius: inherit; }
.bc-prog span { font-size: 12px; font-weight: 700; color: #B45309; }
.bcard .pin { position: absolute; top: 10px; inset-inline-end: 46px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.9); box-shadow: var(--shadow); color: #CBD5E1; opacity: 0; transition: .15s; }
.bcard .pin svg { width: 15px; height: 15px; }
.bcard .pin.on { color: #EAB308; opacity: 1; }
.bcard:hover .pin { opacity: 1; }
@media (hover: none) { .bcard .pin { opacity: 1; } }
.bc-subj2 { display: none; }
.bsort select { max-width: 120px; }
/* الجوال: صف مدمج لكل سبورة حتى تبقى مئات السبورات سهلة التصفح */
@media (max-width: 600px) {
  #savedList { gap: 10px; }
  .bcard .bc-paper { display: none; }
  .bcard { border-radius: 18px; border-inline-start: 5px solid var(--c1); }
  .bc-meta { padding: 12px 14px; padding-inline-end: 86px; }
  .bc-meta b { font-size: 15px; }
  .bc-subj2 { display: inline-block; font-style: normal; font-weight: 800; font-size: 11px; color: var(--c1); background: color-mix(in srgb, var(--c1) 10%, #fff); border-radius: 99px; padding: 1px 8px; margin-inline-end: 6px; }
  .bcard .pin, .bcard .del { top: 50%; transform: translateY(-50%); }
  .bcard .pin { inset-inline-end: 48px; }
  .bgroup { margin-top: 10px; }
}

/* ===== رسائل الإدارة وعرض التذكير ===== */
.inbox-card { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; padding: 12px 14px; background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 20px; cursor: pointer; }
.inbox-card .ib-ic { flex: none; width: 40px; height: 40px; border-radius: 14px; background: #FACC15; color: #1E1B4B; display: grid; place-items: center; }
.inbox-card .ib-ic svg { width: 22px; height: 22px; }
.inbox-card div { flex: 1; min-width: 0; } .inbox-card b { display: block; color: #1E1B4B; } .inbox-card p { margin: 2px 0 0; color: #57534E; font-size: 14px; line-height: 1.5; }
.inbox-card .ib-x { flex: none; border: 0; background: transparent; font-size: 22px; color: #A8A29E; cursor: pointer; padding: 4px 8px; }
.remind-offer { text-align: center; display: grid; gap: 10px; justify-items: center; padding-top: 6px; }
.remind-offer .ro-ic { width: 64px; height: 64px; border-radius: 22px; background: #EEF2FF; color: #4F46E5; display: grid; place-items: center; }
.remind-offer .ro-ic svg { width: 34px; height: 34px; } .remind-offer h3 { margin: 4px 0 0; } .remind-offer p { margin: 0 0 6px; color: #6B6B8A; line-height: 1.7; }
