/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  --primary:        #1a5276;
  --primary-light:  #2874a6;
  --primary-dark:   #154360;
  --accent:         #c9a84c;
  --accent-dark:    #a07830;
  --success:        #1e8449;
  --success-light:  #d5f5e3;
  --danger:         #c0392b;
  --danger-light:   #fce4e1;
  --warning:        #d68910;
  --warning-light:  #fef9e7;
  --info:           #2471a3;
  --info-light:     #d6eaf8;

  --bg:             #f7f5f0;
  --surface:        #ffffff;
  --surface-alt:    #f0ede6;
  --text:           #1c1c2e;
  --text-muted:     #6b6b7a;
  --border:         #ddd9cf;

  --sidebar-bg:     #12304a;
  --sidebar-text:   #c8dae8;
  --sidebar-active: #ffffff;
  --sidebar-w:      240px;

  --font-latin:     'Inter', system-ui, sans-serif;
  --font-arabic:    'Amiri', 'Traditional Arabic', serif;

  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.12);
}

/* ── Reset & base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-latin);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

textarea, input, button { font-family: inherit; font-size: inherit; }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: 1100px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 0 0 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}

.logo-link { text-decoration: none; display: flex; align-items: center; gap: 10px; }

.logo-badge {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-arabic);
  font-size: 1.5rem;
  color: var(--primary-dark);
  flex-shrink: 0;
  font-weight: 400;
}

.logo-text {
  font-weight: 700;
  font-size: .9rem;
  color: white;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.logo-tld { color: var(--accent); font-weight: 700; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 14px;
  margin-bottom: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.07); color: white; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255,255,255,0.12); color: white; font-weight: 500; }

.sidebar-nav svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 0;
}

.sidebar-logout {
  padding: 0 12px;
  margin-top: auto;
}

.sidebar-logout button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-logout button:hover { background: rgba(255,255,255,0.07); color: white; }
.sidebar-logout svg { width: 17px; height: 17px; }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.back-link:hover { color: var(--primary); }

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary    { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent     { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }

.btn-success    { background: var(--success); color: white; }
.btn-success:hover { background: #27ae60; }

.btn-danger     { background: var(--danger); color: white; }
.btn-danger:hover { background: #e74c3c; }

.btn-outline    {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 5px 12px; font-size: 0.82rem; }
.ml-2     { margin-left: 8px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* ── Alert ───────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-lg      { padding: 5px 14px; font-size: 0.88rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 120px; }
.field small { display: block; margin-top: 4px; font-size: 0.78rem; color: var(--text-muted); }

.field-row { display: flex; gap: 16px; }
.field-sm { flex: 0 0 100px; }
.field-grow { flex: 1; }

.required { color: var(--danger); }

.arabic-input { font-family: var(--font-arabic); font-size: 1.2rem; direction: rtl; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-card { max-width: 700px; }

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-logo {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-arabic);
  font-size: 3rem;
  color: var(--accent);
  font-weight: 400;
  margin: 0 auto 14px;
  box-shadow: 0 4px 20px rgba(26,82,118,0.25);
}

.auth-brand h1 { font-size: 1.4rem; margin-bottom: 2px; letter-spacing: -0.02em; }
.auth-brand p  { color: var(--text-muted); font-size: 0.9rem; }
.brand-tld { color: var(--accent); }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
}

.auth-card h2 { margin-bottom: 20px; }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Dashboard ───────────────────────────────────────────────────────────────── */
.review-banner {
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}

.review-banner-done { background: var(--success); }

.review-banner-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.review-count {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  min-width: 40px;
}

.review-banner-info strong { display: block; font-size: 1rem; }
.review-banner-info span  { font-size: 0.85rem; opacity: 0.85; }

.lessons-section h2 { margin-bottom: 16px; }

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.lesson-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 2px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}

.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lesson-card.completed { border-color: var(--success); }
.lesson-card.in_progress { border-color: var(--info); }

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

.lesson-number { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.lesson-title-ar {
  font-family: var(--font-arabic);
  font-size: 1.4rem;
  margin-bottom: 4px;
  direction: rtl;
  text-align: right;
}

.lesson-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.lesson-vocab-count { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; }
.lesson-progress-label { font-size: 0.78rem; color: var(--text-muted); margin: 4px 0 12px; }

.lesson-progress-bar {
  height: 5px;
  background: var(--surface-alt);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 2px;
}

.lesson-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* ── Lesson page ─────────────────────────────────────────────────────────────── */
.lesson-layout { display: flex; flex-direction: column; gap: 16px; }

.ar-title { font-family: var(--font-arabic); direction: rtl; font-size: 2.2rem; line-height: 1.4; }
.ar-subtitle { font-family: var(--font-arabic); font-size: 1.2rem; vertical-align: middle; font-weight: 400; }

.theory-section h2 { margin-bottom: 16px; }

.theory-content {
  line-height: 1.75;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: 1rem;
}
.theory-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary-dark, var(--text));
  margin: 24px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.theory-content h3:first-child { margin-top: 0; }
