/* ============================================================
   أكاديمية HalaGPT — نظام التصميم
   Aesthetic: "Modern Majlis" — warm paper, girih geometry,
   deep teal ink, saffron accents. Arabic-first, RTL-native.
   ============================================================ */

:root {
  /* اللوحة اللونية */
  --paper: #faf4e8;
  --paper-deep: #f1e7d2;
  --surface: #fffcf4;
  --ink: #11302e;
  --ink-soft: #41605c;
  --ink-faint: #54716d; /* 4.9:1 على الورق — يجتاز AA للنص الصغير */
  --teal: #156b66;
  --teal-deep: #0c4744;
  --teal-night: #0a2f2d;
  --saffron: #dfa31e;
  --saffron-soft: #f6dd9a;
  --terracotta: #c2552f;
  --terracotta-soft: #f4d4c6;
  --line: rgba(17, 48, 46, 0.16);
  --line-strong: rgba(17, 48, 46, 0.32);
  --ok: #2e7d4f;
  --ok-soft: #d9eede;
  --bad: #b3402e;
  --bad-soft: #f6ddd7;

  /* الخطوط */
  --font-display: "Aref Ruqaa", serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;

  /* الظل المُزاح — يتجه نحو نهاية السطر (يسار في RTL) */
  --shadow-pop: -5px 6px 0 rgba(12, 71, 68, 0.12);
  --shadow-pop-strong: -7px 8px 0 rgba(12, 71, 68, 0.16);
  --shadow-soft: 0 10px 30px rgba(12, 71, 68, 0.1);

  --radius: 14px;
  --radius-sm: 9px;

  /* مقياس أحجام الخط الصغيرة — درجات نظيفة بفاصل 0.05rem */
  --text-xs: 0.75rem;
  --text-sm: 0.8rem;
  --text-md: 0.85rem;
  --text-lg: 0.9rem;
  --text-xl: 0.95rem;

  /* مقاسات موحّدة للأيقونات والبطاقات */
  --ico: 1.25em; /* الحجم الأساسي للأيقونة داخل النص */
  --ico-lg: 36px; /* أيقونة العنوان (course-hero) */
  --ico-xl: 54px; /* أيقونة بطاقة الدورة */
  --ico-sm: 28px; /* أيقونة داخل دائرة مصغّرة */
  --card-pad: 22px; /* حشوة موحّدة للبطاقات */

  /* نقش النجمة الثمانية (girih) */
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%2311302e' stroke-opacity='0.07' stroke-width='1.2'%3E%3Cpath d='M48 8 L59 37 L88 48 L59 59 L48 88 L37 59 L8 48 L37 37 Z'/%3E%3Cpath d='M48 22 L66 30 L74 48 L66 66 L48 74 L30 66 L22 48 L30 30 Z'/%3E%3Ccircle cx='48' cy='48' r='6'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- أساسيات ---------- */
* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* رابط تجاوز المحتوى */
.skip-link {
  position: absolute;
  inset-block-start: -48px;
  inset-inline-start: 16px;
  z-index: 100;
  background: var(--teal-night);
  color: var(--paper);
  padding: 10px 20px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 700;
  transition: inset-block-start 0.2s;
}
.skip-link:focus {
  inset-block-start: 0;
  color: var(--paper);
}

/* حلقة تركيز موحدة للوحة المفاتيح */
:focus-visible {
  outline: 2.5px solid var(--teal-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

/* أيقونات SVG */
.ico {
  inline-size: var(--ico);
  block-size: var(--ico);
  flex: none;
  vertical-align: -0.22em;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.9;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--girih);
  background-attachment: fixed;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.5;
  margin-block: 0 0.5em;
  color: var(--ink);
}

h1 {
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
}
h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
}
h3 {
  font-size: 1.25rem;
  font-family: var(--font-body);
  font-weight: 700;
}

p {
  margin-block: 0 1em;
}

a {
  color: var(--teal);
  text-decoration: none;
}
a:hover {
  color: var(--teal-deep);
}

::selection {
  background: var(--saffron-soft);
  color: var(--ink);
}

.container {
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

/* ---------- شريط التنقل ---------- */
.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 50;
  background: var(--teal-night);
  color: var(--paper);
  border-block-end: 3px solid var(--saffron);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-block-size: 64px;
  flex-wrap: wrap;
  padding-block: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  white-space: nowrap;
}
.brand:hover {
  color: #fff;
}
.brand .star {
  inline-size: 30px;
  block-size: 30px;
  flex: none;
}
.brand em {
  font-style: normal;
  color: var(--saffron);
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-inline-start: auto;
}

.nav a {
  color: rgba(250, 244, 232, 0.85);
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: var(--text-xl);
  transition:
    background 0.2s,
    color 0.2s;
}
.nav a:hover {
  background: rgba(250, 244, 232, 0.12);
  color: #fff;
}
.nav a.active {
  background: var(--saffron);
  color: var(--teal-night);
  font-weight: 700;
}

/* ---------- الترويسة (hero) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(48px, 9vw, 110px) clamp(44px, 7vw, 90px);
  border-block-end: 1.5px solid var(--line);
  background:
    radial-gradient(
      720px 360px at 12% -10%,
      rgba(223, 163, 30, 0.16),
      transparent 65%
    ),
    radial-gradient(
      900px 480px at 95% 110%,
      rgba(21, 107, 102, 0.12),
      transparent 60%
    );
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--teal-deep);
  box-shadow: var(--shadow-pop);
  margin-block-end: 22px;
}
.hero-kicker .dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  animation: pulse 2.2s ease-in-out infinite;
}

.hero h1 {
  max-inline-size: 17ch;
}
.hero h1 .accent {
  position: relative;
  color: var(--teal);
  white-space: nowrap;
}
.hero h1 .accent::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0.04em;
  block-size: 0.28em;
  background: linear-gradient(90deg, var(--saffron), var(--saffron-soft));
  z-index: -1;
  border-radius: 3px;
  transform: skewY(-1deg);
}

.hero-sub {
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  color: var(--ink-soft);
  max-inline-size: 52ch;
  margin-block: 14px 30px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-ornament {
  position: absolute;
  inset-inline-end: -70px;
  inset-block-start: 50%;
  translate: 0 -50%;
  inline-size: clamp(260px, 32vw, 430px);
  opacity: 0.9;
  pointer-events: none;
  animation: spin-slow 90s linear infinite;
}
@media (max-width: 860px) {
  .hero-ornament {
    opacity: 0.22;
  }
}

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  padding: 11px 26px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--teal-deep);
  cursor: pointer;
  transition:
    translate 0.15s ease,
    box-shadow 0.15s ease,
    background 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--teal);
  color: #fdf9ef;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover {
  background: var(--teal-deep);
  color: #fff;
  translate: -2px 2px;
  box-shadow: -3px 4px 0 rgba(12, 71, 68, 0.14);
}

.btn-gold {
  background: var(--saffron);
  color: var(--teal-night);
  border-color: #b8860b;
  box-shadow: var(--shadow-pop);
}
.btn-gold:hover {
  background: #e9b23a;
  translate: -2px 2px;
  box-shadow: -3px 4px 0 rgba(12, 71, 68, 0.14);
  color: var(--teal-night);
}

.btn-ghost {
  background: transparent;
  color: var(--teal-deep);
  border-color: var(--line-strong);
}
.btn-ghost:hover {
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.btn-sm {
  padding: 6px 14px;
  font-size: var(--text-lg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- شارة الإحصائيات ---------- */
.stats-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-block-start: 46px;
}
.stat {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-pop);
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--teal);
  line-height: 1.3;
}
.stat span {
  color: var(--ink-soft);
  font-size: var(--text-lg);
  font-weight: 500;
}

