/* ============================================================
   Kɔɔnzime — apprentissage du nzime (kɔɔnzime)
   Design system inspiré Duolingo — vanilla CSS, mobile-first
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --green: #58cc02;
  --green-hi: #61e002;
  --green-sh: #58a700;
  --green-pale: #d7ffb8;
  --green-ink: #58a700;
  --red: #ff4b4b;
  --red-sh: #ea2b2b;
  --red-pale: #ffdfe0;
  --blue: #1cb0f6;
  --blue-sh: #1899d6;
  --blue-pale: #ddf4ff;
  --gold: #ffc800;
  --gold-sh: #e6a800;
  --orange: #ff9600;
  --purple: #ce82ff;
  --ink: #3c3c3c;
  --gray: #afafaf;
  --gray-soft: #f7f7f7;
  --bg: #ffffff;
  --line: #e5e5e5;
  --radius: 16px;
  --radius-sm: 12px;
  --font: -apple-system, 'Segoe UI', Roboto, sans-serif;
  --maxw: 560px;
  --tabbar-h: 66px;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { cursor: default; }
img, svg { display: block; }
input, select { font-family: inherit; font-size: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#view { padding-bottom: calc(var(--tabbar-h) + 24px); }
body.in-lesson #view { padding-bottom: 0; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Boutons « 3D » Duolingo ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 15px; letter-spacing: .8px; text-transform: uppercase;
  border-radius: var(--radius-sm);
  padding: 13px 24px;
  border-bottom: 4px solid transparent;
  transition: filter .15s, transform .05s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 1px; margin-bottom: 3px; }
.btn:disabled { background: var(--line) !important; border-bottom-color: var(--line) !important; color: var(--gray) !important; box-shadow: none; }

.btn-primary { background: var(--green); border-bottom-color: var(--green-sh); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-hi); }
.btn-blue { background: var(--blue); border-bottom-color: var(--blue-sh); color: #fff; }
.btn-blue:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger { background: var(--red); border-bottom-color: var(--red-sh); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost {
  background: #fff; color: var(--blue);
  border: 2px solid var(--line); border-bottom-width: 4px;
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-soft); }
.btn-sm { padding: 9px 16px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; min-height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(160deg, var(--green-hi), var(--green-sh));
  color: #fff; font-weight: 900; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 var(--green-sh);
}
.brand-name { font-size: 21px; font-weight: 900; color: var(--green); letter-spacing: .3px; }
.brand-sub {
  font-size: 11px; color: var(--gray); font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-stats { display: flex; gap: 14px; }
.top-stat { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 16px; }
.top-stat .ico { font-size: 19px; }
.top-stat.streak { color: var(--orange); }
.top-stat.xp { color: var(--gold-sh); }
.top-stat.streak.off { filter: grayscale(1); opacity: .55; }

.page-title { font-size: 22px; font-weight: 900; }
.page-head { padding: 18px 0 4px; }
.page-head .page-desc { color: var(--gray); font-weight: 600; font-size: 14px; margin-top: 2px; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; height: var(--tabbar-h);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; margin: 6px 4px;
  color: var(--gray); font-weight: 700; font-size: 11px;
  transition: background .15s;
}
.tab-btn .tab-ico { font-size: 24px; filter: grayscale(1); opacity: .7; transition: filter .15s, opacity .15s; }
.tab-btn .tab-lbl { letter-spacing: .4px; text-transform: uppercase; }
.tab-btn:hover { background: var(--gray-soft); }
.tab-btn.active { color: var(--blue); background: var(--blue-pale); }
.tab-btn.active .tab-ico { filter: none; opacity: 1; }
body.in-lesson .tabbar { display: none; }

/* ---------- Écran de chargement / erreur ---------- */
.boot {
  min-height: 78vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 24px;
}
.boot-logo {
  width: 84px; height: 84px; border-radius: 24px;
  background: linear-gradient(160deg, var(--green-hi), var(--green-sh));
  color: #fff; font-size: 38px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 var(--green-sh);
  animation: pop .4s ease;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-card {
  max-width: 460px; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 22px;
}
.err-card h2 { font-size: 19px; margin-bottom: 8px; }
.err-card p { color: var(--ink); font-size: 14.5px; margin-bottom: 10px; }
.err-card code, .err-card pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--gray-soft); border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px;
}
.err-card pre { padding: 12px 14px; overflow-x: auto; margin: 10px 0; line-height: 1.7; }
.err-card code { padding: 1px 6px; }
.err-detail { color: var(--gray); font-size: 12px; margin-top: 8px; word-break: break-all; }