.theory-content p { margin: 0 0 10px; }
.theory-content p:last-child { margin-bottom: 0; }
.theory-content ul { margin: 0 0 10px; padding-left: 20px; }
.theory-content li { margin-bottom: 8px; }
.theory-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.theory-content strong { color: var(--primary); }
.theory-content .ar-inline { font-family: var(--font-arabic); font-size: 1.5rem; line-height: 2.2; vertical-align: middle; }
.theory-content h3 .ar-inline { font-size: 1.6rem; }
.theory-table { border-collapse: collapse; margin: 0 0 12px; }
.theory-table th, .theory-table td { border: 1px solid var(--border); padding: 8px 16px; text-align: center; }
.theory-table th { background: var(--surface-alt); font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.theory-table td .ar-inline { font-size: 1.4rem; line-height: 2; }

.vocab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.count-badge {
  display: inline-block;
  background: var(--surface-alt);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.vocab-table-wrap { overflow-x: auto; }

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.vocab-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-alt);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vocab-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table tr:hover td { background: var(--bg); }

.arabic-cell { text-align: right; }
.arabic-word { font-family: var(--font-arabic); font-size: 1.5rem; direction: rtl; }
.translit-cell { color: var(--text-muted); font-style: italic; }

.example { margin-top: 4px; }
.ex-ar { display: block; font-family: var(--font-arabic); font-size: 1rem; direction: rtl; color: var(--primary); }
.ex-fr { display: block; font-size: 0.78rem; color: var(--text-muted); }

.category-tag {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--info-light);
  color: var(--info);
  padding: 1px 7px;
  border-radius: 4px;
}

.col-arabic { width: 140px; }
.col-status { width: 48px; text-align: center; }

.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.status-new      { background: var(--border); }
.status-learning { background: var(--warning); }
.status-mastered { background: var(--success); }

.vocab-cta {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.vocab-cta p { margin-bottom: 10px; }

.empty-state { color: var(--text-muted); padding: 20px 0; }

/* ── Flashcards ──────────────────────────────────────────────────────────────── */
.flashcard-main { max-width: 680px; }

.fc-session { min-height: calc(100vh - 64px); display: flex; flex-direction: column; }

.fc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.fc-progress { display: flex; align-items: center; gap: 12px; flex: 1; margin-left: 20px; }

.fc-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.fc-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
  transition: width 0.4s ease;
}

.fc-progress-text { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }

.fc-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* Carte 3D */
.fc-container {
  width: 100%;
  max-width: 560px;
  height: 300px;
  perspective: 1200px;
  cursor: pointer;
  margin-bottom: 28px;
}

.fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.fc-card.is-flipped { transform: rotateY(180deg); }

.fc-front, .fc-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.fc-front {
  background: var(--surface);
  border: 2px solid var(--border);
}

.fc-back {
  background: var(--primary-dark);
  color: white;
  transform: rotateY(180deg);
}

.fc-lesson-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.fc-arabic {
  font-family: var(--font-arabic);
  font-size: 3.5rem;
  line-height: 1.3;
  direction: rtl;
  text-align: center;
  color: var(--text);
}

