/* ═══════════════════════════════════════════════════════════════
   CS Level 5 · Digital Garden · garden.css v8.7 (SM2 Dashboard + Notes + Action Links)
   Master stylesheet — all themes, subjects, components
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&family=Orbitron:wght@700&family=Rajdhani:wght@600;700&family=Exo+2:wght@600;700&family=Share+Tech+Mono&display=swap');

/* ═══ DESIGN SYSTEM ═══ */
:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;
}

/* ═══ SUBJECT COLORS ═══ */
[data-subject="CS353"] {
  --brand-900: #881337;
  --brand-800: #9f1239;
  --brand-700: #be123c;
  --brand-600: #e11d48;
  --brand-500: #f43f5e;
  --brand-400: #fb7185;
  --brand-300: #fda4af;
  --brand-glow: rgba(244, 63, 94, 0.15);
  --display-font: 'Katibeh', sans-serif;
}

[data-subject="CS352"] {
  --brand-900: #1e3a8a;
  --brand-800: #1e40af;
  --brand-700: #1d4ed8;
  --brand-600: #2563eb;
  --brand-500: #3b82f6;
  --brand-400: #60a5fa;
  --brand-300: #93c5fd;
  --brand-glow: rgba(59, 130, 246, 0.15);
  --display-font: 'Katibeh', sans-serif;
}

[data-subject="CS350"] {
  --brand-900: #78350f;
  --brand-800: #92400e;
  --brand-700: #b45309;
  --brand-600: #d97706;
  --brand-500: #f59e0b;
  --brand-400: #fbbf24;
  --brand-300: #fcd34d;
  --brand-glow: rgba(245, 158, 11, 0.15);
  --display-font: 'Katibeh', sans-serif;
}

[data-subject="CS351"] {
  --brand-900: #064e3b;
  --brand-800: #065f46;
  --brand-700: #047857;
  --brand-600: #059669;
  --brand-500: #10b981;
  --brand-400: #34d399;
  --brand-300: #6ee7b7;
  --brand-glow: rgba(16, 185, 129, 0.15);
  --display-font: 'Katibeh', sans-serif;
}

/* ═══ THEME COLORS ═══ */
[data-theme="dark"] {
  --bg-body: var(--gray-900);
  --bg-surface: var(--gray-800);
  --bg-card: var(--gray-800);
  --bg-elevated: var(--gray-700);
  --border-color: var(--gray-700);
  --border-hover: var(--gray-600);
  --text-primary: #ffffff;
  --text-secondary: var(--gray-300);
  --text-muted: var(--gray-400);
  --scrollbar-track: transparent;
  --code-bg: var(--gray-900);
  --shadow-base: rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

[data-theme="dim"] {
  --bg-body: #0f111a;
  --bg-surface: #171923;
  --bg-card: #1a1d27;
  --bg-elevated: #202431;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f8fafc;
  --text-secondary: var(--gray-300);
  --text-muted: var(--gray-500);
  --scrollbar-track: transparent;
  --code-bg: #0b0d14;
  --shadow-base: rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-body: var(--gray-50);
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: var(--gray-50);
  --border-color: var(--gray-200);
  --border-hover: var(--brand-400);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --scrollbar-track: transparent;
  --code-bg: var(--gray-50);
  --shadow-base: rgba(0, 0, 0, 0.05);
  color-scheme: light;
}

/* ═══ RESET & BASE ═══ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px
}

body {
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.75;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

[dir="ltr"] body {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.65;
}

a {
  color: var(--brand-500);
  text-decoration: none;
  transition: color 0.2s ease
}

a:hover {
  color: var(--brand-600)
}

img,
svg {
  max-width: 100%;
  height: auto
}

button,
summary {
  outline: none;
  cursor: pointer;
}

/* ═══ RTL/LTR ARROW FLIP FIX ═══ */
[dir="ltr"] .fa-arrow-right,
[dir="ltr"] .fa-arrow-left {
  transform: scaleX(-1);
  display: inline-block;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-body);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══ FONT SIZE SCALING v9.0 — zoom approach ═══
   الحل النهائي: zoom يكبّر كل شيء (خطوط، مسافات، أيقونات)
   بدون الحاجة لتجاوز كل font-size على حدة.
   المستثنى: header, sidebar, footer — تبقى ثابتة.
   ═══════════════════════════════════════════════════ */
html[data-font-size="xs"] .main-content,
html[data-font-size="xs"] .subject-hub,
html[data-font-size="xs"] .dashboard {
  zoom: 0.82;
  -moz-transform: scale(0.82);
  -moz-transform-origin: top center;
}

html[data-font-size="sm"] .main-content,
html[data-font-size="sm"] .subject-hub,
html[data-font-size="sm"] .dashboard {
  zoom: 0.91;
  -moz-transform: scale(0.91);
  -moz-transform-origin: top center;
}

/* md = default — لا تعديل */

html[data-font-size="lg"] .main-content,
html[data-font-size="lg"] .subject-hub,
html[data-font-size="lg"] .dashboard {
  zoom: 1.12;
  -moz-transform: scale(1.12);
  -moz-transform-origin: top center;
}

html[data-font-size="xl"] .main-content,
html[data-font-size="xl"] .subject-hub,
html[data-font-size="xl"] .dashboard {
  zoom: 1.25;
  -moz-transform: scale(1.25);
  -moz-transform-origin: top center;
}

/* الأزرار في الهيدر — مجموعة التحكم بالخط */
.font-size-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 0;
  transition: border-color 0.2s ease;
}

.font-size-group:hover {
  border-color: var(--brand-500);
}

.font-size-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.font-size-btn:hover {
  background: var(--bg-elevated);
  color: var(--brand-500);
}

.font-size-btn:active {
  transform: scale(0.9);
}

.font-size-btn.at-limit {
  opacity: 0.3;
  pointer-events: none;
}

.font-size-indicator {
  min-width: 26px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  user-select: none;
  font-family: 'Inter', 'Cairo', sans-serif;
}

@media (max-width: 640px) {
  .font-size-group {
    padding: 1px;
  }

  .font-size-btn {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .font-size-indicator {
    min-width: 20px;
    font-size: 0.65rem;
  }
}

/* ═══ TYPOGRAPHY ═══ */
.font-display {
  font-family: var(--display-font)
}

.font-mono {
  font-family: 'JetBrains Mono', monospace
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  letter-spacing: -0.01em;
}

[dir="ltr"] h1,
[dir="ltr"] h2,
[dir="ltr"] h3,
[dir="ltr"] h4 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin-bottom: 0.75rem;
}

h3 {
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  margin-bottom: 0.5rem;
}

/* 💡 تم إصلاح وتأكيد تلوين العناوين باللغتين */
.text-gradient {
  background: linear-gradient(135deg, var(--text-primary) 20%, var(--brand-500) 100%);
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  color: transparent !important;
  display: inline-block;
  padding-bottom: 0.1em;
}

h2 .obj-icon {
  display: none !important;
}

.professor-header .professor-icon {
  display: none !important;
}

/* ═══ LAYOUT ═══ */
.page-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-wrapper {
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  flex: 1;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 3rem 3rem 6rem;
  max-width: 900px;
  margin: 0 auto;
}

@media(max-width:1024px) {
  .main-content {
    padding: 2rem 1.5rem 4rem;
  }
}

/* ═══ READING PROGRESS ═══ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--brand-500);
  width: 0%;
  z-index: 200;
  transition: width 0.1s ease;
}

/* ═══ HEADER (💡 The Innovative Badge Design) ═══ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(var(--bg-surface), 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: 72px;
  display: flex;
  align-items: center;
}

[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .site-header {
  background: rgba(31, 41, 55, 0.9);
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem
}

.header-nav,
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem
}

/* 💡 فرض الاتجاه وإعادة الترتيب بالـ CSS بدون لمس الـ HTML */
.header-center {
  display: inline-flex;
  align-items: center;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  transition: all 0.2s ease;
  direction: ltr !important;
  /* فرض الاتجاه من اليسار لليمين دائماً */
  box-shadow: 0 2px 8px var(--shadow-base);
}

.header-center:hover {
  border-color: var(--brand-500);
}

/* الأيقونة أولاً */
.header-center .subject-icon {
  order: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
}

/* اسم المادة (CS350) ثانياً */
.header-center .subject-name {
  order: 2;
  font-family: var(--display-font);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0 0.75rem 0 0.5rem;
  letter-spacing: 0.05em;
}

/* رقم الموديول (MOD 3) ثالثاً - داخل كبسولة مضيئة */
.header-center .module-badge {
  order: 3;
  font-family: var(--display-font);
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--brand-glow);
  color: var(--brand-600);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.05em;
  margin: 0;
}

[data-theme="dark"] .header-center .module-badge {
  color: var(--brand-400);
}

.nav-btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--bg-surface);
  color: var(--brand-500);
  border-color: var(--brand-500);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.nav-btn--icon {
  width: 40px;
  padding: 0;
}

.toggle-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toggle-btn:hover {
  background: var(--bg-surface);
  color: var(--brand-500);
  border-color: var(--brand-500);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border-color)
}

@media(max-width:640px) {

  .header-center .subject-name,
  .header-center .module-badge {
    display: none
  }

  .nav-btn span {
    display: none
  }

  .header-inner {
    padding: 0 0.6rem;
  }

  .divider-v {
    display: none
  }

  .header-nav,
  .header-actions,
  .dash-actions {
    gap: 0.35rem;
    flex-wrap: wrap;
  }
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  background: transparent;
  border-inline-end: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

/* .sidebar-title{font-size:0.75rem; font-weight:800; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-muted); margin-bottom:1rem; padding:0 0.75rem; flex-shrink:0;} ═══ Not Needed ═══ */
.sidebar-title {
  display: none !important;
}

.toc-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  flex: 1;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: none;
  padding-bottom: 0.5rem;
}

.toc-list::-webkit-scrollbar {
  display: none;
}

/* Smart sidebar: full rules are in the smart-sidebar section below */
.toc-link {
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  border-inline-start: 3px solid transparent;
}

.toc-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.toc-link.active {
  background: var(--brand-glow);
  color: var(--brand-600);
  font-weight: 700;
  border-inline-start-color: var(--brand-500);
}

[data-theme="dark"] .toc-link.active {
  color: var(--brand-400);
}

.toc-divider {
  height: 1px;
  background: var(--border-color);
  margin: 1rem 0.5rem;
  flex-shrink: 0;
}

/* ═══ ACTION LINKS (Flashcards & Quiz highlights in sidebar) ═══ */
/* ACTION LINKS: only a clean border outline — no filled background */
.toc-link--action {
  position: relative;
  background: transparent;
  border: 1px solid var(--brand-500);
  font-weight: 700;
  color: var(--brand-500) !important;
  transition: all 0.25s ease;
  border-radius: var(--radius-md);
}

.toc-link--action:hover {
  background: var(--brand-glow);
  border-color: var(--brand-500);
  transform: translateX(3px);
}

[dir="ltr"] .toc-link--action:hover {
  transform: translateX(-3px);
}

.toc-link--action .toc-action-icon {
  margin-inline-end: 0.4rem;
  font-size: 0.85rem;
}

