/* =========================================================
   المعلم الذكي — شاشة الدرس
   ========================================================= */

:root {
  --bg: #FAFAFA;
  --bg-elevated: #FFFFFF;
  --bg-muted: #F2F1EE;
  --bg-hushed: #EDECE8;

  --identity: #3B5A7A;
  --identity-soft: #E6ECF2;
  --identity-deep: #2F4963;

  --sem-start: #4A7C59;
  --sem-start-soft: #E6EEE9;
  --sem-predicate: #6B5B95;
  --sem-predicate-soft: #ECE8F3;
  --sem-tool: #C9885A;
  --sem-tool-soft: #F5EAE0;
  --sem-minor: #7A7265;

  --sp-kinan: #2F4963;
  --sp-razan: #C9668C;

  --action: #2D6CDF;
  --action-soft: #E7F0FE;

  --ink: #1B1F24;
  --ink-secondary: #4B5563;
  --ink-muted: #8A8680;
  --ink-faded: #B8B4AE;

  --line: #E5E3DE;
  --line-soft: #EEECE7;

  --ff-ar: "Tajawal", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --ff-naskh: "Noto Naskh Arabic", "Tajawal", serif;
  --ff-lat: "Inter", system-ui, sans-serif;

  --fs-title: 17px;
  --fs-dialog: 20px;
  --fs-side: 14px;
  --fs-button: 16px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --shadow-sm: 0 1px 2px rgba(28, 32, 40, 0.04), 0 1px 3px rgba(28, 32, 40, 0.03);
  --shadow-md: 0 4px 12px rgba(28, 32, 40, 0.06), 0 2px 4px rgba(28, 32, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(28, 32, 40, 0.08), 0 4px 8px rgba(28, 32, 40, 0.04);

  --mobile-max: 430px;
  --topbar-h: 56px;
  --bottombar-h: 82px;   /* أعلى قليلاً لاستيعاب الـlabels */
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--ff-ar);
  color: var(--ink);
  background: #E7E5DF;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; padding: 0; }

/* ========== الهيكل ========== */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #EEECE6 0%, #E5E3DD 60%, #DCDAD3 100%);
  padding: 16px;
}

.phone {
  width: 100%;
  max-width: var(--mobile-max);
  height: 100%;
  max-height: 920px;
  background: var(--bg);
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 40px 80px rgba(28, 32, 40, 0.12),
    0 12px 24px rgba(28, 32, 40, 0.08),
    0 0 0 1px rgba(28, 32, 40, 0.04);
}

/* ========== الشريط العلوي ========== */
.topbar {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 10px 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
  position: relative;
  z-index: 5;
}
.topbar-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-secondary);
  transition: background 160ms var(--ease);
}
.topbar-btn:hover { background: var(--bg-hushed); }
.topbar-title { flex: 1; min-width: 0; text-align: center; padding: 0 4px 10px; }
.topbar-title .t-lesson {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.2;
}
.topbar-title .t-eyebrow {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.t-eyebrow .t-dot { color: var(--ink-faded); margin: 0 2px; }

.topbar-title .t-segment {
  font-size: var(--fs-title);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
  margin-top: 6px;
}
.progress-rail {
  position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--line-soft);
}
.progress-fill { height: 100%; background: var(--identity); transition: width 200ms linear; }

/* ========== المسرح ========== */
.stage { flex: 1; min-height: 0; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.stage-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 60px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.stage-scroll::-webkit-scrollbar { width: 0; }

.turn {
  margin-bottom: 22px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 480ms var(--ease), transform 480ms var(--ease), filter 600ms var(--ease);
}
.turn.entered { opacity: 1; transform: translateY(0); }
.turn.past    { opacity: 0.42; filter: saturate(0.6); }

.turn-speaker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-muted);
  margin-bottom: 8px; padding-inline-end: 2px;
  letter-spacing: 0.01em;
}
.turn-speaker .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.turn-speaker.speaking .dot { animation: dotPulse 1.4s var(--ease) infinite; }
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47, 73, 99, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(47, 73, 99, 0); }
}
.turn-speaker.kinan { color: var(--sp-kinan); }
.turn-speaker.razan { color: var(--sp-razan); }
.turn-speaker.razan.speaking .dot { animation-name: dotPulseRazan; }
@keyframes dotPulseRazan {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 102, 140, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(201, 102, 140, 0); }
}

.turn-text {
  font-size: var(--fs-dialog);
  line-height: 1.85;
  color: var(--ink);
  text-wrap: pretty;
  letter-spacing: 0.005em;
}
.word {
  display: inline;
  transition: color 280ms var(--ease), background 280ms var(--ease), font-size 420ms var(--ease);
  border-radius: 4px;
  padding: 0 1px;
}
.word.active { color: var(--identity); background: var(--identity-soft); }
.word.emphasized {
  font-size: 1.25em; font-weight: 600;
  color: var(--identity-deep);
  display: inline-block; transform: translateY(-1px);
}

.turn.hadith .turn-text {
  font-family: var(--ff-naskh);
  font-size: 22px; line-height: 2;
  padding: 18px 20px;
  background: var(--bg-muted);
  border-radius: 12px;
  border-inline-end: 3px solid var(--identity);
  color: var(--ink);
}
.turn.hadith .word.active { background: transparent; color: var(--identity-deep); }

.turn.reflection { margin-top: 10px; }
.turn.reflection .turn-text {
  font-size: 18px; line-height: 1.9;
  padding: 22px 22px;
  background: linear-gradient(180deg, #FBFAF7, #F5F3ED);
  border-radius: 16px;
  border: 1px solid var(--line);
  color: var(--ink-secondary);
  position: relative;
}
.turn.reflection .turn-text::before {
  content: "تأمُّل";
  position: absolute;
  top: -10px; inset-inline-start: 18px;
  background: var(--bg);
  color: var(--identity);
  font-size: 11px; letter-spacing: 0.12em;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 600;
}

.stage.hushed .turn.entered { opacity: 0.55; }

/* ========== الشريط السفلي مع Labels ========== */
.bottombar {
  height: var(--bottombar-h);
  min-height: var(--bottombar-h);
  border-top: 1px solid var(--line-soft);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 8px 8px;
  position: relative;
  z-index: 5;
}

.bb-btn {
  flex: 1;
  max-width: 78px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px 4px;
  border-radius: 12px;
  color: var(--ink-secondary);
  transition: all 160ms var(--ease);
  position: relative;
}
.bb-btn:hover { background: var(--bg-hushed); color: var(--ink); }
.bb-btn:active { transform: scale(0.96); }

.bb-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 160ms var(--ease);
}
.bb-btn.primary .bb-icon {
  background: var(--identity);
  color: #fff;
  width: 42px; height: 42px;
}
.bb-btn.primary:hover .bb-icon { background: var(--identity-deep); }
.bb-btn.primary { color: var(--identity-deep); }

.bb-label {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.bb-btn.primary .bb-label { color: var(--identity-deep); font-weight: 600; }
.bb-btn:hover .bb-label { color: var(--ink); }

.bb-btn .counter {
  position: absolute;
  top: 2px;
  inset-inline-end: 6px;
  font-size: 10px;
  color: var(--identity);
  font-family: var(--ff-lat);
  font-variant-numeric: tabular-nums;
  background: var(--identity-soft);
  border-radius: 999px;
  padding: 1px 6px;
  line-height: 1.3;
  font-weight: 600;
}

.bb-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: rgba(27, 31, 36, 0.95);
  color: #fff;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  animation: tipIn 180ms var(--ease);
}
.bb-tooltip::after {
  content: "";
  position: absolute;
  top: 100%; inset-inline-start: 50%;
  transform: translateX(50%);
  border: 4px solid transparent;
  border-top-color: rgba(27, 31, 36, 0.95);
}
@keyframes tipIn {
  from { opacity: 0; transform: translateX(50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(50%) translateY(0); }
}

/* ========== العمود الجانبي ========== */
.sidebar {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(88%, 340px);
  background: var(--bg);
  z-index: 20;
  transform: translateX(105%);
  transition: transform 360ms var(--ease);
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 40px rgba(28, 32, 40, 0.1);
}
.sidebar.open { transform: translateX(0); }

.scrim {
  position: absolute; inset: 0;
  background: rgba(28, 32, 40, 0.28);
  z-index: 15;
  opacity: 0; pointer-events: none;
  transition: opacity 300ms var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sidebar-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h2 {
  margin: 0; font-size: 15px; color: var(--ink);
  font-weight: 700; letter-spacing: 0.01em;
}
.sidebar-head .close-btn {
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--ink-muted);
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.sb-section { margin-bottom: 26px; }
.sb-section:last-child { margin-bottom: 0; }
.sb-section h3 {
  margin: 0 0 12px;
  font-size: 12px; font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 8px;
}
.sb-section h3 .ico { color: var(--identity); font-size: 14px; }

.map-list { list-style: none; padding: 0; margin: 0; }
.map-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  position: relative;
  font-size: var(--fs-side);
  color: var(--ink-secondary);
  line-height: 1.5;
  transition: background 160ms var(--ease);
  cursor: pointer;
  user-select: none;
}
.map-item:hover { background: var(--bg-muted); }
.map-item:active { background: var(--bg-hushed); }
.map-item .marker {
  width: 20px; height: 20px;
  border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  color: var(--ink-muted);
  font-family: var(--ff-lat);
  font-variant-numeric: tabular-nums;
}
.map-item.done .marker {
  background: var(--identity);
  border-color: var(--identity);
  color: #fff;
}
.map-item.done .marker::before { content: "✓"; font-family: var(--ff-ar); font-size: 11px; line-height: 1; }
.map-item.current { background: var(--identity-soft); }
.map-item.current .marker {
  background: var(--bg); border-color: var(--identity);
  box-shadow: 0 0 0 4px rgba(59, 90, 122, 0.12);
}
.map-item.current .marker::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--identity);
}
.map-item .m-body { flex: 1; min-width: 0; }
.map-item .m-label { color: var(--ink); font-weight: 600; }
.map-item.current .m-label { color: var(--identity-deep); }
.map-item .m-hint { font-size: 12px; color: var(--ink-muted); margin-top: 2px; line-height: 1.4; }

.accum-list { list-style: none; padding: 0; margin: 0; }
.accum-item {
  padding: 8px 0;
  font-size: var(--fs-side);
  color: var(--ink-secondary);
  line-height: 1.5;
  border-bottom: 1px solid var(--line-soft);
  display: flex; gap: 10px; align-items: baseline;
  animation: accumIn 420ms var(--ease) both;
}
.accum-item:last-child { border-bottom: none; }
@keyframes accumIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.accum-item .bullet {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--identity); flex-shrink: 0; transform: translateY(-2px);
}
.accum-item .word-ar { font-weight: 600; color: var(--ink); }
.accum-item .meaning { color: var(--ink-muted); font-size: 13px; }

