:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #0d9488;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.1);
  --font-ar: 'Cairo', sans-serif;
  --font-en: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ar);
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header-main-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-icon {
  font-size: 1.8rem;
  background: rgba(255,255,255,0.1);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-titles {
  min-width: 0;
}

.brand-title {
  font-size: clamp(1.1rem, 2.8vw, 1.5rem);
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hamburger button in header */
.hamburger-btn {
  display: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  color: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ar);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.hamburger-btn:hover, .hamburger-btn:active {
  background: rgba(255,255,255,0.22);
  transform: scale(1.02);
}

.hamburger-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-tab {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ar);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.nav-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 24px auto;
  padding: 0 16px;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.tab-pane {
  display: none;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* 1. Flashcards */
.deck-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  min-width: 0;
}

.filter-group label {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.filter-group select {
  font-family: var(--font-ar);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f1f5f9;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar-bg {
  width: 140px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 1%;
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* 3D Flashcard */
.flashcard-container {
  perspective: 1200px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto 20px;
  height: 420px;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card-front {
  border-top: 6px solid var(--primary);
}

.card-back {
  transform: rotateY(180deg);
  border-top: 6px solid var(--secondary);
  background: #fdfefe;
}

.card-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
}

.pos-badge {
  background: var(--primary-light);
  color: var(--primary);
}

.arabic-badge {
  background: #ccfbf1;
  color: var(--secondary);
}

.card-back-term {
  font-family: var(--font-en);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-audio {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-audio:hover {
  background: #e2e8f0;
}

.card-term {
  font-family: var(--font-en);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--primary-hover);
  letter-spacing: -0.5px;
  margin: 8px 0;
}

.card-category {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.card-collocation-box {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  border-left: 3px solid var(--primary);
  margin-top: 10px;
}

.card-example {
  font-family: var(--font-en);
  font-size: 1.05rem;
  color: #334155;
  font-style: italic;
  line-height: 1.6;
  margin-top: 12px;
}

.click-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: auto;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.card-arabic {
  font-size: 1.9rem;
  font-weight: 800;
  color: #0f766e;
  line-height: 1.4;
  margin: 10px 0;
}

.card-definition-box, .card-example-ar-box {
  margin-top: 10px;
  line-height: 1.5;
}

.card-definition-box .label, .card-example-ar-box .label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.card-definition-box p {
  font-family: var(--font-en);
  font-size: 0.95rem;
  color: #334155;
}

.card-example-ar-box p {
  font-size: 1rem;
  color: #1e293b;
  font-weight: 600;
}

.card-confusing-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.confusing-alert {
  color: #b45309;
  font-weight: 800;
  font-size: 0.85rem;
  display: block;
}

.card-confusing-box p {
  font-size: 0.9rem;
  color: #92400e;
  margin-top: 2px;
  line-height: 1.4;
}

/* Card Nav Buttons */
.card-nav-buttons {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 12px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto 12px;
}

.btn-nav, .btn-flip {
  font-family: var(--font-ar);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-nav {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-nav:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.btn-flip {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.btn-flip:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.shortcut-tip {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 2. Glossary Table */
.glossary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.search-box {
  width: 100%;
  max-width: 400px;
}

.search-box input {
  font-family: var(--font-ar);
  padding: 12px 18px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.table-responsive {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.95rem;
}

.glossary-table th {
  background: #f8fafc;
  padding: 14px 16px;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  color: #475569;
  white-space: nowrap;
}

.glossary-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.glossary-table tr:hover {
  background: #f8fafc;
}

.term-en {
  font-family: var(--font-en);
  font-weight: 700;
  color: var(--primary);
  direction: ltr;
  display: inline-block;
}

.cell-pos {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-en);
}

.cell-ar {
  font-weight: 700;
  color: #0f172a;
}

.cell-example {
  font-family: var(--font-en);
  font-size: 0.85rem;
  color: #475569;
  font-style: italic;
  direction: ltr;
  max-width: 280px;
}

/* 3. Confusing Pairs */
.section-intro {
  margin-bottom: 24px;
}

.section-intro h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.section-intro p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.confusing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  width: 100%;
}

.confusing-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  box-sizing: border-box;
}

.confusing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.pair-terms {
  font-family: var(--font-en);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  direction: ltr;
  word-break: break-word;
}

.confusing-diff-ar {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* 4. Video & Audio Player */
.video-companion-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  width: 100%;
}

@media (max-width: 900px) {
  .video-companion-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
}

.video-player-card, .transcript-card {
  background: var(--bg-card);
  padding: 20px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.video-selector {
  margin-bottom: 14px;
  width: 100%;
  min-width: 0;
}

.video-selector label {
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.video-selector select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: var(--font-ar);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-main);
  outline: none;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

video {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #000;
  display: block;
  border-radius: var(--radius-sm);
}

.video-frame {
  margin-bottom: 12px;
}

.mini-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.35);
}

.mini-return-btn[hidden] {
  display: none !important;
}

/* Floating mini player: when the student scrolls into the transcript while the
   lesson is playing (stacked/portrait layout), pin the running video in the
   corner so it is never lost off-screen. */
@media (max-width: 900px) {
  #studyVideo.mini-player {
    position: fixed;
    bottom: 14px;
    inset-inline-end: 14px;
    width: min(48vw, 200px);
    height: auto;
    aspect-ratio: 16 / 9;
    z-index: 950;
    border-radius: 12px;
    border: 2px solid #0284c7;
    box-shadow: 0 12px 32px rgba(2, 6, 23, 0.5);
  }

  .mini-return-btn.mini-visible {
    position: fixed;
    bottom: calc(14px + min(48vw, 200px) * 9 / 16 + 10px);
    inset-inline-end: 14px;
    z-index: 950;
  }
}

/* Dedicated Live Teleprompter (Directly below video, NEVER blocks the video screen) */
.live-teleprompter {
  background: #0f172a;
  border: 1px solid #0284c7;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.18);
  transition: all 0.25s ease;
  width: 100%;
  box-sizing: border-box;
}

.live-teleprompter.hidden {
  display: none !important;
}

.teleprompter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 6px;
}

.teleprompter-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #ef4444;
  animation: liveBlink 1.5s infinite ease-in-out;
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.teleprompter-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #94a3b8;
}

.teleprompter-time {
  font-family: var(--font-en);
  font-size: 0.82rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(2, 132, 199, 0.25);
  padding: 2px 8px;
  border-radius: 4px;
}

.prompter-en {
  font-family: var(--font-en);
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 700;
  color: #38bdf8;
  direction: ltr;
  text-align: left;
  line-height: 1.5;
  transition: color 0.2s ease;
}

.prompter-ar {
  font-family: var(--font-ar);
  font-size: clamp(0.92rem, 2.5vw, 1.05rem);
  font-weight: 700;
  color: #f1f5f9;
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  padding-top: 6px;
}

/* Toolbar row below video */
.video-toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  width: 100%;
}

.speed-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.speed-controls span {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-speed {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-speed.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-caption-toggle {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--font-ar);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-caption-toggle:hover {
  background: #dcfce7;
}

.btn-caption-toggle.off {
  background: #f1f5f9;
  color: #64748b;
  border-color: var(--border);
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.transcript-header h3 {
  font-size: clamp(0.98rem, 2.8vw, 1.15rem);
  font-weight: 800;
  color: #0f172a;
  line-height: 1.4;
  word-break: break-word;
}

.transcript-note {
  line-height: 1.6;
}

.highlight-list {
  list-style: none;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-left: 6px;
}

.highlight-item {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-right: 4px solid var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.highlight-term {
  font-family: var(--font-en);
  font-weight: 800;
  color: var(--primary);
}

.highlight-ar {
  font-weight: 700;
  color: #334155;
  font-size: 0.95rem;
}

/* 5. Quiz Area */
.quiz-container {
  max-width: 680px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.quiz-header {
  text-align: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quiz-mode-selector {
  margin: 10px auto 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 540px;
  text-align: right;
  width: 100%;
}

.quiz-mode-selector label {
  font-weight: 700;
  font-size: 0.95rem;
  color: #334155;
}

.quiz-mode-selector select {
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-ar);
  font-size: 0.92rem;
  background: #ffffff;
  color: var(--text-main);
  box-sizing: border-box;
  outline: none;
}

.quiz-score-badge {
  display: inline-block;
  margin-top: 6px;
  background: #dbeafe;
  color: #1e40af;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.95rem;
}

.quiz-question-box {
  margin-bottom: 20px;
}

.quiz-q-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.quiz-q-text {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 8px 0 16px;
  color: #0f172a;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option {
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 20px;
  border: 2px solid var(--border);
  background: #ffffff;
  border-radius: var(--radius-md);
  text-align: right;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: #f0f9ff;
}

.quiz-option.correct {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #14532d !important;
  font-weight: 800;
}

.quiz-option.wrong {
  background: #fee2e2 !important;
  border-color: #dc2626 !important;
  color: #7f1d1d !important;
}

.quiz-explanation {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  font-size: 0.95rem;
  line-height: 1.5;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  font-family: var(--font-ar);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  font-family: var(--font-ar);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

/* Passages Styles */
.passage-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.passage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.passage-header h3 {
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  word-break: break-word;
}

.passage-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  width: 100%;
}

@media (max-width: 800px) {
  .passage-content-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
}

.passage-en, .passage-ar {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  line-height: 1.8;
  font-size: 1.05rem;
}

.passage-en h4, .passage-ar h4 {
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 1.1rem;
}

.passage-en strong, .passage-ar strong {
  color: var(--primary-hover);
  background: #e0f2fe;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Sentences Styles */
.sentence-category-group {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.cat-title {
  color: var(--primary);
  font-size: 1.2rem;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.sentence-item {
  background: #f8fafc;
  border-right: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.s-en {
  font-family: var(--font-en);
  font-size: 1rem;
  color: #1e293b;
  line-height: 1.6;
}

.s-ar {
  font-size: 0.95rem;
  color: #475569;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1.5;
}

/* Transcript Live List */
.transcript-body-scroll {
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 6px;
  -webkit-overflow-scrolling: touch;
}

.transcript-row {
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
  word-break: break-word;
  box-sizing: border-box;
  flex-shrink: 0 !important;
  min-height: 64px;
}

.transcript-row:hover {
  background: #f0f9ff;
  border-color: var(--primary);
}

.transcript-row.active {
  background: #e0f2fe;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.t-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.t-time {
  font-family: var(--font-en);
  font-weight: 800;
  color: var(--primary);
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.t-en {
  font-family: var(--font-en);
  font-size: 0.95rem;
  color: #0f172a;
  line-height: 1.5;
  direction: ltr;
  text-align: left;
}

.t-ar {
  font-size: 0.95rem;
  color: #334155;
  font-weight: 600;
  line-height: 1.5;
}

/* Hint Button */
.btn-hint {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 10px;
  display: inline-block;
  transition: background 0.2s ease;
}

.btn-hint:hover {
  background: #fde68a;
}

.quiz-hint-box {
  background: #fffbeb;
  border: 1px dashed #f59e0b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 0.95rem;
  color: #78350f;
  line-height: 1.5;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  background: #ffffff;
  margin-top: auto;
}

/* =========================================================
   HAMBURGER & MOBILE DRAWER (RTL SAFE)
   ========================================================= */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-nav-overlay.open {
  display: block;
  opacity: 1;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: -340px; /* Completely off-screen, no transform RTL bugs */
  width: 300px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: #0f172a;
  z-index: 9999;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: -6px 0 24px rgba(0,0,0,0.5);
  visibility: hidden;
  pointer-events: none;
}

.mobile-nav-drawer.open {
  right: 0 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.drawer-title {
  color: #f8fafc;
  font-weight: 800;
  font-size: 1.1rem;
}

.mobile-nav-close {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #f8fafc;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.mobile-nav-close:hover {
  background: rgba(255,255,255,0.2);
}

.drawer-menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-menu-list .nav-tab {
  width: 100%;
  text-align: right;
  padding: 13px 16px;
  font-size: 0.98rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
  display: block;
}

/* =========================================================
   RESPONSIVE — TABLET (≤ 992px)
   ========================================================= */
@media (max-width: 992px) {
  .nav-tabs {
    display: none !important;
  }

  .hamburger-btn {
    display: inline-flex;
  }

  .main-content {
    margin: 18px auto;
    padding: 0 14px;
  }

  .deck-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group select {
    width: 100%;
  }

  .card-progress {
    justify-content: space-between;
  }

  .confusing-grid {
    grid-template-columns: 1fr;
  }

  .video-companion-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .passage-content-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   RESPONSIVE — MOBILE (≤ 640px)
   ========================================================= */
@media (max-width: 640px) {
  .app-header {
    padding: 12px 14px;
  }

  .logo-icon {
    font-size: 1.5rem;
    padding: 6px 10px;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    font-size: 0.78rem;
  }

  .hamburger-btn {
    padding: 7px 12px;
    font-size: 0.9rem;
  }

  .main-content {
    padding: 0 10px;
    margin: 14px auto;
  }

  /* Flashcard */
  .flashcard-container {
    height: 440px;
    margin-bottom: 16px;
  }

  .card-face {
    padding: 20px 16px;
  }

  .card-term {
    font-size: 2.1rem;
    margin: 4px 0;
  }

  .card-arabic {
    font-size: 1.4rem;
    margin: 6px 0;
  }

  .card-collocation-box {
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  .card-example {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .card-definition-box p {
    font-size: 0.9rem;
  }

  .btn-audio {
    padding: 5px 12px;
    font-size: 0.8rem;
  }

  .click-hint {
    font-size: 0.8rem;
    padding-top: 8px;
  }

  /* Card Nav Buttons on Mobile */
  .card-nav-buttons {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .btn-flip {
    grid-column: span 2;
    order: -1;
    padding: 14px;
    font-size: 1.05rem;
  }

  .btn-nav {
    padding: 12px;
    font-size: 0.92rem;
  }

  .shortcut-tip {
    display: none;
  }

  /* Glossary */
  .glossary-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-box input {
    width: 100%;
  }

  .glossary-table {
    font-size: 0.84rem;
  }

  .glossary-table th, .glossary-table td {
    padding: 10px 8px;
  }

  /* Video & Transcript */
  .speed-controls {
    gap: 6px;
  }

  .btn-speed {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .transcript-body-scroll {
    max-height: 280px;
  }

  .t-en, .t-ar {
    font-size: 0.88rem;
  }

  /* Passages & Sentences */
  .passage-card {
    padding: 16px 14px;
  }

  .passage-en, .passage-ar {
    padding: 12px;
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .passage-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .sentence-item {
    padding: 10px 12px;
  }

  .s-en, .s-ar {
    font-size: 0.92rem;
  }

  /* Quiz */
  .quiz-container {
    padding: 18px 14px;
    border-radius: var(--radius-md);
  }

  .quiz-q-text {
    font-size: 1.05rem;
  }

  .quiz-option {
    padding: 12px 14px;
    font-size: 0.92rem;
    min-height: 48px;
  }

  .quiz-actions {
    flex-direction: column;
    gap: 10px;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
    padding: 13px;
    font-size: 0.98rem;
    text-align: center;
  }

  /* Section intros */
  .section-intro h2 {
    font-size: 1.2rem;
  }

  .section-intro p {
    font-size: 0.88rem;
  }

  /* Footer */
  .app-footer {
    font-size: 0.82rem;
    padding: 14px;
  }
}

/* =========================================================
   RESPONSIVE — VERY SMALL (≤ 380px)
   ========================================================= */
@media (max-width: 380px) {
  .brand-subtitle {
    display: none;
  }

  .flashcard-container {
    height: 470px;
  }

  .card-term {
    font-size: 1.75rem;
  }

  .card-arabic {
    font-size: 1.25rem;
  }

  .btn-nav {
    padding: 10px 8px;
    font-size: 0.85rem;
  }
}

