/* learno — التصميم. الألوان رموز على :root، والوضع الداكن تلقائيّ أو يدويّ (data-theme). */
:root {
  --bg: #f6f6fb; --card: #ffffff; --fg: #181830; --muted: #62627a; --line: #e3e3ef;
  --brand: #4f46e5; --brand-ink: #ffffff; --brand-soft: #eef0ff; --accent: #f59e0b;
  --ok: #15803d; --ok-soft: #dcfce7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(20, 20, 60, .06), 0 6px 20px rgba(20, 20, 60, .06);
  --r: 16px;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Noto Sans Hebrew", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f1d; --card: #181a2e; --fg: #ececf7; --muted: #a3a3bd; --line: #2b2d47;
    --brand: #818cf8; --brand-ink: #0e0f1d; --brand-soft: #23264a; --accent: #fbbf24;
    --ok: #4ade80; --ok-soft: #0f2e1d; --bad: #f87171; --bad-soft: #3a1518;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f1d; --card: #181a2e; --fg: #ececf7; --muted: #a3a3bd; --line: #2b2d47;
  --brand: #818cf8; --brand-ink: #0e0f1d; --brand-soft: #23264a; --accent: #fbbf24;
  --ok: #4ade80; --ok-soft: #0f2e1d; --bad: #f87171; --bad-soft: #3a1518;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--font); min-height: 100vh; }
button, input { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
h1 { font-size: 26px; line-height: 1.3; margin: 6px 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }

/* ── الترويسة ── */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); min-width: 0; }
.brand img { border-radius: 10px; flex: none; }
.brand-tx { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: .2px; direction: ltr; unicode-bidi: isolate; text-align: start; }
.tagline { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none;
  border: 1px solid var(--line); background: var(--card); text-decoration: none; font-size: 20px; cursor: pointer;
}

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; outline: none; }

/* ── عناصر عامّة ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .3s; }
.btn {
  display: block; width: 100%; min-height: 48px; margin: 10px 0 0; padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.back { display: inline-block; margin: 4px 0 8px; text-decoration: none; font-weight: 700; padding: 8px 0; }
.pill { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; background: var(--accent); color: #1c1300; }

/* ── الرئيسيّة ── */
.hero { padding: 8px 0 4px; }
.hero h1 { font-size: 28px; }
.continue { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; cursor: pointer; border-color: var(--brand); }
.continue-ic { font-size: 30px; }
.continue-tx { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.chev { font-size: 26px; color: var(--muted); }
.group { margin-top: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.skill-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: start; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow);
  border-top: 4px solid var(--c, var(--brand)); min-height: 132px; transition: transform .15s;
}
.skill-card:hover { transform: translateY(-2px); }
.skill-card .bar { width: 100%; margin-top: auto; }
.skill-ic { font-size: 30px; line-height: 1; }
.skill-ic.big { font-size: 44px; }
.skill-name { font-weight: 800; }

/* ── المهارة ── */
.skill-head { display: flex; align-items: center; gap: 14px; }
.tier { border-inline-start: 5px solid var(--c, var(--brand)); }
.tier-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.units { display: grid; gap: 8px; }
.unit {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; text-align: start;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.unit-n { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--line); font-weight: 800; font-size: 14px; }
.unit-name { flex: 1; }
.unit.done .unit-n { background: var(--ok); color: #fff; }
.unit.next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ── الدرس ── */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.lesson-top .bar { flex: 1; height: 12px; }
.teach { text-align: center; }
.teach .explain { font-size: 18px; line-height: 1.9; margin: 6px 0 0; }
.teach .label { display: block; margin-top: 12px; color: var(--brand); font-weight: 800; }
.mexpr, .mexpr-in { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.teach .mexpr { font-size: 30px; font-weight: 800; margin: 8px 0; }
.expr { text-align: center; font-size: 34px; font-weight: 800; }
.q-prompt { font-size: 20px; line-height: 1.6; margin: 6px 0 10px; }
.listen { max-width: 220px; margin-inline: auto; }
.choices { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 560px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: start;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--card); cursor: pointer; font-size: 17px; font-weight: 600;
}
.choice:not(:disabled):hover { border-color: var(--brand); }
.choice .key { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.input-row { display: flex; gap: 8px; max-width: 360px; margin: 14px auto 0; }
.answer-input {
  flex: 1; min-width: 0; min-height: 52px; padding: 10px 14px; font-size: 22px; font-weight: 800; text-align: center;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
}
.answer-input.right { border-color: var(--ok); background: var(--ok-soft); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.input-row .btn { width: auto; margin: 0; }
.feedback:empty { display: none; }
.feedback { margin-top: 14px; padding: 14px; border-radius: var(--r); }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback b { font-size: 18px; }
.feedback .ans { margin-inline-start: 8px; font-weight: 800; }
.result h1 { font-size: 24px; }
.stars { font-size: 42px; }

/* ── الإعدادات ── */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

/* رسومات المهارات (من ملفّات المهارات — نفس صنفَي dilo) */
.mviz { display: flex; justify-content: center; align-items: center; margin: 14px auto; color: var(--muted); max-width: 360px; }
.mviz-count { flex-wrap: wrap; gap: 8px; font-size: 30px; line-height: 1; }
.mviz svg { max-width: 100%; height: auto; }

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