/* ========== أزرار التجميعات في العمود الجانبي ========== */
.sb-collections h3 {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.12em;
  margin-bottom: 10px;
}
.collection-list { list-style: none; padding: 0; margin: 0; }
.collection-list li { margin-bottom: 8px; }
.collection-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: start;
  cursor: pointer;
  font-family: inherit;
  transition: all 180ms var(--ease);
}
.collection-btn:hover {
  border-color: var(--identity);
  background: var(--identity-soft);
  transform: translateX(-2px);
}
.collection-btn:active { transform: translateX(-2px) scale(0.98); }
.collection-btn.active {
  border-color: var(--identity);
  background: var(--identity-soft);
}
.col-head { display: flex; align-items: center; gap: 12px; }
.col-ico {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--identity-soft);
  color: var(--identity);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.col-body { flex: 1; min-width: 0; }
.col-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.col-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}
.col-count {
  flex-shrink: 0;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--identity);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--ff-lat);
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em;
}

/* آخر عنصر مكشوف داخل البطاقة */
.col-latest {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border-inline-start: 3px solid var(--identity);
  animation: colLatestIn 280ms var(--ease) both;
}
.col-latest .cl-word {
  display: block;
  font-family: var(--ff-ar);
  font-size: 15px;
  font-weight: 700;
  color: var(--identity-deep, var(--identity));
  margin-bottom: 2px;
}
.col-latest .cl-meaning {
  display: block;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-muted);
}
.col-latest .cl-text {
  display: block;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
}
@keyframes colLatestIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== HUD chip: آخر عنصر مكشوف (أعلى المسرح) ========== */
.hud-chip {
  position: absolute;
  top: 14px;
  inset-inline-end: 16px;
  inset-inline-start: auto;
  max-width: 62%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  z-index: 4;
  pointer-events: none;
  animation: hudIn 420ms var(--ease) both;
}
@keyframes hudIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hud-chip.vocabulary { border-inline-end: 3px solid var(--identity); }
.hud-chip.questions  { border-inline-end: 3px solid var(--sem-predicate); }
.hud-chip.rhetorical { border-inline-end: 3px solid var(--sem-tool); }

.hud-eyebrow {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.hud-chip.vocabulary .hud-eyebrow { color: var(--identity); }
.hud-chip.questions  .hud-eyebrow { color: var(--sem-predicate); }
.hud-chip.rhetorical .hud-eyebrow { color: var(--sem-tool); }
.hud-body { font-size: 13px; line-height: 1.5; color: var(--ink); }
.hud-word {
  display: inline; font-weight: 700; color: var(--ink);
}
.hud-word + .hud-meaning {
  display: inline; color: var(--ink-secondary); margin-inline-start: 6px;
}
.hud-meaning::before { content: "— "; color: var(--ink-faded); }
.hud-text { display: block; color: var(--ink); font-weight: 500; }

/* ========== لوحة القائمة الكاملة في المسرح ========== */
.list-overlay {
  position: absolute;
  inset: var(--topbar-h) 0 var(--bottombar-h) 0;
  background: var(--bg);
  z-index: 12;
  display: flex;
  flex-direction: column;
  animation: lpIn 320ms var(--ease) both;
}
@keyframes lpIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.listpanel {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 22px 0;
}
.listpanel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.lp-ico {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--identity-soft);
  color: var(--identity);
  display: inline-flex; align-items: center; justify-content: center;
}
.listpanel-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.lp-count {
  font-size: 12px;
  font-family: var(--ff-lat);
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  background: var(--bg-muted);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.listpanel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 2px;
}
.lp-empty {
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  padding: 40px 20px;
}

.lp-group { margin-bottom: 22px; }
.lp-group:last-child { margin-bottom: 0; }
.lp-group-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 10px;
  padding-inline: 4px;
}
/* عناوين الأقسام: منهجي / إثرائي */
.lp-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
}
.lp-section-header.manhaji { background: #E8EFF7; color: #185FA5; }
.lp-section-header.ithrai  { background: #F5EBD8; color: #BA7517; }
.lp-section-icon { font-size: 14px; line-height: 1; }

.lp-list { list-style: none; padding: 0; margin: 0; }
.lp-item {
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-muted);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  animation: accumIn 320ms var(--ease) both;
}
.lp-item.manhaji {
  background: var(--bg-elevated);
  border-inline-end: 3px solid #185FA5;
}
.lp-item.ithrai {
  background: var(--bg-elevated);
  border-inline-end: 3px solid #BA7517;
}

/* أيقونة ★ / 💡 أعلى يمين البطاقة */
.lp-badge {
  position: absolute;
  top: 8px;
  inset-inline-end: 10px;
  font-size: 11px;
  line-height: 1;
}
.lp-badge.manhaji { color: #185FA5; }
.lp-badge.ithrai  { color: #BA7517; }
.lp-word {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--ff-naskh);
}
.lp-meaning {
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.5;
}
.lp-text {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
}

/* بطاقة السؤال القابلة للضغط */
.lp-q-card { cursor: pointer; }
.lp-q-card:hover { background: var(--bg-muted); }
.lp-q-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.lp-q-row .lp-text { flex: 1; }
.lp-q-toggle {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--ink-faded);
  transition: transform 200ms var(--ease);
  margin-top: 2px;
}
.lp-q-toggle.open { transform: rotate(-90deg); }
.lp-answer {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-secondary);
  animation: accumIn 240ms var(--ease) both;
}

.listpanel-foot {
  padding: 14px 0 18px;
  border-top: 1px solid var(--line-soft);
}
.lp-back-btn {
  width: 100%;
  background: var(--identity);
  color: #fff;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  cursor: pointer;
  transition: background 180ms var(--ease);
}
.lp-back-btn:hover { background: var(--identity-deep); }
.lp-back-btn:active { transform: scale(0.98); }

/* ========== السؤال المدمج ========== */
.question-card {
  background: var(--bg-elevated);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 20px;
  margin-top: 8px;
  box-shadow: var(--shadow-md);
  animation: qcIn 480ms var(--ease) both;
}
@keyframes qcIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.question-card.shake { animation: qcShake 360ms var(--ease); }
@keyframes qcShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.qc-label {
  font-size: 11px; font-weight: 700;
  color: var(--identity); letter-spacing: 0.16em;
  margin-bottom: 8px;
}
.qc-prompt {
  font-size: 16px; color: var(--ink); line-height: 1.6;
  margin-bottom: 18px; font-weight: 500;
}
.qc-sentence {
  font-size: 19px; line-height: 2.1;
  padding: 14px 14px;
  background: var(--bg-muted); border-radius: 12px;
  text-wrap: pretty; text-align: center;
}
.qc-token {
  display: inline-block;
  padding: 2px 8px; margin: 3px 2px;
  border-radius: 8px;
  transition: all 180ms var(--ease);
  color: var(--ink);
}
.qc-token.static { color: var(--ink-muted); padding: 2px 2px; }
.qc-token.selectable {
  background: var(--bg-elevated); border: 1px solid var(--line);
  cursor: pointer;
}
.qc-token.selectable:hover {
  border-color: var(--identity); background: var(--identity-soft);
}
.qc-token.correct {
  background: var(--sem-start-soft); border-color: var(--sem-start);
  color: var(--sem-start); font-weight: 700; cursor: default;
}
.qc-token.wrong {
  background: #F8E4E4; border-color: #C85050;
  color: #9A3A3A; cursor: default;
}
.qc-feedback {
  margin-top: 14px;
  font-size: 14px; line-height: 1.6;
  color: var(--ink-secondary);
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-muted);
  animation: fbIn 300ms var(--ease) both;
}
.qc-feedback.success { background: var(--sem-start-soft); color: #2A5035; }
.qc-feedback.retry { background: #FBF0E4; color: #8A4F21; }
.qc-feedback.final { background: var(--identity-soft); color: var(--identity-deep); }
@keyframes fbIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.qc-hint {
  text-align: center; font-size: 12px;
  color: var(--ink-muted); margin-top: 12px;
  letter-spacing: 0.02em;
}

/* ========== بطاقة الجسر بين المقاطع ========== */
.bridge-card {
  margin: 20px auto 40px;
  max-width: 360px;
  background: var(--bg-elevated);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: qcIn 520ms var(--ease) both;
}
.bridge-eyebrow {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.16em;
  font-weight: 700;
  margin-bottom: 4px;
}
.bridge-eyebrow.next { color: var(--identity); margin-top: 18px; }
.bridge-from {
  font-size: 17px; color: var(--ink-secondary); font-weight: 600;
  margin-bottom: 4px;
}
.bridge-arrow {
  font-size: 22px; color: var(--ink-faded);
  margin: 8px 0; font-family: var(--ff-lat);
}
.bridge-to {
  font-size: 22px; color: var(--identity-deep);
  font-weight: 700;
  line-height: 1.3;
}
.bridge-btn {
  margin-top: 22px;
  background: var(--identity);
  color: #fff;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  transition: all 180ms var(--ease);
  cursor: pointer;
}
.bridge-btn:hover { background: var(--identity-deep); }
.bridge-btn:active { transform: scale(0.97); }

/* ========== Popovers ========== */
.popover {
  position: absolute;
  bottom: calc(var(--bottombar-h) + 12px);
  inset-inline-start: 16px;
  inset-inline-end: 16px;
  background: var(--bg-elevated);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 20px 22px;
  z-index: 14;
  animation: popIn 280ms var(--ease);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.popover h4 {
  margin: 0 0 12px; font-size: 14px; font-weight: 700;
  color: var(--identity); letter-spacing: 0.08em;
}
.popover p { margin: 8px 0; font-size: 14px; line-height: 1.65; color: var(--ink); }
.popover .close-pop {
  position: absolute; top: 10px; inset-inline-start: 10px;
  width: 28px; height: 28px; color: var(--ink-muted);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}

/* ========== Summary menu + reader ========== */
.popover .back-to-menu {
  position: absolute;
  top: 12px; inset-inline-end: 16px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
  color: var(--ink-muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.popover .back-to-menu:hover { background: var(--bg-muted); color: var(--ink); }

.summary-menu .sum-title.center { text-align: center; font-size: 15px; color: var(--ink); letter-spacing: 0; margin: 0 0 16px; }
.sum-options { display: flex; flex-direction: column; gap: 10px; }
.sum-opt {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 16px;
  background: var(--bg-muted);
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: start;
  transition: all 180ms var(--ease);
}
.sum-opt:hover {
  background: var(--identity-soft);
  border-color: var(--identity);
  transform: translateX(-2px);
}
.sum-opt:active { transform: translateX(-2px) scale(0.98); }
.sum-opt-ico {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--identity);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sum-opt-body { flex: 1; min-width: 0; }
.sum-opt-label { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.sum-opt-hint { display: block; font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

/* Reader view */
.summary-reader { padding-top: 44px; }
.sum-eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--identity);
  font-weight: 700;
  margin-bottom: 6px;
}
.sum-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}
.sum-hint {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 14px;
}
.sum-line.short {
  background: var(--identity-soft);
  color: var(--identity-deep);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 500;
  margin-bottom: 14px;
}
.sum-para {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink);
  margin: 0;
  text-wrap: pretty;
}
.sum-lessonlist {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: sumline;
}
.sum-lessonlist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink);
}
.sum-lessonlist li:last-child { border-bottom: none; }
.sum-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--identity);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-lat);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  margin-top: 3px;
}