/* ---------- الأقسام ---------- */
.section {
  padding-block: clamp(48px, 7vw, 84px);
}
.section.alt {
  background: rgba(255, 252, 244, 0.6);
  border-block: 1.5px solid var(--line);
}

.section-head {
  margin-block-end: 36px;
  max-inline-size: 640px;
}
.section-head .eyebrow {
  display: inline-block;
  color: var(--terracotta);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: 0.02em;
  border: 1.5px solid var(--terracotta-soft);
  background: rgba(244, 212, 198, 0.4);
  padding: 3px 12px;
  border-radius: 999px;
  margin-block-end: 12px;
}
.section-head p {
  color: var(--ink-soft);
  margin-block-start: 6px;
}

/* ---------- بطاقات الدورات ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.course-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--card-pad);
  box-shadow: var(--shadow-pop);
  transition:
    translate 0.18s ease,
    box-shadow 0.18s ease;
  color: var(--ink);
}
.course-card:hover {
  translate: 0 -5px;
  box-shadow: var(--shadow-pop-strong);
  color: var(--ink);
}

.course-card .icon {
  inline-size: var(--ico-xl);
  block-size: var(--ico-xl);
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--paper-deep);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  margin-block-end: 14px;
}
.course-card .icon .ico {
  inline-size: var(--ico-sm);
  block-size: var(--ico-sm);
}

/* حالة الدورة المكتملة */
.course-card.completed {
  border-color: var(--ok);
}
.course-card.completed .icon {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(46, 125, 79, 0.35);
}
.badge.done-badge {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(46, 125, 79, 0.35);
}

