/* ============================================================
   ENGLISH BEPC ORAL MASTER — design system
   Mobile-first, moderne, motivant, adapté aux adolescents.
   ============================================================ */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --accent: #f97316;
  --accent-soft: #fff7ed;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --err: #ef4444;
  --err-soft: #fef2f2;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --gold: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 14px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
h1,h2,h3,h4 { line-height: 1.2; margin: 0 0 .35em; }
p { margin: 0 0 .8em; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(120deg, #4338ca, #6d28d9 60%, #7c3aed);
  color: #fff;
  box-shadow: 0 2px 10px rgba(67,56,202,.35);
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; margin-right: auto; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.16);
  display: grid; place-items: center; font-size: 21px;
  backdrop-filter: blur(4px);
}
.brand-name { font-weight: 800; font-size: 14.5px; line-height: 1.05; letter-spacing: .2px; }
.brand-name small { font-weight: 700; font-size: 10px; opacity: .85; letter-spacing: 1.6px; }
#topnav { display: none; gap: 2px; }
#topnav a {
  color: rgba(255,255,255,.92); font-weight: 600; font-size: 14.5px;
  padding: 8px 12px; border-radius: 10px;
}
#topnav a:hover { background: rgba(255,255,255,.12); }
#topnav a.active { background: rgba(255,255,255,.2); }
.top-actions { display: flex; align-items: center; gap: 8px; }
@media (min-width: 920px) {
  #topnav { display: flex; }
  body { padding-bottom: 0; }
}