[data-theme="dark"] .toc-link--action {
  color: var(--brand-400) !important;
  border-color: var(--brand-400);
}

/* Quiz link: no border, just normal styled */
.toc-link[href="#quiz"].toc-link--action {
  border: none;
  background: transparent;
}

.toc-link[href="#quiz"].toc-link--action:hover {
  background: var(--bg-elevated);
}

[data-theme="dark"] .toc-link[href="#quiz"].toc-link--action {
  border: none;
}

@keyframes softPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 var(--brand-glow);
  }

  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

.toc-link--action.pulse {
  animation: softPulse 2s ease-in-out 3;
}

/* ═══ SM-2 DASHBOARD WIDGET ═══ */
.sidebar-widget {
  margin-top: auto;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  text-align: center;
  box-shadow: 0 4px 6px -1px var(--shadow-base);
  flex-shrink: 0;
  overflow: hidden;
}

.sm2-widget-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
}

.sm2-widget-toggle:hover {
  background: var(--brand-glow);
}

.sm2-widget-toggle>div {
  text-align: center;
  flex: 1;
}

.sm2-widget-toggle .widget-number {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brand-500);
  font-family: var(--display-font);
  line-height: 1;
  text-align: center;
}

.sm2-widget-toggle .widget-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.sm2-widget-toggle .widget-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  margin-inline-start: auto;
}

.sm2-widget-toggle[aria-expanded="true"] .widget-chevron {
  transform: rotate(180deg);
}

@keyframes widgetPulse {

  0%,
  100% {
    border-color: var(--border-color);
  }

  50% {
    border-color: var(--brand-500);
    box-shadow: 0 0 12px var(--brand-glow);
  }
}

.sidebar-widget.has-due {
  animation: widgetPulse 3s ease-in-out 2;
}

/* SM-2 Dashboard Panel (expandable) */
.sm2-dashboard {
  display: none;
  position: fixed;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0.75rem 1rem 1rem;
  z-index: 9990;
}

.sm2-dashboard.open {
  display: block;
  animation: sm2PopIn 0.2s ease;
}

@keyframes sm2PopIn {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.sm2-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9989;
}

.sm2-overlay.open {
  display: block;
}

.sm2-dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

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

.sm2-dash-label {
  color: var(--text-muted);
}

.sm2-dash-value {
  color: var(--text-primary);
  font-weight: 800;
  font-family: var(--display-font);
}

.sm2-dash-bar {
  display: flex;
  height: 6px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.5rem;
  background: var(--bg-elevated);
}

.sm2-dash-bar span {
  height: 100%;
  transition: width 0.5s ease;
}

.sm2-bar-new {
  background: #6b7280;
}

.sm2-bar-learning {
  background: #f59e0b;
}

.sm2-bar-mastered {
  background: #10b981;
}

.sm2-dash-legend {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.sm2-dash-legend span {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sm2-dash-legend span::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.sm2-legend-new::before {
  background: #6b7280;
}

.sm2-legend-learning::before {
  background: #f59e0b;
}

.sm2-legend-mastered::before {
  background: #10b981;
}

/* ═══ STUDENT NOTES SYSTEM ═══ */
.notes-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg-surface);
  border: 1px solid var(--brand-500);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-base);
  padding: 0.5rem;
  display: none;
  animation: tooltipFade 0.15s ease;
}

.notes-tooltip button {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--brand-500);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}

.notes-tooltip button:hover {
  filter: brightness(1.15);
  transform: scale(1.03);
}

.sidebar-notes-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem;
  margin-top: 0.5rem;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  font-family: inherit;
}

.sidebar-notes-btn:hover {
  color: var(--brand-500);
  border-color: var(--brand-500);
  background: var(--brand-glow);
}

.sidebar-notes-btn .notes-count {
  background: var(--brand-500);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  font-weight: 800;
  min-width: 18px;
  text-align: center;
}

/* Notes Panel */
.notes-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  display: none;
  animation: modalFadeIn 0.2s ease;
}

.notes-panel {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  width: min(380px, 90vw);
  height: 100vh;
  z-index: 9999;
  background: var(--bg-surface);
  border-inline-start: 1px solid var(--border-color);
  box-shadow: -8px 0 30px var(--shadow-base);
  display: flex;
  flex-direction: column;
  animation: notesPanelSlide 0.3s ease;
}

@keyframes notesPanelSlide {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

/* [dir="rtl"] @keyframes removed — @keyframes cannot be scoped by selector in CSS.
   RTL panel slide is handled by JS or the inset-inline-end property instead. */

.notes-panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-panel-header h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.notes-panel-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.notes-panel-close:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.notes-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.notes-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.note-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  position: relative;
  transition: all 0.2s;
}

.note-card:hover {
  border-color: var(--brand-500);
}

.note-highlight-text {
  font-size: 0.8rem;
  color: var(--brand-500);
  font-weight: 700;
  font-style: italic;
  margin-bottom: 0.4rem;
  line-height: 1.5;
  border-inline-start: 3px solid var(--brand-500);
  padding-inline-start: 0.6rem;
}

.note-user-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.6;
}

.note-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-delete {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem;
  transition: color 0.15s;
}

.note-delete:hover {
  color: #ef4444;
}

.user-highlight {
  background: rgba(245, 158, 11, 0.15);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-highlight:hover {
  background: rgba(245, 158, 11, 0.3);
}

@media(max-width:1024px) {
  .sidebar {
    display: none
  }
}

/* ═══ THE CLEAN CARD ═══ */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 6px -1px var(--shadow-base);
  transition: all 0.3s ease;
}

.glass-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 12px 20px -5px var(--shadow-base);
}

/* الرفع فقط لبطاقات المفاهيم والعرض — ليس التفاعلية */
.concept-card:hover,
.professor-card:hover,
.objectives-card:hover {
  transform: translateY(-2px);
}

.quiz-card:hover,
.quiz-results:hover,
.flashcard-section .glass-card:hover {
  transform: none;
}

/* ═══ HERO (💡 The Innovative Floating Eyebrow) ═══ */
.hero {
  padding: 2.5rem 0 2rem;
  margin-bottom: 1rem
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-family: var(--display-font);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 15px var(--shadow-base);
}

/* تلوين كلمة الوحدة 3 أو Module 3 فقط */
.hero-eyebrow span {
  color: var(--brand-500);
}

.hero-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.8;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem
}

.tag {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tag--accent {
  background: var(--brand-glow);
  color: var(--brand-600);
  border-color: transparent;
}

[data-theme="dark"] .tag--accent {
  color: var(--brand-400);
}

/* ═══ SIDE ACCENTS ═══ */
.objectives-card,
.concept-card,
.professor-card {
  position: relative;
  border-inline-start: 4px solid var(--brand-500);
}

/* ═══ OBJECTIVES ═══ */
.objectives-card {
  padding: 2rem 2.5rem;
  margin-bottom: 2rem;
}

.objectives-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem
}

.objectives-list li {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.objectives-list .obj-icon {
  color: var(--brand-500);
  margin-top: 0.35rem;
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* ═══ CONCEPT CARDS ═══ */
.concept-card {
  padding: 2.5rem;
  margin-bottom: 2.5rem;
}

.concept-header {
  margin-bottom: 1.5rem
}

.concept-header h2 {
  display: flex;
  align-items: center;
  gap: 0.85rem
}

.concept-number {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--brand-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--display-font);
  flex-shrink: 0;
}

.depth-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 1.5rem;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.depth-tab {
  padding: 0.4rem 1.25rem;
  border-radius: calc(var(--radius-lg) - 4px);
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  transition: all 0.2s;
}

.depth-tab:hover {
  color: var(--text-primary);
}

.depth-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px var(--shadow-base);
  font-weight: 700;
}

.depth-layer {
  display: none;
  animation: layerFade 0.3s ease;
  color: var(--text-secondary);
}

.depth-layer.active {
  display: block
}

.depth-layer p {
  margin-bottom: 1rem;
}

.depth-layer p:last-child {
  margin-bottom: 0;
}

.depth-layer strong {
  color: var(--text-primary);
  font-weight: 700;
}

.depth-layer ul,
.depth-layer ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

[dir="rtl"] .depth-layer ul,
[dir="rtl"] .depth-layer ol {
  margin: 0.75rem 1.5rem 1rem 0;
}

.depth-layer li {
  margin-bottom: 0.5rem;
}

@keyframes layerFade {
  from {
    opacity: 0;
    transform: translateY(4px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ═══ TABLES ═══ */
/* 🛡️ v8.8: الجدول نفسه بدون border/radius/shadow — هذه تنتقل للـ wrapper التلقائي */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
  white-space: normal;
}

.comparison-table th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.comparison-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.7;
  vertical-align: top;
  transition: background 0.2s;
}

.comparison-table tr:last-child td {
  border-bottom: none
}

.comparison-table td:first-child {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-surface);
}

.comparison-table tr:hover td {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.td-good {
  color: #059669;
  font-weight: 700;
}

.td-bad {
  color: #dc2626;
  font-weight: 700;
}

[data-theme="dark"] .td-good {
  color: #34d399;
}

[data-theme="dark"] .td-bad {
  color: #f87171;
}

/* ═══ Code & Formula ═══ */
.formula-block {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.formula-block [data-bilingual] {
  unicode-bidi: isolate;
}

.formula-block strong {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.code-block {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  overflow: hidden
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.code-block pre {
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  direction: ltr !important;
  text-align: left !important
}

.copy-btn {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit
}

.copy-btn:hover {
  color: var(--brand-500);
  border-color: var(--brand-500);
}

/* SVG */
.svg-placeholder {
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-color);
  background: var(--bg-elevated);
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0;
}

.svg-diagram {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

/* Smart Terms */
.smart-term {
  border-bottom: 2px dotted var(--brand-500);
  cursor: help;
  position: relative;
  color: var(--text-primary);
  font-weight: 700;
  transition: all 0.2s
}

.smart-term:hover {
  color: var(--brand-600);
  background: var(--brand-glow);
}

[data-theme="dark"] .smart-term:hover {
  color: var(--brand-400);
}

.smart-term-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .smart-term-tooltip {
  background: var(--gray-100);
  color: var(--gray-900);
}

.smart-term:hover .smart-term-tooltip {
  display: block
}

/* Thinking Question */
.thinking-question {
  border-radius: var(--radius-lg);
  border: 1px solid var(--brand-300);
  background: var(--brand-glow);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

[data-theme="dark"] .thinking-question {
  border-color: rgba(var(--brand-500), 0.3);
}

.thinking-question summary {
  font-weight: 700;
  color: var(--brand-700);
  list-style: none;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

[data-theme="dark"] .thinking-question summary {
  color: var(--brand-400);
}

.thinking-question summary::before {
  content: '💡';
}

.thinking-question[open] summary {
  margin-bottom: 0.75rem;
}

.thinking-question p {
  margin-top: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* ═══ PROFESSOR ═══ */
.professor-card {
  padding: 2.5rem;
  margin-bottom: 2.5rem;
}

.professor-card .professor-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem
}

.professor-card .professor-icon {
  font-size: 2rem
}

.professor-card .professor-text {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-style: italic;
}

/* ═══ ACCORDION ═══ */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem
}

.accordion-item {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: inherit
}

.accordion-trigger .chevron {
  transition: transform 0.3s;
  color: var(--text-muted)
}

.accordion-item.open .accordion-trigger .chevron {
  transform: rotate(180deg);
  color: var(--brand-500);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease
}

.accordion-item.open .accordion-body {
  max-height: 800px
}

.accordion-body-inner {
  padding: 0 1.5rem 1.5rem;
  color: var(--text-secondary);
}

/* ═══ FLASHCARDS ═══ */
.flashcard-section {
  margin-bottom: 3rem
}

.fc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  position: relative;
  z-index: 50;
  /* Must NOT clip tooltip */
  overflow: visible;
}

.fc-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: visible;
  position: relative;
}

.fc-mini-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.fc-mini-btn:hover {
  color: var(--brand-500);
  border-color: var(--brand-500);
  background: var(--brand-glow);
}

.fc-info-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  /* Tooltip context — must NOT clip children */
  overflow: visible;
  z-index: 100;
}

.fc-info-btn:hover,
.fc-info-btn:focus {
  color: var(--brand-500);
  border-color: var(--brand-500);
  background: var(--brand-glow);
  box-shadow: 0 0 0 3px var(--brand-glow);
  outline: none;
}

.fc-info-tooltip {
  display: none;
  position: fixed;
  /* immune to overflow — attached directly to body */
  width: min(300px, calc(100vw - 32px));
  max-height: min(440px, 72vh);
  overflow-y: auto;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 99999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  text-align: start;
  line-height: 1.7;
  pointer-events: none;
}

/* Arrow pointing up toward the button */
.fc-info-tooltip::before {
  content: '';
  position: absolute;
  top: -7px;
  inset-inline-end: 14px;
  width: 12px;
  height: 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  border-inline-end: 1px solid var(--border-color);
  transform: rotate(-45deg);
  border-radius: 2px 0 0 0;
}

.fc-info-tooltip.open {
  display: block;
  animation: sm2PopIn 0.18s ease;
}

/* Overlay behind tooltip */
.fc-info-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99998;
}

.fc-info-overlay.open {
  display: block;
}

@keyframes tooltipFade {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fc-report-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--brand-500);
  font-size: 0.85rem;
  font-weight: 900;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  letter-spacing: 0;
}