.course-card h3 {
  font-size: 1.18rem;
  margin-block-end: 6px;
}
.course-card .desc {
  color: var(--ink-soft);
  font-size: var(--text-xl);
  flex: 1;
  margin-block-end: 14px;
}

.badge {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 2px 11px;
  border-radius: 999px;
  border: 1.5px solid transparent;
}
.badge.beginner {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(46, 125, 79, 0.3);
}
.badge.intermediate {
  background: var(--saffron-soft);
  color: #6e4e05;
  border-color: rgba(184, 134, 11, 0.35);
}
.badge.advanced {
  background: var(--terracotta-soft);
  color: var(--terracotta);
  border-color: rgba(194, 85, 47, 0.3);
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--text-md);
  color: var(--ink-faint);
  margin-block-end: 12px;
  flex-wrap: wrap;
}
.course-meta .sep {
  opacity: 0.5;
}

.progress-track {
  block-size: 8px;
  background: var(--paper-deep);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  block-size: 100%;
  background: linear-gradient(
    -90deg,
    var(--teal),
    var(--saffron)
  ); /* يمتد مع اتجاه RTL */
  border-radius: 999px;
  transition: inline-size 0.6s ease;
}
.progress-label {
  font-size: var(--text-sm);
  color: var(--ink-faint);
  margin-block-start: 6px;
}

.card-number {
  position: absolute;
  inset-block-start: 18px;
  inset-inline-end: 20px;
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: rgba(17, 48, 46, 0.08);
  line-height: 1;
}

/* ---------- بيان الأكاديمية (manifesto) ---------- */
.manifesto {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px 48px;
  max-inline-size: 920px;
}
.m-item {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding-block: 18px;
  border-block-end: 1.5px dashed var(--line);
}
.m-item:nth-child(2) {
  margin-block-start: 44px;
}
.m-item:nth-child(4) {
  margin-block-start: 44px;
}
.m-num {
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1.1;
  color: var(--saffron);
  text-shadow: -2px 2px 0 rgba(12, 71, 68, 0.18);
  flex: none;
}
.m-item h3 {
  font-size: 1.08rem;
  margin-block-end: 4px;
}
.m-item p {
  color: var(--ink-soft);
  font-size: var(--text-xl);
  margin: 0;
}
@media (max-width: 760px) {
  .manifesto {
    grid-template-columns: 1fr;
  }
  .m-item:nth-child(2),
  .m-item:nth-child(4) {
    margin-block-start: 0;
  }
}

