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

: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 {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 8px;
  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; }
.topbar-title .t-lesson {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.2;
}
.topbar-title .t-segment {
  font-size: var(--fs-title);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.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); }
.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-group-label.extra { color: var(--sem-tool); }

.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;
  animation: accumIn 320ms var(--ease) both;
}
.lp-item.extra {
  background: #FBF5EC;
  border-inline-end: 2px solid var(--sem-tool);
}
.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;
}

.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: 10;
  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 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) {
    padding: 0;
    background: var(--bg);
    display: block;
  }
  .app-shell:not(.mobile-locked) .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: var(--topbar-h) 1fr var(--bottombar-h);
    grid-template-areas:
      "sidebar topbar"
      "sidebar stage"
      "sidebar bottombar";
  }

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

  .app-shell:not(.mobile-locked) .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) .scrim { display: none !important; }
  .app-shell:not(.mobile-locked) .sidebar-head .close-btn { display: none; }
  .app-shell:not(.mobile-locked) .topbar-btn.menu-btn { display: none; }

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

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

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

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

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

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