.fc-report-btn:hover {
  border-color: var(--brand-500);
  background: var(--brand-glow);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.flashcard-scene {
  perspective: 1500px;
  margin: 1rem 0;
  min-height: 360px;
}

.flashcard-card {
  position: relative;
  width: 100%;
  min-height: 340px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s ease;
  -webkit-transition: -webkit-transform 0.5s ease;
  cursor: pointer;
  /* NOTE: will-change / translateZ(0) / -webkit-backface-visibility on the CONTAINER
     breaks pointer-events on the back face in WebKit (iOS Safari).
     GPU compositing is handled by the animation itself — no need to force it here. */
}

.flashcard-card.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  min-height: 340px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 10px -2px var(--shadow-base);
  /* Crisp text rendering on GPU layer */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--bg-body);
}

.flashcard-counter {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.flashcard-front .fc-term {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--brand-500);
  font-family: 'Cairo', sans-serif;
}

.flashcard-back .fc-definition {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.flashcard-back .fc-example {
  font-size: 0.95rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  width: 100%;
  border: 1px solid var(--border-color);
}

.sm2-grades {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap
}

.sm2-btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s;
}

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

.sm2-btn--0 {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 3px 10px rgba(239, 68, 68, .35);
}

.sm2-btn--0:hover {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
}

.sm2-btn--2 {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  box-shadow: 0 3px 10px rgba(245, 158, 11, .35);
}

.sm2-btn--2:hover {
  background: linear-gradient(135deg, #b45309, #d97706);
}

.sm2-btn--3 {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 3px 10px rgba(59, 130, 246, .35);
}

.sm2-btn--3:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.sm2-btn--5 {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 3px 10px rgba(16, 185, 129, .35);
}

.sm2-btn--5:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

.fc-empty {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--border-color);
}

.fc-empty .fc-empty-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  animation: bounce 2s infinite;
}

.fc-reset-btn {
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--brand-500);
  background: transparent;
  color: var(--brand-500);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.fc-reset-btn:hover {
  background: var(--brand-500);
  color: #fff;
}

/* ═══ SM-2 REPORT MODAL ═══ */
.sm2-report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sm2-report-overlay.open {
  opacity: 1;
}

.sm2-report-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  transform: translateY(16px);
  transition: transform 0.22s ease;
  overflow: hidden;
}

.sm2-report-overlay.open .sm2-report-modal {
  transform: translateY(0);
}

.sm2-report-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sm2-report-header-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.sm2-report-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.sm2-report-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sm2-report-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sm2-report-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.sm2-report-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
}

.sm2-rsec-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.sm2-rsec-title span:first-child {
  font-size: 1rem;
}

.sm2-rtotal-badge {
  margin-inline-start: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-500);
  background: var(--brand-glow);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  text-transform: none;
  letter-spacing: 0;
}

/* Pills */
.sm2-rpills {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.sm2-rpill {
  flex: 1;
  min-width: 70px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.5rem;
  text-align: center;
}

.sm2-rpill-n {
  display: block;
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
  font-family: var(--display-font);
}

.sm2-rpill-l {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.sm2-rpill--blue .sm2-rpill-n {
  color: #60a5fa;
}

.sm2-rpill--green .sm2-rpill-n {
  color: #34d399;
}

.sm2-rpill--orange .sm2-rpill-n {
  color: #fb923c;
}

/* Status bar */
.sm2-rstat-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-surface);
  margin-bottom: 0.6rem;
}

.sm2-rsb-new {
  background: #6b7280;
  transition: width 0.6s ease;
}

.sm2-rsb-learning {
  background: #f59e0b;
  transition: width 0.6s ease;
}

.sm2-rsb-mastered {
  background: #10b981;
  transition: width 0.6s ease;
}

.sm2-rstat-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.sm2-rsl {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sm2-rsl-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sm2-rsl-new {
  background: #6b7280;
}

.sm2-rsl-learning {
  background: #f59e0b;
}

.sm2-rsl-mastered {
  background: #10b981;
}

.sm2-rsl strong {
  color: var(--text-primary);
  margin-inline-start: 0.2rem;
}

.sm2-ref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  margin-top: 0.4rem;
}

.sm2-ref-row strong {
  color: var(--brand-500);
  font-family: var(--display-font);
  font-size: 1rem;
}

/* Forecast */
.sm2-rfc-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sm2-rfc-row {
  display: grid;
  grid-template-columns: 80px 1fr 36px;
  align-items: center;
  gap: 0.5rem;
}

.sm2-rfc-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.sm2-rfc-track {
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
}

.sm2-rfc-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand-500);
  opacity: 0.5;
  transition: width 0.5s ease;
}

.sm2-rfc-bar.sm2-rfc-today {
  opacity: 1;
  background: var(--brand-500);
}

.sm2-rfc-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: end;
  font-family: var(--display-font);
}

.sm2-rfc-zero {
  color: var(--text-muted);
  font-weight: 600;
}

.sm2-report-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem 0;
  font-weight: 600;
}

/* Practice mode badge */
.fc-practice-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--brand-glow), transparent);
  border: 1px solid var(--brand-500);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-500);
  margin-bottom: 0.75rem;
  text-align: center;
}

/* Practice button style */
.fc-practice-btn {
  border-color: var(--brand-500) !important;
  color: var(--brand-500) !important;
  font-weight: 800 !important;
}

.fc-practice-btn:hover {
  background: var(--brand-500) !important;
  color: #fff !important;
}

/* Mastery path */
.sm2-rmastery-note {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.sm2-rmastery-path {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.6rem;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.sm2-rmp-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 52px;
}

.sm2-rmp-day {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.sm2-rmp-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.sm2-rmp-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sm2-rmp-s4 .sm2-rmp-label {
  color: var(--brand-500);
}

.sm2-rmp-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0 0.1rem;
  margin-top: 0.6rem;
}

.sm2-rmastery-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sm2-rmb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sm2-rmb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Next due date */
.sm2-rnext-date {
  text-align: center;
  padding: 0.5rem 0;
}

.sm2-rnd-big {
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-500);
  font-family: var(--display-font);
  margin-bottom: 0.25rem;
}

.sm2-rnd-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

@media(max-width:480px) {
  .sm2-rmastery-path {
    gap: 0.1rem;
  }

  .sm2-rmp-step {
    min-width: 44px;
  }
}

/* How-to grid */
.sm2-report-howto {}

.sm2-rhow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sm2-rhow-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-color);
}

.sm2-rhow-g {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.sm2-rhow-0 .sm2-rhow-g {
  background: #ef4444;
}

.sm2-rhow-2 .sm2-rhow-g {
  background: #f59e0b;
}

.sm2-rhow-3 .sm2-rhow-g {
  background: #3b82f6;
}

.sm2-rhow-5 .sm2-rhow-g {
  background: #10b981;
}

.sm2-rhow-item strong {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.15rem;
}

.sm2-rhow-item p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  font-weight: 600;
}

/* Formula */
.sm2-rformula {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
}

.sm2-rformula-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.sm2-rformula-code {
  display: block;
  font-size: 0.72rem;
  color: var(--brand-400);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
  word-break: break-all;
}

.sm2-rformula-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-weight: 600;
}

/* Grade stats — compact pills */
.sm2-rgrade-stats {
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-color);
}

.sm2-rgs-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.sm2-rgs-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sm2-rgs-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sm2-rgs-pill strong {
  color: var(--text-primary);
  font-weight: 900;
  font-family: var(--display-font);
  font-size: 0.82rem;
}

.sm2-rgs-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sm2-rgs-pill-0 .sm2-rgs-dot {
  background: #ef4444;
}

.sm2-rgs-pill-2 .sm2-rgs-dot {
  background: #f59e0b;
}

.sm2-rgs-pill-3 .sm2-rgs-dot {
  background: #3b82f6;
}

.sm2-rgs-pill-5 .sm2-rgs-dot {
  background: #10b981;
}

.sm2-rgs-pill+.sm2-rgs-pill::before {
  content: '·';
  color: var(--border-color);
  margin-inline-end: -0.1rem;
}

/* Responsive */
@media(max-width:480px) {
  .sm2-report-modal {
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    align-self: flex-end;
  }

  .sm2-report-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .sm2-rhow-grid {
    grid-template-columns: 1fr;
  }

  .sm2-rfc-row {
    grid-template-columns: 70px 1fr 30px;
  }
}

/* ═══ QUIZ ═══ */
.quiz-section {
  margin-bottom: 3rem
}

.quiz-progress {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--brand-500);
  transition: width 0.3s ease;
}

.quiz-card {
  min-height: 450px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.quiz-question {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem
}

.mcq-option {
  width: 100%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  text-align: inherit;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}

.mcq-option:hover:not(:disabled) {
  border-color: var(--brand-500);
  background: var(--bg-elevated);
}

.mcq-option.correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981
}

.mcq-option.wrong {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444
}

