/* =====================================================================
   مُسمِّع - التصميم المعماري فائق الأداء وسريع الاستجابة (GPU Accelerated)
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri+Quran&family=Scheherazade+New:wght@400;700&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  /* ألوان النمط الفاتح (الورق العتيق الأندلسي) */
  --bg-base: #f5eedf;
  --bg-surface: #faf4e8;
  --bg-card: rgba(255, 250, 240, 0.82);
  --border-color: rgba(184, 163, 128, 0.45);
  --border-focus: #5f6b2f;
  
  --ink-primary: #2d261a;
  --ink-secondary: #6e614d;
  --ink-muted: #9c8e76;

  --accent-primary: #5f6b2f;
  --accent-light: #e4eac4;
  --accent-glow: rgba(95, 107, 47, 0.35);

  --status-ok: #2e7d32;
  --status-ok-bg: rgba(46, 125, 50, 0.14);
  --status-bad: #c62828;
  --status-bad-bg: rgba(198, 40, 40, 0.16);
  --status-skip: #e65100;
  --status-skip-bg: rgba(230, 81, 0, 0.15);

  --shadow-sm: 0 2px 8px rgba(70, 55, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(70, 55, 20, 0.10);
  --shadow-lg: 0 16px 40px rgba(70, 55, 20, 0.16);

  --sidebar-width: 270px;
  --sidebar-collapsed-width: 78px;
  --bottom-nav-height: 64px;

  --font-arabic-mushaf: 'Amiri Quran', 'Scheherazade New', serif;
  --font-ui: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme="dark"] {
  /* ألوان النمط الداكن (المصحف المذهب الليلي) */
  --bg-base: #110e0b;
  --bg-surface: #1b1611;
  --bg-card: rgba(29, 24, 18, 0.85);
  --border-color: rgba(212, 187, 145, 0.16);
  --border-focus: #9cb152;

  --ink-primary: #f8f1df;
  --ink-secondary: #c9bea7;
  --ink-muted: #8a7e68;

  --accent-primary: #8ea843;
  --accent-light: #2b3317;
  --accent-glow: rgba(142, 168, 67, 0.45);

  --status-ok: #66bb6a;
  --status-ok-bg: rgba(102, 187, 106, 0.18);
  --status-bad: #ef5350;
  --status-bad-bg: rgba(239, 83, 80, 0.22);
  --status-skip: #ffa726;
  --status-skip-bg: rgba(255, 167, 38, 0.2);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-base: #110e0b;
    --bg-surface: #1b1611;
    --bg-card: rgba(29, 24, 18, 0.85);
    --border-color: rgba(212, 187, 145, 0.16);
    --border-focus: #9cb152;
    --ink-primary: #f8f1df;
    --ink-secondary: #c9bea7;
    --ink-muted: #8a7e68;
    --accent-primary: #8ea843;
    --accent-light: #2b3317;
    --accent-glow: rgba(142, 168, 67, 0.45);
    --status-ok: #66bb6a;
    --status-ok-bg: rgba(102, 187, 106, 0.18);
    --status-bad: #ef5350;
    --status-bad-bg: rgba(239, 83, 80, 0.22);
    --status-skip: #ffa726;
    --status-skip-bg: rgba(255, 167, 38, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  }
}

/* =====================================================================
   إعادة الضبط الأساسية وتسريع العتاد (Hardware Acceleration)
   ===================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  direction: rtl;
  text-align: right;
  font-family: var(--font-ui);
  color: var(--ink-primary);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* خلفية زخرفية متحركة هادئة مسرعة بالعتاد */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  will-change: transform;
  animation: floatOrb 24s ease-in-out infinite alternate;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(199, 172, 126, 0.45), transparent 70%);
  top: -100px;
  right: -80px;
}

.orb-2 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(142, 168, 67, 0.35), transparent 70%);
  bottom: -60px;
  left: -80px;
  animation-delay: -8s;
}

@keyframes floatOrb {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(40px, -40px, 0) scale(1.15); }
}

/* =====================================================================
   هيكل التطبيق التكيفي (Mobile vs Desktop Layout)
   ===================================================================== */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