/* ========== Tweaks toggle ========== */
.tweaks-toggle {
  position: fixed;
  bottom: 16px;
  inset-inline-end: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(28, 32, 40, 0.7);
  color: #fff;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow-md);
  opacity: 0.5;
  transition: opacity 180ms var(--ease);
  line-height: 1;
}
.tweaks-toggle:hover { opacity: 1; }

/* ========== Tweaks ========== */
.tweaks-panel {
  position: fixed; bottom: 16px; inset-inline-start: 16px;
  width: 240px;
  background: rgba(28, 32, 40, 0.94);
  backdrop-filter: blur(10px);
  color: #fff;
  border-radius: 14px;
  padding: 14px 14px 12px;
  font-size: 12px; z-index: 999;
  box-shadow: var(--shadow-lg);
  font-family: var(--ff-ar);
}
.tweaks-panel h5 {
  margin: 0 0 10px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.16em; color: rgba(255,255,255,0.6);
}
.tweak-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; gap: 8px;
}
.tweak-row label { color: rgba(255,255,255,0.9); }
.tweak-row select, .tweak-row input[type="range"] {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; padding: 3px 6px;
  font-family: inherit; font-size: 12px;
}
.tweak-row select option {
  background: #1a2942;
  color: #fff;
}
.tweak-row button {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; padding: 4px 10px;
  font-family: inherit; font-size: 12px;
  cursor: pointer;
}
.tweak-row button:hover { background: rgba(255,255,255,0.15); }