.mcq-label {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mcq-option:hover:not(:disabled) .mcq-label {
  background: var(--brand-500);
  color: #fff;
}

.mcq-option.correct .mcq-label {
  background: #10b981;
  color: #fff;
}

.mcq-option.wrong .mcq-label {
  background: #ef4444;
  color: #fff;
}

.quiz-hint-btn {
  margin-top: 1.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--brand-500);
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  align-self: flex-start;
}

.quiz-hint-btn:hover {
  background: var(--brand-glow);
  border-color: var(--brand-500);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--brand-glow);
}

.quiz-feedback {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  font-size: 1.05rem;
  font-weight: 600;
}

.quiz-feedback--correct {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3)
}

.quiz-feedback--wrong {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3)
}

[data-theme="dark"] .quiz-feedback--correct {
  color: #34d399;
}

[data-theme="dark"] .quiz-feedback--wrong {
  color: #f87171;
}

.quiz-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem
}

.quiz-results {
  text-align: center;
  padding: 5rem 2rem
}

.quiz-results .score-display {
  font-size: 5rem;
  font-weight: 900;
  font-family: var(--display-font);
  color: var(--brand-500);
}

.quiz-results .score-emoji {
  font-size: 4rem;
  margin-bottom: 1rem
}

/* ═══ VIDEO RECOMMENDATIONS ═══ */
.video-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.video-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  border-radius: var(--radius-lg);
  transition: all 0.2s;
}

.video-card:hover {
  border-color: var(--brand-500);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow-base);
}

.video-card-lang {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

.video-card-body {
  flex: 1;
  min-width: 0;
}

.video-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-card-channel {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.video-card-topic {
  font-size: 0.8rem;
  color: var(--brand-500);
  font-weight: 600;
  margin-top: 0.25rem;
}

.video-card-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-glow);
  color: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.video-card:hover .video-card-play {
  background: var(--brand-500);
  color: #fff;
  transform: scale(1.1);
}

.video-section {
  margin-bottom: 2.5rem;
}

.video-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

.video-toggle:hover {
  border-color: var(--brand-500);
  box-shadow: 0 4px 12px var(--brand-glow);
}

.video-toggle-content {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.video-toggle-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.video-toggle[aria-expanded="true"] .video-toggle-chevron {
  transform: rotate(180deg);
}

.video-toggle[aria-expanded="true"] {
  border-color: var(--brand-500);
  background: var(--brand-glow);
}

.video-collapsible {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
  padding: 0;
}

.video-collapsible.open {
  max-height: 2000px;
  padding: 1rem 0 0;
}

.video-section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ═══ VAULT ═══ */
.vault-section {
  padding: 2rem;
  margin-bottom: 2.5rem;
  border: 2px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.02);
  border-radius: var(--radius-xl);
}

.vault-entry {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px var(--shadow-base);
}

.vault-type {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.vault-type--trap {
  color: #ef4444
}

.vault-type--secret {
  color: #10b981
}

.vault-type--key {
  color: #f59e0b
}

/* ═══ FOOTER ═══ */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0 2rem;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s ease;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid transparent;
}

.footer-link:hover {
  color: var(--brand-500);
  background: var(--bg-surface);
  border-color: var(--brand-500);
  transform: translateY(-2px);
}

.footer-brand {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-muted);
  font-family: var(--display-font);
  letter-spacing: 0.05em;
  text-align: center;
}

/* ═══ UTILS & ANIMATIONS ═══ */
.fade-up {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0)
}

.hidden {
  display: none !important
}

.section-gap {
  margin-bottom: 2.5rem
}

/* ═══ SYNTAX HIGHLIGHTING (CSS-only, class-based) ═══ */
/* Works across all 3 themes via CSS variables */
/* ═══════════════════════════════════════════════════════════════
   ✨ ثيم المُطور الحديث (Modern Minimalist & Vibrant) ✨
   مُصمم خصيصاً لإبراز جماليات SQL و Pseudocode
   ═══════════════════════════════════════════════════════════════ */

/* 1. الوضع الداكن والخافت (مستوحى من Linear App - فخامة وعمق) */
:root,
[data-theme="dark"],
[data-theme="dim"] {
  --syn-keyword: #FF7162;
  /* 🔴 مرجاني ساطع: يجعل SELECT و FROM و IF تبرز كعناوين رئيسية */
  --syn-operator: #F472B6;
  /* 🌸 وردي نيون: هذا هو السحر! سيجعل أسهم السودوكود <- وعلامات = تحفاً فنية */
  --syn-type: #38BDF8;
  /* 💧 أزرق سماوي: مثالي لأسماء الجداول في SQL أو أنواع المتغيرات */
  --syn-function: #818CF8;
  /* 🟣 نيلي ناعم: لأسماء الدوال لتتميز عن الكلمات المفتاحية */
  --syn-string: #34D399;
  /* 🟢 زمردي مضيء: للنصوص، مريح جداً للعين */
  --syn-number: #FBBF24;
  /* 🟡 عنبري ذهبي: الأرقام ستلمع بوضوح وسط الكود */
  --syn-constant: #C084FC;
  /* 🪻 بنفسجي فاتح: للثوابت مثل NULL أو TRUE */
  --syn-comment: #6B7280;
  /* 🔘 رمادي صخري: يختفي قليلاً في الخلفية لكي لا يشتت الانتباه */
  --syn-param: #F3F4F6;
  /* ⚪ أبيض ثلجي: للنص العادي والمتغيرات لتباين ممتاز مع الخلفية الداكنة */
  --syn-line-num: #4B5563;
  /* 🌑 رمادي داكن لأرقام الأسطر */
}

/* 2. الوضع الفاتح (مستوحى من Stripe / Vercel - نظافة وألوان نقية) */
[data-theme="light"] {
  --syn-keyword: #E11D48;
  /* 🔴 أحمر وردي: قوي وجريء لهيكلة الكود */
  --syn-operator: #C026D3;
  /* 🟣 فوشيا عميق: تباين مذهل للعمليات الحسابية والأسهم */
  --syn-type: #0284C7;
  /* 🔵 أزرق محيطي: لأسماء الجداول لتشعر بأنها روابط قابلة للضغط */
  --syn-function: #4F46E5;
  /* 🧿 نيلي داكن: لأسماء الدوال */
  --syn-string: #059669;
  /* 🌲 أخضر غابي: نقي وواضح للقراءة الطويلة */
  --syn-number: #D97706;
  /* 🟠 برتقالي محروق: للأرقام */
  --syn-constant: #7C3AED;
  /* 🪪 بنفسجي ملكي: للثوابت */
  --syn-comment: #9CA3AF;
  /* 🌫️ رمادي فضي: تعليقات هادئة وأنيقة */
  --syn-param: #111827;
  /* ⚫ أسود فحمي: النص الأساسي مريح جداً للعين ومقروء */
  --syn-line-num: #9CA3AF;
  /* 🪨 أرقام أسطر ناعمة */
}

/* Token classes — used inside <code> blocks */
.code-block code .kw {
  color: var(--syn-keyword);
  font-weight: 600;
}

/* keywords */
.code-block code .fn {
  color: var(--syn-function);
}

/* functions */
.code-block code .str {
  color: var(--syn-string);
}

/* strings */
.code-block code .num {
  color: var(--syn-number);
}

/* numbers */
.code-block code .cm {
  color: var(--syn-comment);
  font-style: italic;
}

/* comments */
.code-block code .op {
  color: var(--syn-operator);
}

/* operators */
.code-block code .ty {
  color: var(--syn-type);
}

/* types/tables */
.code-block code .ct {
  color: var(--syn-constant);
  font-weight: 600;
}

/* constants */
.code-block code .pm {
  color: var(--syn-param);
}

/* params */

/* Line numbers (optional — add via <span class="ln"> per line) */
.code-block code .ln {
  display: inline-block;
  width: 2.5em;
  text-align: right;
  color: var(--syn-line-num);
  margin-inline-end: 1em;
  user-select: none;
  opacity: 0.6;
}

/* Language badge in code header */
.code-block-header .lang-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--brand-glow);
  color: var(--brand-500);
}

/* ═══ CONFIRMATION MODAL ═══ */
.garden-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.garden-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.25s ease;
  text-align: center;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.garden-modal-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.garden-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.garden-modal-message {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.garden-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.garden-modal-btn {
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.garden-modal-btn--cancel {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.garden-modal-btn--cancel:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.garden-modal-btn--danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.garden-modal-btn--danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ═══ IMPROVED DEPTH-LAYER CONTENT RENDERING ═══ */
/* Fix: inline numbered lists inside <p> — force line breaks before bold numbers */
.depth-layer p b:not(:first-child) {
  display: inline;
}

/* When bold text starts with a number pattern like "1." "2." etc, force block display */
.depth-layer p {
  white-space: normal;
}

.depth-layer p>br+b,
.depth-layer p b+b {
  display: inline;
}

/* Ensure proper spacing for lists inside depth layers */
.depth-layer ul,
.depth-layer ol {
  margin: 0.75rem 0 1rem 1.5rem;
  padding: 0;
}

[dir="rtl"] .depth-layer ul,
[dir="rtl"] .depth-layer ol {
  margin: 0.75rem 1.5rem 1rem 0;
}

.depth-layer li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.depth-layer li::marker {
  color: var(--brand-500);
  font-weight: 700;
}

/* Nested lists */
.depth-layer ul ul,
.depth-layer ol ol,
.depth-layer ul ol,
.depth-layer ol ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* ═══ IRON DOME RTL ═══ */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] .math-block,
[dir="rtl"] .mermaid,
[dir="rtl"] canvas,
[dir="rtl"] .font-mono,
[dir="rtl"] .pseudo-block,
[dir="rtl"] svg,
[dir="rtl"] .svg-diagram,
[dir="rtl"] .svg-placeholder {
  direction: ltr !important;
  text-align: left !important
}

svg,
svg text,
svg tspan,
.svg-diagram text,
.svg-diagram tspan {
  font-family: 'Inter', sans-serif !important;
}

/* === SMART SIDEBAR - scrollable concepts === */

/* toc-list in smart mode: flex column, fills space between concepts and sidebar-widget */
.sidebar.smart .toc-list {
  overflow: hidden;
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
  justify-content: flex-start;
}

/* pinnedTop (hero/objectives) never scrolls */
.toc-pinned-top {
  flex-shrink: 0;
}

/* pinnedBottom lives directly in .sidebar (not inside toc-list),
   so it is always visible above the widget regardless of toc-list height */
.toc-pinned-bottom {
  flex-shrink: 0;
  padding-top: 0.25rem;
}

/* The scrollable zone — takes ALL remaining height inside toc-list */
.toc-concepts-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Fade gradients — --bg-body is always defined in every theme */
.toc-concepts-wrapper::before,
.toc-concepts-wrapper::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 20px;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.25s;
}

.toc-concepts-wrapper::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-body) 0%, transparent 100%);
}

.toc-concepts-wrapper::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-body) 0%, transparent 100%);
}

.toc-concepts-wrapper.at-top::before {
  opacity: 0;
}

.toc-concepts-wrapper.at-bottom::after {
  opacity: 0;
}

