:root {
  --bg: #f5f3ff;
  --card: #ffffff;
  --ink: #1e1b4b;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #6d28d9;
  --primary-2: #8b5cf6;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #f59e0b;
  --lvl: #22c55e;
  --radius: 18px;
  --shadow: 0 10px 30px -12px rgba(76, 29, 149, .25);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: 'Cairo', 'Nunito', sans-serif; color: var(--ink);
  background: radial-gradient(1200px 600px at 100% -10%, #ede9fe 0, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #e0f2fe 0, transparent 60%), var(--bg);
  min-height: 100vh;
}
.en, .story-text, .q-en { font-family: 'Nunito', sans-serif; direction: ltr; text-align: left; }
button { font-family: inherit; cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.brand .logo { font-size: 30px; }
.brand small { display: block; color: var(--muted); font-family: 'Nunito'; font-size: 12px; }
.stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { background: #f3f0ff; border: 1px solid #e9e3ff; padding: 6px 12px; border-radius: 999px; font-size: 14px; color: var(--ink); }
.btn-ghost:hover { background: #ede9fe; }
main { max-width: 1000px; margin: 0 auto; padding: 22px 16px 80px; overflow-x: clip; }   /* عُقد الخريطة المُزاحة لا تُحدث تمريرًا أفقيًّا */
h1, h2, h3 { margin: .2em 0 .5em; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; border: 1px solid #f0ecff; }
.muted { color: var(--muted); }
.btn {
  border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px -6px rgba(109,40,217,.6);
  transition: transform .1s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: #fff; color: var(--primary); border: 2px solid #ddd6fe; box-shadow: none; }
.btn.ok { background: linear-gradient(135deg, #16a34a, #22c55e); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #f43f5e); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ===== Hero / levels ===== */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  background: linear-gradient(135deg, #4c1d95, #7c3aed 55%, #0ea5e9); color: #fff; }
.hero p { opacity: .9; margin: 0; }
.progress { height: 10px; background: rgba(0,0,0,.08); border-radius: 99px; overflow: hidden; }
.hero .progress { background: rgba(255,255,255,.25); width: 260px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #facc15, #22c55e); border-radius: 99px; transition: width .4s; }
.level-tabs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; }
.level-tab { flex: 0 0 auto; border: 2px solid transparent; background: #fff; border-radius: 16px; padding: 10px 16px; min-width: 130px; text-align: center; box-shadow: var(--shadow); }
.level-tab b { display: block; font-size: 20px; font-family: 'Nunito'; }
.level-tab.active { border-color: var(--lvl); }
.level-tab.locked { opacity: .5; }

/* ===== Journey path ===== */
.path { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 0 30px; }
.node-wrap { display: flex; width: 100%; justify-content: center; position: relative; height: 104px; }
.node-wrap:nth-child(4n+2) { transform: translateX(-90px); }
.node-wrap:nth-child(4n+4) { transform: translateX(90px); }
.node {
  width: 76px; height: 76px; border-radius: 50%; border: 0; font-size: 30px; position: relative;
  background: #fff; box-shadow: 0 6px 0 #d4d4d8, var(--shadow); transition: transform .15s;
}
.node:hover:not(:disabled) { transform: scale(1.07); }
.node.open { background: var(--lvl); box-shadow: 0 6px 0 rgba(0,0,0,.2), 0 0 0 8px color-mix(in srgb, var(--lvl) 25%, transparent); animation: pulse 2s infinite; }
.node.done { background: linear-gradient(135deg, #facc15, #f59e0b); box-shadow: 0 6px 0 #b45309; }
.node:disabled { filter: grayscale(1); opacity: .55; cursor: not-allowed; }
.node .num { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font: 700 11px 'Nunito'; padding: 2px 7px; border-radius: 99px; }
.node-label { position: absolute; top: 18px; inset-inline-start: calc(50% + 50px); width: 190px; font: 600 13px 'Nunito'; direction: ltr; text-align: left; }
.node-label small { display: block; color: var(--muted); font-weight: 400; }
.node-wrap.side .node-label { inset-inline-start: auto; inset-inline-end: calc(50% + 50px); text-align: right; }
.final-node { width: 110px; height: 110px; font-size: 44px; border-radius: 30px; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 rgba(0,0,0,.2), 0 0 0 14px color-mix(in srgb, var(--lvl) 10%, transparent); } }

/* ===== Story stages ===== */
.stepper { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.step { flex: 1 0 92px; text-align: center; padding: 10px 6px; border-radius: 14px; background: #fff; border: 2px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); }
.step .ic { font-size: 22px; display: block; }
.step.current { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }
.step.passed { border-color: #86efac; color: var(--ok); background: #f0fdf4; }
.step.clickable { cursor: pointer; }
.story-text { font-size: 19px; line-height: 1.9; }
.story-text p { margin: 0 0 14px; }
.story-text .vw { background: #fef3c7; border-radius: 6px; padding: 0 3px; cursor: pointer; border-bottom: 2px dotted #f59e0b; }
.story-text .w.hl { background: #c4b5fd; border-radius: 4px; }
.story-text .w.ok { color: var(--ok); }
.story-text .w.miss { color: var(--bad); text-decoration: underline wavy; }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.flash { perspective: 800px; height: 150px; cursor: pointer; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; box-shadow: var(--shadow); }
.flash-front { background: linear-gradient(135deg, #ede9fe, #fff); }
.flash-front b { font: 800 22px 'Nunito'; }
.flash-back { background: linear-gradient(135deg, #dcfce7, #fff); transform: rotateY(180deg); }
.flash.seen .flash-front { outline: 3px solid #86efac; }
.pos { font: 600 11px 'Nunito'; color: var(--primary); background: #f3f0ff; padding: 1px 8px; border-radius: 99px; }

.q { padding: 14px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; background: #fff; }
.q-en { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; direction: ltr; }
.opt { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px; font: 600 15px 'Nunito'; }
.opt:hover { border-color: var(--primary-2); }
.opt.sel { border-color: var(--primary); background: #f5f3ff; }
.opt.right { border-color: var(--ok); background: #dcfce7; }
.opt.wrong { border-color: var(--bad); background: #fee2e2; }
.result { padding: 14px 18px; border-radius: 14px; font-weight: 700; margin: 12px 0; }
.result.pass { background: #dcfce7; color: #166534; }
.result.fail { background: #fee2e2; color: #991b1b; }
.grammar-box { background: linear-gradient(135deg, #fffbeb, #fff); border: 1px solid #fde68a; white-space: pre-line; line-height: 1.9; }
textarea { width: 100%; min-height: 160px; border: 2px solid var(--line); border-radius: 14px; padding: 14px; font: 16px 'Nunito'; direction: ltr; resize: vertical; }
textarea:focus, input:focus { outline: none; border-color: var(--primary-2); }
input[type=text], input[type=password], select { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font: 15px 'Nunito'; width: 100%; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 99px; background: #f3f4f6; margin: 3px; font: 600 13px 'Nunito'; }
.chip.ok { background: #dcfce7; color: #166534; }
.chip.no { background: #fee2e2; color: #991b1b; }
.rec-btn { width: 84px; height: 84px; border-radius: 50%; font-size: 34px; border: 0; background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; box-shadow: 0 8px 20px -6px #e11d48; }
.rec-btn.on { animation: rec 1s infinite; }
@keyframes rec { 50% { box-shadow: 0 0 0 16px rgba(225, 29, 72, .15); } }
.transcript { direction: ltr; text-align: left; font: 16px 'Nunito'; background: #f9fafb; border-radius: 12px; padding: 12px; min-height: 48px; }
.score-ring { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; font: 800 26px 'Nunito'; background: conic-gradient(var(--ok) calc(var(--p) * 1%), #e5e7eb 0); position: relative; }
.score-ring::after { content: ''; position: absolute; inset: 10px; background: #fff; border-radius: 50%; }
.score-ring span { position: relative; z-index: 1; }
.ai-box { border: 1px dashed var(--primary-2); background: #faf5ff; border-radius: 14px; padding: 14px; line-height: 1.9; }
.ai-box .fix { direction: ltr; text-align: left; font-family: 'Nunito'; }
.ai-box del { color: var(--bad); } .ai-box ins { color: var(--ok); text-decoration: none; font-weight: 700; }
.table { width: 100%; border-collapse: collapse; }
.table td, .table th { padding: 10px; border-bottom: 1px solid var(--line); text-align: start; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 14px; transition: transform .3s; z-index: 50; font-weight: 600; }
#toast.show { transform: translateX(-50%) translateY(0); }
.badge-locked { font-size: 60px; text-align: center; }
.cert { text-align: center; background: linear-gradient(135deg, #fef9c3, #fff, #ede9fe); border: 4px double #f59e0b; }

@media (max-width: 640px) {
  /* على الجوال: إزاحة أصغر وعنوان أضيق حتى يبقى عنوان كل قصة داخل الشاشة */
  .node-wrap:nth-child(4n+2) { transform: translateX(-24px); }
  .node-wrap:nth-child(4n+4) { transform: translateX(24px); }
  .node-label { width: min(104px, calc(50vw - 78px)); font-size: 12px; }
  .hero .progress { width: 100%; }
  .story-text { font-size: 17px; }
}

/* ===== Read-aloud: paragraph chips ===== */
.chip-btn { border: 2px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 13px; font: 600 13px 'Cairo', sans-serif; color: var(--ink); }
.chip-btn:hover { border-color: var(--primary-2); }
.chip-btn.done { border-color: #86efac; background: #f0fdf4; }
.chip-btn.active { border-color: var(--primary); background: #f5f3ff; color: var(--primary); }
.story-text p.dim { opacity: .35; }

/* ===== اختبار تحديد المستوى ===== */
.invite { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #eef2ff, #fdf4ff); border: 2px dashed #c4b5fd; }
.invite h2 { margin: 0 0 6px; }
.invite p { margin: 0; max-width: 560px; }
.place-steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.place-step { padding: 6px 16px; border-radius: 999px; background: #f1f5f9; color: #64748b; font: 800 14px 'Nunito', sans-serif; }
.place-step.now { background: var(--primary); color: #fff; }
.place-step.ok { background: #dcfce7; color: #166534; }
.place-rules { margin: 0 0 14px; padding-inline-start: 22px; line-height: 2; }

/* ===== الحسابات: تسجيل الدخول وإنشاء الحساب ===== */
.auth { max-width: 520px; margin: 0 auto; }
.auth .hero h1 { margin: 0 0 6px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.auth-form input[type=email], .auth-form input[type=password], .auth-form input[type=text] {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font: 15px 'Nunito'; width: 100%; box-sizing: border-box; }
.auth-form #nm { direction: rtl; font-family: 'Cairo', sans-serif; }
.auth-form a { align-self: flex-start; }

/* ===== حسابي: القسيمة والدعم ===== */
.acct-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.acct-box input[type=text], .acct-box textarea { direction: rtl; font-family: 'Cairo', sans-serif; }
.acct-box textarea { min-height: 90px; }
.my-ticket { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
.my-ticket .reply { background: #f5f3ff; border-radius: 10px; padding: 8px 12px; margin-top: 8px; }

/* ===== لوحة المدير ===== */
body.admin main { max-width: 1180px; }
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; max-width: 1180px; margin: 14px auto 0; padding: 0 16px; }
.admin-tabs a { padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px; }
.admin-tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
h2.sec { font-size: 17px; color: var(--muted); margin: 18px 4px 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid #f0ecff; border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
a.kpi:hover { border-color: #c4b5fd; }
.kpi small { color: var(--muted); font-weight: 600; }
.kpi b { font: 800 28px 'Nunito', 'Cairo', sans-serif; }
.kpi span { font-size: 13px; }
.st { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; border: 1px solid; }
.st-paid { background: #dcfce7; color: #166534; border-color: #86efac; }
.st-trial { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.st-expired { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }
.st-admin { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.scroll { overflow-x: auto; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #faf8ff; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
body.admin input[type=number], body.admin input[type=date], body.admin input:not([type]) { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font: 15px 'Nunito', 'Cairo', sans-serif; width: 100%; }
body.admin textarea { min-height: 80px; direction: rtl; font-family: 'Cairo', sans-serif; font-size: 15px; }
body.admin pre { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.ticket .body { white-space: pre-wrap; }
.ticket .reply { background: #f5f3ff; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.ticket .reply p { margin: 4px 0 0; white-space: pre-wrap; }
#toast.bad { background: var(--bad); }
/* المخطط: أعمدة رفيعة بلون واحد، وشبكة خافتة، وتلميح عند المرور */
.chart { position: relative; direction: ltr; margin-top: 10px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .g { stroke: #eef0f4; stroke-width: 1; }
.chart .g.base { stroke: #cbd5e1; }
.chart .ax { fill: var(--muted); font: 11px 'Nunito', sans-serif; }
.chart .bar { fill: var(--primary); }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: rgba(109, 40, 217, .07); }
.chart .tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 13px; direction: rtl; min-width: 140px; }
.scroll .table th, .scroll .table td { white-space: nowrap; }
@media (max-width: 640px) {
  .kpi b { font-size: 22px; }
  .admin-tabs a { font-size: 13px; padding: 6px 10px; }
  body.admin #who .muted { display: none; }
  body.admin .brand small { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* الشريط العلوي على الجوال: اسم الحساب يُختصر حتى لا تزدحم الأزرار */
@media (max-width: 640px) {
  .who-name { display: none; }
  .stats { gap: 6px; }
  .stats .pill { padding: 6px 9px; font-size: 13px; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { gap: 6px; flex-shrink: 0; }
  .brand .logo { font-size: 24px; }
  .brand b { white-space: nowrap; font-size: 15px; }
  .brand small { display: none; }
  .stats { justify-content: flex-end; }
}

/* تنبيه رصيد التصحيحات: لا يظهر إلا قرب الحد */
.quota-note { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: #fef9c3; color: #854d0e; font-weight: 600; font-size: 14px; }
.quota-note.full { background: #ffedd5; color: #9a3412; }

/* ===== أخطائي ===== */
.mistake { border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; background: #fff; }
.mistake .q-en { margin: 8px 0 6px; font-weight: 600; }
.mistake small { display: block; color: var(--muted); margin-top: 4px; }
.mk-kind { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #f3f0ff; color: var(--primary); font-size: 12px; font-weight: 700; }
.mk-ans { display: flex; gap: 14px; flex-wrap: wrap; font-weight: 600; }
.mk-bad { color: #b91c1c; }
.mk-good { color: #15803d; }
.mk-fixed { color: #15803d; font-weight: 700; font-size: 14px; }
@media (max-width: 640px) { .pill-label { display: none; } }

/* ===== الهدف اليومي والسلسلة ===== */
.goal-ring { --p: 0; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; vertical-align: middle;
  background: conic-gradient(var(--warn) calc(var(--p) * 1%), #e5e7eb 0); }
.goal-ring > span { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #fff; font-size: 12px; line-height: 1; }
.goal-banner { padding: 14px 18px; background: linear-gradient(135deg, #fff7ed, #fffbeb); border: 1px solid #fed7aa; }
.goal-banner.done { background: linear-gradient(135deg, #f0fdf4, #ecfdf5); border-color: #bbf7d0; }
.progress.goal i { background: linear-gradient(90deg, #f59e0b, #f97316); }
.modal-bg { position: fixed; inset: 0; background: rgba(30, 27, 75, .45); display: grid; place-items: center; padding: 16px; z-index: 60; }
.modal { width: min(460px, 100%); max-height: 90vh; overflow-y: auto; margin: 0; }
.info-stats { display: flex; gap: 12px; margin: 12px 0 4px; }
.info-stats > div { flex: 1; background: #f8f7ff; border-radius: 12px; padding: 10px; text-align: center; }
.info-stats b { display: block; font: 800 26px 'Nunito', sans-serif; }
.info-stats small { color: var(--muted); }

/* ===== الشارات ===== */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; opacity: .75; }
.badge.on { opacity: 1; border-color: #fcd34d; background: linear-gradient(180deg, #fffbeb, #fff); box-shadow: var(--shadow); }
.badge .b-ic { font-size: 34px; line-height: 1.2; }
.badge:not(.on) .b-ic { filter: grayscale(1); }
.badge small { color: var(--muted); font-size: 12px; }
.badge .b-date { color: #92400e; }
.badge .progress { width: 100%; height: 6px; margin-top: 4px; }
.info-stats { flex-wrap: wrap; }

/* ===== المحادثة مع المعلم الذكي ===== */
.talk-promo { display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 14px 18px; border: 2px solid #ddd6fe; }
.talk-promo:hover { border-color: var(--primary); }
.talk-promo div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.talk-promo small { color: var(--muted); }
.t-ic { font-size: 32px; line-height: 1; }
.talk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 8px; }
.talk-card { text-align: start; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 6px; font-family: inherit; color: var(--ink); }
.talk-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.talk-card small { color: var(--muted); line-height: 1.6; }
.talk-goals { margin: 0; padding-inline-start: 22px; line-height: 2; }
.phrase { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.phrase .en { font-weight: 700; }
.phrase small { color: var(--muted); }
.talk-head { position: sticky; top: 64px; z-index: 5; padding: 12px 16px; }
.talk-goals-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tg { font-size: 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.tg.ok { background: #f0fdf4; border-color: #86efac; color: #166534; }
.talk-log { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px; }
.bub { max-width: 82%; padding: 10px 14px; border-radius: 16px; }
.bub.ai { align-self: flex-end; background: #f5f3ff; border: 1px solid #e9e3ff; border-end-end-radius: 4px; }
.bub.me { align-self: flex-start; background: #ecfeff; border: 1px solid #cffafe; border-end-start-radius: 4px; }
.bub .en { font-size: 16px; }
.bub-tools { display: flex; gap: 6px; margin-top: 6px; }
.bub-tools .chip-btn { padding: 3px 9px; }
.bub-ar { margin-top: 6px; color: var(--muted); font-size: 14px; }
.hidden-text { filter: blur(6px); cursor: pointer; user-select: none; }
.talk-compose { display: flex; gap: 8px; align-items: center; }
.talk-compose input { flex: 1; }
.btn.mic { font-size: 22px; padding: 10px 16px; border-radius: 50%; }
.btn.mic.rec { background: linear-gradient(135deg, #dc2626, #f43f5e); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.better { border-bottom: 1px dashed var(--line); padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 640px) { .talk-head { top: 104px; } .bub { max-width: 92%; } }

/* ===== خطط الاشتراك ===== */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 18px; }
.plan-card { position: relative; background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.plan-card.featured { border-color: var(--primary); box-shadow: var(--shadow); }
.plan-card h2 { margin: 0; }
.plan-card ul { margin: 0; padding-inline-start: 20px; line-height: 2; flex: 1; }
.plan-tag { position: absolute; top: -12px; inset-inline-start: 18px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 999px; }
.plan-price b { font: 800 34px 'Nunito', sans-serif; }
.plan-price small { color: var(--muted); margin-inline-start: 4px; }
.plan-save { color: #15803d; font-weight: 700; font-size: 14px; }
.legal-links { text-align: center; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.legal-links a { color: var(--muted); }

/* ===== الصفحات القانونية ===== */
.legal { max-width: 820px; margin: 0 auto; line-height: 1.95; }
.legal h1 { margin-top: 0; }
.legal h2 { margin-top: 26px; font-size: 20px; }
.legal li { margin-bottom: 4px; }
.legal .updated { color: var(--muted); font-size: 14px; }

/* ═══════════════════ نظام التصميم v2 ═══════════════════
   لون واحد للعلامة (البنفسجي)، وكل لون آخر بمعنى ثابت:
   الأخضر = نجاح، البرتقالي = التحفيز والسلسلة، الأحمر = خطأ، الذهبي = إنجاز (نجوم ونقاط)، ولون المستوى = هوية المستوى فقط. */
:root {
  --muted: #5b6472;                      /* تباين أوضح للنص الثانوي */
  --brand-grad: linear-gradient(135deg, #4c1d95, #6d28d9 60%, #7c3aed);
  --brand-soft: #f3f0ff;
  --gold: #f59e0b;
  --flame: #f97316;
}
body { background: radial-gradient(1100px 520px at 100% -10%, #ede9fe 0, transparent 60%), var(--bg); }
.hero { background: var(--brand-grad); }
.progress > i { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.ico { flex: 0 0 auto; vertical-align: middle; }

/* الشريط العلوي */
.topbar { padding: 8px 18px; }
.brand .logo { display: grid; place-items: center; }
.logo-mark { display: block; filter: drop-shadow(0 4px 10px rgba(109, 40, 217, .35)); }
.stats { gap: 6px; }
.pill.stat { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); font: 800 14px 'Nunito', sans-serif; cursor: pointer; }
.pill.stat:hover { border-color: #ddd6fe; }
.stat-xp .ico { color: var(--gold); }
.stat-streak .ico { color: var(--flame); }
.goal-ring { --p: 0; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(var(--flame) calc(var(--p) * 1%), #ececf1 0); }
.goal-ring > span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: var(--flame); }
.goal-ring > span .ico { width: 14px; height: 14px; }
.goal-ring.big { width: 42px; height: 42px; }
.goal-ring.big > span { width: 34px; height: 34px; }
.goal-ring.big > span .ico { width: 20px; height: 20px; }
.nav-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.navlink { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font: 700 14px 'Cairo', sans-serif;
  padding: 8px 10px; border-radius: 12px; }
.navlink:hover { background: var(--brand-soft); color: var(--ink); }
.navlink.on { background: var(--brand-soft); color: var(--primary); }
body.guest .stats, body.guest .bottom-nav { display: none !important; }

/* شريط التنقل السفلي (الجوال فقط) */
.bottom-nav { display: none; }
@media (max-width: 640px) {
  .navlink, .nav-sep { display: none; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted); font: 700 11px 'Cairo', sans-serif; padding: 4px 0; border-radius: 12px; }
  .bottom-nav button.on { color: var(--primary); }
  .bottom-nav button.on .ico { background: var(--brand-soft); border-radius: 10px; padding: 3px 10px; box-sizing: content-box; }
  main { padding-bottom: 104px; }
  #toast { bottom: 92px; }
  .talk-head { top: 60px; }
}

/* رأس الصفحة الرئيسية المضغوط */
.home-head { padding: 16px 18px; }
.hh-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hh-level { display: flex; align-items: center; gap: 12px; }
.lvl-chip { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: var(--lvl); color: #fff;
  font: 800 18px 'Nunito', sans-serif; box-shadow: 0 6px 14px -6px var(--lvl); }
.hh-level b { display: block; font-size: 18px; }
.hh-level small, .hh-goal small { display: block; color: var(--muted); font-size: 13px; }
.hh-goal { display: flex; align-items: center; gap: 10px; text-align: start; font-family: inherit; color: var(--ink);
  background: #fff7ed; border: 1.5px solid #fed7aa; border-radius: 16px; padding: 7px 14px 7px 10px; }
.hh-goal b { font-size: 14px; }
.hh-goal.done { background: #f0fdf4; border-color: #bbf7d0; }
.hh-goal.danger { background: #fef2f2; border-color: #fecaca; }
.progress.lvl { height: 8px; margin: 14px 0 10px; }
.progress.lvl > i { background: var(--lvl); }
.hh-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.talk-chip { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid #ddd6fe; background: var(--brand-soft); color: var(--primary);
  font: 700 13px 'Cairo', sans-serif; padding: 6px 12px; border-radius: 999px; }
.talk-chip:hover { border-color: var(--primary); }
@media (max-width: 640px) { .hh-goal { width: 100%; } }

/* خريطة الرحلة */
.path::before { content: ''; position: absolute; top: 40px; bottom: 120px; left: 50%; border-left: 4px dotted #ddd6fe; transform: translateX(-2px); }
.node-wrap { z-index: 1; }
.node .n-ic { display: grid; place-items: center; line-height: 1; }
.node:disabled .n-ic { color: #9ca3af; }
.node.done { background: linear-gradient(160deg, #fffbeb, #fcd34d); box-shadow: 0 6px 0 #d97706, var(--shadow); }
.node .stars { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: #fff; color: var(--gold);
  font: 800 13px 'Nunito', sans-serif; letter-spacing: 1px; padding: 0 7px; border-radius: 99px; box-shadow: 0 2px 6px rgba(0,0,0,.12); white-space: nowrap; direction: ltr; }
.node-label { font: 700 14px 'Nunito', sans-serif; }
.node-label small { font-size: 12px; margin-top: 2px; }
.final-node .ico { color: #9ca3af; }

/* القصة: تظليل كلمة الدرس وحدها، ولون العلامة بدل الأصفر */
.story-text .vw { background: none; border: 0; padding: 0; cursor: pointer; }
.story-text .vw-core { background: var(--brand-soft); border-radius: 6px; padding: 0 3px; border-bottom: 2px solid #c4b5fd; }
.story-text .vw:hover .vw-core { background: #e4dcff; }
.step .ic { display: grid; place-items: center; height: 26px; }
.step.passed .ic { color: var(--ok); }
.node .stars i { font-style: normal; color: #d6d3d1; }