/* ========================================================= */
/* ========== تجاوب سطح المكتب ========== */
/* ========================================================= */
@media (min-width: 900px) {
  body { overflow: hidden; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) {
    padding: 0;
    background: var(--bg);
    display: block;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .phone {
    max-width: none;
    max-height: none;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: auto 1fr var(--bottombar-h);
    grid-template-areas:
      "sidebar topbar"
      "sidebar stage"
      "sidebar bottombar";
  }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar    { grid-area: topbar; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .stage     { grid-area: stage; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .bottombar { grid-area: bottombar; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .sidebar {
    grid-area: sidebar;
    position: static;
    transform: none;
    width: 360px;
    border-inline-start: 1px solid var(--line);
    box-shadow: none;
    background: #FBFAF7;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .scrim { display: none !important; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .sidebar-head .close-btn { display: none; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar-btn.menu-btn { display: none; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar { padding: 0 32px; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar-title { text-align: start; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar-title .t-lesson { font-size: 13px; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .topbar-title .t-segment { font-size: 20px; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .stage-scroll {
    padding: 48px 80px 60px;
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .turn-text { font-size: 23px; line-height: 1.9; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .turn.hadith .turn-text { font-size: 27px; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .turn.reflection .turn-text { font-size: 20px; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .bottombar { padding: 8px 24px 10px; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .bb-btn { max-width: 110px; }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .popover {
    inset-inline-start: auto;
    inset-inline-end: 40px;
    width: 380px;
  }

  .app-shell:not(.mobile-locked):not(.welcome-mode) .bridge-card {
    max-width: 460px;
    padding: 36px 32px;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .bridge-to { font-size: 26px; }
}

/* شاشات أكبر */
@media (min-width: 1400px) {
  .app-shell:not(.mobile-locked):not(.welcome-mode) .phone {
    grid-template-columns: 400px 1fr;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .sidebar { width: 400px; }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .stage-scroll {
    max-width: 1040px;
    padding: 56px 96px 60px;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .turn-text { font-size: 25px; }
}

/* إصلاح: حصر لوحة القائمة في منطقة المسرح مع تمرير داخلي (سطح المكتب) */
@media (min-width: 769px) {
  .app-shell:not(.mobile-locked):not(.welcome-mode) .list-overlay {
    position: static;
    inset: auto;
    grid-area: stage;
    min-height: 0;
    overflow: hidden;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .list-overlay .listpanel {
    height: 100%;
    min-height: 0;
  }
  .app-shell:not(.mobile-locked):not(.welcome-mode) .list-overlay .listpanel-body {
    min-height: 0;
  }
}


/* ===== اللوغو "حِوار" ===== */
.welcome-card-react .welcome-brand {
  font-family: "Cairo", "Tajawal", sans-serif;
  font-size: 52px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 6px;
  line-height: 1;
  margin: 0 0 14px;
  text-align: center;
}
.welcome-card-react .welcome-rule {
  width: 64px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-soft) 50%,
    transparent 100%);
  margin: 0 auto 38px;
}

/* ===== البطاقة القرآنية ===== */
.welcome-card-react .welcome-quran {
  width: 100%;
  background: linear-gradient(180deg, #FDFAF1 0%, #FFFFFF 100%);
  border-top: 1.5px solid rgba(200,148,10,0.55);
  border-radius: 8px 8px 14px 14px;
  padding: 26px 24px 22px;
  box-shadow:
    0 1px 0 rgba(200,148,10,0.04),
    0 4px 16px rgba(200,148,10,0.06);
  margin-bottom: 30px;
  text-align: center;
}
.welcome-card-react .welcome-quran-text {
  font-family: "Amiri", "Noto Naskh Arabic", serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  line-height: 2.4;
  letter-spacing: 0.5px;
}
.welcome-card-react .welcome-quran-text .qb {
  color: var(--gold);
  font-size: 26px;
  margin: 0 3px;
  font-weight: 700;
}
.welcome-card-react .welcome-quran-source {
  font-size: 10.5px;
  color: var(--gold-soft);
  letter-spacing: 2.5px;
  margin-top: 14px;
  font-weight: 500;
  text-transform: uppercase;
}

/* ===== النداء ===== */
.welcome-card-react .welcome-pledge {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 2.3;
  margin-bottom: 32px;
  text-align: center;
  letter-spacing: 0.3px;
  font-weight: 400;
}

/* ===== زرّ الدعوة ===== */
.welcome-cta-react {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #FFFFFF;
  background: linear-gradient(180deg, #2F4963 0%, var(--navy) 100%);
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  letter-spacing: 0.5px;
  box-shadow:
    0 1px 2px rgba(27,58,92,0.15),
    0 6px 16px rgba(27,58,92,0.20);
  transition: all 280ms var(--ease);
  margin-bottom: 36px;
}
.welcome-cta-react:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 2px rgba(27,58,92,0.18),
    0 10px 24px rgba(27,58,92,0.28);
}
.welcome-cta-react:active {
  transform: translateY(0);
}
.welcome-cta-arrow {
  font-size: 17px;
  line-height: 1;
  transition: transform 220ms var(--ease);
}
.welcome-cta-react:hover .welcome-cta-arrow {
  transform: translateX(-3px);
}

/* ===== الاقتباسان كحاشية مخطوطة ===== */
.welcome-quotes-inline {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 8px 0;
  border-top: 0.5px dashed rgba(139,126,94,0.25);
  margin-top: 8px;
}
.welcome-quotes-inline .wq-line {
  font-family: "Amiri", "Noto Naskh Arabic", serif;
  font-size: 13.5px;
  color: var(--gold-soft);
  line-height: 1.95;
  text-align: center;
  letter-spacing: 0.2px;
  font-style: italic;
  max-width: 90%;
}

/* ===== شاشة التحميل ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Tajawal", sans-serif;
  color: var(--navy);
  font-size: 16px;
  background: var(--canvas);
}

/* ===== على الجوّال ===== */
@media (max-width: 600px) {
  .app-shell.welcome-mode { padding: 12px; }
  .hewar-welcome-stage { padding: 44px 28px 32px; }
  .welcome-card-react .welcome-brand { font-size: 44px; letter-spacing: 5px; }
  .welcome-card-react .welcome-quran-text { font-size: 19px; line-height: 2.2; }
  .welcome-card-react .welcome-pledge { font-size: 14px; }
}

/* ===== انميشن دخول البطاقة ===== */
.welcome-card-react {
  animation: welcomeRise 800ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes welcomeRise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   إطار التطبيق + بطاقة الترحيب — الصفحة بأكملها
   ============================================================ */
html, body {
  margin: 0; padding: 0;
  height: 100%;
  direction: rtl;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(200,148,10,0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(27,58,92,0.05) 0%, transparent 45%),
    linear-gradient(165deg, #ECE8DE 0%, #E2DDD2 60%, #D6D0C3 100%);
}

.app-shell.welcome-mode {
  position: fixed; inset: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.app-shell.welcome-mode .phone {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: none;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* الصفحة الكاملة — حاوية الترحيب */
.hewar-welcome-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 0;
  overflow-y: auto;
}
.welcome-card-react {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: welcomeRise 900ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

/* اللوغو "حِوار" */
.welcome-card-react .welcome-brand {
  font-family: "Cairo", "Tajawal", sans-serif;
  font-size: 88px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 10px;
  line-height: 1;
  margin: 0 0 18px;
}
.welcome-card-react .welcome-rule {
  width: 96px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  margin: 0 auto 56px;
}

/* البطاقة القرآنية */
.welcome-card-react .welcome-quran {
  width: 100%; max-width: 560px;
  background: linear-gradient(180deg, #FDFAF1 0%, #FFFFFF 100%);
  border: 1px solid rgba(200,148,10,0.18);
  border-top: 2px solid rgba(200,148,10,0.55);
  border-radius: 12px;
  padding: 36px 40px 30px;
  box-shadow:
    0 1px 2px rgba(200,148,10,0.04),
    0 8px 24px rgba(27,58,92,0.06);
  margin-bottom: 44px;
}
.welcome-card-react .welcome-quran-text {
  font-family: "Amiri", "Noto Naskh Arabic", serif;
  font-size: 30px;
  font-weight: 500;
  color: var(--ink);
  line-height: 2.4;
  letter-spacing: 0.5px;
}
.welcome-card-react .welcome-quran-text .qb {
  color: var(--gold);
  font-size: 36px;
  margin: 0 4px;
  font-weight: 700;
}
.welcome-card-react .welcome-quran-source {
  font-size: 12px;
  color: var(--gold-soft);
  letter-spacing: 3px;
  margin-top: 18px;
  font-weight: 600;
}

/* النداء */
.welcome-card-react .welcome-pledge {
  font-size: 19px;
  color: var(--ink-soft);
  line-height: 2.4;
  margin: 0 0 44px;
  letter-spacing: 0.3px;
  font-weight: 400;
  max-width: 540px;
}

/* الزرّ — كحليّ واضح بنصّ أبيض */
.welcome-cta-react {
  display: inline-flex !important;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF !important;
  background: var(--navy) !important;
  padding: 16px 36px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  font-family: "Tajawal", sans-serif !important;
  letter-spacing: 0.5px;
  box-shadow:
    0 2px 4px rgba(27,58,92,0.18),
    0 8px 20px rgba(27,58,92,0.22);
  transition: all 280ms var(--ease);
  margin-bottom: 0;
}
.welcome-cta-react:hover {
  background: #2F4963 !important;
  transform: translateY(-2px);
  box-shadow:
    0 2px 4px rgba(27,58,92,0.20),
    0 12px 28px rgba(27,58,92,0.30);
}
.welcome-cta-react span { color: #FFFFFF !important; }
.welcome-cta-arrow {
  font-size: 18px;
  line-height: 1;
  transition: transform 220ms var(--ease);
}
.welcome-cta-react:hover .welcome-cta-arrow { transform: translateX(-4px); }

/* الاقتباسان — قاعدة الصفحة، بدون خط فاصل */
.welcome-quotes-inline {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 24px 28px;
  background: transparent;
  border: none;
  margin: 0;
  flex-shrink: 0;
}
.welcome-quotes-inline .wq-line {
  font-family: "Amiri", "Noto Naskh Arabic", serif;
  font-size: 16px;
  color: var(--gold-soft);
  line-height: 1.9;
  text-align: center;
  letter-spacing: 0.3px;
  max-width: 720px;
}

/* شاشة التحميل */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: "Tajawal", sans-serif;
  color: var(--navy);
  font-size: 16px;
  background: var(--canvas);
}

/* الجوّال */
@media (max-width: 600px) {
  .hewar-welcome-stage { padding: 32px 20px 0; }
  .welcome-card-react .welcome-brand { font-size: 56px; letter-spacing: 6px; }
  .welcome-card-react .welcome-rule { margin-bottom: 36px; }
  .welcome-card-react .welcome-quran { padding: 24px 20px 20px; margin-bottom: 32px; }
  .welcome-card-react .welcome-quran-text { font-size: 22px; line-height: 2.3; }
  .welcome-card-react .welcome-quran-text .qb { font-size: 26px; }
  .welcome-card-react .welcome-pledge { font-size: 16px; margin-bottom: 32px; }
  .welcome-cta-react { font-size: 14px; padding: 14px 28px; }
  .welcome-quotes-inline { padding: 24px 16px 20px; gap: 8px; }
  .welcome-quotes-inline .wq-line { font-size: 13.5px; }
}

@keyframes welcomeRise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   صفحة الترحيب الجديدة - تصميم Claude Design
   كلّ الأنماط محصورة داخل .welcome-v2-page
   ============================================================ */
.welcome-v2-page {
  --w-white:    #ffffff;
  --w-grey-50:  #f6f7f9;
  --w-grey-100: #eef0f3;
  --w-grey-200: #e2e5ea;
  --w-grey-300: #cdd2da;
  --w-grey-400: #a4abb5;
  --w-grey-500: #6e7682;
  --w-grey-600: #4a525e;
  --w-ink:      #0d1b34;
  --w-ink-2:    #16264a;
  --w-ink-soft: rgba(13, 27, 52, 0.70);
  --w-ink-mid:  rgba(13, 27, 52, 0.45);
  --w-ink-faint:rgba(13, 27, 52, 0.18);
  --w-gold:      #b88a36;
  --w-gold-soft: rgba(184, 138, 54, 0.55);
  --w-thuluth: "Aref Ruqaa", "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
  --w-naskh:   "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
  --w-sans:    "Tajawal", "Cairo", system-ui, -apple-system, sans-serif;

  position: fixed; inset: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  font-family: var(--w-sans);
  color: var(--w-ink);
  background: var(--w-grey-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  z-index: 1;
}

.welcome-v2-page .bg {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, var(--w-white) 0%, var(--w-grey-50) 55%, var(--w-grey-100) 100%);
}

.welcome-v2-page .scholars {
  position: absolute;
  inset: 0 0 auto 0;
  height: min(46vh, 420px);
  z-index: 1;
  pointer-events: none;
  display: block;
}
.welcome-v2-page .scholars svg {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.85;
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}
.welcome-v2-page .scholars .term { animation: w-term-drift 9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.welcome-v2-page .scholars .term.t2 { animation-duration: 11s; animation-delay: -2s; }
.welcome-v2-page .scholars .term.t3 { animation-duration: 13s; animation-delay: -4s; }
.welcome-v2-page .scholars .term.t4 { animation-duration: 10s; animation-delay: -1s; }
.welcome-v2-page .scholars .term.t5 { animation-duration: 12s; animation-delay: -3s; }
.welcome-v2-page .scholars .term.t6 { animation-duration: 14s; animation-delay: -5s; }
@keyframes w-term-drift {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0.55; }
  50%      { transform: translateY(-6px) translateX(3px); opacity: 0.9; }
}

.welcome-v2-page .page {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(16px, 2.6vh, 28px) clamp(20px, 5vw, 56px);
  z-index: 2;
}

.welcome-v2-page header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--w-ink-soft);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.welcome-v2-page .mark { display: inline-flex; align-items: center; gap: 12px; color: var(--w-ink); }
.welcome-v2-page .mark .glyph { width: 22px; height: 22px; display: block; }
.welcome-v2-page .mark .name {
  font-family: var(--w-thuluth);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--w-ink);
}
.welcome-v2-page .meta { display: flex; align-items: center; gap: 22px; font-weight: 400; }
.welcome-v2-page .meta a { color: var(--w-ink-soft); text-decoration: none; transition: color .25s ease; cursor: pointer; }
.welcome-v2-page .meta a:hover { color: var(--w-ink); }
.welcome-v2-page .meta .sep { width: 1px; height: 12px; background: var(--w-grey-300); display: inline-block; }

.welcome-v2-page main.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}
.welcome-v2-page .stage-inner {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-rows: auto auto auto;
  place-items: center;
  text-align: center;
  gap: clamp(8px, 1.4vh, 18px);
}

.welcome-v2-page .composition {
  position: relative;
  width: min(94vw, 820px);
  aspect-ratio: 16 / 9;
  max-height: 50vh;
  display: grid;
  place-items: center;
}

.welcome-v2-page .scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.welcome-v2-page .wordmark {
  position: relative;
  z-index: 4;
  font-family: var(--w-thuluth);
  font-weight: 700;
  font-size: clamp(64px, 11.5vw, 156px);
  line-height: 0.95;
  letter-spacing: 0.005em;
  margin: 0;
  transform: translateY(-6%);
  color: var(--w-ink);
  background: linear-gradient(100deg, #0d1b34 0%, #11203c 38%, #1f2c4a 46%, #b88a36 50%, #1f2c4a 54%, #11203c 62%, #0d1b34 100%);
  background-size: 280% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: w-shimmer 11s ease-in-out infinite;
  text-shadow: none;
}
@keyframes w-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.welcome-v2-page .wordmark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6%;
  transform: translateX(-50%);
  width: clamp(110px, 16vw, 200px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--w-gold) 30%, var(--w-gold) 70%, transparent);
  opacity: 0.7;
}

.welcome-v2-page .letters { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.welcome-v2-page .letters span {
  position: absolute;
  font-family: var(--w-thuluth);
  color: var(--w-grey-500);
  line-height: 1;
  user-select: none;
  will-change: transform, opacity;
  font-weight: 400;
  transform: translate(-50%, -50%);
  opacity: 0;
}
.welcome-v2-page .letters span.deep { color: var(--w-ink-soft); }
.welcome-v2-page .letters span.gold { color: var(--w-gold); }
.welcome-v2-page .letters span.dim  { color: var(--w-grey-400); }

@keyframes w-rise-1 {
  0%   { opacity: 0;   transform: translate(-50%, -30%) rotate(-4deg); }
  20%  { opacity: var(--target, 0.7); }
  80%  { opacity: var(--target, 0.7); }
  100% { opacity: 0;   transform: translate(-50%, -90%) rotate(-1deg); }
}
@keyframes w-rise-2 {
  0%   { opacity: 0;   transform: translate(-50%, -30%) rotate(3deg); }
  25%  { opacity: var(--target, 0.7); }
  75%  { opacity: var(--target, 0.7); }
  100% { opacity: 0;   transform: translate(-50%, -95%) rotate(0deg); }
}
@keyframes w-pulse {
  0%, 100% { opacity: var(--target, 0.6); }
  50%      { opacity: calc(var(--target, 0.6) * 0.55); }
}

.welcome-v2-page .tagline {
  font-family: var(--w-naskh);
  font-weight: 400;
  color: var(--w-ink);
  font-size: clamp(16px, 1.95vw, 22px);
  line-height: 1.7;
  max-width: 38ch;
  margin: 0;
  letter-spacing: 0.005em;
}
.welcome-v2-page .tagline .ellipsis { color: var(--w-gold); letter-spacing: 0.1em; opacity: 0.85; }
.welcome-v2-page .tagline em { font-style: normal; color: var(--w-ink); font-weight: 700; }

.welcome-v2-page .cta-row {
  display: flex; align-items: center; gap: 22px;
  flex-wrap: wrap; justify-content: center;
  margin-top: 4px;
}
.welcome-v2-page .cta {
  --pad-x: clamp(30px, 3.6vw, 46px);
  --pad-y: clamp(14px, 1.8vh, 18px);
  appearance: none;
  border: 1px solid var(--w-ink);
  background: var(--w-ink);
  color: var(--w-white);
  font-family: var(--w-sans);
  font-weight: 500;
  font-size: clamp(14px, 1.35vw, 16px);
  letter-spacing: 0.04em;
  padding: var(--pad-y) var(--pad-x);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), background .3s ease, box-shadow .4s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 10px 28px -14px rgba(13, 27, 52, 0.45), 0 2px 6px -2px rgba(13, 27, 52, 0.18);
  position: relative;
}
.welcome-v2-page .cta::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 1px solid rgba(184, 138, 54, 0.20);
  pointer-events: none;
}
.welcome-v2-page .cta:hover {
  background: var(--w-ink-2);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 16px 36px -16px rgba(13, 27, 52, 0.55), 0 3px 8px -2px rgba(13, 27, 52, 0.22);
}
.welcome-v2-page .cta:focus-visible { outline: 2px solid var(--w-gold); outline-offset: 4px; }
.welcome-v2-page .cta .arrow { width: 18px; height: 10px; flex-shrink: 0; }
.welcome-v2-page .cta .pip {
  width: 6px; height: 6px;
  background: var(--w-gold);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(184, 138, 54, 0.22);
}

.welcome-v2-page .listen {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--w-grey-500);
  font-size: 13px;
  letter-spacing: 0.02em;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--w-sans);
  padding: 8px 4px;
}
.welcome-v2-page .listen:hover { color: var(--w-ink); }
.welcome-v2-page .listen .ear { width: 20px; height: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.welcome-v2-page .listen .ear i { display: block; width: 2px; background: currentColor; border-radius: 2px; opacity: 0.6; }
.welcome-v2-page .listen .ear i:nth-child(1) { height: 4px;  animation: w-bar 1.6s ease-in-out infinite; }
.welcome-v2-page .listen .ear i:nth-child(2) { height: 8px;  animation: w-bar 1.6s ease-in-out .15s infinite; }
.welcome-v2-page .listen .ear i:nth-child(3) { height: 12px; animation: w-bar 1.6s ease-in-out .3s  infinite; }
.welcome-v2-page .listen .ear i:nth-child(4) { height: 8px;  animation: w-bar 1.6s ease-in-out .45s infinite; }
.welcome-v2-page .listen .ear i:nth-child(5) { height: 4px;  animation: w-bar 1.6s ease-in-out .6s infinite; }
@keyframes w-bar {
  0%, 100% { transform: scaleY(0.55); opacity: 0.5; }
  50%      { transform: scaleY(1.15); opacity: 1; }
}

.welcome-v2-page footer.bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--w-grey-500);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.welcome-v2-page footer .right { text-align: left; direction: ltr; }
.welcome-v2-page footer .center { color: var(--w-grey-400); font-family: var(--w-naskh); }

.welcome-v2-page .wave-main { animation: w-wave-breathe 5.5s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes w-wave-breathe {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.06); }
}

@media (max-width: 720px) {
  .welcome-v2-page .scholars { height: 32vh; }
  .welcome-v2-page .scholars svg { opacity: 0.6; }
  .welcome-v2-page .composition { aspect-ratio: 5 / 4; max-height: 42vh; }
  .welcome-v2-page header.top { font-size: 12px; }
  .welcome-v2-page .meta { gap: 14px; }
  .welcome-v2-page .meta a:not(.primary-nav) { display: none; }
  .welcome-v2-page .meta .sep { display: none; }
  .welcome-v2-page .composition { width: 100%; }
  .welcome-v2-page .wordmark { font-size: clamp(78px, 24vw, 130px); }
  .welcome-v2-page .stage-inner { gap: 12px; }
  .welcome-v2-page .tagline { font-size: 15px; line-height: 1.85; max-width: 32ch; }
  .welcome-v2-page footer.bottom { font-size: 11px; }
  .welcome-v2-page footer .center { display: none; }
  .welcome-v2-page .letters span.hide-mobile { display: none; }
}

/* ============================================================
   سايدبار التنقّل - NavSidebar
   ============================================================ */
.nav-scrim {
  position: fixed; inset: 0;
  background: rgba(13, 27, 52, 0.32);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}
.nav-scrim.open { opacity: 1; pointer-events: auto; }

.nav-sidebar {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  width: min(88%, 380px);
  background: #FBFAF7;
  z-index: 60;
  transform: translateX(105%);
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 20px 0 40px rgba(13, 27, 52, 0.15);
  font-family: "Tajawal", sans-serif;
  direction: rtl;
}
.nav-sidebar.open { transform: translateX(0); }

@media (min-width: 900px) {
  .nav-sidebar { width: 380px; }
}

.nav-head {
  padding: 22px 24px 16px;
  border-bottom: 0.5px solid #E5E3DE;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.nav-head h2 {
  margin: 0;
  font-size: 15px;
  color: #0d1b34;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.nav-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  color: #6e7682;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: background 160ms ease;
}
.nav-close:hover { background: #F0EDE5; }

.nav-back-stack {
  padding: 14px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 0.5px solid #F0EDE5;
}
.nav-back {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #F6F7F9;
  border: 0.5px solid #E2E5EA;
  color: #4a525e;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 200ms ease;
  text-align: right;
  justify-content: flex-end;
}
.nav-back:hover { background: #EEF0F3; }
.nav-back.primary {
  background: #0d1b34;
  color: #FFFFFF;
  border-color: #0d1b34;
}
.nav-back.primary:hover { background: #16264a; }

.nav-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.nav-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: #a4abb5;
  font-weight: 700;
  margin: 4px 0 16px;
  text-align: center;
}


.nav-levels { display: flex; flex-direction: column; gap: 8px; }
.nav-level-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 0.5px solid #eef0f3;
  background: #f6f7f9;
  transition: all 200ms ease;
}
.nav-level-row.muted { cursor: not-allowed; }

.nav-level-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0.5px solid #cdd2da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #6e7682;
  flex-shrink: 0;
  background: #FFFFFF;
  font-family: "Cairo", sans-serif;
}
.nav-level-circle.active {
  background: #FFFFFF;
  color: #0d1b34;
  border-color: #FFFFFF;
  font-size: 15px;
}
.nav-level-name {
  font-size: 14px;
  color: #6e7682;
  flex: 1;
  font-weight: 500;
}
.nav-soon {
  font-size: 10.5px;
  color: #a4abb5;
  background: #FFFFFF;
  padding: 5px 11px;
  border-radius: 999px;
  border: 0.5px solid #e2e5ea;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.nav-level-active {
  margin-top: 16px;
  background: linear-gradient(180deg, #16264a 0%, #0d1b34 100%);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(13, 27, 52, 0.22);
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
  border: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.nav-level-active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(184,138,54,0.55), transparent);
}
.nav-level-active:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(13, 27, 52, 0.32);
}
.nav-level-active-body {
  flex: 1;
  text-align: right;
}
.nav-level-active-name {
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 3px;
  font-family: "Cairo", sans-serif;
}
.nav-level-active-hint {
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.3px;
}
.nav-arrow {
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  line-height: 1;
}


/* الفصول */
.nav-chapters { display: flex; flex-direction: column; gap: 10px; }
.nav-chapter {
  padding: 18px 20px;
  border-radius: 14px;
  border: 0.5px solid #E2E5EA;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: inherit;
}
.nav-chapter.muted {
  background: #F6F7F9;
  cursor: not-allowed;
}
.nav-chapter.muted .nav-chapter-name { color: #a4abb5; }
.nav-chapter.active {
  background: #0d1b34;
  border-color: #0d1b34;
  box-shadow: 0 6px 18px rgba(13, 27, 52, 0.20);
  border: none;
}
.nav-chapter.active:hover {
  background: #16264a;
  transform: translateX(2px);
}
.nav-chapter-name {
  font-size: 15px;
  font-weight: 700;
  color: #0d1b34;
  flex: 1;
  text-align: right;
}
.nav-chapter.active .nav-chapter-name { color: #FFFFFF; }
.nav-chapter-hint {
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
  margin-top: 3px;
}


.nav-lessons { display: flex; flex-direction: column; gap: 10px; }
.nav-lesson {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  border: 0.5px solid #e2e5ea;
  background: #FFFFFF;
  transition: all 220ms cubic-bezier(0.22,0.61,0.36,1);
}
.nav-lesson.available { cursor: pointer; }
.nav-lesson.available:hover {
  border-color: #0d1b34;
  box-shadow: 0 6px 20px rgba(13,27,52,0.10);
  transform: translateY(-1px);
}
.nav-lesson.muted { background: #f6f7f9; border-color: #eef0f3; }

.nav-lesson-ico {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(180deg, #F6F7F9 0%, #EEF0F3 100%);
  border: 0.5px solid #e2e5ea;
  display: flex; align-items: center; justify-content: center;
  color: #0d1b34;
  flex-shrink: 0;
  transition: all 220ms ease;
}
.nav-lesson-ico svg { width: 22px; height: 22px; }
.nav-lesson.available:hover .nav-lesson-ico {
  background: linear-gradient(180deg, #16264a 0%, #0d1b34 100%);
  color: #FFFFFF;
  border-color: #0d1b34;
}
.nav-lesson.muted .nav-lesson-ico {
  color: #a4abb5;
  background: #FFFFFF;
}

.nav-lesson-body { flex: 1; min-width: 0; }
.nav-lesson-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0d1b34;
  margin-bottom: 4px;
  line-height: 1.4;
}
.nav-lesson.muted .nav-lesson-title { color: #a4abb5; }
.nav-lesson-meta {
  font-size: 11px;
  color: #6e7682;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-lesson.muted .nav-lesson-meta { color: #cdd2da; }
.nav-lesson-meta .meta-dot { color: #cdd2da; }

.nav-lesson-action { flex-shrink: 0; }
.nav-play-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #0d1b34;
  color: #FFFFFF;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 220ms ease;
  box-shadow: 0 2px 8px rgba(13,27,52,0.20);
}
.nav-lesson:hover .nav-play-btn { background: #16264a; transform: scale(1.05); }
.nav-play-btn svg { width: 12px; height: 12px; margin-right: 1px; }
.nav-lesson .nav-soon {
  font-size: 10.5px;
  color: #a4abb5;
  background: #FFFFFF;
  padding: 5px 11px;
  border-radius: 999px;
  border: 0.5px solid #e2e5ea;
  font-weight: 500;
  letter-spacing: 0.5px;
}


.sidebar-back-stack {
  padding: 14px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 0.5px solid #F0EDE5;
}
.sb-back {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #F6F7F9;
  border: 0.5px solid #E2E5EA;
  color: #4a525e;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 200ms ease;
  text-align: right;
  justify-content: flex-end;
}
.sb-back:hover { background: #EEF0F3; }
.sb-back.primary {
  background: #0d1b34;
  color: #FFFFFF;
  border-color: #0d1b34;
}
.sb-back.primary:hover { background: #16264a; }

/* ========== AuthGate ========== */
.auth-gate-loading {
  position: fixed; inset: 0;
  background: #0a1628;
}
.auth-gate {
  position: fixed; inset: 0;
  background: #0a1628;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  font-family: "Cairo", sans-serif;
}
.auth-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-radius: 16px;
  padding: 40px 32px;
  width: 320px;
  max-width: 90vw;
  display: flex; flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.auth-title {
  font-family: "Aref Ruqaa", serif;
  font-size: 42px;
  color: #d4af37;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.auth-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 28px;
}
.auth-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  direction: ltr;
}
.auth-input:focus {
  border-color: rgba(212, 175, 55, 0.5);
}
.auth-input:disabled {
  opacity: 0.5;
}
.auth-error {
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}
.auth-btn {
  width: 100%;
  margin-top: 18px;
  background: #1e3a5f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.auth-btn:hover:not(:disabled) {
  background: #2a4a73;
}
.auth-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Settings Menu (الإعدادات الموحَّدة) ========== */
.settings-menu {
  position: fixed;
  width: 260px;
  background: rgba(28, 32, 40, 0.96);
  backdrop-filter: blur(12px);
  color: #fff;
  border-radius: 14px;
  padding: 8px;
  font-size: 13px;
  z-index: 1500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  font-family: var(--ff-ar);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 6px 4px;
}
.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s;
}
.settings-item:hover:not(.is-disabled) {
  background: rgba(255, 255, 255, 0.06);
}
.settings-item.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.settings-item.is-row {
  cursor: default;
}
.settings-item.is-row:hover {
  background: transparent;
}
.settings-icon {
  font-size: 15px;
  line-height: 1;
  width: 20px;
  text-align: center;
}
.settings-label {
  flex: 1;
}
.settings-badge {
  font-size: 11px;
  background: rgba(212, 175, 55, 0.18);
  color: #d4af37;
  padding: 2px 8px;
  border-radius: 10px;
}
.settings-toggle {
  width: 32px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}
.settings-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: inset-inline-start 0.2s;
}
.settings-toggle.on {
  background: #d4af37;
}
.settings-toggle.on::after {
  inset-inline-start: 16px;
}
.settings-select {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
}
.settings-select option {
  background: #1a2942;
  color: #fff;
}

/* ========== Philosophy Modal ========== */
.philosophy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.philosophy-modal {
  background: #fefcf6;
  color: #0d1b34;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 36px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  position: relative;
  font-family: var(--ff-ar);
}
.philosophy-close {
  position: absolute;
  top: 14px;
  inset-inline-start: 18px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: #0d1b34;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
}
.philosophy-close:hover { opacity: 1; }
.philosophy-title {
  font-family: "Aref Ruqaa", serif;
  font-size: 32px;
  color: #b88a36;
  text-align: center;
  margin: 0 0 24px;
}
.philosophy-body p {
  line-height: 1.95;
  font-size: 15px;
  margin: 0 0 16px;
  text-align: justify;
}
.philosophy-closer {
  font-weight: 600;
  color: #0d1b34;
  border-top: 1px solid rgba(13, 27, 52, 0.15);
  padding-top: 16px;
  margin-top: 20px !important;
}

/* ========== "اسأل المعلم الذكي" — البطاقة + المحادثة ========== */

/* البطاقة الأم: محاذاة + ارتفاع متحكَّم به */
.popover.ask-popover {
  max-height: min(70vh, calc(100vh - var(--bottombar-h) - 80px));
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}

/* وضع الديسكتوب: البطاقة تبقى داخل منطقة المسرح، أعرض من السابق */
@media (min-width: 769px) {
  .app-shell:not(.mobile-locked):not(.welcome-mode) .phone:not(.phone-nahw) .popover {
    grid-area: stage;
    align-self: end;
    position: relative;
    inset: auto;
    margin: 0 16px 16px auto;
    width: min(880px, calc(100% - 32px));
    max-height: min(82vh, calc(100vh - var(--bottombar-h) - 60px));
  }
}

/* رأس البطاقة + زرّ الطباعة */
.ask-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ask-tools {
  display: flex;
  gap: 6px;
}
.ask-tool-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 9px;
  font-family: var(--ff-ar);
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-width: 32px;
}
.ask-tool-btn:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--ink);
  border-color: #b88a36;
}
.ask-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


.ask-counter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 2px;
  font-family: var(--ff-ar);
  font-size: 12.5px;
  color: var(--ink-secondary);
}
.ask-counter-label {
  font-weight: 600;
}
.ask-counter-dots {
  display: inline-flex;
  gap: 4px;
}
.ask-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: background 0.3s, transform 0.2s;
}
.ask-dot.available {
  background: #b88a36;
  box-shadow: 0 0 0 2px rgba(184,138,54,0.15);
}
.ask-dot.used {
  background: var(--bg-muted);
  border: 1px solid var(--line);
}
.ask-counter-text {
  font-size: 12px;
  opacity: 0.85;
}

/* سجلّ المحادثة */
.ask-history {
  flex: 1;
  overflow-y: auto;
  margin-top: 14px;
  margin-bottom: 12px;
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
}
.ask-history:empty { display: none; }

.ask-exchange {
  border-right: 3px solid #b88a36;
  padding-right: 14px;
  animation: askFadeIn 0.3s ease-out;
}
@keyframes askFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ask-q {
  font-family: var(--ff-ar);
  font-size: 13.5px;
  color: var(--ink-secondary);
  margin-bottom: 10px;
  line-height: 1.7;
}
.ask-q-label {
  color: #b88a36;
  font-weight: 700;
  margin-left: 4px;
}

.ask-a {
  font-family: var(--ff-ar);
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink);
}

.ask-error {
  color: #b04545;
  background: #fef2f2;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

/* صفّ الإدخال */
.ask-input-row {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.ask-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--ff-ar);
  font-size: 14px;
  direction: rtl;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}
.ask-input:focus { border-color: #b88a36; }
.ask-input:disabled { opacity: 0.6; cursor: not-allowed; }

.ask-textarea {
  resize: none;
  min-height: 42px;
  max-height: 140px;
  line-height: 1.6;
  overflow-y: auto;
  font-family: var(--ff-ar);
}

.ask-send-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: #b88a36;
  color: #fff;
  font-family: var(--ff-ar);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  min-width: 76px;
}
.ask-send-btn:hover:not(:disabled) { opacity: 0.9; }
.ask-send-btn:active:not(:disabled) { transform: scale(0.97); }
.ask-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ask-hint {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 8px;
  margin-bottom: 0;
  text-align: center;
}

/* Markdown داخل الإجابة */
.answer-rendered {
  font-family: var(--ff-ar);
  font-size: 15px;
  line-height: 1.95;
}
.answer-rendered .md-block { margin-bottom: 6px; }
.answer-rendered h1,
.answer-rendered h2,
.answer-rendered h3 {
  font-family: var(--ff-ar);
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 8px;
  padding-right: 10px;
  border-right: 3px solid #b88a36;
}
.answer-rendered h1 {
  font-size: 17px;
  color: #1B1F24;
  background: linear-gradient(to left, rgba(184,138,54,0.08), transparent);
  padding: 6px 10px;
  border-radius: 6px;
}
.answer-rendered h2 {
  font-size: 15.5px;
  color: #2a3340;
}
.answer-rendered h3 {
  font-size: 14.5px;
  color: #b88a36;
  border-right-color: rgba(184,138,54,0.5);
}

/* فقرات منسّقة */
.answer-rendered p {
  margin: 8px 0;
  color: #1B1F24;
}

.answer-rendered ul,
.answer-rendered ol {
  padding-right: 22px;
  margin: 6px 0;
}
.answer-rendered li { margin-bottom: 4px; }

.answer-rendered strong {
  color: var(--ink);
  font-weight: 700;
}

.answer-rendered hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.answer-rendered blockquote {
  border-right: 3px solid #b88a36;
  background: linear-gradient(to left, rgba(184,138,54,0.06), transparent);
  padding: 8px 14px 8px 12px;
  color: #2a3340;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
  font-style: normal;
}

/* علامات الترقيم في القوائم بلون ذهبي */
.answer-rendered ul li::marker,
.answer-rendered ol li::marker {
  color: #b88a36;
  font-weight: 700;
}

/* تحسين Strong */
.answer-rendered strong {
  color: #b88a36;
  font-weight: 700;
}

.answer-rendered code {
  background: var(--bg-muted);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--ff-lat);
}

.answer-rendered table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 13.5px;
}
.answer-rendered th,
.answer-rendered td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: right;
}
.answer-rendered th {
  background: var(--bg-muted);
  font-weight: 700;
}

/* Mermaid */
.answer-rendered .mermaid {
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
  overflow-x: auto;
}
.answer-rendered .mermaid svg {
  max-width: 100%;
  height: auto;
}
.answer-rendered .mermaid-loading {
  text-align: center;
  background: var(--bg-muted);
  color: var(--ink-secondary);
  padding: 18px;
  border-radius: 12px;
  margin: 14px 0;
  font-size: 13px;
  font-style: italic;
}


/* ============================================
   لوحة النحو — الخريطة الذهنيّة + الاختبار
   ============================================ */
/* === mindmap === */
.mindmap-stage {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-shadow: var(--shadow-sm);
}

/* Ø§ÙÙØ±ÙØ² */
.mm-center-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
}
.mm-center {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 30px;
  background: var(--identity-deep);
  color: white;
  border-radius: 14px;
  font-family: var(--ff-naskh);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 20px rgba(47,73,99,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
}
.mm-center::before {
  content: ""; width: 6px; height: 6px;
  border-radius: 50%; background: rgba(255,255,255,0.85);
}
.mm-center-stem {
  width: 1.5px; height: 18px;
  background: var(--ink-faded);
  border-radius: 1px;
}

/* Ø§ÙØ£ÙØ³Ø§Ù */
.mm-sections {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mm-section {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-soft);
  position: relative;
}
.mm-section:last-child { border-bottom: none; }

/* Ø¹ÙÙØ¯ Ø§ÙÙØ±Ø¹ Ø§ÙØ±Ø¦ÙØ³ÙÙ Ø¹ÙÙ Ø§ÙÙÙÙÙ (RTL: ÙØ£Ø®Ø° Ø§ÙØ¹ÙÙØ¯ Ø§ÙØ£ÙÙÙ ÙÙ Ø§ÙÙ grid) */
.mm-branch-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 14px 0 14px 0;
  position: sticky;
  top: 0;
  min-height: 60px;
}

.mm-branch-conn {
  width: 28px; height: 1.5px;
  background: var(--ink-faded);
  margin-inline-start: 4px;
}

.mm-branch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--identity);
  color: white;
  border-radius: 11px;
  font-family: var(--ff-naskh);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(199,107,90,0.22), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: opacity 500ms var(--ease), background 400ms var(--ease), color 400ms var(--ease);
  min-width: 110px;
  justify-content: center;
}
.mm-branch::before {
  content: ""; width: 5px; height: 5px;
  border-radius: 50%; background: rgba(255,255,255,0.9);
}
.mm-branch.hidden {
  background: var(--bg-elevated);
  color: var(--ink-faded);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 600;
}
.mm-branch.hidden::before { background: var(--ink-faded); }
.mm-branch.revealing { animation: glowMain 1100ms var(--ease) both; }

/* Ø¹ÙÙØ¯ Ø§ÙØ¹ÙØ¯ Ø¹ÙÙ Ø§ÙÙØ³Ø§Ø± */
.mm-leaves {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px 12px 0;
}

.mm-leaf-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 14px;
}

.mm-leaf-row.hidden {
  align-items: center;
  padding: 6px 0;
}

/* ÙØµÙØ© ÙÙ Ø§ÙØ¹ÙÙØ¯ Ø§ÙØ±Ø£Ø³ÙÙ Ø¥ÙÙ Ø§ÙØ¹ÙØ¯Ø© */
.mm-leaf-conn {
  width: 28px;
  flex-shrink: 0;
  border-top: 1.5px solid var(--ink-faded);
  align-self: center;
  position: relative;
}

/* Ø¹ÙÙØ¯ Ø±Ø£Ø³ÙÙ ÙØ±Ø¨Ø· ÙÙÙ Ø§ÙØ¹ÙØ¯ Ø¨Ø§ÙÙØ±Ø¹ â ÙØ¶Ø¹Ù Ø¹Ø¨Ø± pseudo Ø¹ÙÙ .mm-leaves */
.mm-leaves {
  position: relative;
}
.mm-leaves::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  /* ÙØ¶Ø¹Ù Ø¹ÙØ¯ Ø¨Ø¯Ø§ÙØ© Ø§ÙØ¬Ø²Ø¡ Ø§ÙØ£ÙØ³Ø± ÙÙ Ø§ÙÙØ³Ù (RTL: ÙØ³Ø§Ø± = right edge) */
  inset-inline-end: -1px;
  width: 1.5px;
  background: var(--ink-faded);
  border-radius: 1px;
}