/* الشريط الجانبي للشاشات الكبيرة (Desktop Sidebar) */
.desktop-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-left: 1px solid var(--border-color);
  padding: 20px 16px;
  flex-shrink: 0;
  z-index: 20;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
  contain: content;
  user-select: none;
}

.desktop-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  padding: 20px 10px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-primary), #485223);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.brand-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.desktop-sidebar.collapsed .brand-details {
  display: none;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink-primary);
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: right;
  position: relative;
  white-space: nowrap;
}

.sidebar-nav-item:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
  transform: translate3d(-3px, 0, 0);
}

.sidebar-nav-item.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 6px 18px var(--accent-glow);
}

.sidebar-nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  flex-shrink: 0;
}

.desktop-sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 12px 0;
}

.desktop-sidebar.collapsed .sidebar-nav-item span {
  display: none;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.sidebar-btn-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-btn-hint:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.desktop-sidebar.collapsed .sidebar-btn-hint span {
  display: none;
}

kbd {
  font-family: monospace;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  box-shadow: 0 2px 0 var(--border-color);
}

/* منطقة المحتوى الرئيسية */
.main-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* شريط التنقل السفلي للأجهزة المحمولة (Mobile Bottom Nav) */
.mobile-bottom-nav {
  display: none; /* يظهر فقط في شاشات الجوال عبر Media Query */
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 12px;
  right: 12px;
  max-width: 440px;
  margin: 0 auto;
  height: var(--bottom-nav-height);
  background: var(--bg-card);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1.5px solid var(--border-color);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  user-select: none;
  touch-action: none;
  transform: translate3d(0, 0, 0);
}

.mobile-bottom-nav-pill {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 999px;
  background: var(--accent-light);
  border: 1px solid var(--accent-primary);
  box-shadow: 0 3px 12px var(--accent-glow);
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1), width 0.35s ease;
  pointer-events: none;
  z-index: 1;
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  transition: color 0.25s ease;
}

.mobile-nav-btn.active {
  color: var(--accent-primary);
}

.mobile-nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
}

/* =====================================================================
   نظام النوافذ الفوري (Zero-Lag View Switching & GPU Accelerated)
   ===================================================================== */
.views-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.view-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 10px, 0);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px calc(var(--bottom-nav-height) + 30px);
  contain: content;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.view-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
}

.view-panel::-webkit-scrollbar {
  width: 6px;
}
.view-panel::-webkit-scrollbar-track {
  background: transparent;
}
.view-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

/* =====================================================================
   تخطيطات سطح المكتب المنقسمة (Side-by-Side Desktop Split Grids)
   ===================================================================== */
.split-view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .split-view-grid {
    grid-template-columns: 1fr 390px;
    align-items: start;
  }
  .split-view-grid.equal-split {
    grid-template-columns: 1fr 1fr;
  }
}

/* بطاقات الواجهة الحديثة (Glassmorphism Cards) */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(95, 107, 47, 0.3);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.card-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

/* عناصر الإدخال والأزرار */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.form-select, .form-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6b2f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 16px;
  padding-left: 38px;
}

.form-select:focus, .form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: 14px;
  border: none;
  background: var(--accent-primary);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px var(--accent-glow);
  white-space: nowrap;
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translate3d(0, -2px, 0);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-primary:active {
  transform: translate3d(0, 0, 0) scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--ink-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* =====================================================================
   مصحف التسميع والتدقيق الذكي (Tasmie View & Word Highlighting)
   ===================================================================== */
.mushaf-card {
  position: relative;
  min-height: 400px;
  padding: 26px 20px;
  border: 2px solid var(--border-color);
  border-radius: 28px;
  background: var(--bg-card);
}

.surah-header-ornament {
  position: relative;
  text-align: center;
  padding: 14px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  outline: 4px double var(--border-color);
  outline-offset: -5px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
  box-shadow: var(--shadow-sm);
}

.surah-title-arabic {
  font-family: var(--font-arabic-mushaf);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-primary);
}

.surah-meta-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.bismillah-banner {
  text-align: center;
  font-family: var(--font-arabic-mushaf);
  font-size: 28px;
  line-height: 2;
  color: var(--ink-secondary);
  margin-bottom: 18px;
}