/* ---------- Parcours ---------- */
.path { max-width: var(--maxw); margin: 0 auto; padding: 8px 16px 40px; }
.unit-block { margin-top: 26px; --uc: var(--green); }
.unit-block.locked { --uc: #d5d5d5; }

.unit-banner {
  display: flex; align-items: center; gap: 16px;
  background: var(--uc);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.unit-block.locked .unit-banner { color: #8a8a8a; box-shadow: 0 4px 0 rgba(0,0,0,.07); }
.unit-txt { flex: 1; min-width: 0; }
.unit-kicker { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; opacity: .85; }
.unit-title { font-size: 19px; font-weight: 900; line-height: 1.2; }
.unit-desc { font-size: 13px; opacity: .92; margin-top: 3px; font-weight: 600; }
.unit-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.unit-mini-btn {
  background: rgba(255,255,255,.22);
  border: 2px solid rgba(255,255,255,.55);
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .6px; text-transform: uppercase;
  border-radius: 10px; padding: 7px 12px;
  transition: background .15s;
  white-space: nowrap;
}
.unit-mini-btn:hover { background: rgba(255,255,255,.34); }
.unit-block.locked .unit-mini-btn { border-color: rgba(0,0,0,.12); color: #8a8a8a; }

/* nœud d'unité avec anneau SVG */
.unit-node {
  position: relative; width: 84px; height: 84px; flex: none;
  border-radius: 50%;
}
.unit-node .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.unit-node .ring-bg { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 7; }
.unit-block.locked .unit-node .ring-bg { stroke: rgba(0,0,0,.08); }
.unit-node .ring-fg {
  fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 257.6;
  transition: stroke-dashoffset .6s ease;
}
.unit-emoji {
  position: absolute; inset: 11px;
  background: rgba(255,255,255,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.unit-block.locked .unit-emoji { filter: grayscale(1); opacity: .6; background: rgba(0,0,0,.05); }

/* sentier de leçons */
.trail { display: flex; flex-direction: column; align-items: center; padding: 52px 0 6px; gap: 24px; }
.trail-step { position: relative; transition: transform .2s; }
.lesson-pill {
  position: relative;
  width: 62px; height: 58px;
  border-radius: 50% / 46%;
  font-size: 24px; font-weight: 900; color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: var(--uc);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--uc), #000 28%);
  transition: transform .06s, filter .15s;
}
.lesson-pill:hover:not(:disabled) { filter: brightness(1.05); }
.lesson-pill:active:not(.locked) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--uc), #000 28%); }
.lesson-pill.locked {
  background: #e5e5e5; color: #b5b5b5;
  box-shadow: 0 6px 0 #cfcfcf;
  font-size: 20px;
}
.lesson-pill.done { background: var(--gold); box-shadow: 0 6px 0 var(--gold-sh); }
.lesson-pill.done .pill-ico { text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.lesson-pill.current::after {
  content: ""; position: absolute; inset: -9px;
  border-radius: inherit;
  border: 4px solid color-mix(in srgb, var(--uc), transparent 45%);
  animation: halo 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes halo {
  0%   { transform: scale(.92); opacity: 1; }
  70%  { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}
.pill-tip {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--uc);
  border: 2px solid var(--line); border-radius: 10px;
  font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  padding: 6px 12px; white-space: nowrap;
  animation: bob 1.1s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 5;
}
.pill-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #fff;
  filter: drop-shadow(0 2px 0 var(--line));
}
@keyframes bob { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-6px); } }

.path-foot {
  margin-top: 44px; text-align: center; color: var(--gray);
  font-size: 13px; font-weight: 600;
}
.path-foot .flag { font-size: 22px; }

/* ---------- Écran leçon ---------- */
.lesson { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lesson-top {
  display: flex; align-items: center; gap: 14px;
  max-width: var(--maxw); width: 100%; margin: 0 auto;
  padding: 16px;
}
.quit-x {
  font-size: 22px; color: var(--gray); font-weight: 700;
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.quit-x:hover { background: var(--gray-soft); color: var(--ink); }
.lbar { flex: 1; height: 16px; background: var(--line); border-radius: 8px; overflow: hidden; }
.lbar-fill {
  height: 100%; width: 0%;
  background: var(--green); border-radius: 8px;
  transition: width .45s cubic-bezier(.3,1.2,.4,1);
  position: relative;
}
.lbar-fill::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px;
  border-radius: 2px; background: rgba(255,255,255,.35);
}
.hearts { display: flex; gap: 4px; font-size: 20px; flex: none; }
.heart { transition: transform .2s, filter .2s, opacity .2s; }
.heart.lost { filter: grayscale(1); opacity: .35; transform: scale(.82); }
.heart.pop { animation: heartpop .45s ease; }
@keyframes heartpop { 30% { transform: scale(1.45); } 60% { transform: scale(.7); } }

.ex-area {
  flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 8px 16px 170px;
  display: flex; flex-direction: column;
}
.ex-consigne { font-size: 21px; font-weight: 900; margin: 10px 0 18px; }
.prompt-card {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 22px;
  font-size: 26px; font-weight: 800; text-align: center;
  background: #fff;
}
.prompt-card.nz { color: var(--green-ink); }
.prompt-sub { text-align: center; color: var(--gray); font-weight: 600; font-size: 14px; margin: -12px 0 20px; }

.choices { display: flex; flex-direction: column; gap: 12px; }
.choice-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: 2px solid var(--line); border-bottom-width: 4px;
  border-radius: var(--radius-sm);
  background: #fff; padding: 14px 16px;
  font-size: 17px; font-weight: 700;
  transition: background .12s, border-color .12s, transform .05s;
}
.choice-btn:hover:not(:disabled) { background: var(--gray-soft); }
.choice-btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }
.choice-btn .key {
  flex: none; width: 28px; height: 28px;
  border: 2px solid var(--line); border-radius: 8px;
  color: var(--gray); font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.choice-btn.selected { border-color: var(--blue); background: var(--blue-pale); color: var(--blue-sh); }
.choice-btn.selected .key { border-color: var(--blue); color: var(--blue); }
.choice-btn.good { border-color: var(--green); background: var(--green-pale); color: var(--green-ink); }
.choice-btn.good .key { border-color: var(--green); color: var(--green-ink); }
.choice-btn.bad { border-color: var(--red); background: var(--red-pale); color: var(--red-sh); }
.choice-btn.bad .key { border-color: var(--red); color: var(--red); }
.choice-btn:disabled { opacity: .95; }

/* texte à trou */
.gap-sentence {
  font-size: 23px; font-weight: 800; text-align: center; line-height: 1.7;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 22px 18px; margin-bottom: 6px; color: var(--green-ink);
}
.gap-slot {
  display: inline-block; min-width: 86px;
  border-bottom: 3px solid var(--gray);
  color: var(--blue-sh); text-align: center; padding: 0 6px;
}
.gap-slot.empty { color: transparent; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.chip {
  border: 2px solid var(--line); border-bottom-width: 4px;
  border-radius: var(--radius-sm);
  background: #fff; padding: 10px 16px;
  font-size: 17px; font-weight: 700;
  transition: transform .05s, background .12s;
}
.chip:hover:not(:disabled):not(.used) { background: var(--gray-soft); }
.chip:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }
.chip.selected { border-color: var(--blue); background: var(--blue-pale); color: var(--blue-sh); }
.chip .key {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-right: 8px;
  border: 2px solid var(--line); border-radius: 6px;
  font-size: 11px; font-weight: 800; color: var(--gray); vertical-align: 1px;
}
.chip.selected .key { border-color: var(--blue); color: var(--blue); }
.chip.good { border-color: var(--green); background: var(--green-pale); color: var(--green-ink); }
.chip.good .key { border-color: var(--green); color: var(--green-ink); }
.chip.bad { border-color: var(--red); background: var(--red-pale); color: var(--red-sh); }
.chip.bad .key { border-color: var(--red); color: var(--red); }

/* banque de mots */
.bank-target-fr {
  font-size: 20px; font-weight: 800; text-align: center;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.answer-zone {
  min-height: 64px;
  border-top: 2px solid var(--line); border-bottom: 2px solid var(--line);
  padding: 10px 4px;
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  margin-bottom: 20px;
}
.answer-zone .chip { animation: pop .18s ease; }
.bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.bank .chip.used {
  background: var(--line); border-color: var(--line); color: transparent;
  box-shadow: none; pointer-events: none;
}
.nz-chip { color: var(--green-ink); }

/* paires */
.pairs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.pairs-col { display: flex; flex-direction: column; gap: 10px; }
.pair-btn {
  border: 2px solid var(--line); border-bottom-width: 4px;
  border-radius: var(--radius-sm);
  background: #fff; padding: 14px 10px;
  font-size: 16px; font-weight: 700; text-align: center;
  min-height: 56px;
  transition: background .12s, border-color .12s, opacity .2s;
}
.pair-btn:hover:not(:disabled) { background: var(--gray-soft); }
.pair-btn.selected { border-color: var(--blue); background: var(--blue-pale); color: var(--blue-sh); }
.pair-btn.matched {
  border-color: var(--line); background: var(--gray-soft);
  color: var(--gray); opacity: .6; pointer-events: none;
  animation: pop .25s ease;
}
.pair-btn.bad { border-color: var(--red); background: var(--red-pale); color: var(--red-sh); }
.pair-btn.nz { color: var(--green-ink); }
.pair-btn.nz.selected { color: var(--blue-sh); }

/* pied de leçon + feedback */
.lesson-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: #fff; border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.lesson-footer.ok { background: var(--green-pale); border-top-color: var(--green-pale); }
.lesson-footer.ko { background: var(--red-pale); border-top-color: var(--red-pale); }
.lf-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px 16px 18px;
}
.feedback { display: none; align-items: flex-start; gap: 12px; margin-bottom: 12px; animation: slideup .28s ease; }
.lesson-footer.ok .feedback, .lesson-footer.ko .feedback { display: flex; }
.fb-ico {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: #fff; font-size: 22px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.lesson-footer.ok .fb-ico { color: var(--green-ink); }
.lesson-footer.ko .fb-ico { color: var(--red); }
.fb-title { font-size: 19px; font-weight: 900; }
.lesson-footer.ok .fb-title { color: var(--green-ink); }
.lesson-footer.ko .fb-title { color: var(--red-sh); }
.fb-detail { font-size: 15px; font-weight: 600; margin-top: 2px; }
.lesson-footer.ko .fb-detail { color: var(--red-sh); }
.fb-detail .nz-answer { font-weight: 800; }
@keyframes slideup { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* fin de leçon / échec */
.result {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: 14px; padding: 24px 16px 40px;
  max-width: var(--maxw); margin: 0 auto; width: 100%;
}
.result .big-emoji { font-size: 74px; animation: pop .45s cubic-bezier(.3,1.6,.4,1); }
.result h2 { font-size: 26px; font-weight: 900; }
.result h2.gold { color: var(--gold-sh); }
.result h2.red { color: var(--red); }
.result .result-sub { color: var(--gray); font-weight: 600; max-width: 340px; }
.stat-boxes { display: flex; gap: 12px; margin: 14px 0 6px; }
.stat-box {
  border-radius: var(--radius); padding: 3px;
  min-width: 120px; overflow: hidden;
}
.stat-box .sb-label {
  font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  color: #fff; padding: 4px 0 6px;
}
.stat-box .sb-value {
  background: #fff; border-radius: 13px;
  font-size: 22px; font-weight: 900; padding: 12px 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.stat-box.gold { background: var(--gold); }
.stat-box.gold .sb-value { color: var(--gold-sh); }
.stat-box.green { background: var(--green); }
.stat-box.green .sb-value { color: var(--green-ink); }
.stat-box.blue { background: var(--blue); }
.stat-box.blue .sb-value { color: var(--blue-sh); }
.badge-pop {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--gold); background: #fffbe8;
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-weight: 800; color: var(--gold-sh);
  animation: pop .4s ease;
}
.badge-pop .bp-ico { font-size: 24px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin-top: 16px; }

/* ---------- Modal ---------- */
.modal-ov {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(60,60,60,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .18s ease;
}
.modal-ov.closing { animation: fadeoutov .18s ease forwards; }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeoutov { to { opacity: 0; } }
.modal {
  background: #fff; width: 100%; max-width: var(--maxw);
  max-height: 88vh; max-height: 88dvh;
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  animation: sheetup .28s cubic-bezier(.3,1.2,.4,1);
}
@keyframes sheetup { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 20px 12px; border-bottom: 2px solid var(--line);
}
.modal-title { font-size: 19px; font-weight: 900; }
.modal-x {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  font-size: 24px; line-height: 1; color: var(--gray);
  display: flex; align-items: center; justify-content: center;
}
.modal-x:hover { background: var(--gray-soft); color: var(--ink); }
.modal-body { overflow-y: auto; padding: 16px 20px; }
.modal-foot { padding: 12px 20px 20px; border-top: 2px solid var(--line); }

/* fiches de conseils (tips) */
.tip-card { margin-bottom: 22px; }
.tip-card:last-child { margin-bottom: 4px; }
.tip-card h3 { font-size: 17px; font-weight: 900; color: var(--blue-sh); margin-bottom: 6px; }
.tip-corps p { font-size: 15px; margin-bottom: 8px; }
.tip-corps strong { color: var(--green-ink); }
.tip-ex {
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  margin-top: 10px; overflow: hidden;
}
.tip-ex-row { display: flex; flex-direction: column; padding: 9px 14px; gap: 1px; }
.tip-ex-row + .tip-ex-row { border-top: 1px solid var(--line); }
.tip-ex-nz { font-weight: 800; color: var(--green-ink); font-size: 15.5px; }
.tip-ex-fr { color: var(--gray); font-size: 14px; font-weight: 600; }

/* ---------- Dictionnaire ---------- */
.dict-tools {
  position: sticky; top: 0; z-index: 40;
  background: #fff; padding: 10px 0 8px;
}
.search-box { position: relative; }
.search-box .lens { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 17px; opacity: .55; }
.search-input {
  width: 100%; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--gray-soft);
  padding: 13px 14px 13px 42px;
  font-size: 16px; font-weight: 600;
}
.search-input:focus { outline: none; border-color: var(--blue); background: #fff; }
.theme-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 6px;
  scrollbar-width: none;
}
.theme-row::-webkit-scrollbar { display: none; }
.theme-chip {
  flex: none; border: 2px solid var(--line); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-weight: 800; color: var(--gray);
  white-space: nowrap; transition: background .12s;
}
.theme-chip:hover { background: var(--gray-soft); }
.theme-chip.active { border-color: var(--blue); background: var(--blue-pale); color: var(--blue-sh); }
.dict-count { color: var(--gray); font-size: 13px; font-weight: 700; margin: 4px 0 10px; }
.dict-list { display: flex; flex-direction: column; gap: 10px; }
.dict-entry {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 13px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.de-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.de-nz { font-size: 19px; font-weight: 900; color: var(--green-ink); }
.de-pl { font-size: 13px; color: var(--gray); font-weight: 700; }
.de-fr { font-size: 15.5px; font-weight: 700; }
.de-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.de-pos {
  font-size: 11px; font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  color: var(--blue-sh); background: var(--blue-pale);
  border-radius: 6px; padding: 2px 8px;
}
.de-theme { font-size: 12px; color: var(--gray); font-weight: 700; }
.de-note { font-size: 13px; color: var(--gray); font-style: italic; margin-top: 3px; }
.empty-state { text-align: center; color: var(--gray); font-weight: 700; padding: 44px 0; }
.empty-state .es-ico { font-size: 44px; margin-bottom: 8px; filter: grayscale(.4); }

/* ---------- Grammaire ---------- */
.gram-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
details.gram-card, details.ref-card {
  border: 2px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
details.gram-card summary, details.ref-card summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px;
  font-weight: 800; font-size: 16px;
}
details summary::-webkit-details-marker { display: none; }
details.gram-card summary:hover, details.ref-card summary:hover { background: var(--gray-soft); }
.sum-ico {
  flex: none; width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--blue-pale);
}
.sum-arrow { margin-left: auto; color: var(--gray); font-size: 13px; transition: transform .2s; }
details[open] .sum-arrow { transform: rotate(180deg); }
.gram-tag {
  font-size: 10.5px; font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  color: var(--gray); border: 1.5px solid var(--line); border-radius: 6px; padding: 1px 7px;
}
.gram-body { padding: 2px 16px 16px; border-top: 2px solid var(--line); padding-top: 12px; }
.section-label {
  font-size: 13px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--gray); margin: 26px 0 10px;
}

/* références (listes.json) */
.alpha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.alpha-cell {
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 6px; text-align: center;
}
.alpha-letter { font-size: 22px; font-weight: 900; color: var(--green-ink); }
.alpha-ex { font-size: 12px; font-weight: 700; margin-top: 2px; }
.alpha-fr { font-size: 11px; color: var(--gray); font-weight: 600; }
.ref-table { width: 100%; border-collapse: collapse; }
.ref-table td { padding: 8px 10px; border-top: 1px solid var(--line); font-size: 14.5px; }
.ref-table tr:first-child td { border-top: none; }
.ref-table .rt-nz { font-weight: 800; color: var(--green-ink); }
.ref-table .rt-fr { color: var(--ink); font-weight: 600; }
.ref-table .rt-val { color: var(--gray); font-weight: 800; text-align: right; }

/* ---------- Profil ---------- */
.profile-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(150deg, var(--green-hi), var(--green-sh));
  border-radius: var(--radius); padding: 20px;
  color: #fff; margin-top: 12px;
  box-shadow: 0 4px 0 var(--green-sh);
}
.avatar {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.25); border: 3px solid rgba(255,255,255,.6);
  font-size: 30px; display: flex; align-items: center; justify-content: center;
}
.profile-hero h2 { font-size: 20px; font-weight: 900; }
.profile-hero p { font-size: 13px; opacity: .92; font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat-tile {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; display: flex; align-items: center; gap: 12px;
}
.stat-tile .st-ico { font-size: 26px; }
.stat-tile .st-num { font-size: 19px; font-weight: 900; line-height: 1.1; }
.stat-tile .st-lbl { font-size: 11.5px; color: var(--gray); font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.course-bar-card { border: 2px solid var(--line); border-radius: var(--radius); padding: 15px; margin-top: 10px; }
.cb-top { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.cb-top .pc { color: var(--green-ink); }
.course-bar { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.course-bar > div { height: 100%; background: var(--green); border-radius: 7px; transition: width .6s ease; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-tile {
  border: 2px solid var(--gold); background: #fffbe8;
  border-radius: var(--radius); padding: 13px 12px; text-align: center;
}
.badge-tile.locked { border-color: var(--line); background: var(--gray-soft); }
.badge-tile .bt-ico { font-size: 30px; }
.badge-tile.locked .bt-ico { filter: grayscale(1); opacity: .45; }
.badge-tile .bt-name { font-weight: 900; font-size: 13.5px; margin-top: 4px; }
.badge-tile.locked .bt-name { color: var(--gray); }
.badge-tile .bt-desc { font-size: 11.5px; color: var(--gray); font-weight: 600; margin-top: 1px; }
.reset-zone { margin: 26px 0 10px; text-align: center; }
.reset-link { color: var(--gray); font-size: 13px; font-weight: 700; text-decoration: underline; }
.reset-link:hover { color: var(--red); }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 500; pointer-events: none; padding: 0 16px;
}
body.in-lesson #toast-root { bottom: 120px; }
.toast {
  background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 12px;
  font-weight: 700; font-size: 14.5px;
  max-width: 420px; text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  animation: slideup .25s ease, toastout .3s ease 2.4s forwards;
}
@keyframes toastout { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.cf {
  position: absolute; top: -24px;
  border-radius: 2px;
  animation: cfall linear forwards;
}
@keyframes cfall {
  to { transform: translateY(108vh) rotate(var(--rz, 480deg)); }
}

/* ---------- Animations génériques ---------- */
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 80% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
.shake { animation: shake .45s both; }

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

/* ---------- Écrans un peu plus larges ---------- */
@media (min-width: 600px) {
  .unit-title { font-size: 21px; }
  .prompt-card { font-size: 30px; }
  .ex-consigne { font-size: 23px; }
  .modal-ov { align-items: center; padding: 20px; }
  .modal { border-radius: 22px; max-height: 82vh; }
}

/* ---------- réglages (profil) : effets sonores ---------- */
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px;
}
.sr-title { font-weight: 800; }
.sr-desc { font-size: 13px; color: var(--gray); margin-top: 2px; }
.sound-toggle { flex-shrink: 0; white-space: nowrap; }

/* ---------- confort tactile (PWA mobile) ---------- */
* { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* ---------- Écran de connexion (portail privé) ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0));
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-logo {
  width: 76px; height: 76px;
  margin: 0 auto 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--green);
  color: #fff; font-weight: 900; font-size: 40px;
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--green-sh);
}
.login-title { font-size: 28px; font-weight: 900; color: var(--green-ink); letter-spacing: .5px; }
.login-sub { color: #6b6b6b; font-weight: 600; margin-bottom: 6px; }
.login-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-field > span { font-size: 13px; font-weight: 800; color: #6b6b6b; text-transform: uppercase; letter-spacing: .5px; }
.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--gray-soft);
  font-weight: 700;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.login-input:focus { outline: none; border-color: var(--blue); background: #fff; }
.login-err { color: var(--red-sh); font-weight: 800; min-height: 20px; font-size: 14px; }
.login-card .btn-block { margin-top: 4px; }
.login-card.shake { animation: login-shake .4s; }
@keyframes login-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
@media (prefers-reduced-motion: reduce) {
  .login-card.shake { animation: none; }
}