/* ---------- مسار التعلم ---------- */
.path {
  counter-reset: step;
  display: grid;
  gap: 0;
  position: relative;
}
.path-step {
  position: relative;
  display: flex;
  gap: 20px;
  padding-block: 18px;
}
.path-step::before {
  counter-increment: step;
  content: counter(step, arabic-indic);
  flex: none;
  inline-size: 46px;
  block-size: 46px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.25rem;
  border-radius: 50%;
  border: 3px solid var(--saffron);
  z-index: 1;
}
.path-step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: 22px;
  inset-block-start: 64px;
  inset-block-end: -18px;
  border-inline-start: 2px dashed var(--line-strong);
}
.path-step h3 {
  margin-block-end: 2px;
  font-size: 1.08rem;
}
.path-step h3 a {
  color: var(--ink);
}
.path-step h3 a:hover {
  color: var(--teal);
}
.path-step p {
  color: var(--ink-soft);
  font-size: var(--text-lg);
  margin: 0;
}
.path-step.done::before {
  background: var(--ok);
  border-color: var(--ok-soft);
  content: "✓";
  font-size: 1.4rem;
}
.path-step .here-badge {
  display: inline-block;
  background: var(--saffron);
  color: var(--teal-night);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
  margin-inline-start: 8px;
  vertical-align: 2px;
}
.path-step .p-progress {
  font-size: var(--text-sm);
  color: var(--ink-faint);
  margin-block-start: 4px;
}
.path-step .p-progress a {
  font-weight: 700;
}

/* ---------- صفحة الدورة ---------- */
.course-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
  align-items: start;
  padding-block: 36px 70px;
}
@media (max-width: 900px) {
  .course-layout {
    grid-template-columns: 1fr;
  }
}

.lesson-nav {
  position: sticky;
  inset-block-start: 84px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-pop);
  max-block-size: calc(100vh - 110px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .lesson-nav {
    position: static;
    max-block-size: none;
  }
}

.lesson-nav h3 {
  font-size: var(--text-xl);
  color: var(--ink-faint);
  margin-block-end: 10px;
}
.lesson-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.lesson-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  inline-size: 100%;
  text-align: start;
  background: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s;
}
.lesson-nav button:hover {
  background: var(--paper-deep);
}
.lesson-nav button.active {
  background: var(--teal);
  color: var(--paper);
  font-weight: 600;
}
.lesson-nav .check {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font-size: var(--text-xs);
  background: var(--surface);
  color: transparent;
}
.lesson-nav .check.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.lesson-nav button.active .check {
  border-color: rgba(250, 244, 232, 0.6);
}
.lesson-nav button.active .check.done {
  background: var(--saffron);
  border-color: var(--saffron);
  color: var(--teal-night);
}

.course-progress-box {
  margin-block-start: 16px;
  padding-block-start: 14px;
  border-block-start: 1.5px dashed var(--line);
}

/* محتوى الدرس */
.lesson-body {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 44px);
  box-shadow: var(--shadow-pop);
  min-inline-size: 0;
}

.lesson-header {
  border-block-end: 1.5px solid var(--line);
  padding-block-end: 18px;
  margin-block-end: 26px;
}
.lesson-header .crumbs {
  font-size: var(--text-md);
  color: var(--ink-faint);
  margin-block-end: 8px;
}
.lesson-header h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  margin: 0;
}
.lesson-header .lmeta {
  color: var(--ink-faint);
  font-size: var(--text-lg);
  margin-block-start: 6px;
}

.lesson-content h3 {
  margin-block-start: 1.8em;
  padding-inline-start: 14px;
  border-inline-start: 4px solid var(--saffron);
}
.lesson-content ul,
.lesson-content ol {
  padding-inline-start: 24px;
  margin-block: 0 1.2em;
}
.lesson-content li {
  margin-block-end: 6px;
}
.lesson-content li::marker {
  color: var(--teal);
  font-weight: 700;
}
.lesson-content code {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.88em;
  direction: ltr;
  unicode-bidi: embed;
}