/* حاوية النص القرآني المنساب */
.mushaf-text-flow {
  font-family: var(--font-arabic-mushaf);
  font-size: 28px;
  line-height: 2.6;
  text-align: justify;
  text-justify: kashida;
  color: var(--ink-primary);
  position: relative;
  word-spacing: 2px;
}

/* الكلمات القرآنية الفردية في وضع التسميع */
.w {
  display: inline-block;
  padding: 0 4px;
  border-radius: 8px;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: text;
}

/* كلمة صحيحة (أخضر زمردي) */
.w.ok {
  color: var(--status-ok) !important;
  background: var(--status-ok-bg) !important;
  filter: none !important;
  opacity: 1 !important;
  font-weight: 700;
}

/* كلمة خاطئة (أحمر ساطع مع بطاقة التصحيح) */
.w.bad {
  color: #ffffff !important;
  background: var(--status-bad) !important;
  filter: none !important;
  opacity: 1 !important;
  animation: shake 0.4s ease;
}

/* كلمة ساقطة تم تخطيها */
.w.missing {
  color: var(--status-skip) !important;
  background: var(--status-skip-bg) !important;
  border-bottom: 2px dashed var(--status-skip);
  filter: none !important;
  opacity: 1 !important;
}

/* الكلمة المنتظرة للقراءة حالياً */
.w.current {
  background: rgba(95, 107, 47, 0.22);
  border-bottom: 2.5px solid var(--accent-primary);
  transform: scale(1.06);
}

/* علامة رقم الآية القرآنية */
.num, .ayah-marker {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-primary);
  background: var(--accent-light);
  border: 1px solid var(--accent-primary);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 0 4px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* =====================================================================
   وضع إخفاء الآيات الفوري (Instant Hide Mode)
   الكلمات تُحجب مع بقاء أرقام الآيات ظاهرة بالكامل
   ===================================================================== */
.mushaf-card.mushaf-hidden .w:not(.ok):not(.bad) {
  color: transparent !important;
  text-shadow: 0 0 12px var(--ink-secondary);
  filter: blur(7px);
  opacity: 0.35;
  background: var(--bg-surface);
  user-select: none;
  transform: translate3d(0, 0, 0);
}

/* الأرقام تظل واضحة بنسبة 100% وبدون أي غباش */
.mushaf-card.mushaf-hidden .num,
.mushaf-card.mushaf-hidden .ayah-marker {
  filter: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  color: var(--accent-primary) !important;
  background: var(--accent-light) !important;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 2px 8px var(--accent-glow) !important;
}

/* =====================================================================
   المسمّع الذكي ولوحة التحكم (AI Recitation Companion Panel)
   ===================================================================== */
.companion-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* بطاقة المعلم الذكي والرسائل الحية */
.teacher-speech-bubble {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.teacher-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), #404c1c);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.teacher-avatar svg {
  width: 24px;
  height: 24px;
}

.teacher-content {
  flex: 1;
}

.teacher-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.teacher-message {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink-primary);
  transition: color 0.2s ease;
}

.teacher-message.success { color: var(--status-ok); font-weight: 700; }
.teacher-message.error { color: var(--status-bad); font-weight: 700; }
.teacher-message.warning { color: var(--status-skip); font-weight: 700; }

/* زر الميكروفون التفاعلي الدائري مع حلقات التموج المسرعة بالعتاد */
.mic-action-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 0 10px;
}

.mic-hero-btn {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-primary), #4a5422);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 26px var(--accent-glow);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
  user-select: none;
  z-index: 2;
}

.mic-hero-btn:hover {
  transform: scale(1.05);
}

.mic-hero-btn:active {
  transform: scale(0.94);
}

.mic-hero-btn.recording {
  background: linear-gradient(135deg, var(--status-bad), #911717);
  box-shadow: 0 8px 26px rgba(198, 40, 40, 0.45);
  animation: pulseRecording 1.5s infinite;
}

.mic-hero-btn svg {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

@keyframes pulseRecording {
  0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.55); }
  70% { box-shadow: 0 0 0 24px rgba(198, 40, 40, 0); }
  100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}

.mic-status-label {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-secondary);
  text-align: center;
}

