:root {
  --bg: #0e1014; --panel: #171a21; --panel2: #1f232c; --line: #2b303b;
  --text: #e9ebef; --muted: #98a0ad;
  --accent: #3d8bfd; --accent2: #2a6fd6;
  --ok: #3fb950; --okbg: #10241a; --bad: #f2564b; --badbg: #2a1414;
  --gold: #e5b53a; --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image: linear-gradient(#ffffff07 1px, transparent 1px), linear-gradient(90deg, #ffffff07 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: #ffffff14; padding: .05em .35em; border-radius: 5px; }
.muted { color: var(--muted); }

/* Barre du haut */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #0e1014e8; backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: 9px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; }
.stats { display: flex; gap: 16px; font-weight: 700; }

/* Accueil */
.home { padding: 16px 16px 40px; }
.home h2 { margin: 14px 0 6px; }
.review { width: 100%; padding: 14px 16px; border-radius: var(--r); border: 1px solid #f2564b55; background: var(--badbg);
  text-align: left; font-weight: 700; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.review b { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 10px; }
.unit { margin-bottom: 28px; }
.unit header { border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.unit .uh { background: linear-gradient(90deg, var(--uc), transparent 85%); padding: 10px 16px; }
.unit small { font-weight: 800; letter-spacing: .12em; font-size: 11px; opacity: .85; }
.unit h2 { margin: 0; font-size: 20px; }
.unit p { margin: 0; padding: 10px 16px 12px; color: var(--muted); font-size: 14px; }
.path { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 0 4px; }
.lnode { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: 0; transform: translateX(var(--off)); }
.lnode .ic { width: 72px; height: 68px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; color: #fff;
  background: var(--uc); box-shadow: 0 6px 0 color-mix(in srgb, var(--uc) 50%, #000); transition: transform .1s, box-shadow .1s; }
.lnode:active:not(:disabled) .ic { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--uc) 50%, #000); }
.lnode .lt { font-size: 13px; font-weight: 600; color: var(--muted); max-width: 150px; text-align: center; }
.lnode.done .ic { background: var(--gold); box-shadow: 0 6px 0 #9c7a1f; color: #3b2a00; }
.lnode.locked .ic { background: #2a2e37; box-shadow: 0 6px 0 #1b1e25; font-size: 20px; }
.lnode.current .ic { outline: 4px solid #ffffff22; outline-offset: 6px; animation: pulse 1.6s infinite; }
.lnode.current .lt { color: var(--text); }
@keyframes pulse { 50% { outline-color: #ffffff5a; } }
.foot-links { text-align: center; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* Leçon */
.lesson { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lbar { display: flex; align-items: center; gap: 12px; padding: 16px; }
.x { background: none; border: 0; font-size: 22px; color: var(--muted); padding: 4px 8px; }
.prog { flex: 1; height: 14px; border-radius: 99px; background: var(--panel2); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .35s; }
.qwrap { flex: 1; padding: 8px 16px 24px; }
.kind { margin: 0 0 4px; color: var(--accent); font-weight: 800; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.q { margin: 0 0 20px; font-size: 21px; line-height: 1.3; }
.body.locked { pointer-events: none; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt, .chip, .mt { background: var(--panel); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; padding: 13px 14px; text-align: left; }
.opt.sel, .mt.sel { border-color: var(--accent); background: #3d8bfd18; }
.right { border-color: var(--ok) !important; background: var(--okbg) !important; }
.wrong { border-color: var(--bad) !important; background: var(--badbg) !important; }

/* Graphe Blueprint */
.graph { display: flex; align-items: center; flex-wrap: wrap; row-gap: 12px; padding: 18px 12px; border-radius: var(--r);
  background: #13161c; border: 1px solid var(--line); margin-bottom: 18px; }
.node { min-width: 118px; border-radius: 8px; background: #1c1f26; border: 1px solid #000; box-shadow: 0 2px 8px #0008; overflow: hidden; font-size: 13px; }
.nh { padding: 6px 10px; font-weight: 700; background: linear-gradient(90deg, var(--nc), #0000); }
.k-event { --nc: #b3261e; } .k-func { --nc: #2f6fd6; } .k-pure { --nc: #2e9e5b; } .k-flow { --nc: #6b6f78; }
.np { padding: 4px 10px 6px; color: #c9ced6; font-size: 12px; }
.node.slot { border: 2px dashed var(--accent); background: #3d8bfd14; }
.node.slot .nh { background: none; color: var(--accent); }
.wire { width: 22px; height: 3px; background: #fff; flex: none; border-radius: 2px; }
.opt.nodeopt { font-family: ui-monospace, Consolas, monospace; font-size: 15px; }

/* Trouve le problème */
.code { background: #13161c; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.ln { display: flex; gap: 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 13px 14px; }
.ln:last-child { border-bottom: 0; }
.ln .no { color: #5c6370; min-width: 16px; }
.ln.sel { background: #3d8bfd22; box-shadow: inset 4px 0 var(--accent); }
.ln.right { box-shadow: inset 4px 0 var(--ok); }
.ln.wrong { box-shadow: inset 4px 0 var(--bad); }

/* Remets dans l'ordre */
.slots { min-height: 120px; border-bottom: 2px dashed var(--line); padding-bottom: 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.chip { display: flex; gap: 10px; align-items: center; width: 100%; padding: 11px 12px; }
.chip b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.pool { display: flex; flex-direction: column; gap: 8px; }
.pool .chip:disabled { opacity: .22; }
.hint { color: var(--muted); text-align: center; margin: auto; font-size: 14px; }

/* Associe */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match > div { display: flex; flex-direction: column; gap: 10px; }
.mt { min-height: 66px; font-size: 14px; text-align: center; }
.mt.right { opacity: .5; }

/* Pied de leçon */
.foot { position: sticky; bottom: 0; padding: 16px; border-top: 1px solid var(--line); background: var(--bg); }
.foot.ok { background: var(--okbg); border-color: #3fb95055; }
.foot.bad { background: var(--badbg); border-color: #f2564b55; }
.fb { max-height: 42vh; overflow: auto; }
.fb:empty { display: none; }
.fb strong { display: block; font-size: 19px; margin-bottom: 4px; }
.foot.ok .fb strong { color: var(--ok); }
.foot.bad .fb strong { color: var(--bad); }
.fb p { margin: 0 0 8px; color: #d5d9e0; font-size: 15px; }
.fb .sol { margin: 4px 0 8px; padding-left: 22px; font-size: 15px; }
.fb .link { margin-bottom: 12px; }
.btn { width: 100%; padding: 14px; border-radius: 12px; border: 0; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--panel2); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent2); }
.btn.primary:disabled { background: #2a2e37; color: #6b7280; box-shadow: none; }
.foot.ok .btn.primary { background: var(--ok); box-shadow: 0 4px 0 #2a8a3b; }
.foot.bad .btn.primary { background: var(--bad); box-shadow: 0 4px 0 #b13a31; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }

/* Fin de leçon */
.end { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 16px; gap: 6px; }
.end .big { font-size: 64px; }
.end h2 { margin: 0; }
.cards { display: flex; gap: 10px; margin: 20px 0 28px; flex-wrap: wrap; justify-content: center; }
.card { border: 2px solid var(--line); border-radius: 14px; padding: 10px 16px; min-width: 96px; background: var(--panel); }
.card small { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.card b { font-size: 22px; }

/* Premium */
.pro { background: linear-gradient(135deg, var(--gold), #c98a12); color: #2b1d00; border: 0; border-radius: 8px; padding: 2px 9px; font-weight: 800; font-size: 12px; letter-spacing: .08em; }
.lnode.prem .ic { color: var(--gold); }
.prem { text-align: center; padding: 18px 0; }
.prem .big { font-size: 54px; color: var(--gold); }
.prem ul { text-align: left; display: inline-block; margin: 10px 0 6px; padding-left: 20px; }
.prem li { margin: 6px 0; }
.price { font-size: 20px; font-weight: 800; margin: 12px 0 18px; }
.plans { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto; }
.btn.plan { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; }
.btn.plan small { font-weight: 700; letter-spacing: 0; text-transform: none; font-size: 15px; opacity: .9; }
.field.nocaps { text-transform: none; }
.small { font-size: 12px; }

/* Langue, options, confidentialité */
.brand { background: none; border: 0; padding: 0; font-size: 16px; white-space: nowrap; }
.stats { white-space: nowrap; }
@media (max-width: 420px) { .brand { font-size: 14px; } .stats { gap: 11px; font-size: 14px; } }
.gear { background: none; border: 0; color: var(--muted); font-size: 19px; padding: 0 2px; line-height: 1; }
.logo-big { color: var(--accent); }
.langs { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; margin-top: 22px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin: 14px 0; overflow: hidden; }
.opt-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 14px 16px;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 16px; }
.opt-row:last-child { border-bottom: 0; }
.opt-row.nav span:last-child { color: var(--muted); font-size: 20px; }
.opt-row.danger span:first-child { color: var(--bad); }
.switch { min-width: 64px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-weight: 700; font-size: 13px; }
.switch.on { background: var(--ok); border-color: var(--ok); color: #06210f; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 7px 12px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.fbl { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 12px; }
.fbl .link { margin: 0; }
.src { color: var(--accent); font-size: 13px; text-decoration: none; }
.src:hover { text-decoration: underline; }
a.btn { display: block; text-align: center; text-decoration: none; }
.field { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; text-transform: uppercase; }
.prose p { color: #d5d9e0; max-width: 65ch; }
.prose a { color: var(--accent); }
.sel { user-select: all; }

/* Sensations : petites animations qui accompagnent les sons */
.confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.combo { display: inline-block; margin-left: 10px; padding: 1px 10px; border-radius: 99px; background: #e5b53a26; color: var(--gold);
  font-size: 14px; vertical-align: middle; animation: pop .35s ease-out; }
.opt.right, .ln.right, .chip.right, .mt.right { animation: pop .3s ease-out; }
.opt.wrong, .ln.wrong, .chip.wrong, .mt.wrong { animation: shake .3s; }
.foot.ok .fb, .foot.bad .fb { animation: rise .22s ease-out; }
.prog i.bump { animation: glow .5s ease-out; }
.big.pop { animation: pop .5s ease-out; }
.card.flame { border-color: var(--gold); animation: pop .5s .9s ease-out both; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes glow { 0% { box-shadow: 0 0 0 #3fb950; } 40% { box-shadow: 0 0 14px #3fb950cc; } 100% { box-shadow: 0 0 0 #3fb95000; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Progression : grades, objectif du jour, étoiles, badges */
.xpbtn { background: none; border: 0; font-weight: 700; padding: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin: 6px 0 10px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #8ab8ff); transition: width .5s; }
.bar.goal i { background: linear-gradient(90deg, var(--gold), #ffd66b); }
.dash { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 6px; margin-bottom: 18px; }
.dash-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rank { font-weight: 800; }
.stars { display: block; color: var(--gold); font-size: 13px; letter-spacing: 2px; }
.big-stars { font-size: 28px; letter-spacing: 6px; animation: pop .5s .2s ease-out both; }
.extras { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: -10px 0 14px; }
.chip-ok { background: var(--okbg); color: var(--ok); border: 1px solid #3fb95055; border-radius: 99px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.promo { background: linear-gradient(90deg, #e5b53a33, #e5b53a11); border: 1px solid var(--gold); color: var(--gold); border-radius: 12px;
  padding: 10px 16px; margin-bottom: 14px; font-weight: 700; animation: pop .6s 1.1s ease-out both; }
.promo b { color: var(--text); }
.end-rank { width: 100%; max-width: 340px; margin-bottom: 14px; text-align: left; }
.newbadges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-bottom: 20px; }
.newbadges small { width: 100%; color: var(--muted); font-weight: 800; letter-spacing: .1em; font-size: 11px; text-transform: uppercase; }
.badge-chip { background: var(--panel2); border: 1px solid var(--gold); border-radius: 99px; padding: 4px 12px; font-weight: 700; font-size: 14px; animation: pop .5s 1.3s ease-out both; }
.prof-head { text-align: center; margin: 8px 0 6px; }
.prof-head h2 { margin: 0 0 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 20px; }
.stats-grid .card { min-width: 0; padding: 10px 8px; text-align: center; }
.stats-grid .card b { font-size: 18px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 22px; }
.badge { background: var(--panel); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.badge span { font-size: 24px; }
.badge small { color: var(--muted); font-size: 12px; }
.badge.off { border-color: var(--line); opacity: .45; filter: grayscale(1); }
.ranklist { list-style: none; padding: 0; margin: 0 0 30px; display: flex; flex-direction: column; gap: 6px; }
.ranklist li { display: flex; justify-content: space-between; padding: 9px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.ranklist li.past { color: var(--text); }
.ranklist li.now { border-color: var(--accent); color: var(--text); font-weight: 800; background: #3d8bfd18; }

/* Retours testeurs */
.rep { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.rep small { color: var(--muted); }
.rep p { margin: 4px 0; }
.rep em { color: var(--muted); font-size: 13px; }
.modal { position: fixed; inset: 0; z-index: 20; background: #000a; display: grid; place-items: end center; padding: 16px; }
.sheet { width: 100%; max-width: 528px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.sheet h3 { margin: 0 0 4px; }
.sheet textarea { width: 100%; margin: 12px 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; resize: vertical; }
.row { display: flex; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--panel2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 99px; font-weight: 600; animation: fade 2.2s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