/* Inner-pinned rows (first 2 / last 2 links) when >= 10 concepts */
.toc-inner-top,
.toc-inner-bottom {
  flex-shrink: 0;
}

/* The actual scrollable middle strip */
.toc-concepts {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.toc-concepts::-webkit-scrollbar {
  display: none;
}

/* Centering container used when < 10 concepts (no scroll needed) */
.toc-center-group {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* === FREE NOTE BUTTON in notes panel === */
.notes-add-free {
  background: var(--brand-glow);
  border: 1px solid var(--brand-500);
  color: var(--brand-500);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-inline-end: 0.5rem;
  line-height: 1;
}

.notes-add-free:hover {
  background: var(--brand-500);
  color: #fff;
}

/* === MOBILE NOTE SAVE BAR (after text selection) === */
.mobile-note-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--bg-surface);
  border-top: 2px solid var(--brand-500);
  padding: 0.6rem 1rem;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 -4px 20px var(--shadow-base);
  animation: slideUpBar 0.25s ease;
}

@keyframes slideUpBar {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.mnb-text {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

.mnb-save {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--brand-500);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

/* === MOBILE FABs === */
@media (max-width: 1024px) {
  .mobile-fab-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    top: 80px;
    z-index: 900;
    transition: opacity 0.3s, transform 0.3s;
  }

  [dir="rtl"] .mobile-fab-container {
    right: 0;
    left: auto;
  }

  [dir="ltr"] .mobile-fab-container {
    left: 0;
    right: auto;
  }

  .mobile-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 42px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    cursor: pointer;
    opacity: 0.45;
    transition: all 0.25s ease;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  /* RTL: tabs peek from right edge */
  [dir="rtl"] .mobile-fab {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-right: none;
    box-shadow: -2px 2px 8px var(--shadow-base);
  }

  /* LTR: tabs peek from left edge */
  [dir="ltr"] .mobile-fab {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-left: none;
    box-shadow: 2px 2px 8px var(--shadow-base);
  }

  .mobile-fab:hover,
  .mobile-fab:active {
    opacity: 1;
    width: 46px;
    background: var(--brand-glow);
    border-color: var(--brand-500);
  }

  .mobile-fab .fab-badge {
    position: absolute;
    top: -4px;
    background: var(--brand-500);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 900;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  [dir="rtl"] .mobile-fab .fab-badge {
    left: -4px;
    right: auto;
  }

  [dir="ltr"] .mobile-fab .fab-badge {
    right: -4px;
    left: auto;
  }

  .mobile-fab-container.scrolling-down {
    opacity: 0.15;
  }

  [dir="rtl"] .mobile-fab-container.scrolling-down {
    transform: translateX(20px);
  }

  [dir="ltr"] .mobile-fab-container.scrolling-down {
    transform: translateX(-20px);
  }

  .mobile-fab-container.docked {
    display: none !important;
  }

  /* Bottom Sheet */
  .mobile-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 950;
    background: var(--bg-surface);
    border-top: 2px solid var(--brand-500);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 0.5rem 1.25rem 1rem;
    box-shadow: 0 -8px 30px var(--shadow-base);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-bottom-sheet.open {
    transform: translateY(0);
  }

  .mbs-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
    cursor: pointer;
  }

  .mbs-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mbs-icon {
    font-size: 1.5rem;
  }

  .mbs-info {
    flex: 1;
  }

  .mbs-count {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--brand-500);
    font-family: var(--display-font);
    line-height: 1;
  }

  .mbs-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
  }

  .mbs-go {
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-md);
    background: var(--brand-500);
    color: #fff;
    border: none;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
  }

  .mbs-go:hover {
    filter: brightness(1.1);
  }

  .mbs-dismiss {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.4rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
  }

  .mbs-dismiss:hover {
    color: var(--brand-500);
    border-color: var(--brand-500);
  }
}

/* ═══ INTERACTIVE ALGORITHM WIDGETS ═══ */
/*
 * Default CSS fallback — JS (initAlgoPalette) overrides these on every
 * page load with one of three curated palettes:
 *   • Catppuccin Mocha / Latte  (catppuccin.com)
 *   • Nord / Aurora             (nordtheme.com)
 *   • Gruvbox                   (github.com/morhetz/gruvbox)
 *
 * Glow variables (--algo-*-glow) are semi-transparent versions of the
 * same hue so the pulse animation feels cohesive, not jarring.
 */

/* ── DARK + DIM fallback (Retro Arcade / Vaporwave 400) ── */
[data-theme="dark"],
[data-theme="dim"] {
  --algo-compare: #FDE047;
  /* أصفر شمسي */
  --algo-swap: #F472B6;
  /* خوخي نيون */
  --algo-sorted: #34D399;
  /* نعناعي مضيء */
  --algo-active: #C084FC;
  /* لافندر فاقع */
  --algo-compare-glow: rgba(253, 224, 71, 0.35);
  --algo-swap-glow: rgba(244, 114, 182, 0.35);
  --algo-active-glow: rgba(192, 132, 252, 0.35);
  --algo-bg: var(--bg-elevated);
  --algo-bar: var(--brand-400);
  /* لون الثيم الأساسي نيون */
  --algo-text: var(--text-primary);
  --algo-muted: var(--text-muted);
  --algo-border: var(--border-color);
  --algo-node-text: #0F172A;
  /* كحلي داكن جداً ليبرز داخل النيون */
  --algo-bar-label: #0F172A;
  --algo-canvas-bg: rgba(0, 0, 0, 0.22);
}

/* ── LIGHT fallback (Retro Arcade / Deep 600) ── */
[data-theme="light"] {
  --algo-compare: #CA8A04;
  --algo-swap: #DB2777;
  --algo-sorted: #059669;
  --algo-active: #9333EA;
  --algo-compare-glow: rgba(202, 138, 4, 0.25);
  --algo-swap-glow: rgba(219, 39, 119, 0.25);
  --algo-active-glow: rgba(147, 51, 234, 0.25);
  --algo-bg: #f1f5f9;
  --algo-bar: var(--brand-500);
  /* لون الثيم الأساسي عميق */
  --algo-text: var(--text-primary);
  --algo-muted: var(--text-muted);
  --algo-border: var(--border-color);
  --algo-node-text: #ffffff;
  /* أبيض ناصع ليبرز داخل اللون العميق */
  --algo-bar-label: #ffffff;
  --algo-canvas-bg: rgba(0, 0, 0, 0.03);
}

/* Widget container — inherits page direction */
.algo-widget {
  background: var(--algo-bg);
  border: 1px solid var(--algo-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin: 1.5rem 0;
  /* NO direction:ltr — inherits from page for text */
}

.algo-widget * {
  box-sizing: border-box;
}

/* Only visual/graphic elements are forced LTR */
.algo-widget svg,
.algo-widget canvas,
.algo-widget .algo-array,
.algo-widget .algo-graph,
.algo-widget table {
  direction: ltr !important;
}

/* Algorithm title — centered, with bottom margin to separate from buttons */
.algo-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-500);
  margin: 0 0 1rem 0;
  padding: 0;
  letter-spacing: 0.01em;
  direction: inherit !important;
}

/* Controls row: step counter + speed slider on same line */
.algo-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: nowrap;
}

/* RTL: counter on right (inline-start), speed on left (inline-end) */
[dir="rtl"] .algo-controls-row {
  flex-direction: row;
}

/* LTR: speed on left (inline-start), counter on right (inline-end) */
[dir="ltr"] .algo-controls-row {
  flex-direction: row-reverse;
}

.algo-controls-row .step-counter {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--algo-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}

.algo-controls-row .algo-speed {
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Toolbar — centered, direction-aware */
.algo-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.algo-toolbar button {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--algo-border);
  background: var(--bg-surface);
  color: var(--algo-text);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.algo-toolbar button:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
  background: var(--brand-glow);
}

.algo-toolbar button:active {
  transform: scale(0.95);
}

.algo-toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Step counter: end-aligned (right in LTR, left in RTL) */
.algo-toolbar .step-counter {
  margin-inline-start: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--algo-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Speed slider — always LTR so slider mechanics work correctly */
.algo-speed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--algo-muted);
  direction: ltr !important;
}

/* In RTL, reverse the visual order so "fast" label appears on the right (which is reading-start in RTL)
   and "slow" appears on the left (reading-end) — matching RTL user expectation */
[dir="rtl"] .algo-speed {
  flex-direction: row-reverse;
}

[dir="rtl"] .algo-speed input[type="range"] {
  direction: ltr !important;
}

.algo-speed input[type="range"] {
  width: 100px;
  accent-color: var(--brand-500);
  cursor: pointer;
  direction: ltr !important;
}

/* Array visualization — always LTR */
.algo-array {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-height: 180px;
  padding: 1rem 0;
  direction: ltr !important;
}

.algo-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 32px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--algo-bar);
  transition: all 0.3s ease;
  position: relative;
  /* ── التعديلات السحرية هنا 👇 ── */
  color: var(--algo-node-text) !important;
  /* لون ذكي متفاعل */
  font-family: 'Inter', 'JetBrains Mono', sans-serif !important;
  /* فرض الخط */
  font-weight: 800 !important;
  /* فرض السماكة */
  font-size: 0.95rem !important;
  padding-bottom: 0.4rem !important;
  /* مسافة لكي لا يلتصق الرقم بأسفل العمود */
}

.algo-bar-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--algo-bar-label);
  padding: 0.35rem 0.25rem;
  font-family: 'Inter', 'JetBrains Mono', sans-serif;
  /* توحيد الخط ليكون عصرياً */
  text-shadow: none;
  /* إزالة الظل القديم ليظهر اللون بشكل صافي ونقي */
}

.algo-bar.comparing {
  background: var(--algo-compare);
}

.algo-bar.swapping {
  background: var(--algo-swap);
}

.algo-bar.sorted {
  background: var(--algo-sorted);
}

.algo-bar.active {
  background: var(--algo-active);
}

/* Pulse animation — each state glows with its OWN color, not a single shared one */
@keyframes algoPulseCompare {

  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }

  50% {
    box-shadow: 0 0 10px 3px var(--algo-compare-glow, var(--algo-compare));
  }
}

@keyframes algoPulseSwap {

  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }

  50% {
    box-shadow: 0 0 10px 3px var(--algo-swap-glow, var(--algo-swap));
  }
}

@keyframes algoPulseActive {

  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }

  50% {
    box-shadow: 0 0 12px 4px var(--algo-active-glow, var(--algo-active));
  }
}

.algo-bar.comparing {
  animation: algoPulseCompare 0.8s ease-in-out;
}

.algo-bar.swapping {
  animation: algoPulseSwap 0.8s ease-in-out;
}

.algo-node.current {
  animation: algoPulseActive 1s ease-in-out infinite;
}

/* Step explanation — follows page direction (overrides Iron Dome on svg-placeholder parent) */
.algo-explanation {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--algo-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--algo-text);
  min-height: 2.5rem;
  line-height: 1.7;
  /* Override Iron Dome: svg-placeholder forces ltr, but explanation text must follow page */
  direction: inherit !important;
  text-align: inherit !important;
}

[dir="rtl"] .algo-explanation {
  direction: rtl !important;
  text-align: right !important;
}