/* Ø§ÙØ¹ÙØ¯Ø© Ø§ÙØ«Ø§ÙÙÙÙØ© (ÙØ±Øª) */
.mm-leaf {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--ff-naskh);
  box-shadow: var(--shadow-sm);
  transition: opacity 500ms var(--ease), border-color 400ms var(--ease);
  min-width: 0;
}

.mm-leaf-label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--identity);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.5;
  text-wrap: pretty;
}
.mm-leaf-label::before {
  content: "";
  flex-shrink: 0;
  width: 6px; height: 6px; margin-top: 8px;
  border-radius: 50%;
  background: var(--identity);
}

.mm-leaf.revealing {
  border-color: var(--identity);
  animation: glowLeaf 1000ms var(--ease) both;
}

.mm-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-inline-start: 13px;
}

.mm-example {
  font-family: var(--ff-naskh);
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  background: var(--bg-muted);
  color: var(--ink-secondary);
  border-radius: 7px;
  border: 1px solid var(--line);
  letter-spacing: 0.01em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: nodeIn 400ms var(--ease) both;
}
.mm-example .arrow { color: var(--ink-faded); font-size: 11px; }

/* Ø§ÙÙÙØ·Ø© Ø§ÙÙØ®ÙÙÙØ© */
.mm-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bg-hushed);
  border: 1px solid var(--line);
  margin-inline-start: 28px;
}

