/* ---------- Espace élève : design joyeux, lisible, gros boutons ---------- */
:root {
  --bg: #f4f7ff;
  --card: #ffffff;
  --ink: #1f2544;
  --muted: #6b7290;
  --primary: #4f6df5;
  --primary-dark: #3b55d6;
  --accent: #ff8a5b;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --line: #e4e8f5;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(31, 37, 68, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: linear-gradient(160deg, #eef3ff 0%, #fdf5ef 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 2rem; font-weight: 900; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 800; }
p { margin: 0 0 12px; }
strong { font-weight: 800; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Cartes & boutons ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
  animation: pop .25s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; padding: 14px 26px; border: 0; border-radius: 18px;
  font: inherit; font-size: 1.15rem; font-weight: 800; color: #fff;
  background: var(--primary); cursor: pointer; width: 100%;
  box-shadow: 0 6px 0 var(--primary-dark);
  transition: transform .08s, box-shadow .08s, filter .15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn:disabled { filter: grayscale(.5) opacity(.55); cursor: not-allowed; transform: none; }
.btn-accent { background: var(--accent); box-shadow: 0 6px 0 #d96b3f; }
.btn-accent:active { box-shadow: 0 2px 0 #d96b3f; }
.btn-success { background: var(--success); box-shadow: 0 6px 0 #16a34a; }
.btn-success:active { box-shadow: 0 2px 0 #16a34a; }
.btn-ghost { background: transparent; color: var(--primary); box-shadow: none; min-height: 48px; font-size: 1rem; }
.btn-ghost:active { transform: none; box-shadow: none; }
.btn-done { background: #e6f9ee; color: #15803d; box-shadow: none; cursor: default; }
.btn-done:active { transform: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 800; margin-bottom: 8px; }
.input {
  width: 100%; min-height: 60px; padding: 12px 18px; font: inherit; font-size: 1.3rem; font-weight: 700;
  border: 3px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,109,245,.15); }
.input-initial { width: 96px; text-align: center; text-transform: uppercase; font-size: 1.8rem; }
textarea.input { min-height: 96px; resize: vertical; font-size: 1.15rem; line-height: 1.4; }
.error {
  background: #fef2f2; color: #b91c1c; border: 2px solid #fecaca; border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-weight: 700;
}

/* ---------- Accueil ---------- */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.hello h1 { margin: 0; }
.hw-card { border-top: 8px solid var(--primary); }
.hw-card.is-done { border-top-color: var(--success); }
.hw-card.is-progress { border-top-color: var(--warning); }
.hw-card h2 { font-size: 1.7rem; }
.subjects { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.subjects li { background: #f5f7ff; border-radius: 12px; padding: 10px 14px; font-weight: 700; }
.subjects li span { font-size: 1.3rem; margin-right: 6px; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .9rem; font-weight: 800; }
.badge-done { background: #e6f9ee; color: #15803d; }
.badge-progress { background: #fff4e0; color: #b45309; }

/* ---------- Progression ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.steps { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.step {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  background: #e9edfb; color: var(--muted); font-size: .85rem; font-weight: 800; white-space: nowrap;
}
.step .lbl { display: none; }
.step.done { background: #dcfce7; color: #15803d; }
.step.current { background: var(--primary); color: #fff; }
.step.current .lbl { display: inline; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.section-head .icon { font-size: 2rem; }
.section-head .lbl { color: var(--muted); font-weight: 800; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Leçon ---------- */
.lesson h2 { font-size: 1.7rem; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; margin: 0 0 18px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-title { font-size: .95rem; color: var(--muted); margin: -10px 0 18px; }
.block { margin-bottom: 20px; }
.block h3 { margin-bottom: 8px; }
.block ul { margin: 0; padding-left: 22px; }
.block li { margin-bottom: 6px; }
.examples { background: #f5f7ff; border-radius: 16px; padding: 16px 18px; }
.examples ul { list-style: none; padding: 0; }
.examples li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.examples li:last-child { border-bottom: 0; }
.remember { background: #fff7ed; border-left: 6px solid var(--accent); border-radius: 16px; padding: 16px 18px; }
.remember h3 { color: #c2410c; }
.reading { background: #fffdf5; border: 2px solid #fde68a; border-radius: 16px; padding: 18px 20px; font-size: 1.2rem; line-height: 1.7; }
.reading p:last-child { margin-bottom: 0; }
.num-table { width: 100%; border-collapse: separate; border-spacing: 6px; text-align: center; font-weight: 800; }
.num-table th { background: #e9edfb; border-radius: 10px; padding: 8px; font-size: .9rem; color: var(--primary-dark); }
.num-table td { background: #fff7ed; border-radius: 10px; padding: 12px; font-size: 1.8rem; }
.caption { text-align: center; color: var(--muted); font-weight: 700; margin-top: 6px; }
.block img { max-width: 100%; border-radius: 16px; }

/* ---------- Questions ---------- */
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.q-count { font-weight: 900; color: var(--primary); font-size: 1.05rem; }
.q-bar { height: 10px; background: #e9edfb; border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.q-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), #8b9cff); border-radius: 999px; transition: width .3s; }
.q-prompt { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; }
.q-prompt.big { font-size: 3rem; text-align: center; margin: 10px 0 24px; }
.options { display: grid; gap: 12px; margin-bottom: 20px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; min-height: 64px; padding: 14px 18px;
  border: 3px solid var(--line); border-radius: 18px; background: #fff; font: inherit; font-size: 1.15rem; font-weight: 700;
  color: var(--ink); cursor: pointer; transition: border-color .12s, background .12s, transform .08s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.opt:active { transform: scale(.985); }
.opt .box {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #c5cbe6; display: inline-flex;
  align-items: center; justify-content: center; font-size: 1rem; color: #fff; background: #fff;
}
.opt.square .box { border-radius: 9px; }
.opt.selected { border-color: var(--primary); background: #eef2ff; }
.opt.selected .box { background: var(--primary); border-color: var(--primary); }
.tf { grid-template-columns: 1fr 1fr; }
.tf .opt { justify-content: center; font-size: 1.4rem; min-height: 90px; }
.tf .opt .box { display: none; }
.tf .opt.selected.vrai { border-color: var(--success); background: #e6f9ee; }
.tf .opt.selected.faux { border-color: var(--danger); background: #fef2f2; }
.input-number { font-size: 2rem; text-align: center; }
.hint { background: #fff7ed; border-radius: 14px; padding: 12px 16px; margin-bottom: 18px; }
.hint strong { color: #c2410c; }
.hint ul { margin: 6px 0 0; padding-left: 20px; }
.context { margin-bottom: 18px; }
.context summary { cursor: pointer; font-weight: 800; color: var(--primary); padding: 10px 0; list-style: none; }
.context summary::before { content: '▸ '; }
.context[open] summary::before { content: '▾ '; }
.context .reading { font-size: 1.05rem; }
.saving { opacity: .6; pointer-events: none; }

/* ---------- Chrono ---------- */
.timer { font-variant-numeric: tabular-nums; font-weight: 900; font-size: 1.4rem; background: #eef2ff; color: var(--primary-dark); padding: 6px 14px; border-radius: 999px; }
.timer.urgent { background: #fef2f2; color: var(--danger); animation: pulse .6s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.timer-intro { position: relative; overflow: hidden; }
.blur-bg { position: absolute; inset: 0; padding: 24px; filter: blur(9px); opacity: .45; pointer-events: none; user-select: none; }
.blur-bg .fake { height: 54px; border-radius: 14px; background: #dfe5ff; margin-bottom: 12px; }
.timer-intro .front { position: relative; }
.overlay {
  position: fixed; inset: 0; background: rgba(31,37,68,.75); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 24px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay .card { text-align: center; max-width: 420px; width: 100%; }
.overlay h2 { font-size: 2.2rem; }

/* ---------- Résultat ---------- */
.result-hero { text-align: center; padding: 32px 24px; }
.result-hero .emoji { font-size: 4rem; line-height: 1; margin-bottom: 8px; animation: bounce 1s ease-out; }
@keyframes bounce { 0% { transform: scale(.4); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.note { display: inline-block; margin: 12px 0; padding: 14px 32px; border-radius: 999px; background: #eef2ff; color: var(--primary-dark); font-size: 2.2rem; font-weight: 900; }
.corr-section { margin-top: 20px; }
.corr-section h3 { display: flex; align-items: center; gap: 8px; }
.corr-ex { color: var(--muted); font-weight: 800; margin: 12px 0 8px; display: flex; justify-content: space-between; }
.corr {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; font-size: 1rem;
}
.corr.ok { border-color: #bbf7d0; background: #f0fdf4; }
.corr.ko { border-color: #fecaca; background: #fef2f2; }
.corr .q { font-weight: 800; margin-bottom: 4px; white-space: pre-wrap; }
.corr .r { margin: 2px 0; }
.corr .r span { color: var(--muted); font-weight: 700; }
.corr .expl { margin-top: 6px; color: #475569; font-style: italic; }
.corr pre { white-space: pre-wrap; font: inherit; margin: 0; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .card { padding: 18px; border-radius: 18px; }
  h1 { font-size: 1.6rem; }
  .q-prompt { font-size: 1.25rem; }
  .q-prompt.big { font-size: 2.4rem; }
  .tf .opt { min-height: 76px; }
}
