/* Mobile-first responsive French learning site. iOS Safari + Android compatible. */

:root {
  --bleu: #0055A4;
  --blanc: #FFFFFF;
  --rouge: #EF4135;
  --cream: #FFF9E6;
  --ink: #1a1a2e;
  --mute: #6b7280;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #f59e0b;
  --card: #ffffff;
  --bg: #FFF9E6;
  --accent: #7c3aed;
  --shadow: 0 6px 24px rgba(0,0,0,.08);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(0,85,164,.06) 0, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(239,65,53,.06) 0, transparent 40%);
}

/* TOPBAR — desktop */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  padding-top: calc(12px + var(--safe-top));
  padding-left: calc(24px + var(--safe-left));
  padding-right: calc(24px + var(--safe-right));
  background: var(--blanc);
  border-bottom: 3px solid var(--bleu);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: transparent;
  border: 2px solid var(--bleu);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  -webkit-appearance: none;
  appearance: none;
}
.hamburger span {
  display: block;
  height: 3px;
  background: var(--bleu);
  border-radius: 2px;
  transition: transform .25s, opacity .2s;
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 22px;
  cursor: pointer;
  color: var(--bleu);
  flex-shrink: 0;
}
.logo { font-size: 28px; }

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.nav a {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav a:hover { background: var(--cream); color: var(--bleu); }
.nav a.active { background: var(--bleu); color: white; }

.stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.stat {
  background: var(--cream);
  border: 2px solid var(--bleu);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.nav-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  z-index: 49;
  opacity: 0;
  transition: opacity .2s;
}
.nav-backdrop.open {
  display: block;
  opacity: 1;
}

/* MAIN */
main {
  flex: 1;
  padding: 24px;
  padding-left: calc(24px + var(--safe-left));
  padding-right: calc(24px + var(--safe-right));
  padding-bottom: calc(24px + var(--safe-bottom));
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.footer {
  text-align: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  color: var(--mute);
  font-size: 13px;
}

/* HERO */
.hero {
  background: linear-gradient(135deg, var(--bleu) 0%, #1e40af 50%, var(--rouge) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero h1 { font-family: 'Fredoka', sans-serif; font-size: 38px; margin-bottom: 8px; line-height: 1.1; }
.hero p { font-size: 17px; opacity: .92; max-width: 640px; line-height: 1.5; }
.hero .flag-stripes {
  position: absolute; right: -50px; top: -50px;
  width: 200px; height: 200px; opacity: .15;
  background: repeating-linear-gradient(45deg, white 0 30px, transparent 30px 60px);
  border-radius: 50%;
  pointer-events: none;
}

/* GRID + CARD */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border: 2px solid transparent;
}
.card:hover, .card:active {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,.12);
  border-color: var(--bleu);
}
.card .icon { font-size: 36px; margin-bottom: 8px; }
.card h3 { font-family: 'Fredoka', sans-serif; font-size: 19px; margin-bottom: 6px; color: var(--bleu); }
.card p { color: var(--mute); font-size: 14px; line-height: 1.5; }
.card .meter {
  margin-top: 12px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.card .meter > div {
  height: 100%;
  background: linear-gradient(90deg, var(--bleu), var(--rouge));
}

/* PATH */
.path-list { display: flex; flex-direction: column; gap: 10px; }
.path-node {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 6px solid var(--mute);
  min-height: 64px;
}
.path-node.unlocked { border-left-color: var(--bleu); }
.path-node.done { border-left-color: var(--good); background: #f0fdf4; }
.path-node.locked { opacity: .5; cursor: not-allowed; }
.path-node .num {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bleu);
  color: white;
  display: grid; place-items: center;
  font-weight: 800;
  font-family: 'Fredoka', sans-serif;
  flex-shrink: 0;
  font-size: 16px;
}
.path-node.done .num { background: var(--good); }
.path-node.locked .num { background: var(--mute); }
.path-node .info { min-width: 0; flex: 1; }
.path-node .info h4 {
  font-family: 'Fredoka', sans-serif;
  font-size: 17px;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.path-node .info p {
  color: var(--mute);
  font-size: 13px;
  margin-top: 2px;
}
.path-node .badge {
  margin-left: auto;
  background: var(--cream);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bleu);
  flex-shrink: 0;
  display: none;
}

/* LESSON SHELL */
.lesson {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-height: 400px;
}
.lesson h2 { font-family: 'Fredoka', sans-serif; color: var(--bleu); margin-bottom: 8px; font-size: 24px; }
.lesson .progress {
  height: 10px; background: #e5e7eb; border-radius: 999px;
  overflow: hidden; margin-bottom: 20px;
}
.lesson .progress > div {
  height: 100%; background: linear-gradient(90deg, var(--bleu), var(--rouge));
  transition: width .3s;
}

/* BUTTONS — min 44px tall for touch */
.btn {
  background: var(--bleu);
  color: white;
  border: none;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .1s;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.btn:hover { background: #003d7a; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--cream); color: var(--bleu); border: 2px solid var(--bleu); }
.btn.success { background: var(--good); }
.btn.danger { background: var(--bad); }
.btn.ghost { background: transparent; color: var(--bleu); border: 2px solid var(--bleu); }
.btn.big { padding: 14px 26px; font-size: 16px; min-height: 48px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.spacer { height: 16px; }

/* FLASHCARD */
.flashcard {
  perspective: 1200px;
  height: 280px;
  margin: 20px auto;
  max-width: 480px;
  width: 100%;
  cursor: pointer;
}
.flashcard .inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .6s;
  transform-style: preserve-3d;
}
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0;
  background: var(--card);
  border: 3px solid var(--bleu);
  border-radius: var(--radius);
  display: grid; place-items: center;
  text-align: center;
  padding: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.flashcard .face.back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--cream), #fff);
  border-color: var(--rouge);
}
.flashcard .word { font-family: 'Fredoka', sans-serif; font-size: 34px; color: var(--bleu); word-break: break-word; }
.flashcard .emoji { font-size: 52px; margin-bottom: 10px; }
.flashcard .ipa { color: var(--mute); margin-top: 6px; font-size: 15px; }
.flashcard .translation { font-size: 26px; color: var(--ink); word-break: break-word; }
.flashcard .example { color: var(--mute); font-style: italic; margin-top: 10px; font-size: 14px; }

.srs-controls { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.srs-controls .btn { min-width: 90px; flex: 1; max-width: 130px; }

/* QUIZ */
.q-prompt { font-size: 20px; margin-bottom: 16px; font-family: 'Fredoka', sans-serif; line-height: 1.4; }
.q-prompt b { color: var(--bleu); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.option {
  background: var(--cream);
  border: 2px solid #e5e7eb;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: border-color .15s, transform .1s;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.option:hover { border-color: var(--bleu); }
.option:active { transform: scale(.98); }
.option.correct { background: #dcfce7; border-color: var(--good); color: var(--good); }
.option.wrong { background: #fee2e2; border-color: var(--bad); color: var(--bad); }
.option.disabled { pointer-events: none; }

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
}
.feedback.good { background: #dcfce7; color: var(--good); }
.feedback.bad { background: #fee2e2; color: var(--bad); }
.feedback small { display: block; font-weight: 400; margin-top: 6px; color: var(--ink); }

/* INPUTS — font-size 16px to prevent iOS auto-zoom */
.input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  color: var(--ink);
  background: white;
}
.input:focus { outline: none; border-color: var(--bleu); }

textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }

/* GAMES */
.dnd-zone {
  min-height: 80px;
  border: 3px dashed var(--mute);
  border-radius: 12px;
  padding: 14px;
  background: #fafafa;
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: flex-start;
  align-content: flex-start;
}
.dnd-zone.over { border-color: var(--bleu); background: #eff6ff; }
.dnd-zone h4 { width: 100%; color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.token {
  background: var(--blanc);
  border: 2px solid var(--bleu);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  font-size: 15px;
}
.token.fem { border-color: var(--rouge); }
.token:active { transform: scale(.95); }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}
.mem-card {
  aspect-ratio: 1;
  background: var(--bleu);
  border-radius: 12px;
  display: grid; place-items: center;
  cursor: pointer;
  color: white;
  font-weight: 800;
  font-size: 15px;
  transition: background .2s, transform .1s;
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
  padding: 6px;
  word-break: break-word;
  line-height: 1.2;
}
.mem-card.flipped { background: var(--cream); color: var(--bleu); }
.mem-card.matched { background: var(--good); color: white; opacity: .7; cursor: default; }
.mem-card:active:not(.matched) { transform: scale(.97); }

/* GRAMMAR */
.grammar-box {
  background: linear-gradient(135deg, #eff6ff, #fef2f2);
  border-left: 6px solid var(--bleu);
  padding: 18px 22px;
  border-radius: 12px;
  margin: 16px 0;
}
.grammar-box h3 { color: var(--bleu); margin-bottom: 8px; font-family: 'Fredoka', sans-serif; font-size: 18px; }
.grammar-box p { line-height: 1.7; margin-bottom: 8px; }
.grammar-box .example {
  background: white; padding: 10px 14px;
  border-radius: 8px; margin: 6px 0;
  font-family: 'Fredoka', sans-serif;
  color: var(--ink);
  word-break: break-word;
}
.grammar-box .example em { color: var(--bleu); font-style: normal; font-weight: 700; }
.conj-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.conj-table th { background: var(--bleu); color: white; padding: 10px; text-align: left; }
.conj-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
.conj-table td:first-child { font-weight: 700; color: var(--mute); }
.conj-table td:last-child { font-family: 'Fredoka', sans-serif; color: var(--bleu); font-size: 17px; }

/* SPEAK */
.mic-btn {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--rouge);
  border: none;
  color: white;
  font-size: 38px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.mic-btn:active { transform: scale(.95); }
.mic-btn.listening { animation: pulse 1s infinite; background: var(--bad); }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,65,53,.6); }
  50% { box-shadow: 0 0 0 20px rgba(239,65,53,0); }
}
.transcript {
  background: #f9fafb;
  padding: 14px;
  border-radius: 10px;
  margin-top: 14px;
  min-height: 50px;
  font-style: italic;
  word-break: break-word;
}

/* MISC */
.kbd {
  background: #1e293b; color: #f8fafc;
  padding: 2px 8px; border-radius: 4px;
  font-family: monospace; font-size: 13px;
}
.tag {
  display: inline-block;
  background: var(--cream);
  color: var(--bleu);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
  white-space: nowrap;
}
.tag.fem { background: #fee2e2; color: var(--rouge); }
.tag.masc { background: #dbeafe; color: var(--bleu); }
.tag.verb { background: #f3e8ff; color: var(--accent); }

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--mute);
}
.empty .big-icon { font-size: 60px; margin-bottom: 14px; }

/* --- MOBILE (under 900px: collapse nav into hamburger) --- */
@media (max-width: 900px) {
  .hamburger { display: flex; order: -1; }
  .topbar { gap: 10px; padding: 10px 16px; padding-top: calc(10px + var(--safe-top)); }
  .brand-name { display: none; }
  .brand { font-size: 22px; }
  .logo { font-size: 32px; }

  .nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80vw;
    max-width: 320px;
    background: white;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 80px 16px 24px;
    padding-left: calc(16px + var(--safe-left));
    padding-top: calc(80px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    overflow-y: auto;
  }
  .nav.open { transform: translateX(0); }
  .nav a {
    padding: 14px 16px;
    font-size: 16px;
    border-radius: 10px;
    width: 100%;
    min-height: 48px;
  }

  .stats {
    margin-left: auto;
    gap: 6px;
  }
  .stat {
    font-size: 12px;
    padding: 5px 10px;
    min-height: 32px;
  }

  main { padding: 16px; padding-left: calc(16px + var(--safe-left)); padding-right: calc(16px + var(--safe-right)); padding-bottom: calc(16px + var(--safe-bottom)); }

  .hero { padding: 22px; border-radius: 14px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }

  .grid { gap: 12px; grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 14px; }
  .card .icon { font-size: 32px; }
  .card h3 { font-size: 17px; }
  .card p { font-size: 13.5px; }

  .lesson { padding: 18px; border-radius: 14px; min-height: 360px; }
  .lesson h2 { font-size: 21px; }

  .q-prompt { font-size: 18px; }
  .options { grid-template-columns: 1fr; }
  .option { padding: 16px; font-size: 16px; }

  .flashcard { height: 260px; }
  .flashcard .word { font-size: 28px; }
  .flashcard .emoji { font-size: 44px; }
  .flashcard .translation { font-size: 22px; }

  .path-node { padding: 12px; gap: 10px; }
  .path-node .num { width: 38px; height: 38px; font-size: 14px; }
  .path-node .info h4 { font-size: 15px; }
  .path-node .info p { font-size: 12.5px; }
  .path-node .badge { display: none; }

  .memory-grid { grid-template-columns: repeat(3, 1fr); }
  .mem-card { font-size: 13px; }

  .grammar-box { padding: 14px 16px; }
  .grammar-box h3 { font-size: 16px; }
  .grammar-box p { font-size: 14.5px; }

  .conj-table { font-size: 14px; }
  .conj-table th, .conj-table td { padding: 8px; }

  .btn { padding: 12px 18px; font-size: 14.5px; }
  .btn.big { padding: 14px 22px; font-size: 15.5px; }

  .mic-btn { width: 88px; height: 88px; font-size: 34px; }
}

/* --- TINY MOBILE (under 380px) --- */
@media (max-width: 380px) {
  .topbar { padding: 8px 12px; gap: 6px; }
  .stats { gap: 4px; }
  .stat { font-size: 11px; padding: 4px 8px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14px; }
  .flashcard .word { font-size: 24px; }
  .flashcard .translation { font-size: 20px; }
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
  .nav { width: 86vw; }
}

/* Landscape phone — reduce vertical padding */
@media (max-width: 900px) and (orientation: landscape) {
  .hero { padding: 16px; }
  .hero h1 { font-size: 22px; margin-bottom: 4px; }
  .hero p { font-size: 13px; }
  .flashcard { height: 200px; }
}

/* Print: hide nav, save ink */
@media print {
  .topbar, .footer, .nav-backdrop { display: none; }
  main { max-width: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============ TOASTS ============ */
#toast-host {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  max-width: 92vw;
}
.toast {
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .22s, transform .22s;
  text-align: center;
  pointer-events: auto;
  max-width: 100%;
}
.toast.toast-in { opacity: 1; transform: translateY(0); }
.toast.toast-out { opacity: 0; transform: translateY(-10px); }
.toast.toast-good { background: var(--good); }
.toast.toast-bad { background: var(--bad); }
.toast.toast-warn { background: var(--warn); color: var(--ink); }

/* ============ LOADING SKELETON ============ */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ============ FOCUS-VISIBLE ============ */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--bleu);
  outline-offset: 2px;
  border-radius: 6px;
}
.btn:focus-visible, .option:focus-visible, .token:focus-visible {
  outline-offset: 3px;
}

/* ============ DARK MODE ============ */
body.dark {
  --bleu: #4d8bd5;
  --rouge: #ef6655;
  --cream: #1e293b;
  --ink: #e2e8f0;
  --mute: #94a3b8;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #fbbf24;
  --card: #1e293b;
  --bg: #0f172a;
  --shadow: 0 6px 24px rgba(0,0,0,.4);
}
body.dark { background-image: radial-gradient(circle at 10% 20%, rgba(77,139,213,.08) 0, transparent 40%), radial-gradient(circle at 90% 80%, rgba(239,102,85,.08) 0, transparent 40%); }
body.dark .topbar { background: #1e293b; border-bottom-color: #4d8bd5; }
body.dark .nav a { color: #e2e8f0; }
body.dark .stat { background: #0f172a; }
body.dark .card { background: #1e293b; color: #e2e8f0; }
body.dark .card h3 { color: #4d8bd5; }
body.dark .input { background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.dark .input:focus { border-color: #4d8bd5; }
body.dark .option { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .option:hover { border-color: #4d8bd5; }
body.dark .grammar-box { background: linear-gradient(135deg, #1e293b, #1c1f2e); }
body.dark .grammar-box .example { background: #0f172a; color: #e2e8f0; }
body.dark .conj-table { background: #1e293b; }
body.dark .conj-table td { border-bottom-color: #334155; }
body.dark .path-node { background: #1e293b; color: #e2e8f0; }
body.dark .path-node .info h4 { color: #e2e8f0; }
body.dark .path-node.done { background: #14532d; }
body.dark .flashcard .face { background: #1e293b; }
body.dark .flashcard .face.back { background: linear-gradient(135deg, #1e293b, #1c1f2e); }
body.dark .nav { background: #1e293b; }
body.dark .hamburger { border-color: #4d8bd5; }
body.dark .hamburger span { background: #4d8bd5; }
body.dark .toast { background: #0f172a; }
body.dark .mem-card { background: #1e293b; }
body.dark .mem-card.flipped { background: #4d8bd5; color: white; }

/* ============ STICKY MOBILE NEXT BUTTON ============ */
@media (max-width: 900px) {
  .lesson .sticky-next {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--card) 60%, rgba(255,255,255,0));
    padding: 12px 0;
    margin: 0 -18px -18px;
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: calc(12px + var(--safe-bottom));
  }
  body.dark .lesson .sticky-next {
    background: linear-gradient(to top, var(--card) 60%, rgba(30,41,59,0));
  }
}

/* ============ WORD POPUP ============ */
#wordpop {
  position: absolute;
  background: var(--card);
  border: 2px solid var(--bleu);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  width: 280px;
  max-width: calc(100vw - 24px);
  z-index: 200;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s, transform .15s;
  pointer-events: none;
}
#wordpop.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.wp-head { display: flex; align-items: center; gap: 8px; }
.wp-fr {
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  color: var(--bleu);
  font-weight: 700;
  flex: 1;
}
.wp-play, .wp-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--bleu);
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  -webkit-appearance: none;
  appearance: none;
}
.wp-close { background: transparent; color: var(--mute); border-color: #e5e7eb; font-size: 18px; }
.wp-en { color: var(--ink); margin-top: 6px; font-size: 15px; }

body.dark #wordpop { background: #1e293b; }
body.dark .wp-play, body.dark .wp-close { background: #0f172a; color: #e2e8f0; }

/* ============ DIALOGUE LINES ============ */
.dialogue-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 10px 0;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 10px;
  transition: background .2s, transform .2s;
}
.dialogue-line.active {
  background: #fef3c7;
  transform: scale(1.02);
  box-shadow: var(--shadow);
}
.dl-speaker {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.dl-A { background: #dbeafe; color: var(--bleu); }
.dl-B { background: #fee2e2; color: var(--rouge); }
.dl-NARR { background: #f3e8ff; color: var(--accent); }
.dl-text { flex: 1; line-height: 1.5; word-break: break-word; }
body.dark .dialogue-line { background: #0f172a; }
body.dark .dialogue-line.active { background: #1e293b; border: 1px solid var(--bleu); }


/* ============ READING PLAYER + SENTENCE HIGHLIGHT ============ */
.reading-text .r-sent {
  display: inline;
  transition: background .25s;
  border-radius: 4px;
  padding: 2px 0;
}
.reading-text .r-sent.active {
  background: #fcd34d;
  padding: 2px 4px;
  box-shadow: 0 0 0 2px #fcd34d;
}
body.dark .reading-text .r-sent.active {
  background: #f59e0b;
  color: #0f172a;
}
.reading-player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--cream);
  border: 2px solid var(--bleu);
  border-radius: 12px;
  flex-wrap: wrap;
}
body.dark .reading-player { background: #0f172a; }