@keyframes nodeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes glowMain {
  0% { box-shadow: 0 0 0 0 rgba(199,107,90,0); }
  40% { box-shadow: 0 4px 12px rgba(199,107,90,0.25), 0 0 0 8px rgba(199,107,90,0.16); }
  100% { box-shadow: 0 4px 12px rgba(199,107,90,0.22), 0 0 0 0 transparent; }
}
@keyframes glowLeaf {
  0% { box-shadow: 0 0 0 0 transparent; }
  40% { box-shadow: var(--shadow-sm), 0 0 0 6px rgba(110,155,114,0.14); }
  100% { box-shadow: var(--shadow-sm), 0 0 0 0 transparent; }
}



/* === quiz === */
.quiz-cta-card {
  margin: 8px 4px 0;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--identity);
  border-radius: 14px;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.quiz-cta-msg {
  font-family: var(--ff-naskh); font-size: 15px;
  color: var(--ink-secondary); text-align: center;
  margin: 0; font-weight: 500;
}
.quiz-cta {
  width: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px;
  background: var(--identity-deep); color: white;
  border: none; border-radius: 10px;
  font-family: var(--ff-ar); font-size: 13.5px; font-weight: 700;
  cursor: pointer;
  transition: transform 150ms var(--ease), background 200ms var(--ease);
}
.quiz-cta:hover { transform: translateY(-1px); background: var(--identity); }