[dir="ltr"] .algo-explanation {
  direction: ltr !important;
  text-align: left !important;
}

/* Also fix toolbar and labels inside algo-widget */
.algo-toolbar,
.algo-legend,
[data-algo-text],
.algo-speed {
  direction: inherit !important;
  text-align: inherit !important;
}

[dir="rtl"] .algo-toolbar,
[dir="rtl"] .algo-legend,
[dir="rtl"] [data-algo-text],
[dir="rtl"] .algo-speed {
  direction: rtl !important;
}

[dir="ltr"] .algo-toolbar,
[dir="ltr"] .algo-legend,
[dir="ltr"] [data-algo-text],
[dir="ltr"] .algo-speed {
  direction: ltr !important;
}

/* Legend — centered */
.algo-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.algo-legend span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--algo-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.algo-legend span::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.algo-legend .legend-compare::before {
  background: var(--algo-compare);
}

.algo-legend .legend-swap::before {
  background: var(--algo-swap);
}

.algo-legend .legend-sorted::before {
  background: var(--algo-sorted);
}

.algo-legend .legend-active::before {
  background: var(--algo-active);
}

/* Graph/node visualizations */
.algo-graph {
  position: relative;
  min-height: 200px;
  direction: ltr !important;
}

div.algo-node {
  /*تعديل خاص للمحافظة على الروسمات للخوارزميات وعدم تعديلها.. لازالته في حال سبب مشاكل .. فقط قمت باضافة div. قبل .algo-node وفي حال الرغبة بالعودة تزال div.*/
  min-width: 45px;
  min-height: 45px;
  border-radius: var(--radius-md);
  /* تحويل الشكل إلى مربع بحواف ناعمة وعصرية */
  background: var(--algo-bar);
  color: var(--algo-node-text);
  /* سيأخذ لوناً فاتحاً أو داكناً تلقائياً حسب الثيم */
  font-family: 'Inter', 'JetBrains Mono', sans-serif;
  /* توحيد الخط مع الأعمدة */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  /* تكبير الرقم قليلاً ليكون مريحاً للعين */
  position: absolute;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  box-shadow: 0 4px 6px var(--shadow-base);
  /* إضافة ظل خفيف يعطي عمقاً للمربع */
}

.algo-node.visited {
  background: var(--algo-sorted);
}

.algo-node.current {
  background: var(--algo-active);
  border-color: #fff;
  box-shadow: 0 0 15px var(--algo-active-glow);
  transform: scale(1.1);
  /* تأثير حركي جميل عند تفعيل المربع */
}

/* SVG canvas area */
.algo-canvas {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: var(--algo-canvas-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--algo-border);
  overflow: hidden;
  direction: ltr !important;
}

/* Responsive */
@media (max-width: 640px) {
  .algo-widget {
    padding: 1rem;
  }

  .algo-toolbar {
    gap: 0.35rem;
  }

  .algo-toolbar button {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .algo-toolbar .step-counter {
    font-size: 0.7rem;
  }

  .algo-bar {
    min-width: 22px;
  }

  .algo-bar-label {
    font-size: 0.65rem;
  }

  .algo-legend {
    gap: 0.5rem;
  }

  .algo-legend span {
    font-size: 0.65rem;
  }

  .algo-speed input[type="range"] {
    width: 70px;
  }

  .algo-explanation {
    font-size: 0.82rem;
    padding: 0.7rem;
  }

  .algo-canvas {
    min-height: 220px;
  }
}

@media (max-width: 400px) {
  .algo-toolbar {
    flex-direction: column;
    gap: 0.4rem;
  }

  .algo-toolbar .step-counter {
    margin-inline-start: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   فرض الخط الحديث على جميع عناصر وعقد الرسم الخوارزمي (متوافق مع اللغتين)
   ═══════════════════════════════════════════════════════════════ */

/* 1. الخط الأساسي (الافتراضي للغة العربية) */
.algo-canvas *,
.algo-array *,
.algo-graph *,
.algo-node,
.algo-node *,
.algo-bar-label {
  font-family: 'Cairo', sans-serif !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em !important;
}

/* 2. الخط المخصص للغة الإنجليزية */
[dir="ltr"] .algo-canvas *,
[dir="ltr"] .algo-array *,
[dir="ltr"] .algo-graph *,
[dir="ltr"] .algo-node,
[dir="ltr"] .algo-node *,
[dir="ltr"] .algo-bar-label {
  font-family: 'Inter', sans-serif !important;
}

/* تحديث إضافي لضمان أن الأرقام أسفل الأعمدة تأخذ مساحتها وتلغي أي ظل */
.algo-bar-label {
  font-size: 0.85rem !important;
  color: var(--algo-bar-label) !important;
  text-shadow: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   CS Level 5 · Digital Garden · garden_additions.css v1.0
   ─────────────────────────────────────────────────────────────
   APPEND this entire file to the END of garden.css
   Adds: Review page styles + Essay Q&A + Quiz Gauntlet + Score UI
   ═══════════════════════════════════════════════════════════════ */

/* ═══ REVIEW PAGE — HERO ═══ */
[data-page="review"] .hero,
[data-page="quiz"] .hero {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

/* ═══ REVIEW — MODULE BADGE IN VAULT / TABLE ═══ */
.module-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--brand-glow);
  color: var(--brand-500);
  font-family: var(--display-font);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

[data-theme="dark"] .module-chip {
  color: var(--brand-400);
}

/* ═══ ESSAY Q&A ENGINE ═══ */
.essay-score-tracker {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
}

.essay-score-tracker strong {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--brand-500);
  font-family: var(--display-font);
}

/* Essay item card */
.essay-item {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-inline-start: 4px solid var(--brand-500);
  box-shadow: 0 4px 6px -1px var(--shadow-base);
  transition: all 0.3s ease;
}

.essay-item[data-graded="1"] {
  border-inline-start-color: #10b981;
}

.essay-item[data-graded="0"] {
  border-inline-start-color: #ef4444;
}

.essay-item:hover {
  border-color: var(--border-hover);
}

.essay-item-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.essay-question-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 1rem;
}

/* Textarea where user writes answer */
.essay-textarea {
  width: 100%;
  min-height: 110px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.75;
  resize: vertical;
  transition: border-color 0.2s;
}

.essay-textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

[dir="rtl"] .essay-textarea {
  direction: rtl;
  text-align: right;
}

[dir="ltr"] .essay-textarea {
  direction: ltr;
  text-align: left;
}

/* Reveal button */
.essay-reveal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--brand-500);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.essay-reveal-btn:hover {
  background: var(--brand-glow);
  border-color: var(--brand-500);
  transform: translateY(-1px);
}

[data-theme="dark"] .essay-reveal-btn {
  color: var(--brand-400);
  border-color: var(--brand-400);
}

/* Model answer box */
.essay-answer-box {
  margin-top: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-inline-start: 3px solid var(--brand-500);
  animation: layerFade 0.3s ease;
  line-height: 1.8;
  color: var(--text-secondary);
}

.essay-answer-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-500);
  margin-bottom: 0.6rem;
  display: block;
}

[data-theme="dark"] .essay-answer-box {
  border-inline-start-color: var(--brand-400);
}