/* بطاقة الإحصائيات الحية */
.stats-grid-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  background: var(--bg-surface);
  border-radius: 18px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink-primary);
}

.stat-number.ok { color: var(--status-ok); }
.stat-number.bad { color: var(--status-bad); }

.stat-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* قائمة تدقيق الأخطاء في الجلسة */
.mistakes-drawer {
  max-height: 220px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  padding: 8px;
  scrollbar-width: thin;
}

.mistake-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  animation: fadeIn 0.3s ease;
}

.mistake-row:last-child {
  border-bottom: none;
}

.mistake-expected {
  font-family: var(--font-arabic-mushaf);
  font-size: 18px;
  font-weight: 700;
  color: var(--status-bad);
}

.mistake-heard {
  color: var(--ink-secondary);
  font-size: 12px;
}

.mistake-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--status-bad-bg);
  color: var(--status-bad);
  font-weight: 700;
}

/* =====================================================================
   مشغل الاستماع والمصحف المتصل (Istimaa View & Continuous Mushaf Flow)
   ===================================================================== */
.continuous-mushaf-wrapper {
  font-family: var(--font-arabic-mushaf);
  font-size: 28px;
  line-height: 2.7;
  text-align: justify;
  text-justify: kashida;
  color: var(--ink-primary);
  padding: 10px;
}

.mushaf-ayah {
  display: inline;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.mushaf-ayah:hover {
  background-color: var(--accent-light);
}

/* الآية التي تُتلى حالياً بالمشغل */
.mushaf-ayah.playing-ayah {
  background-color: rgba(95, 107, 47, 0.22);
  box-shadow: 0 0 0 3px rgba(95, 107, 47, 0.25);
  border-radius: 8px;
  font-weight: 700;
}

/* وحدة التحكم بالمشغل الصوتي (Audio Player Console) */
.player-console {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
}

.player-track-info {
  text-align: center;
  padding: 8px 0;
}

.player-track-surah {
  font-size: 19px;
  font-weight: 800;
  color: var(--ink-primary);
}

.player-track-reciter {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
  margin-top: 4px;
}

/* شريط التقدم والوقت للمشغل */
.player-scrubber-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.player-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.player-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* أزرار التحكم بالتشغيل */
.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-player-play {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent-primary);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-player-play:hover {
  transform: scale(1.08);
}

.btn-player-play:active {
  transform: scale(0.95);
}

.btn-player-play svg {
  width: 28px;
  height: 28px;
}

/* مؤشر التخزين المؤقت (Buffering Spinner) */
.buffering-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* خيارات تكرار الآيات والسرعة */
.player-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

/* =====================================================================
   ختمتي والإعدادات (Khatmati & Settings Views)
   ===================================================================== */
.khatma-progress-ring-card {
  text-align: center;
  padding: 24px;
}

.progress-big-number {
  font-size: 46px;
  font-weight: 800;
  color: var(--accent-primary);
  margin: 10px 0;
}

.khatma-bar-container {
  height: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 16px;
}

.khatma-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), #8fa73b);
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: 900px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* نافذة الاختصارات المنبثقة (Shortcuts Modal) */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 11, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.modal-scrim.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(0.96);
  width: min(92vw, 520px);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 26px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  z-index: 201;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s;
}

.modal-box.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.shortcuts-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

/* =====================================================================
   التنبيهات السريعة (Toasts) والمؤثرات
   ===================================================================== */
.toast-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 50%;
  transform: translate3d(-50%, -100px, 0);
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
  z-index: 300;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
  white-space: nowrap;
}

.toast-banner.show {
  transform: translate3d(-50%, 0, 0);
  opacity: 1;
}

@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

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

/* =====================================================================
   التوافق مع شاشات الجوال (< 768px)
   ===================================================================== */
@media (max-width: 767.98px) {
  .desktop-sidebar {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  .view-panel {
    padding: 14px 14px calc(var(--bottom-nav-height) + 38px);
  }

  .mushaf-text-flow,
  .continuous-mushaf-wrapper {
    font-size: 24px;
    line-height: 2.3;
  }

  .card-header h2, .card-title {
    font-size: 16px;
  }
}