.callout {
  display: flex;
  gap: 14px;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-block: 18px;
  border: 1.5px solid;
  font-size: var(--text-xl);
}
.callout .c-icon {
  font-size: 1.25rem;
  line-height: 1.6;
  flex: none;
}
.callout p {
  margin: 0;
}
.callout b.c-title {
  display: block;
  margin-block-end: 2px;
}
.callout.tip {
  background: var(--ok-soft);
  border-color: rgba(46, 125, 79, 0.35);
}
.callout.warn {
  background: var(--bad-soft);
  border-color: rgba(179, 64, 46, 0.3);
}
.callout.example {
  background: rgba(246, 221, 154, 0.3);
  border-color: rgba(184, 134, 11, 0.35);
}

.prompt-block {
  position: relative;
  background: var(--teal-night);
  color: #e8f0ea;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--teal-deep);
  padding: 18px 20px;
  margin-block: 18px;
  box-shadow: var(--shadow-pop);
}
.prompt-block .p-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--saffron);
  margin-block-end: 8px;
}
.prompt-block pre {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-xl);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.85;
}
.copy-btn {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  background: rgba(250, 244, 232, 0.12);
  color: var(--paper);
  border: 1px solid rgba(250, 244, 232, 0.3);
  border-radius: 7px;
  padding: 4px 12px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.copy-btn:hover {
  background: rgba(250, 244, 232, 0.22);
}
.copy-btn.copied {
  background: var(--saffron);
  color: var(--teal-night);
  border-color: var(--saffron);
}

.table-scroll {
  overflow-x: auto;
  margin-block: 18px;
  -webkit-overflow-scrolling: touch;
}
.lesson-content table {
  inline-size: 100%;
  min-inline-size: 480px;
  border-collapse: collapse;
  font-size: var(--text-lg);
  background: var(--surface);
}
.lesson-content th,
.lesson-content td {
  border: 1.5px solid var(--line-strong);
  padding: 10px 14px;
  text-align: start;
}
.lesson-content th {
  background: var(--teal);
  color: var(--paper);
  font-weight: 600;
}
.lesson-content tr:nth-child(even) td {
  background: rgba(241, 231, 210, 0.45);
}

/* الاختبار */
.quiz-box {
  margin-block-start: 34px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 24px;
  background: rgba(241, 231, 210, 0.35);
}
.quiz-box > h3 {
  margin-block-start: 0;
  border: none;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.quiz-q {
  margin-block-start: 20px;
}
.quiz-q .q-text {
  font-weight: 700;
  margin-block-end: 10px;
}
.quiz-opts {
  display: grid;
  gap: 8px;
}
.quiz-opt {
  text-align: start;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: var(--text-xl);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.quiz-opt:hover:not(:disabled) {
  background: var(--paper-deep);
}
.quiz-opt.correct {
  background: var(--ok-soft);
  border-color: var(--ok);
  font-weight: 700;
}
.quiz-opt.wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
}
.quiz-opt:disabled {
  cursor: default;
}
.quiz-explain {
  margin-block-start: 10px;
  font-size: var(--text-lg);
  background: var(--surface);
  border-inline-start: 4px solid var(--saffron);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: none;
}
.quiz-explain.show {
  display: block;
  animation: fade-up 0.35s ease;
}
.quiz-score {
  margin-block-start: 18px;
  font-weight: 700;
  display: none;
}
.quiz-score.show {
  display: block;
  animation: fade-up 0.4s ease;
}

.lesson-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-block-start: 34px;
  padding-block-start: 22px;
  border-block-start: 1.5px solid var(--line);
}

/* ---------- مكتبة الأوامر ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-block-end: 28px;
}
.chip {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 18px;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  background: var(--paper-deep);
}
.chip.active {
  background: var(--teal);
  color: var(--paper);
  border-color: var(--teal-deep);
  box-shadow: var(--shadow-pop);
}

.search-input {
  flex: 1;
  min-inline-size: 220px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 20px;
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--ink);
}
.search-input:focus {
  outline: 2.5px solid var(--teal-deep);
  outline-offset: 1px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.prompt-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--card-pad);
  box-shadow: var(--shadow-pop);
  transition: translate 0.18s ease;
}
.prompt-card:hover {
  translate: 0 -4px;
}
.prompt-card .p-cat {
  align-self: start;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--terracotta);
  background: var(--terracotta-soft);
  padding: 2px 11px;
  border-radius: 999px;
  margin-block-end: 10px;
}
.prompt-card h3 {
  font-size: 1.02rem;
  margin-block-end: 8px;
}
.prompt-card .p-text {
  flex: 1;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: var(--text-lg);
  color: var(--ink-soft);
  white-space: pre-wrap;
  margin-block-end: 12px;
  max-block-size: 200px;
  overflow-y: auto;
}
.prompt-card .p-tip {
  font-size: var(--text-sm);
  color: var(--ink-faint);
  margin-block-end: 10px;
}
.prompt-card .p-actions {
  display: flex;
  gap: 8px;
}

/* ---------- المعجم ---------- */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.term-card {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--card-pad);
  box-shadow: var(--shadow-pop);
}
.term-card h3 {
  font-size: 1.08rem;
  margin-block-end: 2px;
}
.term-card .t-en {
  display: inline-block;
  direction: ltr;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--teal);
  background: rgba(21, 107, 102, 0.08);
  border: 1px solid rgba(21, 107, 102, 0.2);
  padding: 1px 10px;
  border-radius: 999px;
  margin-block-end: 10px;
}
.term-card .t-def {
  font-size: var(--text-lg);
  color: var(--ink-soft);
  margin: 0;
}
.term-card .t-ex {
  margin-block-start: 10px;
  font-size: var(--text-md);
  background: var(--paper-deep);
  border-inline-start: 3px solid var(--saffron);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
}