.gathered-section { display: flex; flex-direction: column; gap: 8px; padding: 4px 4px 0; }
.gathered-title {
  font-size: 11px; color: var(--ink-muted);
  font-weight: 600; letter-spacing: 0.06em;
  text-align: center; font-family: var(--ff-naskh);
}

/* Quiz modal */
.quiz-overlay {
  position: fixed; inset: 0;
  background: rgba(28,32,40,0.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.quiz-modal {
  background: var(--bg-elevated); border-radius: 18px;
  width: min(560px, 100%); max-height: 92vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.quiz-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.quiz-head-title {
  font-size: 17px; font-weight: 700; margin: 0;
  display: inline-flex; align-items: center; gap: 8px;
}
.quiz-head-counter {
  font-size: 12px; color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  background: var(--bg-muted); padding: 4px 10px; border-radius: 999px;
}
.quiz-progress { height: 3px; background: var(--line-soft); position: relative; }
.quiz-progress-fill {
  position: absolute; inset: 0 0 0 auto;
  background: var(--identity);
  transition: width 400ms var(--ease);
}
.quiz-body { padding: 26px 22px 22px; overflow-y: auto; }
.quiz-question {
  font-family: var(--ff-naskh); font-size: 19px; line-height: 1.7;
  margin: 0 0 18px; font-weight: 600;
}
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; text-align: right;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--line); border-radius: 12px;
  font-family: var(--ff-naskh); font-size: 16px;
  cursor: pointer; transition: all 200ms var(--ease);
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--identity); background: var(--identity-soft);
}
.quiz-option .option-letter {
  flex-shrink: 0; width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--bg-muted); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--ink-secondary);
}
.quiz-option .option-text { flex:1; padding-top: 2px; line-height: 1.5; }
.quiz-option.correct { background: #E6EEE9; border-color: var(--identity); color: #3F6E48; }
.quiz-option.correct .option-letter { background: var(--identity); color: white; border-color: var(--identity); }
.quiz-option.wrong { background: #FBE9E9; border-color: #C25555; color: #8B3A3A; }
.quiz-option.wrong .option-letter { background: #C25555; color: white; border-color: #C25555; }
.quiz-option:disabled { cursor: default; }
.quiz-explanation {
  margin-top: 18px; padding: 14px 16px;
  background: var(--bg-muted);
  border-right: 3px solid var(--identity);
  border-radius: 8px;
  font-family: var(--ff-naskh); font-size: 15px; line-height: 1.7;
  color: var(--ink-secondary);
}
.quiz-explanation .label {
  display: block; font-family: var(--ff-ar);
  font-size: 11px; font-weight: 700;
  color: var(--identity); letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.quiz-foot {
  padding: 14px 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px;
  background: var(--bg);
}
.quiz-btn {
  padding: 10px 22px; border-radius: 10px;
  font-family: var(--ff-ar); font-size: 14px; font-weight: 700;
  cursor: pointer; border: none;
}
.quiz-btn-primary { background: var(--identity-deep); color: white; }
.quiz-btn-primary:hover { background: var(--identity); }
.quiz-btn-primary:disabled { background: var(--bg-hushed); color: var(--ink-faded); cursor:not-allowed; }
.quiz-btn-ghost { background: transparent; color: var(--ink-secondary); border: 1px solid var(--line); }
.quiz-btn-ghost:hover { background: var(--bg-muted); }
.quiz-result { padding: 36px 24px; text-align: center; }
.quiz-result-score {
  font-family: var(--ff-naskh); font-size: 56px; font-weight: 700;
  color: var(--identity-deep); line-height: 1;
  margin: 0 0 6px; font-variant-numeric: tabular-nums;
}
.quiz-result-score .of { color: var(--ink-faded); font-weight: 400; margin: 0 6px; }
.quiz-result-label { font-family: var(--ff-naskh); font-size: 17px; color: var(--ink-secondary); margin: 0 0 24px; }
.quiz-result-bars { display:flex; justify-content:center; gap:8px; margin-bottom:28px; }
.quiz-result-bar { width:36px; height:6px; border-radius:999px; background: var(--line); }
.quiz-result-bar.right { background: var(--identity); }
.quiz-result-bar.wrong { background: #C25555; }



/* === sidebar_cta === */
.sidebar-cta {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 -8px 22px -18px rgba(28,32,40,0.18);
}
.sidebar-cta-msg {
  font-family: var(--ff-naskh); font-size: 13.5px;
  color: var(--ink-secondary); text-align: center;
  margin: 0; font-weight: 500;
}
.sidebar-cta .quiz-cta {
  align-self: center;
  min-width: 200px;
  min-height: 42px;
  font-size: 14px;
  border-radius: 11px;
  box-shadow: 0 4px 14px -4px rgba(47,73,99,0.42);
}



/* رأس فرع ثانٍ في قائمة الدروس */
.nav-eyebrow-spaced { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }



/* ============================================
   لوحة النحو — قواعد الحالات الصَريحة
   ============================================ */
/* الفرع — الحالات الثلاث */
.mm-branch.is-hidden {
  background: var(--bg-elevated);
  color: var(--ink-faded);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 600;
}
.mm-branch.is-hidden::before { background: var(--ink-faded); }
.mm-branch.is-revealing,
.mm-branch.is-revealed {
  background: var(--identity);
  color: white;
  border: 1px solid transparent;
  box-shadow: 0 4px 12px rgba(47,73,99,0.18), inset 0 1px 0 rgba(255,255,255,0.18);
  font-weight: 700;
}
.mm-branch.is-revealing { animation: glowMain 1100ms var(--ease) both; }

/* العقدة (الكرت) — الحالات الثلاث */
.mm-leaf-row.is-hidden {
  align-items: center;
  padding: 6px 0;
  min-height: 14px;
}
.mm-leaf-row.is-revealing,
.mm-leaf-row.is-revealed { min-height: 14px; }
.mm-leaf.is-revealing,
.mm-leaf.is-revealed {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.mm-leaf.is-revealing { animation: glowLeaf 1000ms var(--ease) both; border-color: var(--identity-soft); }



/* الفروع المخفيّة: لا تُظهر اسماً ولا إطاراً */
.mm-branch.is-hidden {
  visibility: hidden;
}
.mm-branch-wrap:has(.mm-branch.is-hidden) {
  min-height: 14px;
  padding: 6px 0;
}
.mm-section.is-hidden {
  display: none;
}

/* ============================================
   لوحة النحو — عَرض أوسع (لا يَمسّ النصوص)
   ============================================ */
.sidebar:has(.mindmap-stage) {
  width: min(92%, 480px);
}



/* تَخطيط النَحو: حِوار ٤٠٪ + خَريطة ٦٠٪ */
.phone-nahw > .stage { flex: 4 0 0; min-height: 0; }
.nahw-stage-wrap { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.nahw-stage-wrap > .stage { flex: 0 0 50%; min-height: 0; min-width: 0; }
.nahw-stage-wrap > .nahw-mindmap-bottom { flex: 0 0 50%; }
.nahw-mindmap-bottom {
  flex: 6 0 0;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  background: var(--bg);
}




/* خَريطة النَحو: مَركَز فَوق، فُروع أُفُقيّة، أَمثِلة رَأسيّة */
.nahw-mindmap-bottom .mindmap-stage { align-items: center; }
.nahw-mindmap-bottom .mm-sections {
  flex-direction: row;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}
.nahw-mindmap-bottom .mm-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: none;
}
.nahw-mindmap-bottom .mm-branch-wrap {
  flex-direction: column;
  align-items: center;
  position: static;
}
.nahw-mindmap-bottom .mm-branch-conn {
  width: 1.5px; height: 18px; margin-inline-start: 0;
}

/* خَريطة النَحو الأُفُقيّة: الأَوراق وأَمثِلتها رَأسيّة */
.nahw-mindmap-bottom .mm-leaves {
  padding: 12px 0 0 0;
  align-items: center;
}
.nahw-mindmap-bottom .mm-leaves::before { display: none; }
.nahw-mindmap-bottom .mm-leaf-row {
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.nahw-mindmap-bottom .mm-leaf-conn {
  width: 1.5px;
  height: 14px;
  border-top: none;
  border-inline-start: 1.5px solid var(--ink-faded);
}
.nahw-mindmap-bottom .mm-examples {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  padding-inline-start: 0;
  padding-top: 4px;
}

/* خَريطة النَحو الأُفُقيّة: اتِّصال الخُطوط بدون فَجَوات */
.nahw-mindmap-bottom .mm-section { padding: 0; }
.nahw-mindmap-bottom .mm-branch-wrap { padding: 0; }
.nahw-mindmap-bottom .mm-leaves { padding: 0; gap: 0; }
.nahw-mindmap-bottom .mm-center-stem { height: 16px; }
.nahw-mindmap-bottom .mm-branch-conn { height: 16px; }
.nahw-mindmap-bottom .mm-leaf-conn { height: 16px; }

/* خَريطة النَحو: إلغاء فَجَوات is-hidden */
.nahw-mindmap-bottom .mm-leaf-row.is-hidden { padding: 0; min-height: 0; }
.nahw-mindmap-bottom .mm-leaf-row.hidden { padding: 0; min-height: 0; }
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-hidden) { padding: 0; min-height: 0; }
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.hidden) { padding: 0; min-height: 0; }

/* خَريطة النَحو: إغلاق فَجَوات أَخيرة */
.nahw-mindmap-bottom .mm-center-wrap { margin-bottom: 0; }
.nahw-mindmap-bottom .mm-branch-wrap { padding: 0; min-height: 0; }

/* خَريطة النَحو: نُمُوّ الخُطوط حَيّاً مَع كَشف الفُروع */
.nahw-mindmap-bottom .mm-branch-conn,
.nahw-mindmap-bottom .mm-leaf-conn {
  height: 0;
  transition: height 0.6s ease-out;
}
.nahw-mindmap-bottom .mm-branch.is-hidden { display: none; }
.nahw-mindmap-bottom .mm-leaf-row.is-hidden .mm-leaf { display: none; }
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-revealing) .mm-branch-conn,
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-revealed) .mm-branch-conn {
  height: 16px;
}
.nahw-mindmap-bottom .mm-leaf-row.is-revealing .mm-leaf-conn,
.nahw-mindmap-bottom .mm-leaf-row.is-revealed .mm-leaf-conn {
  height: 16px;
}

/* خَريطة النَحو: إخفاء النُقاط والفُروع المَستورة كاملاً */
.nahw-mindmap-bottom .mm-leaf-row.is-hidden { display: none; }
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-hidden) { display: none; }

/* خَريطة النَحو: تَوحيد الخُطوط — background وعَرض ٢px وطول ٢٤px */
.nahw-mindmap-bottom .mm-leaf-conn {
  border: none;
  background: var(--ink-faded);
}
.nahw-mindmap-bottom .mm-center-stem,
.nahw-mindmap-bottom .mm-branch-conn,
.nahw-mindmap-bottom .mm-leaf-conn {
  width: 2px;
}
.nahw-mindmap-bottom .mm-center-stem { height: 24px; }
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-revealing) .mm-branch-conn,
.nahw-mindmap-bottom .mm-branch-wrap:has(.mm-branch.is-revealed) .mm-branch-conn,
.nahw-mindmap-bottom .mm-leaf-row.is-revealing .mm-leaf-conn,
.nahw-mindmap-bottom .mm-leaf-row.is-revealed .mm-leaf-conn {
  height: 24px;
}

/* خَريطة النَحو: خَطّ أُفُقيّ يَربِط الفُروع بالمَركَز */
.nahw-mindmap-bottom .mm-sections {
  position: relative;
}
.nahw-mindmap-bottom .mm-sections::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ink-faded);
}