.fc-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fc-french {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.fc-translit {
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0.75;
  margin-bottom: 6px;
}

.fc-category {
  font-size: 0.78rem;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.fc-example {
  text-align: center;
  margin-top: 4px;
}

.fc-example .ex-ar {
  color: var(--accent);
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  direction: rtl;
}

.fc-example .ex-fr { color: rgba(255,255,255,0.7); font-size: 0.82rem; }

/* Boutons de notation */
.fc-rating {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.btn-rating {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  font-family: inherit;
}

.btn-rating:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-rating:active { transform: translateY(0); }
.btn-rating:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-rating.again { background: #fde8e6; color: var(--danger); }
.btn-rating.hard  { background: #fef3e2; color: var(--warning); }
.btn-rating.good  { background: #d5f5e3; color: var(--success); }
.btn-rating.easy  { background: var(--info-light); color: var(--info); }

.rating-label    { font-weight: 600; font-size: 0.88rem; }
.rating-interval { font-size: 0.75rem; opacity: 0.7; margin-top: 2px; }

/* Écran fin de session */
.fc-done {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  gap: 12px;
}

.done-icon { font-size: 3rem; }
.fc-done h2 { font-size: 1.5rem; }
.fc-done p  { color: var(--text-muted); }
.done-actions { display: flex; gap: 12px; margin-top: 12px; }

/* Écran vide */
.empty-review {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  gap: 10px;
}
.empty-icon { font-size: 3rem; }
.empty-review h2 { font-size: 1.5rem; }
.empty-review p  { color: var(--text-muted); max-width: 360px; }
.next-review-time { font-size: 0.88rem; }
.empty-actions { display: flex; gap: 12px; margin-top: 12px; }

/* ── Stats ───────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-due .stat-value      { color: var(--warning); }
.stat-mastered .stat-value { color: var(--success); }
.stat-learning .stat-value { color: var(--info); }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stats-table th { text-align: left; padding: 8px 12px; background: var(--surface-alt); font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.stats-table tr:last-child td { border-bottom: none; }

.mini-progress { height: 5px; background: var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 2px; min-width: 80px; }
.mini-progress-fill { height: 100%; background: var(--success); border-radius: 10px; }

/* ── Admin ───────────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th { text-align: left; padding: 8px 12px; background: var(--surface-alt); font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

.action-cell { display: flex; gap: 6px; align-items: center; }
.lesson-num-badge { display: inline-block; background: var(--primary); color: white; border-radius: 4px; padding: 2px 8px; font-size: 0.8rem; font-weight: 600; }

.ar-inline { font-family: var(--font-arabic); direction: rtl; font-weight: 400; }
.ar-sm { font-family: var(--font-arabic); font-size: 1.1rem; direction: rtl; font-weight: 400; }

/* Aucun élément arabe ne doit être en gras */
.ar-inline, .ar-sm, .ar-title, .arabic-word, .arabic-input,
.theory-content, .fc-arabic, .quiz-arabic,
.ex-sentence-ar, .ex-word, .brand-logo, .logo-ar, .lesson-title-ar { font-weight: 400; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 20px; }

/* ── Bottom nav (mobile only) ────────────────────────────────────────────────── */
.bottom-nav { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar cachée */
  .sidebar { display: none; }

  /* Contenu plein écran */
  .main-content {
    margin-left: 0;
    padding: 16px 16px calc(72px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  /* Page header → colonne */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  h1 { font-size: 1.35rem; }

  /* Review banner → colonne */
  .review-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
  .review-banner .btn { width: 100%; justify-content: center; }

  /* Grille leçons → 1 colonne */
  .lessons-grid { grid-template-columns: 1fr; }

  /* Table vocab → masquer colonnes secondaires */
  .col-translit,
  .translit-cell,
  .col-category { display: none; }

  /* Flashcard */
  .fc-container { height: 220px; }
  .fc-arabic    { font-size: 2.8rem; }
  .fc-front, .fc-back { padding: 20px; }

  /* Boutons de rating → texte plus compact */
  .rating-label    { font-size: 0.8rem; }
  .rating-interval { font-size: 0.68rem; }

  /* Stats grid → 2 colonnes */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Formulaires côte à côte → colonne */
  .field-row { flex-direction: column; }

  /* Actions fin de flashcard */
  .done-actions,
  .empty-actions { flex-direction: column; }
  .done-actions .btn,
  .empty-actions .btn { width: 100%; justify-content: center; }

  /* Auth */
  .auth-card { padding: 20px; }

  /* Bottom nav visible */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px 8px;
    color: var(--sidebar-text);
    font-size: 0.62rem;
    text-decoration: none;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bnav-item svg      { width: 22px; height: 22px; flex-shrink: 0; }
  .bnav-item.active   { color: #ffffff; }
  .bnav-item:hover    { color: #ffffff; text-decoration: none; }
  .bnav-item:active   { opacity: 0.7; }
}

/* ── Quiz ─────────────────────────────────────────────────────────────────────── */

.quiz-start-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 520px; }
.mode-selector { display: flex; gap: 12px; }
.mode-card { flex: 1; padding: 16px 12px; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.mode-card input { display: none; }
.mode-card.selected, .mode-card:has(input:checked) { border-color: var(--primary); background: var(--info-light); }
.mode-card-icon { font-size: 1.6rem; margin-bottom: 6px; }
.mode-card-title { font-weight: 600; font-size: .95rem; }
.mode-card-desc { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }
.btn-full { width: 100%; justify-content: center; }

.quiz-history-list { display: flex; flex-direction: column; gap: 8px; }
.quiz-history-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-alt); border-radius: var(--radius-sm); font-size: .85rem; }
.quiz-history-score { font-weight: 700; min-width: 38px; }
.quiz-history-score.good { color: var(--success); }
.quiz-history-score.avg  { color: var(--warning); }
.quiz-history-score.bad  { color: var(--danger);  }

/* Quiz play */
.quiz-container { max-width: 580px; margin: 0 auto; }
.quiz-header { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.quiz-progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .35s ease; }
.quiz-counter { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.quiz-question { text-align: center; margin-bottom: 32px; }
.quiz-mode-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px; }
.quiz-arabic { font-family: var(--font-arabic); font-size: 2.8rem; line-height: 1.8; direction: rtl; color: var(--text); margin-bottom: 8px; padding-top: 12px; }
.quiz-translit { font-size: .9rem; color: var(--text-muted); font-style: italic; }

.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option { padding: 14px 20px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: .95rem; cursor: pointer; text-align: left; transition: border-color .12s, background .12s; }
.quiz-option:hover:not(:disabled) { border-color: var(--primary-light); background: var(--info-light); }
.quiz-option.correct { border-color: var(--success) !important; background: var(--success-light) !important; color: var(--success); font-weight: 600; }
.quiz-option.wrong   { border-color: var(--danger)  !important; background: var(--danger-light)  !important; color: var(--danger); }

.quiz-saisie { display: flex; gap: 10px; }
.quiz-input { flex: 1; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius); font-size: .95rem; font-family: var(--font-latin); transition: border-color .15s; }
.quiz-input:focus { outline: none; border-color: var(--primary); }
.quiz-input.input-correct { border-color: var(--success); background: var(--success-light); }
.quiz-input.input-wrong   { border-color: var(--danger);  background: var(--danger-light);  }

.quiz-feedback { padding: 12px 16px; border-radius: var(--radius); margin-top: 16px; display: flex; align-items: center; gap: 10px; }
.quiz-feedback.correct { background: var(--success-light); color: var(--success); }
.quiz-feedback.wrong   { background: var(--danger-light);  color: var(--danger);  }
.quiz-fb-icon { font-size: 1.2rem; font-weight: 700; }
.quiz-fb-text { font-weight: 600; }
.quiz-fb-correct { margin-left: auto; font-size: .88rem; font-style: italic; }

.quiz-nav { margin-top: 20px; display: flex; justify-content: center; }

/* Quiz result */
.quiz-result-header { text-align: center; margin-bottom: 28px; }
.quiz-score-circle { width: 110px; height: 110px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 16px; border: 4px solid; }
.quiz-score-circle.grade-a { background: var(--success-light); color: var(--success); border-color: var(--success); }
.quiz-score-circle.grade-b { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.quiz-score-circle.grade-c { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger);  }
.score-num { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.score-pct { font-size: .8rem; margin-top: 2px; }
.quiz-result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.quiz-errors-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.quiz-errors-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 500; }
.quiz-errors-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.answer-correct { color: var(--success); }
.answer-wrong   { color: var(--danger);  }
.translit { color: var(--text-muted); font-style: italic; }

@media (max-width: 768px) {
  .quiz-start-wrap { max-width: 100%; }
  .quiz-arabic { font-size: 2.2rem; }
  .quiz-saisie { flex-direction: column; }
  .quiz-fb-correct { margin-left: 0; margin-top: 4px; }
  .quiz-feedback { flex-wrap: wrap; }
}

/* ── Vocabulaire hub ─────────────────────────────────────────────────────────── */
.vocab-hub-grid { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.vocab-hub-card { display: flex; align-items: center; gap: 20px; padding: 24px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.vocab-hub-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); text-decoration: none; }
.vocab-hub-icon { font-size: 2.2rem; flex-shrink: 0; width: 52px; text-align: center; }
.vocab-hub-body { flex: 1; }
.vocab-hub-body h2 { font-size: 1.1rem; margin-bottom: 4px; }
.vocab-hub-body p { font-size: .88rem; color: var(--text-muted); margin-bottom: 10px; line-height: 1.4; }
.vocab-hub-badge { }
.vocab-hub-arrow { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }

/* ── Exercices ───────────────────────────────────────────────────────────────── */
.ex-lesson-row { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:10px; }
.ex-lesson-info { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.ex-lesson-title { font-size:1rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ex-lesson-count { color:var(--text-muted); font-size:.85rem; white-space:nowrap; }

.ex-lesson-cta { margin-top:20px; }
.ex-lesson-btn { width:100%; justify-content:center; font-size:1rem; padding:14px; }

.ex-container { max-width:600px; margin:0 auto; }
.ex-header { display:flex; align-items:center; gap:12px; margin-bottom:32px; }
.ex-progress-bar { flex:1; height:6px; background:var(--border); border-radius:3px; overflow:hidden; }
.ex-progress-fill { height:100%; background:var(--accent); border-radius:3px; transition:width .35s ease; }
.ex-counter { font-size:.85rem; color:var(--text-muted); white-space:nowrap; }

.ex-type-label { font-size:.75rem; text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted); margin-bottom:12px; }
.ex-sentence-fr { font-size:1.15rem; font-weight:600; margin-bottom:20px; color:var(--text); line-height:1.5; }
.ex-sentence-ar { font-family:var(--font-arabic); font-size:2.2rem; line-height:2; direction:rtl; text-align:center; padding:16px 0; margin-bottom:16px; }

.ex-answer-zone { min-height:60px; border:2px dashed var(--border); border-radius:var(--radius); padding:12px 16px; display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:flex-start; margin-bottom:12px; transition:border-color .15s, background .15s; }
.ex-answer-zone.drag-over { border-color:var(--accent); background:var(--warning-light); }
.ex-placeholder { color:var(--text-muted); font-size:.9rem; font-style:italic; pointer-events:none; }

.ex-word-bank { display:flex; flex-wrap:wrap; gap:8px; padding:12px 0; margin-bottom:8px; justify-content:flex-end; direction:rtl; }
.ex-word-bank.drag-over { background:var(--surface-alt); border-radius:var(--radius); padding:12px; }
.ex-word { display:inline-flex; align-items:center; padding:8px 16px; background:var(--surface); border:2px solid var(--border); border-radius:var(--radius-sm); font-family:var(--font-arabic); font-size:1.5rem; cursor:grab; user-select:none; transition:border-color .12s, transform .1s; }
.ex-word:hover { border-color:var(--primary-light); transform:translateY(-1px); }
.ex-word:active { cursor:grabbing; transform:scale(.97); }
.ex-word.dragging { opacity:.4; }
#answer-zone .ex-word { border-color:var(--accent); background:var(--warning-light); }

.ex-validate-btn { width:100%; margin-top:8px; justify-content:center; }

.ex-saisie { display:flex; gap:10px; }

.ex-feedback { padding:13px 16px; border-radius:var(--radius); margin-top:16px; display:flex; align-items:flex-start; gap:10px; }
.ex-feedback.correct { background:var(--success-light); color:var(--success); }
.ex-feedback.wrong   { background:var(--danger-light);  color:var(--danger); }
.ex-fb-icon { font-size:1.2rem; font-weight:700; flex-shrink:0; margin-top:1px; }
.ex-fb-body { display:flex; flex-direction:column; gap:3px; }
.ex-fb-text { font-weight:600; }
.ex-fb-answer { font-size:.9rem; font-style:italic; }

.ex-nav { margin-top:20px; display:flex; justify-content:center; }

/* Result */
.ex-result-header { text-align:center; margin-bottom:24px; }
.ex-passed-banner { background:var(--success-light); border:1px solid var(--success); border-radius:var(--radius); padding:16px 20px; margin:16px 0; }
.ex-passed-banner p { color:var(--success); font-weight:600; margin-bottom:12px; }
.ex-result-actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:16px; }
.ex-errors-list { display:flex; flex-direction:column; gap:12px; }
.ex-error-item { display:flex; gap:12px; padding:12px; background:var(--surface-alt); border-radius:var(--radius-sm); }
.ex-error-type { flex-shrink:0; }
.ex-error-body { flex:1; display:flex; flex-direction:column; gap:4px; }
.ex-error-sentence { font-size:.9rem; color:var(--text-muted); }
.ex-error-correct { font-size:.95rem; }

@media (max-width: 768px) {
  .ex-lesson-row { flex-direction:column; align-items:flex-start; }
  .ex-sentence-ar { font-size:1.8rem; }
  .ex-saisie { flex-direction:column; }
  .ex-word { font-size:1rem; padding:5px 10px; }
}