/* ---------- ساحة التدريب ---------- */
.playground-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 26px;
  align-items: start;
  padding-block: 36px 70px;
}
@media (max-width: 900px) {
  .playground-layout {
    grid-template-columns: 1fr;
  }
}

.pg-side {
  display: grid;
  gap: 18px;
  position: sticky;
  inset-block-start: 84px;
}
@media (max-width: 900px) {
  .pg-side {
    position: static;
  }
}

.pg-panel {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-pop);
}
.pg-panel h3 {
  font-size: 1rem;
  margin-block-end: 10px;
}
.pg-panel .hint {
  font-size: var(--text-md);
  color: var(--ink-faint);
}

.starter-list {
  display: grid;
  gap: 8px;
}
.starter-btn {
  text-align: start;
  background: var(--paper-deep);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-family: var(--font-body);
  font-size: var(--text-md);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.starter-btn:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
  background: var(--surface);
}

.chat-box {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  min-block-size: 70vh;
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--teal-night);
  color: var(--paper);
  padding: 14px 20px;
  font-weight: 700;
}
.chat-head .status-dot {
  inline-size: 9px;
  block-size: 9px;
  border-radius: 50%;
  background: var(--saffron);
  animation: pulse 2s infinite;
}
.chat-head select {
  margin-inline-start: auto;
  background: rgba(250, 244, 232, 0.1);
  color: var(--paper);
  border: 1px solid rgba(250, 244, 232, 0.3);
  border-radius: 7px;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
}
.chat-head select option {
  color: var(--ink);
  background: var(--surface);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  max-inline-size: 85%;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: var(--text-xl);
  white-space: pre-wrap;
  word-break: break-word;
  animation: fade-up 0.3s ease;
}
/* اصطلاح واتساب العربي: رسائلك في جهة نهاية السطر (اليسار في RTL) */
.msg.user {
  align-self: flex-end;
  background: var(--teal);
  color: #f2f7f0;
  border-end-end-radius: 4px;
}
.msg.bot {
  align-self: flex-start;
  background: var(--paper-deep);
  border: 1.5px solid var(--line);
  border-end-start-radius: 4px;
}
.msg.user.failed {
  opacity: 0.65;
  border: 1.5px dashed var(--bad);
}
.msg .failed-note {
  display: block;
  font-size: var(--text-xs);
  color: var(--bad-soft);
  margin-block-start: 6px;
  font-weight: 700;
}
.msg.error {
  align-self: center;
  background: var(--bad-soft);
  border: 1.5px solid var(--bad);
  font-size: var(--text-lg);
}
.msg.thinking {
  align-self: flex-end;
  color: var(--ink-faint);
  background: var(--paper-deep);
  border: 1.5px dashed var(--line-strong);
}
@media (prefers-reduced-motion: no-preference) {
  .msg.thinking {
    animation: thinking-pulse 1.4s ease-in-out infinite;
  }
}
@keyframes thinking-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* زر إعادة المحاولة داخل فقاعة الخطأ */
.retry-btn {
  display: inline-block;
  margin-block-start: 8px;
  background: var(--bad);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 4px 16px;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease;
}
.retry-btn:hover {
  background: var(--terracotta);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--ink-faint);
  max-inline-size: 40ch;
}
.chat-empty .big {
  font-size: 2.6rem;
  margin-block-end: 8px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-block-start: 1.5px solid var(--line);
  background: rgba(241, 231, 210, 0.35);
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-family: var(--font-body);
  font-size: var(--text-xl);
  line-height: 1.7;
  color: var(--ink);
  min-block-size: 52px;
  max-block-size: 160px;
}
.chat-input-row textarea:focus {
  outline: 2.5px solid var(--teal-deep);
}

