:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: rgba(5, 150, 105, 0.12);
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font-ar: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;
  --font-fr: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

[data-theme='dark'] {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-alt: #1e293b;
  --border: #28354d;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-soft: rgba(16, 185, 129, 0.16);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 88px;
  transition: background 0.25s ease, color 0.25s ease;
}

html[lang='fr'] body { font-family: var(--font-fr); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #047857);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 16px;
}

.hero-card {
  background: linear-gradient(135deg, #065f46, #059669 65%, #0d9488);
  color: #fff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-balance {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.pill-gold { background: var(--gold-soft); color: var(--gold); }
.pill-primary { background: var(--primary-soft); color: var(--primary); }
.pill-white { background: rgba(255, 255, 255, 0.18); color: #fff; }

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 18px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.lesson-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.lesson-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn {
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-full { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.wallet-providers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.provider-btn {
  min-height: 52px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.provider-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px;
}

.nav-item {
  min-height: 56px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border-radius: 12px;
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow);
}

.quiz-option {
  width: 100%;
  text-align: start;
  min-height: 48px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.quiz-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 700;
}

.toast {
  position: fixed;
  top: 76px;
  inset-inline: 16px;
  max-width: 460px;
  margin: 0 auto;
  z-index: 80;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  text-align: center;
  display: none;
}

.toast.show { display: block; }
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-row:last-child { border-bottom: none; }
.muted { color: var(--text-muted); font-size: 0.88rem; }
.demo-banner {
  background: var(--gold-soft);
  color: var(--gold);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
}
