/* رواد المستقبل — Future Leaders learner UI
   Design language: a calm "dawn" for future leaders.
   Cool paper + knowledge-teal, with a warm honey accent reserved for
   achievement (points, streaks, badges). Display: El Messiri. Body: Tajawal. */

:root {
  /* Unified with the marketing site (index.html): vibrant indigo → purple brand
     with a warm amber achievement accent + gradients. Legacy names (--teal/--honey/
     --sky) are kept but re-valued so every existing component recolors automatically. */
  --ink:      #182545;   /* deep navy ink — text */
  --ink-soft: #5a678a;   /* muted text */
  --ink-mute: #8b97b3;
  --paper:    #f7f9fd;   /* calm cool paper — app background */
  --surface:  #ffffff;   /* cards */
  --card:     #ffffff;

  /* brand palette (same as index.html) */
  --blue:#2B4CC8; --blue-bright:#3f6fe6; --blue-050:#eef2fd;
  --purple:#7A2FB0; --violet:#9b4fd4; --purple-050:#f6eefc;
  --orange:#F5A623; --amber:#ffc24d; --orange-050:#fef4e0;
  --green:    #1fa564;   /* success / growth */
  --teal-accent:#149aa6; --coral:#ef6a2e; --pink:#e0457b;
  --danger:   #e0457b;

  /* legacy semantic aliases → revalued to the brand so components recolor */
  --teal:     #2B4CC8;   /* primary → brand blue */
  --teal-700: #1e3aa0;
  --teal-050: #eef2fd;
  --honey:    #F5A623;   /* achievement accent → amber */
  --honey-050:#fef4e0;
  --sky:      #7A2FB0;   /* secondary → purple (brand-dot/gradients become blue→purple) */
  --mist:     #e9edf6;   /* borders / dividers */

  --grad:     linear-gradient(120deg,#2B4CC8,#7A2FB0);
  --grad-soft:linear-gradient(120deg,#3f6fe6,#9b4fd4);
  --grad-warm:linear-gradient(120deg,#F5A623,#ef6a2e);

  --radius:   18px;
  --radius-sm:12px;
  --r:18px; --r-sm:12px; --r-lg:26px; --r-xl:34px;
  --shadow:   0 6px 16px -4px rgba(11,21,51,.09), 0 18px 40px -12px rgba(11,21,51,.14);
  --shadow-lg:0 30px 70px -24px rgba(43,76,200,.4);
  --sh-sm:    0 1px 2px rgba(11,21,51,.06),0 2px 6px rgba(11,21,51,.05);
  --sh:       0 6px 16px -4px rgba(11,21,51,.09),0 18px 40px -12px rgba(11,21,51,.14);
  --ring:     0 0 0 3px rgba(43,76,200,.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: 'El Messiri', 'Tajawal', serif; font-weight: 700; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--honey-050); }

/* ---------- Auth screen ---------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(245,166,35,.20) 0%, rgba(245,166,35,0) 55%),
    radial-gradient(1000px 520px at 5% 110%, rgba(122,47,176,.16) 0%, rgba(122,47,176,0) 55%),
    radial-gradient(900px 480px at 50% 0%, rgba(43,76,200,.10) 0%, rgba(43,76,200,0) 55%),
    var(--paper);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--mist);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 40px 34px;
}
.brand-mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'El Messiri', serif; font-weight: 700; font-size: 22px;
}
.brand-dot {
  width: 34px; height: 34px; border-radius: 12px;
  background: var(--grad);
  display: grid; place-items: center; color: #fff; font-size: 18px;
  box-shadow: 0 8px 18px -6px rgba(43,76,200,.6);
}
.auth h1 { font-size: 26px; margin: 22px 0 4px; }
.auth .sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 15px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 500; }
.input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--mist); border-radius: var(--radius-sm);
  background: #fcfdff; color: var(--ink); font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-weight: 700; font-size: 15px; transition: transform .08s ease, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 10px 24px -12px rgba(14,124,134,.9); }
.btn-primary:hover { background: var(--teal-700); }
.btn-honey { background: var(--honey); color: #4a2f07; }
.btn-honey:hover { filter: brightness(.97); }
.btn-ghost { background: transparent; border-color: var(--mist); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

.form-error { color: var(--danger); font-size: 14px; margin-top: 6px; min-height: 18px; }
.form-hint { color: var(--ink-soft); font-size: 13px; margin-top: 14px; text-align: center; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--surface);
  border-inline-start: 1px solid var(--mist); /* RTL: on the right edge */
  padding: 22px 16px; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar .brand-mark { padding: 6px 8px 18px; font-size: 20px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; color: var(--ink-soft);
  font-weight: 500; transition: background .15s, color .15s;
}
.nav-link .ic { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: var(--paper); color: var(--ink); }
.nav-link.active { background: var(--teal-050); color: var(--teal-700); font-weight: 700; }
.nav-spacer { flex: 1; }
.nav-foot { font-size: 12px; color: var(--ink-soft); padding: 8px; border-top: 1px solid var(--mist); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 30px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--mist);
}
.topbar .title { font-size: 15px; color: var(--ink-soft); }
.stat-cluster { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: 14px;
  border: 1px solid var(--mist); background: var(--surface);
}
.pill.points { background: var(--honey-050); border-color: #f0d9ac; color: #8a5a12; }
.pill.streak { background: #fff2ec; border-color: #f6d3c4; color: #b4552f; }
.pill.bell { position: relative; padding: 8px 11px; color: var(--ink-soft); text-decoration: none; }
.pill.bell:hover { border-color: var(--sky); color: var(--sky); }
.nb-badge { position: absolute; top: -5px; left: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 2px 6px -1px rgba(201,85,107,.6); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: linear-gradient(150deg, var(--sky), var(--teal)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}

.content { padding: 26px 30px 60px; max-width: 1080px; }

/* ---------- Greeting hero ---------- */
.hero {
  border-radius: 20px; padding: 26px 28px; margin-bottom: 26px;
  background:
    radial-gradient(600px 200px at 92% -40%, rgba(232,163,61,.28), rgba(232,163,61,0) 60%),
    linear-gradient(120deg, #0e7c86 0%, #14808b 40%, #2f6f9e 100%);
  color: #fff; box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.hero h1 { font-size: 26px; margin: 0 0 4px; color: #fff; }
.hero p { margin: 0; opacity: .9; font-size: 15px; }

/* ---------- Cards / grid ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 2px 16px; }
.section-head h2 { font-size: 20px; margin: 0; }
.section-head .muted { color: var(--ink-soft); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--mist); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: transform .12s ease, box-shadow .2s;
  display: flex; flex-direction: column;
}
.card.click:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cfe4e6; }
.card-cover {
  height: 92px;
  background: linear-gradient(135deg, var(--teal-050), #eef2fb);
  display: flex; align-items: flex-end; padding: 12px 14px;
  border-bottom: 1px solid var(--mist);
}
.chip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 8px; background: #fff; color: var(--teal-700); border: 1px solid var(--mist); }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h3 { font-size: 17px; margin: 0; line-height: 1.4; }
.card-body .desc { color: var(--ink-soft); font-size: 14px; margin: 0; }
.card-meta { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: 13px; margin-top: auto; padding-top: 6px; }
.price-free { color: var(--green); font-weight: 700; }

/* ---------- Progress ring & bars ---------- */
.ring { --p: 0; width: 64px; height: 64px; flex: none; }
.bar { height: 9px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: 999px; transition: width .5s ease; }

/* ---------- Lessons list ---------- */
.lessons { display: flex; flex-direction: column; gap: 10px; }
.lesson {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--mist); border-radius: 12px;
}
.lesson.done { background: #f2faf5; border-color: #cdebd9; }
.lesson .lx {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--paper); color: var(--ink-soft); font-size: 13px; font-weight: 700; border: 1.5px solid var(--mist);
}
.lesson.done .lx { background: var(--green); color: #fff; border-color: var(--green); }
.lesson .lt { flex: 1; }
.lesson .lt b { display: block; font-weight: 700; }
.lesson .lt small { color: var(--ink-soft); }

/* ---------- Badges & leaderboard ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge {
  text-align: center; padding: 20px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--mist);
}
.badge .medal {
  width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe6b0, var(--honey)); color: #7a4c07;
  display: grid; place-items: center; font-size: 24px; box-shadow: 0 8px 18px -8px rgba(232,163,61,.8);
}
.badge.locked { opacity: .5; filter: grayscale(.5); }
.badge.locked .medal { background: var(--mist); color: var(--ink-soft); box-shadow: none; }
.badge b { display: block; font-size: 14px; }
.badge small { color: var(--ink-soft); font-size: 12px; }

.lb-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--mist); }
.lb-row:last-child { border-bottom: 0; }
.lb-rank { width: 28px; font-weight: 800; color: var(--ink-soft); text-align: center; }
.lb-row.me { background: var(--teal-050); border-radius: 10px; }

/* ---------- AI tutor (3D) ---------- */
.tutor3d{
  --nv:#0B1533; --bl:#2B4CC8; --pu:#7A2FB0; --or:#F5A623;
  --grad:linear-gradient(125deg,#2B4CC8,#7A2FB0);
  position:relative; display:flex; flex-direction:column;
  height:calc(100dvh - 172px); min-height:460px;
  border-radius:28px; padding:20px; overflow:hidden;
  background:
    radial-gradient(600px 300px at 12% -10%, rgba(43,76,200,.16), transparent 60%),
    radial-gradient(560px 320px at 100% 0%, rgba(122,47,176,.16), transparent 55%),
    linear-gradient(180deg,#0c1330,#0a1027);
  border:1px solid #1e2a4a;
  box-shadow:0 40px 80px -40px rgba(11,21,51,.75), inset 0 1px 0 rgba(255,255,255,.05);
  perspective:1400px;
}
.tutor-head{ display:flex; align-items:center; gap:14px; padding:6px 6px 16px; border-bottom:1px solid rgba(255,255,255,.08); margin-bottom:12px; }
.th-bot{ width:56px; height:56px; flex:none; filter:drop-shadow(0 10px 18px rgba(43,76,200,.6)); animation:floaty 5s ease-in-out infinite; transform-style:preserve-3d; }
.th-bot svg{ width:100%; height:100%; display:block; }
.th-txt h2{ margin:0; font-size:19px; color:#fff; }
.th-status{ display:inline-flex; align-items:center; gap:7px; font-size:12.5px; color:#9fb0d6; }
.th-status i{ width:8px; height:8px; border-radius:50%; background:#2fe08a; box-shadow:0 0 0 4px rgba(47,224,138,.18); animation:pulse 1.8s ease-in-out infinite; }

.chat-log{ flex:1; overflow-y:auto; padding:6px 4px; display:flex; flex-direction:column; gap:16px; scroll-behavior:smooth; }
.chat-log::-webkit-scrollbar{ width:8px; } .chat-log::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.12); border-radius:99px; }

.msg{ display:flex; align-items:flex-end; gap:10px; max-width:86%; }
.msg.user{ align-self:flex-start; flex-direction:row-reverse; }
.msg.bot{ align-self:flex-end; }
.msg-av{ width:40px; height:40px; flex:none; border-radius:50%; padding:5px; background:linear-gradient(160deg,#16224a,#0e1836); border:1px solid rgba(255,255,255,.1); box-shadow:0 8px 16px -8px rgba(0,0,0,.6); }
.msg-av svg{ width:100%; height:100%; display:block; }
.bubble{ position:relative; padding:13px 16px; border-radius:18px; font-size:15px; line-height:1.7; transform:translateZ(0); transition:transform .25s ease; }
.msg.bot .bubble{
  background:linear-gradient(180deg,#ffffff,#f3f6ff); color:#14203d;
  border:1px solid rgba(255,255,255,.6);
  border-bottom-inline-end-radius:6px;
  box-shadow:0 18px 34px -18px rgba(11,21,51,.7), inset 0 1px 0 #fff;
}
.msg.user .bubble{
  background:var(--grad); color:#fff;
  border-bottom-inline-start-radius:6px;
  box-shadow:0 16px 30px -14px rgba(122,47,176,.7);
}
.msg.bot:hover .bubble{ transform:translateY(-2px) rotateX(2deg); }
.bubble p{ margin:0 0 8px; } .bubble p:last-child{ margin-bottom:0; }
.bubble strong{ color:#2B4CC8; font-weight:800; }
.bubble h4,.bubble h5{ margin:10px 0 6px; font-size:15.5px; color:#0B1533; }
.bubble ul,.bubble ol{ margin:6px 0; padding-inline-start:22px; display:flex; flex-direction:column; gap:5px; }
.bubble li{ line-height:1.6; }
.bubble code{ background:#eef1fb; color:#7A2FB0; padding:1px 6px; border-radius:6px; font-size:13px; font-family:'Poppins',monospace; }
.bubble hr{ border:0; border-top:1px dashed #d4dcf0; margin:11px 0; }
.msg.user .bubble strong,.msg.user .bubble code{ color:#fff; background:rgba(255,255,255,.2); }

.dots{ display:inline-flex; gap:5px; padding:3px 0; }
.dots i{ width:8px; height:8px; border-radius:50%; background:#2B4CC8; opacity:.5; animation:typing 1.3s ease-in-out infinite; }
.dots i:nth-child(2){ animation-delay:.18s; } .dots i:nth-child(3){ animation-delay:.36s; }

.chat-chips{ display:flex; flex-wrap:wrap; gap:8px; padding:12px 2px 4px; }
.qchip{ font-size:13px; font-weight:600; color:#dfe7ff; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.14); padding:8px 14px; border-radius:999px; transition:.2s; }
.qchip:hover{ background:rgba(255,255,255,.14); transform:translateY(-1px); }

.chat-input{ display:flex; gap:10px; padding-top:14px; }
.chat-input .input{ flex:1; background:rgba(255,255,255,.96); border:1px solid rgba(255,255,255,.2); box-shadow:0 12px 24px -14px rgba(0,0,0,.5); }
.chat-input .btn-primary{ background:var(--grad); border:0; box-shadow:0 14px 26px -12px rgba(122,47,176,.8); }
.chat-input .btn-primary .ic{ width:18px; height:18px; }

@keyframes floaty{ 0%,100%{ transform:translateY(0) rotateZ(-2deg); } 50%{ transform:translateY(-9px) rotateZ(2deg); } }
@keyframes pulse{ 0%,100%{ box-shadow:0 0 0 3px rgba(47,224,138,.2); } 50%{ box-shadow:0 0 0 6px rgba(47,224,138,0); } }
@keyframes typing{ 0%,60%,100%{ transform:translateY(0); opacity:.4; } 30%{ transform:translateY(-6px); opacity:1; } }
@media (prefers-reduced-motion: reduce){ .th-bot,.dots i,.th-status i{ animation:none; } }
@media (max-width:640px){ .tutor3d{ height:calc(100dvh - 150px); border-radius:20px; padding:14px; } .msg{ max-width:94%; } }

/* ---------- Homework ---------- */
.hw-list{display:flex;flex-direction:column;gap:14px}
.hw-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.hw-b{font-size:12px;font-weight:800;padding:5px 12px;border-radius:999px;white-space:nowrap;flex:none}
.hw-b.todo{background:#fdf0e0;color:#b56a10}
.hw-b.wait{background:#e6eeff;color:#2B4CC8}
.hw-b.done{background:#e7f7ef;color:#158a54}
.hw-submit{display:flex;gap:10px;margin-top:12px;align-items:flex-end}
.hw-txt{flex:1;resize:vertical;min-height:64px}
.hw-fb{margin-top:12px;padding:12px 14px;border-radius:12px;background:#f2faf5;border:1px solid #c9ecd8}

/* ---------- Study schedule (D) ---------- */
.sch-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:14px}
.sch-day{background:var(--surface);border:1px solid var(--mist);border-radius:16px;padding:14px;box-shadow:var(--shadow)}
.sch-day.today{border-color:var(--brand-blue,#2B4CC8);box-shadow:0 0 0 2px rgba(43,76,200,.16)}
.sch-d-h{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px;padding-bottom:8px;border-bottom:1px dashed var(--mist)}
.sch-d-h b{font-size:15px}.sch-d-h span{font-size:12px;color:var(--ink-soft)}
.sch-items{display:flex;flex-direction:column;gap:8px}
.sch-it{font-size:13.5px;color:var(--ink-soft);display:flex;gap:8px;align-items:flex-start;line-height:1.5}
.sch-it span{flex:none}

/* ---------- Adaptive practice (#1-5) ---------- */
.subj-row{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px}
.subj-chip{border:1px solid var(--mist);background:var(--surface);border-radius:999px;padding:8px 16px;font-family:inherit;font-weight:700;font-size:14px;cursor:pointer;color:var(--ink-soft)}
.subj-chip.on{background:var(--grad,linear-gradient(120deg,#2B4CC8,#7A2FB0));color:#fff;border-color:transparent}
.skill-map{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px}
.skill{background:var(--surface);border:1px solid var(--mist);border-radius:16px;padding:16px;box-shadow:var(--shadow)}
.skill.locked{opacity:.55}
.sk-top{display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:10px}
.sk-top b{font-size:15px}.sk-grade{font-size:11.5px;color:var(--ink-soft)}
.sk-bar{height:10px;background:#eef2fb;border-radius:99px;overflow:hidden}
.sk-bar i{display:block;height:100%;background:linear-gradient(90deg,#1fa564,#149aa6);border-radius:99px}
.sk-m{font-size:12px;color:var(--ink-soft);margin-top:6px}
.quiz{max-width:640px;margin:0 auto;background:var(--surface);border:1px solid var(--mist);border-radius:22px;box-shadow:var(--shadow);padding:26px}
.quiz-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}
.q-prompt{font-size:22px;font-weight:800;color:var(--ink);margin:8px 0 20px;line-height:1.5;text-align:center}
.q-choices{display:flex;flex-direction:column;gap:10px}
.q-choice{border:2px solid var(--mist);background:var(--surface);border-radius:14px;padding:15px 18px;font-family:inherit;font-size:16px;font-weight:700;cursor:pointer;transition:.15s;text-align:right}
.q-choice:hover:not(:disabled){border-color:var(--sky);transform:translateY(-1px)}
.q-choice:disabled{cursor:default}
.q-choice.ok{border-color:#1fa564;background:#eafaf1;color:#0f7a4d}
.q-choice.bad{border-color:#e0455f;background:#fdeef1;color:#b23}
.q-fb .fb{margin-top:16px;padding:14px 16px;border-radius:12px;font-size:14.5px;line-height:1.6}
.q-fb .fb.ok{background:#eafaf1;border:1px solid #c3ecd3;color:#0f7a4d}
.q-fb .fb.bad{background:#fdeef1;border:1px solid #f6ccd4;color:#b23}

/* ---------- Accessibility / easy-reading mode (#20) ---------- */
.a11y body, .a11y .content, .a11y .q-prompt, .a11y .reader, .a11y p, .a11y li, .a11y .bubble {
  letter-spacing: .3px; word-spacing: 2px; line-height: 2;
}
.a11y { font-size: 17.5px; }
.a11y .q-prompt { font-size: 25px; }
.a11y .bubble, .a11y .desc, .a11y .card p { font-weight: 600; }
.a11y .muted, .a11y .card-meta { color: #35405c !important; } /* higher contrast */
.a11y .btn { letter-spacing: .2px; }
.a11y :focus-visible { outline: 3px solid #F5A623; outline-offset: 2px; }

/* ---------- Smart tools (#11-14) ---------- */
.voice-toggle{display:flex;align-items:center;gap:8px;font-weight:700;font-size:13.5px;color:var(--ink-soft);margin-top:10px}
.voice-toggle input{width:16px;height:16px;accent-color:var(--sky)}
#chatMic.listening{background:#fdeef1;border-color:#e0455f}
.tool-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:16px}
.tool-card{background:var(--surface);border:1px solid var(--mist);border-radius:18px;box-shadow:var(--shadow);padding:20px;text-align:center;cursor:pointer;font-family:inherit;display:flex;flex-direction:column;gap:6px;align-items:center;transition:.15s}
.tool-card:hover{transform:translateY(-3px);border-color:var(--sky)}
.tool-card.on{border-color:var(--sky);box-shadow:0 0 0 2px rgba(43,76,200,.18)}
.tool-ic{font-size:40px}
.tool-card b{font-size:16px}.tool-card span{font-size:13px;color:var(--ink-soft)}
.read-text{font-size:22px;font-weight:700;line-height:1.9;text-align:center;background:#f7faff;border:1px dashed var(--mist);border-radius:14px;padding:18px;margin:12px 0}
.flash-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:14px}
.flashcard{perspective:800px;height:120px;cursor:pointer}
.fc-in{position:relative;width:100%;height:100%;transition:transform .5s;transform-style:preserve-3d}
.flashcard.flip .fc-in{transform:rotateY(180deg)}
.fc-front,.fc-back{position:absolute;inset:0;backface-visibility:hidden;border-radius:14px;display:grid;place-items:center;padding:14px;text-align:center;font-weight:700;border:1px solid var(--mist)}
.fc-front{background:var(--surface);color:var(--ink)}
.fc-back{background:linear-gradient(120deg,#2B4CC8,#7A2FB0);color:#fff;transform:rotateY(180deg);font-weight:600;font-size:14px}

/* ---------- Engagement (#6-10) ---------- */
.goal-card{display:flex;align-items:center;gap:20px;background:var(--surface);border:1px solid var(--mist);border-radius:20px;box-shadow:var(--shadow);padding:20px 22px;margin-bottom:22px}
.goal-ring{width:92px;height:92px;border-radius:50%;flex:none;
  background:conic-gradient(#1fa564 calc(var(--p)*1%), #eef2fb 0);display:grid;place-items:center}
.goal-in{width:70px;height:70px;border-radius:50%;background:var(--surface);display:grid;place-items:center;text-align:center;line-height:1}
.goal-in b{font-family:'Poppins';font-size:22px;color:var(--ink)}.goal-in span{font-size:12px;color:var(--ink-soft)}
.goal-txt b{font-size:16px}
.wallet{display:flex;gap:14px;flex-wrap:wrap;margin-top:8px;font-weight:700;font-size:14px;color:var(--ink-soft)}
.shop-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px;margin-bottom:26px}
.shop-item{background:var(--surface);border:1px solid var(--mist);border-radius:16px;box-shadow:var(--shadow);padding:16px;text-align:center;display:flex;flex-direction:column;gap:6px;align-items:center}
.shop-item.owned{opacity:.75}
.shop-emoji{font-size:40px}
.shop-cost{font-weight:800;color:#8a5a12;font-size:14px}
.duel-list{display:flex;flex-direction:column;gap:10px;margin-bottom:26px}
.duel-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 18px}
.duel-picker{margin-bottom:14px}

/* ---------- Screen-time lock (C) ---------- */
.screen-lock{position:fixed;inset:0;z-index:9999;display:none;align-items:center;justify-content:center;padding:24px;
  background:radial-gradient(700px 500px at 50% 0%,rgba(122,47,176,.45),transparent 60%),rgba(11,21,51,.82);backdrop-filter:blur(6px)}
.sl-card{background:#fff;border-radius:24px;padding:34px 30px;max-width:400px;text-align:center;box-shadow:0 40px 90px -30px rgba(0,0,0,.6)}
.sl-emoji{font-size:56px;margin-bottom:10px}
.sl-card h2{font-size:24px;margin-bottom:8px;color:var(--ink)}
.sl-card p{color:var(--ink-soft);font-size:15.5px;line-height:1.7}
.sl-note{margin-top:16px;font-size:13px;color:var(--ink-soft);background:#f2f6ff;border-radius:12px;padding:10px 14px}

/* ---------- Misc ---------- */
.panel { background: var(--surface); border: 1px solid var(--mist); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.empty { text-align: center; color: var(--ink-soft); padding: 48px 20px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.notice { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: var(--honey-050); border: 1px solid #f0d9ac; color: #7a4c07; font-size: 14px; }
.notif-item { display: flex; gap: 12px; padding: 14px 6px; border-bottom: 1px solid var(--mist); }
.notif-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); margin-top: 8px; flex: none; }
.notif-item.read .dot { background: var(--mist); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--mist); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .25s, transform .25s; z-index: 50; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #14707a; } .toast.err { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; height: auto; flex-direction: row; align-items: center; overflow-x: auto;
    border-inline-start: 0; border-bottom: 1px solid var(--mist); padding: 10px 12px; gap: 4px;
  }
  .sidebar .brand-mark { display: none; }
  .nav-link span.lbl { display: none; }
  .nav-spacer, .nav-foot { display: none; }
  .content, .topbar { padding-inline: 16px; }
}
/* ============================================================
   نبغة design foundation — dark mode, mascot, micro-interactions
   ============================================================ */

/* ---- Dark theme: token overrides (NUI stamps data-theme) ---- */
:root[data-theme="dark"] {
  --ink:      #e8edf7;
  --ink-soft: #9fabc6;
  --paper:    #0d1424;
  --surface:  #161f36;
  --teal:     #2bb6c2;
  --teal-700: #4fc9d4;
  --teal-050: rgba(43,182,194,.16);
  --honey:    #f0ab45;
  --honey-050:rgba(240,171,69,.16);
  --sky:      #6d8fe0;
  --mist:     #27324e;
  --green:    #45b985;
  --danger:   #e0708a;
  --shadow:   0 1px 2px rgba(0,0,0,.3), 0 12px 30px -18px rgba(0,0,0,.7);
  --shadow-lg:0 24px 60px -28px rgba(0,0,0,.8);
  --ring:     0 0 0 3px rgba(43,182,194,.35);
}
/* dark: repaint the few hard-coded light surfaces */
:root[data-theme="dark"] .input { background: #101a30; }
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .goal-in { background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .card-cover { background: linear-gradient(135deg, var(--teal-050), rgba(109,143,224,.12)); }
:root[data-theme="dark"] .sl-card { background: var(--surface); }
:root[data-theme="dark"] .notice { background: var(--honey-050); border-color: #5a4416; color: #f0c68a; }
:root[data-theme="dark"] .pill.points { background: var(--honey-050); border-color: #5a4416; color: #f0c68a; }
:root[data-theme="dark"] .pill.streak { background: rgba(224,112,138,.14); border-color: #5a2f38; color: #f0a3b3; }
:root[data-theme="dark"] .sl-note,
:root[data-theme="dark"] .goal-ring { --lift: #101a30; }
:root[data-theme="dark"] .sl-note { background: #101a30; }
:root[data-theme="dark"] .goal-ring { background: conic-gradient(var(--green) calc(var(--p)*1%), #101a30 0); }

/* smooth theme transition (killed under reduced-motion below) */
body, .sidebar, .topbar, .card, .panel, .lesson, .input, .pill, .shop-item {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

/* ---- Icon buttons (theme + sound toggles) ---- */
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--mist);
  background: var(--surface); color: var(--ink-soft); font-size: 18px;
  display: inline-grid; place-items: center; transition: transform .1s, border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { color: var(--teal); border-color: var(--teal); background: var(--teal-050); }
.icon-btn:active { transform: scale(.92); }

/* ---- Toast variants (NUI kinds) ---- */
.toast-success { background: #14707a; } .toast-error { background: var(--danger); }
.toast-info { background: var(--sky); }
.toast.show { animation: toastPop .3s cubic-bezier(.2,1.4,.4,1); }
@keyframes toastPop { 0% { transform: translateX(-50%) translateY(20px) scale(.9); } 100% { transform: translateX(-50%) translateY(0) scale(1); } }

/* ---- The نبغة mascot ---- */
.nui-mascot { display: inline-block; filter: drop-shadow(0 8px 14px rgba(232,163,61,.4)); }
.nui-mascot .nui-star { transform-origin: 52px 46px; }
.nui-mascot.mood-happy, .nui-mascot.mood-wave { animation: mascotFloat 3.2s ease-in-out infinite; }
.nui-mascot.mood-cheer { animation: mascotCheer .6s ease-in-out infinite alternate; }
@keyframes mascotFloat { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
@keyframes mascotCheer { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(-6px) scale(1.06); } }
.nui-mascot-say { display: flex; align-items: center; gap: 14px; }
.nui-bubble {
  position: relative; background: var(--surface); border: 1.5px solid var(--mist); border-radius: 16px;
  padding: 12px 16px; font-weight: 600; color: var(--ink); box-shadow: var(--shadow); max-width: 340px;
}
.nui-bubble::before {
  content: ''; position: absolute; inset-inline-start: -8px; top: 22px; width: 14px; height: 14px;
  background: var(--surface); border-inline-start: 1.5px solid var(--mist); border-block-end: 1.5px solid var(--mist);
  transform: rotate(45deg);
}

/* ---- Skeleton loaders (shimmer) ---- */
.nui-skel-wrap { display: flex; flex-direction: column; gap: 12px; padding: 8px 2px; }
.nui-skel { height: 14px; border-radius: 8px; background: var(--mist);
  background-image: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--surface) 70%, #fff) 45%, transparent 70%);
  background-size: 200% 100%; animation: skelShimmer 1.3s linear infinite; }
.nui-skel-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.nui-skel-card { background: var(--surface); border: 1px solid var(--mist); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.nui-skel-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--mist); animation: skelShimmer 1.3s linear infinite; }
@keyframes skelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Rich empty state ---- */
.nui-empty { text-align: center; padding: 44px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nui-empty h3 { margin: 12px 0 0; font-size: 20px; }
.nui-empty p { margin: 0 0 8px; color: var(--ink-soft); }

/* ---- Micro-interaction utilities ---- */
.pop-in { animation: popIn .35s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes popIn { 0% { opacity: 0; transform: scale(.9) translateY(8px); } 100% { opacity: 1; transform: none; } }
.btn-primary:hover { transform: translateY(-1px); }
.card.click { cursor: pointer; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Learning path cards ---- */
.path-card { border-inline-start: 4px solid var(--pc, var(--teal)); }
.path-top { display: flex; align-items: center; gap: 12px; }
.path-emoji { font-size: 34px; flex: none; }
.skill.done { border-color: color-mix(in srgb, var(--green) 40%, var(--mist)); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.q-choice.picked { border-color: var(--sky); background: var(--teal-050); }

/* ---- First-run wizard ---- */
.wiz-overlay { position: fixed; inset: 0; z-index: 9998; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(700px 500px at 50% 0%, rgba(122,47,176,.5), transparent 60%), rgba(11,21,51,.82); backdrop-filter: blur(6px); }
.wiz-card { background: var(--surface); border-radius: 24px; padding: 30px 26px; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.6); }
.wiz-card h2 { margin: 14px 0 6px; font-size: 22px; }
.wiz-card p { color: var(--ink-soft); font-size: 15px; margin: 0 0 18px; }
.wiz-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.wiz-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--mist); transition: .2s; }
.wiz-dots span.on { background: var(--teal); width: 22px; border-radius: 6px; }

/* ---- Learning-world adventure map ---- */
.world-map { display: flex; flex-direction: column; gap: 20px; }
.region { background: var(--surface); border: 1px solid var(--mist); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.region-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.region-emoji { font-size: 30px; }
.region-head h3 { margin: 0 0 6px; font-size: 18px; }
.wtrail-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.wnode { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; padding: 8px 4px; border: 0; background: transparent; border-radius: 14px; transition: transform .12s; }
.wnode:hover { transform: translateY(-3px); }
.wnode .wn-ic { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 24px;
  background: var(--mist); box-shadow: inset 0 -3px 8px rgba(0,0,0,.08); }
.wnode.done .wn-ic { background: radial-gradient(circle at 40% 35%, #ffd873, var(--honey)); }
.wnode.current { position: relative; }
.wnode.current .nui-mascot { filter: drop-shadow(0 6px 10px rgba(232,163,61,.5)); }
.wnode.locked { opacity: .55; }
.wn-label { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.25; color: var(--ink-soft); }
.wnode.current .wn-label, .wnode.done .wn-label { color: var(--ink); }
.wtrail { flex: 1; min-width: 20px; height: 4px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--mist) 0 8px, transparent 8px 14px); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ============================================================
   Accessibility toolkit (driven by data-* on :root from NUI)
   ============================================================ */
/* In-app "reduce motion" — same nuke as the OS media query, user-toggled */
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* Dyslexia-friendly reading: more air between letters/words/lines */
:root[data-dyslexia="1"] body { letter-spacing: .035em; word-spacing: .12em; line-height: 1.85; }
:root[data-dyslexia="1"] p,
:root[data-dyslexia="1"] li,
:root[data-dyslexia="1"] .nui-bubble,
:root[data-dyslexia="1"] label { font-family: 'Tajawal', Verdana, system-ui, sans-serif; max-width: 72ch; }

/* High-contrast: stronger text, visible link underlines, heavier borders.
   Deliberately no root-level filter (would break position:fixed children). */
:root[data-contrast="high"] a { text-decoration: underline; }
:root[data-contrast="high"] .btn { border-width: 2px; font-weight: 800; }
:root[data-contrast="high"] .muted,
:root[data-contrast="high"] .sub,
:root[data-contrast="high"] small { color: var(--ink, #12203f) !important; opacity: 1 !important; }
:root[data-contrast="high"] * { text-shadow: none !important; }
:root[data-contrast="high"] :focus-visible { outline: 3px solid #F5A623 !important; outline-offset: 2px; }

/* Read-aloud affordance: hovering a readable element hints it's tappable */
:root[data-readaloud="1"] p:hover,
:root[data-readaloud="1"] li:hover,
:root[data-readaloud="1"] h1:hover,
:root[data-readaloud="1"] h2:hover,
:root[data-readaloud="1"] h3:hover,
:root[data-readaloud="1"] .nui-bubble:hover {
  outline: 2px dashed var(--brand, #2B4CC8); outline-offset: 3px; border-radius: 8px; cursor: pointer;
}

/* Floating accessibility button + panel (bottom-start, clears page chrome) */
.nui-a11y-fab {
  position: fixed; inset-inline-start: 16px; bottom: 16px; z-index: 9998;
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #2B4CC8, #7A2FB0); color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px -8px rgba(11, 21, 51, .55); transition: transform .15s ease;
}
.nui-a11y-fab:hover { transform: translateY(-2px); }
.nui-a11y-fab:focus-visible { outline: 3px solid #F5A623; outline-offset: 3px; }
.nui-a11y-pop {
  position: fixed; inset-inline-start: 16px; bottom: 78px; z-index: 9998;
  width: min(300px, calc(100vw - 32px));
  background: var(--surface, #fff); color: var(--ink, #12203f);
  border: 1px solid var(--mist, #e3e9f6); border-radius: 16px; padding: 14px;
  box-shadow: 0 22px 48px -18px rgba(11, 21, 51, .5);
}
:root[data-theme="dark"] .nui-a11y-pop { background: #141c30; color: #e8eefc; border-color: #263248; }
.nui-a11y-title { font-weight: 800; font-size: 15px; margin-bottom: 12px; }
.nui-a11y-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 14px; font-weight: 700; }
.nui-a11y-scale { display: flex; gap: 4px; }
.nui-a11y-scale button {
  border: 1px solid var(--mist, #d6def0); background: transparent; color: inherit;
  border-radius: 9px; padding: 6px 10px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13px;
}
.nui-a11y-scale button.on { background: linear-gradient(135deg, #2B4CC8, #7A2FB0); color: #fff; border-color: transparent; }
.nui-a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nui-a11y-opt {
  border: 1.5px solid var(--mist, #d6def0); background: transparent; color: inherit;
  border-radius: 12px; padding: 11px 8px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13.5px; text-align: center;
}
.nui-a11y-opt.on { background: linear-gradient(135deg, #2B4CC8, #7A2FB0); color: #fff; border-color: transparent; }
.nui-a11y-close {
  margin-top: 12px; width: 100%; border: none; border-radius: 11px; padding: 10px;
  background: var(--mist, #eef2fb); color: var(--ink, #12203f); font-family: inherit; font-weight: 800; cursor: pointer;
}
:root[data-theme="dark"] .nui-a11y-close { background: #263248; color: #e8eefc; }