/* Self-grading bar */
.essay-grade-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.essay-grade-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.essay-grade-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.essay-grade-btn--correct {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.essay-grade-btn--correct:hover {
  background: rgba(16, 185, 129, 0.25);
}

.essay-grade-btn--correct.active {
  background: #10b981;
  color: #fff;
}

.essay-grade-btn--wrong {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.essay-grade-btn--wrong:hover {
  background: rgba(239, 68, 68, 0.25);
}

.essay-grade-btn--wrong.active {
  background: #ef4444;
  color: #fff;
}

.essay-grade-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ═══ QUIZ GAUNTLET — STANDALONE QUIZ PAGE ═══ */
[data-page="quiz"] .main-content {
  max-width: 800px;
}

/* Quiz card — enforced min-height for zero layout shift */
[data-page="quiz"] .quiz-card {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

/* Module badge in quiz card */
.quiz-module-badge {
  display: inline-flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Final score screen overlay */
.final-score-screen {
  text-align: center;
  padding: 3rem 2rem;
  animation: layerFade 0.4s ease;
}

.final-score-screen .score-display {
  font-size: 4.5rem;
  font-weight: 900;
  font-family: var(--display-font);
  color: var(--brand-500);
  margin: 0.5rem 0;
}

.final-score-screen .motivational-msg {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 1rem 0 2rem;
  line-height: 1.7;
}

.final-score-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ═══ FORMULA QUICK-REFERENCE PANEL ═══ */
#formula-panel table th:nth-child(3),
#formula-panel table td:nth-child(3) {
  direction: ltr !important;
  text-align: left !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

/* ═══ MEGA VAULT — module chip next to type badge ═══ */
.vault-type-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* ═══ REVIEW BEST SCORE BADGE ═══ */
.best-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--brand-glow);
  border: 1px solid var(--brand-500);
  color: var(--brand-500);
  font-weight: 800;
  font-size: 0.9rem;
  font-family: var(--display-font);
}

[data-theme="dark"] .best-score-badge {
  color: var(--brand-400);
  border-color: var(--brand-400);
}

/* ═══ CONCEPT REVIEW DIVIDER ═══ */
.concept-review-divider {
  margin: 2rem 0 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 640px) {
  .essay-grade-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .final-score-screen .score-display {
    font-size: 3rem;
  }

  .essay-item {
    padding: 1rem;
  }
}


/* ═══════════════════════════════════════════════════════════════
   المكون: جدول المقارنات (Typographic & Clean Design)
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   v8.8 — Bulletproof Table & Formula Overflow System
   الحل الجذري: كل جدول يحصل على wrapper تلقائياً عبر JS
   وعبر CSS نضمن أن أي جدول — حتى بدون wrapper — لا يخرج
   ═══════════════════════════════════════════════════════════════ */

/* 1. الغلاف — يُطبّق من JS تلقائياً أو يكون موجوداً في HTML */
.comparison-wrapper,
.equations-wrapper {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  background: var(--bg-card, var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.2);
  margin: 1.5rem 0;
  padding: 0;
}

/* 2. الجدول داخل wrapper — بلا حدود أو ظلال (الـ wrapper يتكفل) */
.comparison-wrapper>.comparison-table {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* 3. الحماية الأخيرة: جدول بدون wrapper (bare table) */
.concept-card>.comparison-table,
.depth-layer>.comparison-table,
.glass-card>.comparison-table,
.main-content>.comparison-table,
section>.comparison-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card, var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.2);
}

/* 4. formula-block — كانت مُدمجة مع wrapper لكن لها padding خاص */
.formula-block {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  background: var(--bg-card, var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.2);
  margin: 1.5rem 0;
  padding: 1.5rem;
}

/* 5. الإيجابيات والسلبيات */
.comparison-table td.td-good .content-target,
.comparison-table td.td-bad .content-target {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
}

.comparison-table td.td-good .content-target {
  color: #10b981;
}

.comparison-table td.td-bad .content-target {
  color: #ef4444;
}

.comparison-table td.td-good .content-target::before {
  content: '\f00c';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.9em;
}

.comparison-table td.td-bad .content-target::before {
  content: '\f00d';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.9em;
}

/* === MODULE INTRO ALIGNMENT === */
.module-intro h2 {
  display: flex !important;
  align-items: center !important;
  gap: 0.85rem !important;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   ترويض معادلات MathJax (لمنعها من كسر الجداول والبطاقات)
   ═══════════════════════════════════════════════════════════════ */
mjx-container {
  max-width: 100% !important;
  min-width: 0 !important;
  /* يجبر المعادلة على احترام حدود الأب */
  overflow-x: auto !important;
  overflow-y: hidden !important;
  box-sizing: border-box;
  padding-bottom: 0.25rem;
  /* مساحة صغيرة أسفل المعادلة لشريط التمرير */
}

/* لتخصيص الخلية التي تحتوي على معادلة داخل الجدول (استبدال الستايل المدمج) */
.comparison-table td.math-cell {
  text-align: start;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  direction: ltr;
  /* المعادلات دائماً من اليسار لليمين */
}

/* تصميم شريط تمرير أنيق للمعادلات الطويلة جداً */
mjx-container::-webkit-scrollbar {
  height: 4px;
}

mjx-container::-webkit-scrollbar-thumb {
  background-color: var(--brand-500);
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   📱 GARDEN MOBILE OPTIMIZATION BLOCK v1.0
   Digital Garden · 2026-03-07
   ─────────────────────────────────────────────────────────────
   يصلح هذا البلوك مشاكل التوافق مع الجوال دون لمس أي ملف HTML
   ═══════════════════════════════════════════════════════════════ */

/* ══ FIX #1: Layout - Content Wrapper ==
   مشكلة: عند الجوال يختفي السيدبار لكن .content-wrapper
   يبقى كـ flex مع فراغ للعمود الذي اختفى
   الحل: تحويله لـ block عند 1024px
*/
@media (max-width: 1024px) {
  .content-wrapper {
    display: block;
    width: 100%;
  }

  .main-content {
    max-width: 100%;
    padding: 2rem 1.5rem 5rem;
    margin: 0 auto;
  }
}

/* ══ FIX #2: Reduce Padding on Small Screens ══ */
@media (max-width: 640px) {
  .main-content {
    padding: 1rem 0.9rem 5rem;
  }

  .concept-card {
    padding: 1.5rem 1rem;
  }

  .objectives-card {
    padding: 1.25rem 1rem;
  }

  .professor-card {
    padding: 1.5rem 1rem;
  }
}

/* ══ FIX #3: Depth Tabs Responsive Wrap ══
   مشكلة: أزرار (⚡ سريع / 📖 كامل / 🔬 عميق) تتكدس على الجوال
   الحل: السماح لها بالانتقال لسطر جديد
*/
@media (max-width: 640px) {
  .depth-tabs {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }

  .depth-tab {
    flex: 1 1 auto;
    min-width: 80px;
    text-align: center;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }
}

/* ══ FIX #4: Comparison Tables Scrollable ══
   مشكلة: الجداول تتجاوز حافة الشاشة — حتى مع wrapper
   الحل: تصغير الخط + حد أدنى للعرض يسمح بالتمرير
*/
@media (max-width: 768px) {

  .comparison-wrapper,
  .concept-card>.comparison-table,
  .depth-layer>.comparison-table,
  .glass-card>.comparison-table,
  .main-content>.comparison-table,
  section>.comparison-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
  }

  .comparison-table {
    min-width: 420px;
    font-size: 0.85rem;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 0.7rem 0.6rem;
    font-size: 0.85rem;
  }
}

/* ══ FIX #5: Quiz Card Padding ══
   مشكلة: .quiz-card و [data-page="quiz"] .quiz-card
   لهما padding: 2.5rem وهذا يهدر 40% من العرض على الجوال
*/
@media (max-width: 640px) {

  .quiz-card,
  [data-page="quiz"] .quiz-card {
    padding: 1.25rem 1rem;
    min-height: auto;
  }

  .quiz-question {
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
  }

  .mcq-option {
    padding: 0.75rem 0.9rem;
    font-size: 0.9rem;
  }

  .mcq-label {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }
}

/* ══ FIX #6: Quiz Gauntlet Top Bar ══
   مشكلة: شريط (70/0 + recall + سهل + M5) يتكدس
*/
@media (max-width: 640px) {

  .gauntlet-status-bar,
  .gauntlet-header {
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
  }

  .gauntlet-counter {
    font-size: 0.78rem;
  }

  /* Module filter buttons in quiz */
  .quiz-module-filters,
  .gauntlet-filters {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .gauntlet-filters .tag,
  .quiz-filter-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
  }
}

/* ══ FIX #7: Hero Tags / Module Navigation Pills ══
   مشكلة: تيجان الوحدات والمقارنات تتراكم في سطور كثيرة
*/
@media (max-width: 640px) {
  .tag-list {
    gap: 0.35rem;
  }

  .tag {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
  }

  .hero-eyebrow {
    font-size: 0.78rem;
    padding: 0.35rem 0.85rem;
  }

  .hero-description {
    font-size: 0.97rem;
  }
}

/* ══ FIX #8: Formula Panel Mobile ══ */
@media (max-width: 640px) {
  .formula-block {
    padding: 1rem;
    font-size: 0.9rem;
  }

  #formula-panel table {
    min-width: 360px;
  }
}

/* ══ FIX #9: Flashcard Mobile ══ */
@media (max-width: 480px) {
  .flashcard-scene {
    min-height: 280px;
  }

  .flashcard-card,
  .flashcard-face {
    min-height: 260px;
  }

  /* ── Mobile 3D: ON by default. Class .mobile-3d-off switches to flat opacity ── */
  /* No overrides here — 3D is active. Flat mode handled below via .mobile-3d-off */

  .flashcard-front .fc-term {
    font-size: 1.4rem;
  }

  .flashcard-back .fc-definition {
    font-size: 1rem;
  }

  /* ── 5 grade buttons: 2 rows ── */
  .sm2-grades {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .sm2-btn {
    padding: 0.55rem 0.5rem;
    font-size: 0.82rem;
    min-width: 0;
  }

  /* Last 2 buttons center on second row */
  .sm2-btn:nth-child(4),
  .sm2-btn:nth-child(5) {
    grid-column: span 1;
  }

  .sm2-grades .sm2-btn:nth-child(4) {
    grid-column: 1 / 2;
  }

  .sm2-grades .sm2-btn:nth-child(5) {
    grid-column: 3 / 4;
  }
}

/* ══ FIX #10: Review Page Module Sections ══ */
@media (max-width: 640px) {
  .module-intro {
    padding: 1.25rem 0.9rem;
  }

  /* Vault entries */
  .vault-section {
    padding: 1.25rem 0.9rem;
  }

  .vault-entry {
    padding: 0.9rem;
  }
}

/* ══ FIX #11: Code Blocks Scrollable ══ */
@media (max-width: 640px) {
  .code-block pre {
    font-size: 0.78rem;
    padding: 0.9rem 1rem;
  }
}

/* ══ FIX #12: Header Inner Spacing on Narrow Screens ══ */
@media (max-width: 360px) {
  .header-inner {
    gap: 0.4rem;
    padding: 0 0.6rem;
  }

  .nav-btn--icon,
  .toggle-btn {
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
  }
}

/* ══ FIX #13: SVG Diagrams — Readable on Mobile ══
   مشكلة: الرسمات تتقلص لـ ~140px ارتفاع ولا تُقرأ
   الحل: min-width يجبر التمرير الأفقي بدل التقليص
*/
@media (max-width: 768px) {
  .svg-diagram {
    padding: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .svg-diagram svg {
    min-width: 600px;
    min-height: 280px;
    height: auto;
  }
}

@media (max-width: 480px) {
  .svg-diagram svg {
    min-width: 520px;
    min-height: 260px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   v8.8 — SCROLL-TO-TOP BUTTON (global, injected by garden.js)
   ═══════════════════════════════════════════════════════════════ */
.garden-scroll-top {
  position: fixed;
  bottom: 1.75rem;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px var(--shadow-base);
}

/* RTL: يسار، LTR: يمين */
[dir="rtl"] .garden-scroll-top {
  left: 1.75rem;
  right: auto;
}

[dir="ltr"] .garden-scroll-top {
  right: 1.75rem;
  left: auto;
}

.garden-scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.garden-scroll-top:hover {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
  transform: translateY(-2px);
}

/* على الجوال يكون أصغر ومنزاح قليلاً لعدم التعارض مع FABs */
@media (max-width: 1024px) {
  .garden-scroll-top {
    bottom: 5.5rem;
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  [dir="rtl"] .garden-scroll-top {
    left: 1rem;
  }

  [dir="ltr"] .garden-scroll-top {
    right: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   v8.8 — NUCLEAR OVERFLOW PROTECTION
   آخر خط دفاع: أي عنصر مباشر داخل main-content لا يتجاوز عرضها
   ═══════════════════════════════════════════════════════════════ */
.main-content {
  min-width: 0;
}

.main-content>* {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.concept-card,
.glass-card,
.professor-card,
.vault-section,
.quiz-section,
.flashcard-section {
  min-width: 0;
  overflow: hidden;
  /* يمنع أي child من كسر البطاقة */
}

/* السماح بالتمرير الأفقي للمحتوى التقني فقط */
.concept-card .depth-layer,
.concept-card .code-block,
.concept-card .formula-block,
.concept-card .svg-diagram,
.concept-card .comparison-wrapper,
.concept-card>.comparison-table {
  overflow-x: auto;
}

/* ضمان عدم تسرب أي table خارج حدود الأب */
table {
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   AI EXPLAIN SYSTEM v1.0 — أيقونة ✨ على كل بطاقة
   ═══════════════════════════════════════════════════════════════ */

/* ── زر AI على كل بطاقة ── */
.ai-explain-btn {
  position: absolute;
  top: 1rem;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid transparent;
  background:
    var(--bg-elevated) url("https://fe-static.deepseek.com/chat/favicon.svg") center / 16px 16px no-repeat;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  /* ظل أنيق جداً وخفيف */
  cursor: pointer;
  transition: all 0.25s ease;
  opacity: 0.65;
  /* شفافية مريحة للعين */
  padding: 0;
}

/* ── إخفاء زر AI في المناطق التفاعلية لتجنب تعارضه مع أسهم البطاقات والأسئلة ── */
.flashcard-section .ai-explain-btn,
.professor-card .ai-explain-btn {
  display: none !important;
}

/* ── زر AI في accordion (اسأل البروفسور) — يظهر في الأسفل عند الفتح فقط ── */
.accordion-item .ai-explain-btn {
  display: none;
  /* مخفي عند الإغلاق */
  top: auto;
  bottom: 0.75rem;
  /* يجلس في الأسفل بدلاً من الأعلى */
  z-index: 10;
}

/* يظهر فقط حين يكون الـ accordion مفتوحاً */
.accordion-item.open .ai-explain-btn {
  display: flex;
}

/* RTL: أسفل يسار */
[dir="rtl"] .accordion-item .ai-explain-btn {
  left: 1rem;
  right: auto;
}

/* LTR: أسفل يمين */
[dir="ltr"] .accordion-item .ai-explain-btn {
  right: 1rem;
  left: auto;
}

[dir="rtl"] .ai-explain-btn {
  left: 1rem;
  right: auto;
}

[dir="ltr"] .ai-explain-btn {
  right: 1rem;
  left: auto;
}

.ai-explain-btn:hover {
  opacity: 1;
  background-color: var(--bg-card);
  border-color: var(--brand-500);
  transform: scale(1.18) rotate(15deg);
  box-shadow: 0 0 14px var(--brand-glow), 0 0 4px rgba(139, 92, 246, 0.4);
}

/* تحديث الـ background-size في الـ hover بدون إعادة كتابة الصورة */
.ai-explain-btn:hover {
  background-size: 18px 18px;
}

/* ── النافذة المنبثقة (Modal) ── */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ai-modal-overlay.open {
  opacity: 1;
}

.ai-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.ai-modal-overlay.open .ai-modal {
  transform: translateY(0) scale(1);
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.ai-modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

/* ── أيقونة الهيدر (شبكة عصبية) ── */
.ai-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f5bd5, #962fbf);
  flex-shrink: 0;
}

/* ── إعادة التوليد ── */
.ai-action-btn--regen {
  background: color-mix(in srgb, var(--brand-500) 12%, transparent);
  color: var(--brand-400);
  border-color: color-mix(in srgb, var(--brand-500) 30%, transparent);
}
.ai-action-btn--regen:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand-500) 22%, transparent);
  border-color: var(--brand-400);
}
.ai-action-btn--regen:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.ai-regen-spin {
  display: inline-block;
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* ── شارة "شرح جديد" ── */
.ai-fresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--brand-400);
  padding: 0.2rem 0.6rem;
  background: color-mix(in srgb, var(--brand-500) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-500) 25%, transparent);
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
}

.ai-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-modal-close:hover {
  background: var(--brand-500);
  color: #fff;
}

.ai-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* حالة التحميل */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
  color: var(--text-muted);
}

.ai-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: aiSpin 0.8s linear infinite;
}

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

/* نتيجة الشرح */
.ai-result {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

.ai-result p {
  margin-bottom: 0.75rem;
}

.ai-result strong {
  color: var(--text-primary);
}

.ai-result code {
  background: var(--bg-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* رسالة خطأ */
.ai-error {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-muted);
}

.ai-error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.ai-error-msg {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── أزرار الأسفل ── */
.ai-modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ai-action-btn {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-family: inherit;
}

.ai-action-btn:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
}

.ai-action-btn--primary {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}

.ai-action-btn--primary:hover {
  background: var(--brand-600);
  color: #fff;
}

/* ── Cached badge ── */
.ai-cached-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
  .ai-modal {
    max-height: 90vh;
  }

  .ai-modal-footer {
    flex-direction: column;
  }

  .ai-action-btn {
    min-width: 100%;
  }

  .ai-explain-btn {
    width: 28px;
    height: 28px;
    background-size: 14px 14px;
  }
}

/* ═══════════════════════════════════════════════════════════
   garden.js v3.2 additions
   ═══════════════════════════════════════════════════════════ */

/* ── Grade 4 "ممتاز / Very Good" button ── */
.sm2-btn--4 {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  border: none;
  box-shadow: 0 3px 10px rgba(167, 139, 250, .35);
}

.sm2-btn--4:hover {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
}

/* ── Grade 4 in report ── */
.sm2-rgs-pill-4 .sm2-rgs-dot {
  background: #a855f7;
}

.sm2-rhow-4 {
  border-color: #a855f7;
}

.sm2-rhow-4 .sm2-rhow-g {
  background: #a855f7;
}

/* ── Undo / Bury util row ── */
.fc-util-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
}

.fc-util-btn {
  font-size: .78rem;
  font-weight: 600;
  padding: .3rem .9rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  letter-spacing: 0.01em;
}

.fc-util-btn:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
  background: var(--brand-glow);
}

.fc-undo-btn {
  /* Override: same calm ghost style, just slightly distinct */
  border-color: var(--border-color);
  color: var(--text-secondary);
  background: transparent;
  box-shadow: none;
  font-size: 0.78rem;
  padding: .3rem .9rem;
}

.fc-undo-btn:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
  background: var(--brand-glow);
  filter: none;
  transform: none;
}

.fc-bury-btn {
  border-color: var(--warning, #f59e0b);
  color: var(--warning, #f59e0b);
}

.fc-bury-btn:hover {
  background: rgba(245, 158, 11, .1);
}

/* ── Leech badge ── */
.fc-leech-badge {
  position: absolute;
  top: .6rem;
  inset-inline-end: .6rem;
  font-size: .7rem;
  font-weight: 800;
  background: rgba(239, 68, 68, .15);
  color: #ef4444;
  border: 1.5px solid #ef4444;
  border-radius: var(--radius-pill);
  padding: .15rem .5rem;
  pointer-events: none;
  z-index: 2;
}

/* .flashcard-front stays position:absolute via .flashcard-face — do not override */

/* ── Review Mode badge (toolbar counter) ── */
.fc-review-badge {
  font-size: .72rem;
  font-weight: 800;
  color: var(--brand-400);
  background: var(--brand-glow);
  border: 1.5px solid var(--brand-500);
  border-radius: var(--radius-pill);
  padding: .18rem .65rem;
  white-space: nowrap;
}

/* ── Filter bar ── */
.fc-filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
  margin-top: .9rem;
}

.fc-filter-btn {
  font-size: .72rem;
  font-weight: 700;
  padding: .22rem .7rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}

.fc-filter-btn:hover,
.fc-filter-btn.active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
}

/* ── Red retention pill in report ── */
.sm2-rpill--red {
  background: rgba(239, 68, 68, .1);
  border: 1.5px solid rgba(239, 68, 68, .4);
}

.sm2-rpill--red .sm2-rpill-n {
  color: #ef4444;
}

/* ── Activity Heatmap ── */
.sm2-heatmap {
  display: grid;
  grid-template-columns: repeat(84, 1fr);
  gap: 2px;
  margin: .5rem 0 .3rem;
}

.sm2-hm-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
}