/* خَريطة النَحو: خَطّ أُفُقيّ ديناميكيّ */
.nahw-mindmap-bottom .mm-sections::before { display: none; }
.nahw-mindmap-bottom .mm-h-line {
  position: absolute;
  top: 0;
  height: 2px;
  background: var(--ink-faded);
  opacity: 0;
  transition: left 0.6s ease-out, right 0.6s ease-out, opacity 0.4s ease-out;
}
.nahw-mindmap-bottom .mm-h-line.active { opacity: 1; }

.nahw-mindmap-bottom .mm-center-wrap {
  transition: transform 0.6s ease-out;
}

/* خَريطة النَحو: لَون الفُروع الثانَويّة سَماويّ تَمييزاً عَن المَركَز */
.nahw-mindmap-bottom .mm-branch.is-revealing,
.nahw-mindmap-bottom .mm-branch.is-revealed {
  background: var(--identity-soft);
  color: var(--identity-deep);
  border: 1px solid var(--identity);
  box-shadow: none;
}
.nahw-mindmap-bottom .mm-branch.is-revealing::before,
.nahw-mindmap-bottom .mm-branch.is-revealed::before {
  background: var(--identity-deep);
}

/* بِطاقات السايدبار النَحويّة */
.card-pull{background:var(--bg-elevated);border:1px solid var(--line);border-radius:12px;margin-bottom:12px}
.card-pull>summary{padding:14px 16px;cursor:pointer;font-weight:700;list-style:none}
.card-pull>summary::-webkit-details-marker{display:none}
.card-pull[open]>summary{border-bottom:1px solid var(--line)}
.card-prose{padding:14px 16px;margin:0;line-height:1.85}
.qlist{list-style:none;padding:8px 12px 14px;margin:0}
.qlist>li{margin-bottom:8px}
.qcard{background:var(--bg);border:1px solid var(--line);border-radius:8px}
.qcard>summary{padding:10px 12px;cursor:pointer;font-size:14px;list-style:none}
.qcard>summary::-webkit-details-marker{display:none}
.qcard-brief,.qcard-explained{padding:8px 12px;border-top:1px solid var(--line);font-size:13px;line-height:1.7}

/* بِطاقات coll مُتَّسِقة مَع collection-btn النَصّيّ */
.coll-card{background:var(--bg-elevated);border:1px solid var(--line);border-radius:12px;margin-bottom:8px;list-style:none}
.coll-card>summary{padding:12px 14px;cursor:pointer;list-style:none;display:flex;align-items:center;gap:10px}
.coll-card>summary::-webkit-details-marker{display:none}
.coll-card[open]>summary{border-bottom:1px solid var(--line)}
.coll-card:hover{border-color:var(--identity);background:var(--identity-soft)}
.coll-pull{padding:14px;margin:0;line-height:1.85;font-size:14px;color:var(--ink)}

/* تَمرير الخَريطة في حاوية داخِليّة لكي تَبقى الأيقونة ثابِتة */
.nahw-mindmap-bottom { overflow: hidden; position: relative; }
.nahw-mindmap-scroll {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nahw-mindmap-scroll .mindmap-stage {
  min-width: max-content;
}

/* ============================================
   أَوضاع عَرض النَحو الثلاثة + أَيقونات التَّبديل
   ============================================ */
.nahw-pane { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.nahw-pane-dialog { flex: 0 0 50%; }
.nahw-stage-wrap > .nahw-pane-dialog > .stage { flex: 1; min-height: 0; min-width: 0; }

/* الوَضع المُشترَك (افتراضيّ): الحاليّ بلا تَغيير */
.nahw-stage-wrap.view-split > .nahw-pane-dialog { flex: 0 0 50%; }
.nahw-stage-wrap.view-split > .nahw-mindmap-bottom { flex: 0 0 50%; display: flex; }

/* الحوار كامل: الخَريطة مَخفيّة */
.nahw-stage-wrap.view-dialog > .nahw-pane-dialog { flex: 1 1 100%; }
.nahw-stage-wrap.view-dialog > .nahw-mindmap-bottom { display: none; }

/* الخَريطة كامِلة: الحِوار مَخفيّ، الصوت مُستَمِرّ */
.nahw-stage-wrap.view-map > .nahw-pane-dialog > .stage { display: none; }
.nahw-stage-wrap.view-map > .nahw-pane-dialog { flex: 0 0 auto; }
.nahw-stage-wrap.view-map > .nahw-mindmap-bottom { flex: 1 1 100%; display: flex; }

/* أَيقونات التَّبديل في الزاوية العُليا اليُمنى لكلّ لَوحة */
.nahw-view-toggle {
  position: absolute;
  top: 8px;
  inset-inline-start: 10px;
  display: inline-flex;
  gap: 4px;
  z-index: 5;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}
.nvt-btn {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--ink-faded);
  cursor: pointer;
  padding: 0;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.nvt-btn:hover { background: var(--bg-elevated); color: var(--ink); }
.nvt-btn.is-on { background: var(--identity); color: white; }

/* أَيقونة الحِوار تَختفي في وَضع الخَريطة الكامِلة (لأنّ لَوحة الحِوار مَخفيّة) */
.nahw-stage-wrap.view-map > .nahw-pane-dialog > .nahw-view-toggle { display: none; }

/* في الجَوّال الأَفقيّ: التَّطبيق يَمتدّ كامل الشاشة، والخَريطة كامِلة افتراضيّاً */
@media (orientation: landscape) and (max-height: 500px) {
  .app-shell { padding: 0 !important; }
  .phone {
    max-width: none !important;
    max-height: none !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
  }
  .nahw-stage-wrap:not(.view-dialog) > .nahw-pane-dialog > .stage { display: none; }
  .nahw-stage-wrap:not(.view-dialog) > .nahw-mindmap-bottom { flex: 1 1 100%; display: flex; }
  .nahw-stage-wrap.view-dialog > .nahw-pane-dialog > .stage { display: flex; }
  .nahw-stage-wrap.view-dialog > .nahw-mindmap-bottom { display: none; }
}

/* بطاقة اختبر فهمك في الموارد — ثلاث حالات */
.coll-card.quiz-card { transition: opacity 300ms var(--ease); }
.coll-card.quiz-card.is-ready > summary { cursor: pointer; }
.coll-card.quiz-card.is-locked,
.coll-card.quiz-card.is-pending { opacity: 0.55; }
.coll-card.quiz-card.is-locked > summary,
.coll-card.quiz-card.is-pending > summary { cursor: not-allowed; }
.coll-card.quiz-card.is-locked:hover,
.coll-card.quiz-card.is-pending:hover {
  border-color: var(--line);
  background: var(--bg-elevated);
}