/* ---------- bottom nav (mobile) ---------- */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 18px rgba(15,23,42,.07);
}
#bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 7px; color: var(--muted); font-size: 10.5px; font-weight: 700;
}
#bottomnav a .ico { font-size: 20px; line-height: 1; }
#bottomnav a.active { color: var(--brand); }
@media (min-width: 920px) { #bottomnav { display: none; } }

/* ---------- layout ---------- */
#app { max-width: 1080px; margin: 0 auto; padding: 14px 14px 34px; }
#app:focus { outline: none; }
@media (min-width: 920px) { #app { padding: 26px 22px 60px; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 400px) {
  .grid-2 { grid-template-columns: 1fr; }
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mt2 { margin-top: 26px; }
.hidden { display: none !important; }

/* ---------- components ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(226,232,240,.7);
  padding: 16px;
}
.card.pad-lg { padding: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; border-radius: 12px;
  padding: 11px 18px; font-weight: 700; font-size: 15px;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
  text-align: center; color: #fff; background: var(--brand);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(120deg, var(--brand), var(--brand-2)); box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.btn.accent { background: linear-gradient(120deg, #f97316, #ef4444); box-shadow: 0 4px 14px rgba(249,115,22,.35); }
.btn.ok { background: linear-gradient(120deg, #10b981, #059669); }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ghost-dark { background: rgba(255,255,255,.14); color: #fff; border: 1.5px solid rgba(255,255,255,.4); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--err-soft); color: var(--err); }
.btn.sm { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.lg { padding: 15px 26px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon-btn {
  padding: 8px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
  min-width: 38px; min-height: 38px;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand);
}
.chip.ok { background: var(--ok-soft); color: #059669; }
.chip.warn { background: var(--warn-soft); color: #b45309; }
.chip.err { background: var(--err-soft); color: #dc2626; }
.chip.gold { background: #fef3c7; color: #b45309; }

.hero {
  border-radius: 22px; padding: 26px 20px; color: #fff;
  background:
    radial-gradient(1200px 400px at 110% -20%, rgba(249,115,22,.55), transparent 60%),
    radial-gradient(900px 420px at -20% 120%, rgba(16,185,129,.4), transparent 60%),
    linear-gradient(125deg, #312e81, #4f46e5 45%, #7c3aed);
  box-shadow: 0 14px 40px rgba(67,56,202,.35);
  position: relative; overflow: hidden;
}
.hero h1 { font-size: clamp(26px, 5.4vw, 40px); font-weight: 900; letter-spacing: -.5px; margin-bottom: 6px; }
.hero .tagline { font-size: 15.5px; opacity: .92; font-weight: 600; }
.hero .cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero .mini-stats { display: flex; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.hero .mini-stats .st { text-align: left; }
.hero .mini-stats .st b { display: block; font-size: 22px; }
.hero .mini-stats .st span { font-size: 12px; opacity: .85; }

.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 12px; font-size: 20px; font-weight: 800; }
.section-title .emoji { font-size: 22px; }

/* lesson cards */
.lesson-card {
  position: relative; overflow: hidden; cursor: pointer;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(226,232,240,.7);
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.lesson-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.lesson-card .thumb {
  height: 104px; background-size: cover; background-position: center;
  display: flex; align-items: flex-end; padding: 8px;
}
.lesson-card .thumb .num {
  background: rgba(15,23,42,.72); color: #fff; font-weight: 800; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; backdrop-filter: blur(3px);
}
.lesson-card .body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.lesson-card h3 { font-size: 15px; margin: 0; line-height: 1.25; }
.lesson-card .sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.lesson-card.locked .thumb { filter: grayscale(.35) brightness(.88); }
.lesson-card.locked .lock-veil {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(15,23,42,.28); color: #fff; font-size: 30px;
}
.lesson-card.locked .lock-veil span { background: rgba(15,23,42,.75); border-radius: 999px; padding: 10px 16px; font-size: 13px; font-weight: 800; display: flex; gap: 7px; align-items: center; }
.lesson-card.done::after {
  content: "✓"; position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%; background: var(--ok);
  color: #fff; font-weight: 900; display: grid; place-items: center; font-size: 15px;
  box-shadow: 0 2px 8px rgba(16,185,129,.5);
}

/* speak buttons */
.speak {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; cursor: pointer; background: var(--brand-soft); color: var(--brand);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 700;
}
.speak:hover { background: #e0e7ff; }
.speak.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 8px; }
.speak.playing { background: var(--brand); color: #fff; }

/* vocab / word rows */
.word-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  margin-bottom: 8px;
}
.word-row .en { font-weight: 700; flex: 1; }
.word-row .fr { color: var(--muted); font-size: 14px; text-align: right; }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  white-space: nowrap; border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* flashcards */
.flash {
  position: relative; min-height: 210px; perspective: 900px; cursor: pointer; margin-bottom: 12px;
}
.flash .face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 18px; border-radius: 18px; background: #fff; border: 1.5px solid var(--line);
  box-shadow: var(--shadow); backface-visibility: hidden; transition: transform .5s;
}
.flash .back { transform: rotateY(180deg); background: var(--brand-soft); border-color: #c7d2fe; }
.flash.flipped .face.front { transform: rotateY(180deg); }
.flash.flipped .face.back { transform: rotateY(360deg); }
.flash .word { font-size: 24px; font-weight: 800; text-align: center; }
.flash .hint { color: var(--muted); font-size: 13px; }

/* progress bars */
.bar { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s ease; }
.bar.ok > i { background: linear-gradient(90deg, #10b981, #34d399); }
.bar.accent > i { background: linear-gradient(90deg, #f97316, #fb923c); }

/* timer ring */
.timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 0; }
.timer-ring { position: relative; width: 190px; height: 190px; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .track { stroke: #e2e8f0; }
.timer-ring .fill { stroke: var(--brand); transition: stroke-dashoffset 1s linear; }
.timer-ring .fill.ok { stroke: #10b981; }
.timer-ring .fill.accent { stroke: #f97316; }
.timer-ring .time {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.timer-ring .time small { display: block; font-size: 12px; color: var(--muted); font-weight: 700; text-align: center; }

/* locked screen */
.lock-hero {
  text-align: center; padding: 34px 18px; border-radius: 22px;
  background: linear-gradient(140deg, #312e81, #6d28d9);
  color: #fff; box-shadow: var(--shadow-lg);
}
.lock-hero .lock-ico { font-size: 46px; display: block; margin-bottom: 8px; }
.lock-hero h2 { font-size: 24px; font-weight: 900; }
.lock-hero ul { text-align: left; max-width: 420px; margin: 14px auto; padding-left: 22px; opacity: .95; }

/* exercises */
.quiz-q { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.quiz-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: #fff; border: 1.5px solid var(--line); border-radius: 13px;
  padding: 13px 15px; font-size: 15.5px; font-weight: 600; cursor: pointer; margin-bottom: 9px;
  transition: border-color .15s, background .15s;
}
.quiz-opt:hover { border-color: #c7d2fe; }
.quiz-opt .letter { width: 28px; height: 28px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.quiz-opt.correct { border-color: #34d399; background: var(--ok-soft); }
.quiz-opt.wrong { border-color: #fca5a5; background: var(--err-soft); }
.quiz-opt.correct .letter { background: var(--ok); color: #fff; }
.quiz-opt.wrong .letter { background: var(--err); color: #fff; }

/* reveal */
.reveal-box { border: 1.5px dashed #c7d2fe; background: var(--brand-soft); border-radius: 13px; padding: 14px; }
.reveal-box .answer { display: none; margin-top: 10px; background: #fff; border-radius: 10px; padding: 12px; }
.reveal-box.open .answer { display: block; }

/* dialogue */
.dialogue-line { display: flex; gap: 10px; margin-bottom: 10px; }
.dialogue-line .who {
  flex: none; width: 74px; font-weight: 800; font-size: 11.5px; text-align: right;
  color: var(--muted); padding-top: 9px;
}
.dialogue-line .bubble {
  flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 13px; position: relative;
}
.dialogue-line.me .bubble { background: var(--brand-soft); border-color: #c7d2fe; }

/* toasts */
#toast-root { position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 480px); pointer-events: none; }
@media (min-width: 920px) { #toast-root { bottom: 26px; } }
.toast {
  background: #0f172a; color: #fff; border-radius: 12px; padding: 11px 18px;
  font-size: 14.5px; font-weight: 600; box-shadow: 0 8px 30px rgba(15,23,42,.35);
  animation: toastIn .25s ease; max-width: 100%;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* modal */
#modal-root:empty { display: none; }
#modal-root {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center;
  background: rgba(15,23,42,.55); padding: 18px;
}
.modal {
  background: #fff; border-radius: 20px; max-width: 520px; width: 100%;
  max-height: 88vh; overflow: auto; padding: 22px; box-shadow: var(--shadow-lg);
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 19px; font-weight: 900; margin-bottom: 12px; }

/* forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 5px; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 11px 13px; font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.14);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-error { background: var(--err-soft); color: #b91c1c; border-radius: 10px; padding: 10px 13px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* steps (mock exam) */
.steps { display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.step {
  display: flex; gap: 13px; align-items: flex-start; background: #fff;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 13px 15px;
}
.step .n {
  flex: none; width: 34px; height: 34px; border-radius: 11px; background: var(--brand-soft);
  color: var(--brand); font-weight: 900; display: grid; place-items: center;
}
.step.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.step.done .n { background: var(--ok); color: #fff; }

/* stat tiles */
.stat-tile { background: #fff; border-radius: 14px; border: 1px solid var(--line); padding: 14px; }
.stat-tile b { display: block; font-size: 26px; font-weight: 900; }
.stat-tile span { font-size: 12.5px; color: var(--muted); font-weight: 700; }

/* tables (admin) */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 2px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: #f8fafc; }

/* question card (subject practice) */
.q-item {
  background: #fff; border: 1px solid var(--line); border-radius: 13px;
  padding: 13px 15px; margin-bottom: 10px;
}
.q-item .q { font-weight: 700; margin-bottom: 8px; }

/* exercise option shuffle animation */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* helpers */
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.sticky-sub { position: sticky; top: 66px; z-index: 20; }
@media (max-width: 600px) { .sticky-sub { top: 62px; } }
.pill-label { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.quote {
  border-left: 4px solid var(--brand); background: var(--brand-soft);
  border-radius: 0 12px 12px 0; padding: 12px 15px; margin: 10px 0;
  font-style: italic;
}