/* عدّاد الأحرف — يظهر قرب الحد فقط */
.char-counter {
  padding-inline: 16px;
  padding-block-end: 10px;
  font-size: var(--text-xs);
  color: var(--ink-faint);
  text-align: start;
}
.char-counter.near {
  color: var(--bad);
  font-weight: 700;
}

/* ---------- صفحة عامة ---------- */
.page-head {
  padding-block: clamp(40px, 6vw, 70px) 10px;
}
.page-head h1 {
  margin-block-end: 8px;
}
.page-head p {
  color: var(--ink-soft);
  max-inline-size: 60ch;
  font-size: 1.05rem;
}

.empty-note {
  text-align: center;
  color: var(--ink-faint);
  padding-block: 60px;
  font-size: 1.05rem;
}

/* ---------- التذييل ---------- */
.footer {
  background: var(--teal-night);
  color: rgba(250, 244, 232, 0.75);
  padding-block: 44px 30px;
  margin-block-start: 40px;
  border-block-start: 3px solid var(--saffron);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
.footer .brand {
  font-size: 1.2rem;
}
.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.footer-links a {
  color: rgba(250, 244, 232, 0.75);
  font-size: var(--text-lg);
}
.footer-links a:hover {
  color: var(--saffron);
}
.footer-cols {
  display: grid;
  grid-template-columns: 1.4fr 1.05fr 0.9fr 0.95fr 0.85fr 1.05fr;
  gap: 26px;
  align-items: start;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-start;
}
.footer-col a {
  color: rgba(250, 244, 232, 0.75);
  font-size: var(--text-lg);
}
.footer-col a:hover {
  color: var(--saffron);
}
.footer-head {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--saffron);
  margin: 0 0 2px;
}
.footer-tag {
  font-size: var(--text-lg);
  opacity: 0.78;
  margin-block-start: 10px;
  max-inline-size: 30ch;
}
@media (max-width: 720px) {
  .footer-cols {
    grid-template-columns: 1fr 1fr;
    gap: 22px;
  }
  .footer-brand-col {
    grid-column: 1 / -1;
  }
}
.footer .fine {
  font-size: var(--text-sm);
  opacity: 0.6;
  margin-block-start: 24px;
  text-align: center;
  inline-size: 100%;
}

/* ---------- الحركات ---------- */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    translate: 0 14px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes spin-slow {
  from {
    rotate: 0deg;
  }
  to {
    rotate: 360deg;
  }
}

.reveal {
  opacity: 0;
  translate: 0 22px;
  transition:
    opacity 0.6s ease,
    translate 0.6s ease;
  transition-delay: var(--d, 0s);
}
.reveal.in {
  opacity: 1;
  translate: 0 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    translate: 0 0;
  }
}