.sm2-hm-i0 {
  background: var(--surface-3, rgba(255, 255, 255, .07));
}

.sm2-hm-i1 {
  background: rgba(99, 102, 241, .3);
}

.sm2-hm-i2 {
  background: rgba(99, 102, 241, .5);
}

.sm2-hm-i3 {
  background: rgba(99, 102, 241, .75);
}

.sm2-hm-i4 {
  background: rgba(99, 102, 241, 1);
}

.sm2-hm-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

.sm2-hm-legend span {
  padding: 0 .2rem;
}

.sm2-hm-legend .sm2-hm-cell {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}


/* ── Toolbar bury button ── */
.fc-toolbar-bury {
  height: 32px;
  padding: 0 0.8rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(245, 158, 11, .5);
  background: rgba(245, 158, 11, .08);
  color: #d97706;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.fc-toolbar-bury::before {
  content: '⏸';
  font-size: 0.82rem;
}

.fc-toolbar-bury:hover {
  background: rgba(245, 158, 11, .18);
  border-color: #f59e0b;
  color: #b45309;
  transform: scale(1.03);
}

[data-theme="dark"] .fc-toolbar-bury {
  color: #fbbf24;
}

[data-theme="dark"] .fc-toolbar-bury:hover {
  color: #fde68a;
}

/* ── 3D toggle button ── */
.fc-3d-btn {
  height: 30px;
  padding: 0 0.65rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 900;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.2s;
  user-select: none;
}

.fc-3d-btn::before {
  content: '◈';
  font-size: 0.78rem;
}

/* Hide on desktop — only relevant on mobile */
@media (min-width: 481px) {
  .fc-3d-btn {
    display: none;
  }
}

/* OFF state — default, muted */
.fc-3d-btn:not(.active) {
  opacity: 0.55;
}

/* ON / active state */
.fc-3d-btn.active {
  background: var(--brand-glow);
  border-color: var(--brand-500);
  color: var(--brand-500);
  opacity: 1;
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.fc-3d-btn:active {
  transform: scale(0.95);
}

/* ══════════════════════════════════════════════════════
   Flat flip mode — MOBILE ONLY (≤480px)
   Desktop always uses 3D regardless of .mobile-3d-off class.
   ══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .mobile-3d-off .flashcard-card {
    transform-style: flat !important;
    -webkit-transform-style: flat !important;
    will-change: auto;
    transform: none !important;
    -webkit-transform: none !important;
    transition: none !important;
  }

  .mobile-3d-off .flashcard-card.flipped {
    transform: none !important;
    -webkit-transform: none !important;
  }

  .mobile-3d-off .flashcard-face {
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
    transition: opacity 0.22s ease;
    transform: none !important;
    -webkit-transform: none !important;
    -webkit-font-smoothing: subpixel-antialiased;
    text-rendering: optimizeLegibility;
  }

  .mobile-3d-off .flashcard-front {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-3d-off .flashcard-back {
    opacity: 0;
    pointer-events: none;
  }

  .mobile-3d-off .flashcard-card.flipped .flashcard-front {
    opacity: 0;
    pointer-events: none;
  }

  .mobile-3d-off .flashcard-card.flipped .flashcard-back {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ══════════════════════════════════════════════════════
   v3.2 NEW COMPONENTS
   ══════════════════════════════════════════════════════ */

/* ── Retrievability badge ───────────────────────────────────────────── */
.fc-ret-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  margin-bottom: 0.6rem;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.fc-ret-badge:hover {
  opacity: 1;
}

/* green: ≥80% */
.fc-ret--high {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* yellow: 50-79% */
.fc-ret--mid {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* red: <50% */
.fc-ret--low {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Daily limit control ────────────────────────────────────────────── */
.fc-daily-limit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.fc-dl-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.fc-dl-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
}

.fc-dl-btn {
  background: transparent;
  border: none;
  color: var(--brand-500);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
  transition: color 0.15s, transform 0.1s;
}

.fc-dl-btn:hover {
  color: var(--brand-400);
  transform: scale(1.2);
}

.fc-dl-btn:active {
  transform: scale(0.9);
}

.fc-dl-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 2rem;
  text-align: center;
}

/* ── Ease Hell warning (inside SM-2 report) ─────────────────────────── */
.sm2-ease-warning {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.sm2-ease-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.sm2-ease-warning strong {
  display: block;
  color: #ef4444;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}

.sm2-ease-warning p {
  margin: 0;
  color: var(--text-secondary);
}

/* ═══ SVG DIAGRAM · Bilingual Text Control ═══
   يظهر النص المناسب تلقائياً حسب اتجاه الصفحة
   ═══════════════════════════════════════════ */

/* الوضع الافتراضي: كلا اللغتين مرئيتان */
.svg-diagram text.svg-lang-ar,
.svg-diagram text.svg-lang-en {
  display: inline;
}

/* صفحة عربية (RTL) ← أخفِ النصوص الإنجليزية */
[dir="rtl"] .svg-diagram text.svg-lang-en {
  display: none;
}

/* صفحة إنجليزية (LTR) ← أخفِ النصوص العربية */
[dir="ltr"] .svg-diagram text.svg-lang-ar {
  display: none;
}