/* ---------- توست ---------- */
.toast {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-start: 50%;
  translate: -50% 0;
  background: var(--teal-night);
  color: var(--paper);
  border: 1.5px solid var(--saffron);
  padding: 10px 24px;
  border-radius: 999px;
  font-size: var(--text-lg);
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s,
    translate 0.3s;
}
[dir="rtl"] .toast {
  translate: 50% 0;
}
.toast.show {
  opacity: 1;
}

/* ---------- نظرة عامة على الدورة وشاشة الإتمام ---------- */
.course-hero {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-block-end: 22px;
}
.course-hero .icon {
  inline-size: 68px;
  block-size: 68px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--paper-deep);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
}
.course-hero .icon .ico {
  inline-size: var(--ico-lg);
  block-size: var(--ico-lg);
}
.course-hero h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  margin-block-end: 4px;
}
.course-hero .subtitle {
  color: var(--ink-soft);
  margin: 0;
}

.outcomes-list {
  list-style: none;
  padding: 0;
  margin-block: 14px 24px;
  display: grid;
  gap: 10px;
}
.outcomes-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.outcomes-list .ico {
  color: var(--ok);
  margin-block-start: 4px;
}

.quiz-recap {
  background: rgba(241, 231, 210, 0.5);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-block: 18px;
  font-size: var(--text-xl);
}

.completion-panel {
  text-align: center;
  padding-block: 24px;
}
.completion-panel .big-star {
  inline-size: 90px;
  block-size: 90px;
  margin-block-end: 10px;
  animation: pulse 2.5s ease-in-out infinite;
}
.completion-panel h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}
.completion-panel .outcomes-list {
  text-align: start;
  max-inline-size: 56ch;
  margin-inline: auto;
}
.completion-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-block-start: 24px;
}

.next-course-card {
  display: flex;
  gap: 16px;
  align-items: center;
  text-align: start;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-pop);
  max-inline-size: 480px;
  margin-inline: auto;
  margin-block-start: 22px;
}
.next-course-card .icon {
  inline-size: 48px;
  block-size: 48px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--paper-deep);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}
.next-course-card .nc-kicker {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--terracotta);
}
.next-course-card h3 {
  font-size: 1.02rem;
  margin: 0;
}

/* ---------- الجوال: ترويسة مدمجة وترتيب ساحة التدريب ---------- */
@media (max-width: 700px) {
  .topbar {
    position: static;
  }
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-block: 10px 6px;
    max-inline-size: 100%;
    overflow: hidden;
  }
  .brand {
    justify-content: center;
    max-inline-size: 100%;
    min-inline-size: 0;
  }
  .brand span {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    text-align: center;
  }
  .nav {
    margin-inline-start: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    max-inline-size: 100%;
    padding-block-end: 6px;
  }
  .nav a {
    white-space: nowrap;
    flex: none;
  }
  .lesson-nav {
    inset-block-start: 0;
  }
}

@media (max-width: 900px) {
  .playground-layout {
    display: flex;
    flex-direction: column;
    inline-size: 100%;
    min-inline-size: 0;
  }
  .chat-box {
    order: 1;
    min-block-size: 60vh;
    inline-size: 100%;
    min-inline-size: 0;
  }
  .pg-side {
    order: 2;
    position: static;
    inline-size: 100%;
    min-inline-size: 0;
  }
  .pg-panel {
    inline-size: 100%;
    min-inline-size: 0;
  }
  .starter-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    padding-block-end: 4px;
  }
  .starter-btn {
    flex: none;
    inline-size: min(260px, 78vw);
  }
}

/* ---------- أهداف لمس مريحة ---------- */
@media (pointer: coarse) {
  .copy-btn,
  .btn-sm,
  .chip,
  .starter-btn,
  .quiz-opt {
    min-block-size: 44px;
  }
  .nav a {
    padding-block: 11px;
  }
  .lesson-nav button {
    min-block-size: 44px;
  }
}
