/* ================================================================
   Pythonk — styles
   ================================================================ */
:root {
  --bg: #eef5ff;
  --bg-soft: #e2edfb;
  --surface: #ffffff;
  --surface-2: #f6f9ff;
  --ink: #1b2747;
  --ink-soft: #4a587a;
  --muted: #7d8aa8;
  --line: #d6e2f3;
  --navy: #22325c;
  --py-blue: #3776ab;
  --py-yellow: #ffd43b;
  --orange: #ff9f1c;
  --pink: #ff7aa2;
  --ok: #1f9d63;
  --ok-bg: #e3f7ec;
  --ko: #d1435b;
  --ko-bg: #fde8ec;
  --code-bg: #f1f5fd;
  --console-bg: #14203d;
  --console-ink: #e8eefc;
  --shadow: 0 1px 2px rgba(27, 39, 71, .06), 0 8px 24px rgba(27, 39, 71, .08);
  --shadow-lg: 0 2px 4px rgba(27, 39, 71, .06), 0 18px 40px rgba(27, 39, 71, .14);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1527;
    --bg-soft: #141e36;
    --surface: #172340;
    --surface-2: #1c2a4c;
    --ink: #e9efff;
    --ink-soft: #b4c0dd;
    --muted: #8391b3;
    --line: #283a63;
    --ok: #4cd18f;
    --ok-bg: #143a2b;
    --ko: #ff7d91;
    --ko-bg: #3e1a26;
    --code-bg: #101a33;
    --console-bg: #0a1122;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1527; --bg-soft: #141e36; --surface: #172340; --surface-2: #1c2a4c;
  --ink: #e9efff; --ink-soft: #b4c0dd; --muted: #8391b3; --line: #283a63;
  --ok: #4cd18f; --ok-bg: #143a2b; --ko: #ff7d91; --ko-bg: #3e1a26;
  --code-bg: #101a33; --console-bg: #0a1122;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(55, 118, 171, .16), transparent 60%),
    radial-gradient(900px 400px at -10% 10%, rgba(255, 212, 59, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
a { color: var(--py-blue); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: #7fb4e6; } }
code, kbd, pre, .CodeMirror, .console, .fallback-editor { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
:not(pre) > code { background: var(--code-bg); border: 1px solid var(--line); padding: .08em .38em; border-radius: 6px; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; line-height: 1.55; }
kbd { background: var(--surface); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 .4em; font-size: .78em; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--py-yellow); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.center .mascot { margin: 0 auto 12px; }

main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px 48px; outline: none; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, calc((100vw - 1240px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.logo-mascot { width: 38px; height: 44px; display: block; }
.logo-mascot svg { width: 100%; height: 100%; }
.logo-mascot .t-shadow { display: none; }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em; }
.logo-text span { color: var(--py-blue); }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { text-decoration: none; color: var(--ink-soft); font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.nav a:hover { background: var(--bg-soft); color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.xp-pill { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px 4px 6px; box-shadow: var(--shadow); cursor: default; }
.lv-emoji { font-size: 1.35rem; width: 32px; height: 32px; display: grid; place-items: center; background: var(--bg-soft); border-radius: 50%; }
.lv-text { display: flex; flex-direction: column; line-height: 1.1; }
.lv-text strong { font-family: var(--font-display); font-size: .98rem; }
.lv-text small { color: var(--muted); font-size: .74rem; font-weight: 700; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1.05rem; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--bg-soft); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { background: var(--py-blue); color: #fff !important; box-shadow: 0 4px 0 #24557f, var(--shadow); }
.btn-primary:hover { background: #2f6a9b; }
.btn-primary:active { box-shadow: 0 2px 0 #24557f; }
.btn-primary:disabled { opacity: .7; cursor: wait; }
.btn-ghost { background: var(--surface); color: var(--ink) !important; border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { padding: 14px 26px; font-size: 1.1rem; }
.btn-small { padding: 6px 14px; font-size: .92rem; }

.badge { display: inline-block; font-family: var(--font-display); font-weight: 600; font-size: .85rem; padding: 3px 12px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft); vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.big { font-size: 1.05rem; padding: 10px 18px; }
.xp { font-family: var(--font-display); font-weight: 600; font-size: .82rem; color: #8a6a00; background: #fff4c2; border-radius: 999px; padding: 1px 10px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xp { background: #3d3410; color: #ffd43b; } }

.bar { height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; margin: 10px 0 4px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--py-blue), #4f9be0); border-radius: inherit; transition: width .6s ease; min-width: 0; }
.bar.big { height: 14px; }

/* ---------- mascotte ---------- */
.thonk { display: block; width: 100%; height: auto; overflow: visible; }
.thonk .t-shadow { fill: rgba(20, 32, 61, .14); }
.thonk .mood-el { display: none; }
.thonk[data-mood="idle"] .m-idle,
.thonk[data-mood="think"] .m-think,
.thonk[data-mood="happy"] .m-happy,
.thonk[data-mood="sad"] .m-sad,
.thonk[data-mood="talk"] .m-talk { display: inline; }
.thonk .t-body { transform-origin: 100px 216px; animation: bob 3.2s ease-in-out infinite; }
.thonk[data-mood="think"] .t-body { animation: ponder 2.4s ease-in-out infinite; }
.thonk[data-mood="sad"] .t-body { animation: none; transform: scaleY(.96); }
.thonk.bounce .t-body { animation: hop .55s cubic-bezier(.3, 1.6, .5, 1) 2; }
.thonk .t-bubbles { animation: float 2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes ponder { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(3deg); } }
@keyframes hop { 0% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(0) scale(1.06, .92); } 60% { transform: translateY(-16px) scale(.96, 1.05); } 100% { transform: translateY(0) scale(1, 1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .thonk .t-body, .thonk .t-bubbles { animation: none !important; } }

.mascot { display: flex; align-items: center; gap: 12px; }
.mascot-btn { background: none; border: 0; padding: 0; cursor: pointer; flex: none; border-radius: 24px; }
.bubble {
  position: relative; margin: 0; background: var(--surface); border: 2px solid var(--navy);
  border-radius: 18px; padding: 10px 14px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble { border-color: #5d77b8; } }
.bubble::before { content: ""; position: absolute; left: -10px; top: 50%; width: 16px; height: 16px; background: inherit; border-left: 2px solid; border-bottom: 2px solid; border-color: inherit; transform: translateY(-50%) rotate(45deg); }
.bubble.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.85); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }

.mascot.big { flex-direction: column-reverse; gap: 8px; }
.mascot.big .mascot-btn { width: min(300px, 62vw); }
.mascot.big .bubble { font-size: 1.1rem; }
.mascot.big .bubble::before { left: 50%; top: auto; bottom: -10px; transform: translateX(-50%) rotate(-45deg); }
.mascot.mid { flex-direction: column-reverse; width: fit-content; }
.mascot.mid .mascot-btn { width: 170px; }
.mascot.mid .bubble::before { left: 50%; top: auto; bottom: -10px; transform: translateX(-50%) rotate(-45deg); }
.mascot.small .mascot-btn { width: 74px; }
.mascot.small .bubble { font-size: .95rem; }

/* ---------- accueil ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center; padding: 48px 0 24px; }
.eyebrow { font-family: var(--font-display); font-weight: 600; color: var(--py-blue); margin: 0 0 8px; font-size: 1.1rem; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.8rem); }
.hl { background: linear-gradient(transparent 62%, var(--py-yellow) 62%); padding: 0 .08em; color: inherit; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hl { background: linear-gradient(transparent 62%, rgba(255, 212, 59, .45) 62%); } }
.lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 58ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-progress { margin-top: 22px; max-width: 380px; }
.hero-progress small { color: var(--muted); font-weight: 700; }
.hero-mascot { display: flex; justify-content: center; }

.section { padding: 32px 0; }
.tracks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.track-card {
  position: relative; display: block; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  border-top: 6px solid var(--c); transition: transform .15s ease, box-shadow .15s ease;
}
.track-card:not(.soon):hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.track-card h3 { font-size: 1.4rem; margin: 6px 0 4px; }
.track-card p { margin: 0; color: var(--ink-soft); font-size: .96rem; }
.track-card small { color: var(--muted); font-weight: 700; }
.track-card .badge { margin-top: 14px; }
.track-card.soon { opacity: .72; cursor: default; filter: saturate(.7); }
.track-emoji { font-size: 2.2rem; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.steps span { font-size: 1.8rem; }
.steps h3 { margin: 6px 0 2px; }
.steps p { margin: 0; color: var(--ink-soft); font-size: .95rem; }

/* ---------- parcours ---------- */
.track-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; padding: 32px 0 16px; }
.track-head > div { flex: 1 1 420px; max-width: 640px; }
.track-head small { color: var(--muted); font-weight: 700; }
.back { text-decoration: none; font-weight: 700; display: inline-block; margin-bottom: 10px; }
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.chapter header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chapter header h2 { margin: 0; font-size: 1.2rem; flex: 1; }
.chapter header small { color: var(--muted); font-weight: 800; }
.ch-num { width: 30px; height: 30px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; }
.chapter ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lesson-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.lesson-link:hover { background: var(--surface-2); border-color: var(--line); }
.lesson-link .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 800; flex: none; color: var(--muted); }
.lesson-link.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson-link.next { background: #fff8d9; border-color: #ffe17a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lesson-link.next { background: #2e2a14; border-color: #6b5a14; } }
.lesson-link.next .check { border-color: var(--py-blue); color: var(--py-blue); }
.l-title { flex: 1; font-weight: 700; }

/* ---------- leçon ---------- */
.lesson { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 28px; padding-top: 24px; align-items: start; }
.crumbs { font-size: .92rem; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.crumbs a { text-decoration: none; }
.crumbs span { margin: 0 4px; }
.lesson-text h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.prose p { margin: 0 0 .9em; }
.prose ul { padding-left: 1.2em; margin: 0 0 .9em; }
.prose li { margin-bottom: .3em; }
.prose .tip { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--py-yellow); padding: 10px 14px; border-radius: var(--radius-sm); }
.task { background: var(--surface); border: 2px solid var(--py-blue); border-radius: var(--radius); padding: 18px 20px; margin: 22px 0 12px; box-shadow: var(--shadow); }
.task h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.25rem; }
.task .prose { line-height: 1.8; }
.help { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { margin-top: 12px; background: #fff8d9; border: 1px dashed #e8c341; border-radius: var(--radius-sm); padding: 12px 16px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hint { background: #2e2a14; border-color: #6b5a14; } }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; flex-wrap: wrap; }

.workspace { position: sticky; top: 76px; display: grid; gap: 14px; }
.editor-card, .console-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.editor-bar .file { font-family: var(--font-mono); font-size: .85rem; font-weight: 600; }
.editor-bar .status { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--muted); }
.editor-bar .icon-btn { width: 32px; height: 32px; }
.editor .CodeMirror, .fallback-editor { height: 280px; font-family: var(--font-mono); font-size: 15px; line-height: 1.6; background: var(--surface); color: var(--ink); }
.editor.tall .CodeMirror, .editor.tall .fallback-editor { height: 420px; }
.fallback-editor { width: 100%; border: 0; padding: 12px 16px; resize: vertical; tab-size: 4; }
.run-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.kbd-hint { color: var(--muted); font-size: .85rem; }
.stdin { display: block; padding: 10px 14px 0; border-top: 1px solid var(--line); font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.stdin textarea { display: block; width: 100%; margin-top: 4px; font-family: var(--font-mono); font-size: .9rem; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface-2); color: var(--ink); resize: vertical; }

.console-head { padding: 6px 16px; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #9fb0d8; background: var(--console-bg); border-bottom: 1px solid rgba(255, 255, 255, .06); }
.console { background: var(--console-bg); color: var(--console-ink); font-family: var(--font-mono); font-size: .88rem; padding: 10px 16px; min-height: 110px; max-height: 230px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console.tall { min-height: 420px; max-height: 560px; }
.console:not(.has-content)::before { content: "La sortie de ton code apparaîtra ici…"; color: #6f7fa6; font-style: italic; }
.console .out { padding: 1px 0; }
.console .err { color: #ff9aaa; font-family: var(--font); }
.console .tip-line { color: #ffe08a; font-family: var(--font); }
.console .muted { color: #7f8db3; font-family: var(--font); }
.console .stdin-val { color: #8fd3a8; font-weight: 600; }
.console code { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); color: inherit; }

.result { border-radius: var(--radius); padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-weight: 600; animation: pop .3s ease; }
.result.ok { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
.result.ok .btn { margin-left: auto; }
.result.ko { background: var(--ko-bg); color: var(--ko); border: 2px solid var(--ko); }
.result strong { font-family: var(--font-display); }
.lesson-mascot { padding: 4px 0; }

/* CodeMirror : couleurs maison */
.CodeMirror { background: var(--surface); color: var(--ink); }
.CodeMirror-gutters { background: var(--surface-2); border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: var(--muted); }
.CodeMirror-cursor { border-left: 2px solid var(--py-blue); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: rgba(55, 118, 171, .2) !important; }
.cm-s-default .cm-keyword { color: #7b3fbf; font-weight: 600; }
.cm-s-default .cm-def { color: #1f6fb2; font-weight: 600; }
.cm-s-default .cm-string { color: #22863a; }
.cm-s-default .cm-number { color: #c2410c; }
.cm-s-default .cm-comment { color: #8a94ad; font-style: italic; }
.cm-s-default .cm-builtin { color: #0e7490; }
.cm-s-default .cm-variable-2 { color: #1f6fb2; }
.cm-s-default .cm-operator { color: #b45309; }
.cm-error-line { background: rgba(209, 67, 91, .14); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cm-s-default .cm-keyword { color: #c792ea; }
  :root:not([data-theme="light"]) .cm-s-default .cm-def,
  :root:not([data-theme="light"]) .cm-s-default .cm-variable-2 { color: #82aaff; }
  :root:not([data-theme="light"]) .cm-s-default .cm-string { color: #a5e07a; }
  :root:not([data-theme="light"]) .cm-s-default .cm-number { color: #f78c6c; }
  :root:not([data-theme="light"]) .cm-s-default .cm-builtin { color: #89ddff; }
  :root:not([data-theme="light"]) .cm-s-default .cm-operator { color: #ffcb6b; }
  :root:not([data-theme="light"]) .cm-s-default .cm-variable,
  :root:not([data-theme="light"]) .cm-s-default .cm-property { color: var(--ink); }
  :root:not([data-theme="light"]) .CodeMirror-matchingbracket { color: #ffd43b !important; }
}

/* ---------- bac à sable ---------- */
.sandbox-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 28px 0 16px; }
.sandbox-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- confettis & toast ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--navy); color: #fff; padding: 14px 22px; border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 60; text-align: center; transition: transform .35s cubic-bezier(.3, 1.4, .5, 1); }
.toast.show { transform: translate(-50%, 0); }
.toast strong { font-family: var(--font-display); font-size: 1.15rem; }

/* ---------- pied de page ---------- */
.footer { text-align: center; color: var(--muted); font-size: .88rem; padding: 24px 16px 32px; border-top: 1px solid var(--line); }
.footer p { margin: 4px 0; }
.footer a { color: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .lesson, .sandbox-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace { position: static; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 28px; }
  .hero-mascot { order: -1; }
  .mascot.big .mascot-btn { width: min(220px, 55vw); }
  .console.tall { min-height: 200px; }
  .editor.tall .CodeMirror { height: 340px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar { gap: 8px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; justify-content: center; }
  .lv-text small { display: none; }
  .chapters { grid-template-columns: minmax(0, 1fr); }
  .kbd-hint { display: none; }
  .track-head .btn { width: 100%; white-space: normal; }
}

/* ---------- comptes ---------- */
.account-btn[hidden] { display: none; }
.acc-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }

.auth { display: grid; place-items: center; padding: 40px 0; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.9rem; margin-top: 16px; }
.auth-card > .muted { margin-top: -4px; }
.auth-switch { text-align: center; margin: 18px 0 0; font-weight: 600; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 800; font-size: .92rem; margin-bottom: 4px; }
.field input { width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; transition: border-color .15s ease; }
.field input:focus { outline: none; border-color: var(--py-blue); background: var(--surface); }
.field small { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; line-height: 1.4; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--ink-soft); margin: -4px 0 14px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--py-blue); }
.note { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; font-size: .92rem; }
.form-error { background: var(--ko-bg); color: var(--ko); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; font-size: .92rem; margin: 0 0 14px; }
.form-error[hidden] { display: none; }
.btn-block { width: 100%; }
.btn-danger { background: var(--ko); color: #fff !important; }
.btn-danger:hover { filter: brightness(.95); }
.small { font-size: .86rem; }

.account { max-width: 900px; margin: 0 auto; padding: 32px 0; }
.account-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.account-head h1 { margin: 0; }
.account-head p { margin: 0; }
.account-head > div { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat span { font-size: 1.8rem; }
.stat strong { font-family: var(--font-display); font-size: 1.3rem; }
.stat small { color: var(--muted); font-weight: 700; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.2rem; }
.panel.danger { border-color: color-mix(in srgb, var(--ko) 40%, var(--line)); }

@media (max-width: 640px) {
  .acc-name { display: none; }
  .account-btn.is-user { padding: 0 4px; }
  .auth-card { padding: 22px 18px; }
  .xp-pill { padding-right: 10px; }
}

.join { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; background: linear-gradient(120deg, var(--navy), #2f4f8f); color: #fff; border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow-lg); margin-top: 8px; }
.join h2 { margin: 0 0 4px; font-size: 1.35rem; }
.join p { margin: 0; color: #d6e1ff; max-width: 52ch; }
.join-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.join .btn-primary { background: var(--py-yellow); color: #1b2747 !important; box-shadow: 0 4px 0 #c9a51f; }
.join .btn-primary:hover { background: #ffdc5c; }
.join .btn-ghost { background: transparent; color: #fff !important; border-color: rgba(255, 255, 255, .4); }
.join .btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.admin-why { max-width: 560px; margin: 0 auto 22px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 16px; }
.admin-why summary { cursor: pointer; font-weight: 800; }
.admin-why p { margin: 10px 0 4px; color: var(--ink-soft); }
.version { opacity: .7; }
.join-actions .btn { white-space: nowrap; }
@media (max-width: 640px) { .join { padding: 20px; } .join-actions { width: 100%; flex-direction: column; } .join-actions .btn { width: 100%; } }

/* ================================================================
   Leçon « un écran à la fois »
   ================================================================ */
[hidden] { display: none !important; }
body.immersive .topbar, body.immersive .footer, body.immersive .tabbar { display: none; }
body.immersive main { padding: 0; }

.lz {
  position: fixed; inset: 0; z-index: 30; margin: 0 auto; max-width: 820px;
  display: flex; flex-direction: column; background: var(--bg);
  padding-top: env(safe-area-inset-top);
}
.lz-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px 8px; flex: none; }
.lz-close { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; text-decoration: none; color: var(--muted); font-size: 1.3rem; font-weight: 800; flex: none; }
.lz-close:hover { background: var(--bg-soft); color: var(--ink); }
.lz-bar { flex: 1; height: 16px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.lz-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--py-yellow), var(--orange)); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .08), inset 0 4px 0 rgba(255, 255, 255, .35); transition: width .45s cubic-bezier(.3, 1.2, .5, 1); }
.lz-skip { border: 0; background: none; color: var(--py-blue); font: 800 .9rem var(--font); cursor: pointer; padding: 6px 4px; flex: none; }

.lz-stage { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; }
.lz-slide { flex: 1; display: flex; flex-direction: column; justify-content: center; animation: lzIn .28s ease; min-height: 0; }
@keyframes lzIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .lz-slide { animation: none; } }
.lz-intro { margin-bottom: 6px; }
.lz-kicker { margin: 0; font-weight: 800; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lz-title { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: 2px 0 12px; }
.lz-card { font-size: 1.06rem; }
.lz-card pre { font-size: .92rem; }
.lz-card > :last-child { margin-bottom: 0; }

.lz-ex { justify-content: flex-start; gap: 8px; }
.lz-task { flex: none; max-height: 34%; overflow-y: auto; background: var(--surface); border: 2px solid var(--py-blue); border-radius: 16px; padding: 10px 14px; font-size: .96rem; line-height: 1.55; }
.lz-task-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; font-family: var(--font-display); }
.lz-task-body p { margin: 0; }
.lz-task .hint { margin-top: 8px; padding: 8px 12px; }
.lz-editor { position: relative; flex: 1; min-height: 130px; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.lz-editor .editor, .lz-editor .editor .CodeMirror, .lz-editor .fallback-editor { height: 100%; }
.lz-editor .CodeMirror { font-size: 15px; }
.lz-status { position: absolute; top: 6px; right: 10px; z-index: 5; font-size: .72rem; font-weight: 800; color: var(--muted); background: var(--surface); padding: 1px 8px; border-radius: 999px; pointer-events: none; }
.lz-status[data-state="ready"] { display: none; }

.keys { flex: none; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; -webkit-overflow-scrolling: touch; }
.keys::-webkit-scrollbar { display: none; }
.key { flex: none; min-width: 42px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--surface); color: var(--ink); font: 600 .9rem var(--font-mono); cursor: pointer; touch-action: manipulation; }
.key:active { transform: translateY(2px); border-bottom-width: 1px; }
.lz-ex .stdin { border: 0; padding: 0; flex: none; }
.lz-console { flex: none; min-height: 0; max-height: 22%; border-radius: 14px; padding: 8px 12px; font-size: .84rem; }

.lz-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 2px solid var(--line); background: var(--bg); }
.lz-icon { flex: none; width: 52px; height: 52px; border-radius: 16px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); color: var(--ink); font-size: 1.4rem; font-weight: 800; cursor: pointer; display: grid; place-items: center; }
.lz-icon:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn-go { flex: 1; height: 52px; border-radius: 16px; font-size: 1.12rem; letter-spacing: .04em; text-transform: uppercase; background: var(--py-blue); color: #fff !important; box-shadow: 0 4px 0 #24557f; border: 0; }
.btn-go:hover { background: #2f6a9b; }
.btn-go:active { transform: translateY(3px); box-shadow: 0 1px 0 #24557f; }
.btn-go:disabled { opacity: .75; cursor: wait; }

.lz-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; border-top: 2px solid; animation: sheetUp .28s cubic-bezier(.3, 1.3, .5, 1); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.lz-sheet.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.lz-sheet.ko { background: var(--ko-bg); border-color: var(--ko); color: var(--ko); }
.sheet-row { display: flex; align-items: center; gap: 12px; }
.sheet-thonk { width: 62px; flex: none; }
.sheet-thonk .t-shadow { display: none; }
.sheet-row strong { font-family: var(--font-display); font-size: 1.35rem; margin-right: 8px; }
.sheet-row p { margin: 2px 0 0; font-weight: 700; color: var(--ink); line-height: 1.4; }
.lz-sheet.ok .btn-go { background: var(--ok); box-shadow: 0 4px 0 color-mix(in srgb, var(--ok) 60%, #000); }
.lz-sheet.ko .btn-go { background: var(--ko); box-shadow: 0 4px 0 color-mix(in srgb, var(--ko) 60%, #000); }
.sheet-actions { display: flex; gap: 8px; align-items: center; }
.sheet-actions .btn-ghost { height: 52px; border-radius: 16px; padding: 0 14px; flex: none; }

@media (min-width: 700px) {
  .lz-top { padding-top: 20px; }
  .lz-stage { padding: 8px 28px 16px; }
  .lz-foot { padding-left: 28px; padding-right: 28px; }
  .btn-go { flex: 0 0 220px; margin-left: auto; }
  .lz-sheet { padding-left: 28px; padding-right: 28px; flex-direction: row; align-items: center; justify-content: space-between; }
  .lz-sheet .btn-go { flex: 0 0 220px; }
}

/* ================================================================
   Parcours en chemin
   ================================================================ */
.path-head { position: sticky; top: 61px; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 14px 0 10px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); max-width: 560px; margin: 0 auto; }
.path-head h1 { font-size: 1.5rem; margin: 0; white-space: nowrap; }
.path-prog { flex: 1; display: flex; align-items: center; gap: 10px; }
.path-prog .bar { flex: 1; margin: 0; }
.path-prog small { font-weight: 800; color: var(--muted); }
.path { max-width: 560px; margin: 0 auto; padding-bottom: 40px; }
.unit { margin-top: 18px; }
.unit-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--u); color: #fff; border-radius: 18px; padding: 12px 18px; box-shadow: 0 4px 0 color-mix(in srgb, var(--u) 65%, #000); }
.unit-banner small { font-weight: 800; opacity: .85; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.unit-banner h2 { margin: 0; font-size: 1.2rem; }
.unit-count { font-family: var(--font-display); font-weight: 700; background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 2px 12px; }
.nodes { list-style: none; margin: 0; padding: 22px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.nodes li { transform: translateX(var(--x)); display: flex; flex-direction: column; align-items: center; position: relative; }
.node { width: 74px; height: 68px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; font: 700 1.5rem var(--font-display); color: #fff; background: var(--u); box-shadow: 0 7px 0 color-mix(in srgb, var(--u) 60%, #000); transition: transform .1s ease; }
.node:active { transform: translateY(5px); box-shadow: 0 2px 0 color-mix(in srgb, var(--u) 60%, #000); }
.node.done { background: var(--py-yellow); color: #7a5a00; box-shadow: 0 7px 0 #c9a51f; }
.node.todo { background: var(--bg-soft); color: var(--muted); box-shadow: 0 7px 0 var(--line); font-size: 1.15rem; }
.node.current { outline: 6px solid color-mix(in srgb, var(--u) 30%, transparent); outline-offset: 5px; animation: nodePulse 1.8s ease-in-out infinite; }
@keyframes nodePulse { 50% { outline-color: color-mix(in srgb, var(--u) 10%, transparent); } }
.node-label { margin-top: 10px; font-size: .82rem; font-weight: 800; color: var(--ink-soft); max-width: 150px; text-align: center; line-height: 1.25; }
.start-tip { position: absolute; bottom: calc(100% + 10px); background: var(--surface); color: var(--u); border: 2px solid var(--line); border-radius: 12px; padding: 4px 12px; font: 700 .85rem var(--font-display); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; animation: float 1.6s ease-in-out infinite; }
.start-tip::after { content: ""; position: absolute; left: 50%; top: 100%; width: 10px; height: 10px; background: inherit; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: translate(-50%, -5px) rotate(45deg); }
.path-end { display: flex; justify-content: center; margin-top: 24px; }

/* ================================================================
   Barre d'onglets (mobile) et accueil compact
   ================================================================ */
.tabbar { display: none; }
@media (max-width: 640px) {
  body.immersive { padding-bottom: 0; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 2px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 800; padding: 4px 0; border-radius: 12px; }
  .tabbar a span { font-size: 1.35rem; line-height: 1.2; filter: grayscale(.6); opacity: .75; }
  .tabbar a.active { color: var(--py-blue); background: var(--bg-soft); }
  .tabbar a.active span { filter: none; opacity: 1; }

  .topbar { flex-wrap: nowrap; padding-top: 8px; padding-bottom: 8px; }
  .nav, .account-btn { display: none !important; }
  .logo-mascot { width: 32px; height: 38px; }
  .logo-text { font-size: 1.3rem; }
  .xp-pill { padding: 3px 10px 3px 4px; }
  .lv-emoji { width: 28px; height: 28px; font-size: 1.1rem; }
  .icon-btn { width: 36px; height: 36px; }
  .footer { padding-bottom: 12px; }
  .path-head { top: 55px; }

  .hero { padding: 14px 0 4px; gap: 6px; }
  .hero-mascot { order: -1; justify-content: flex-start; }
  .hero .mascot.big { flex-direction: row; gap: 10px; }
  .hero .mascot.big .mascot-btn { width: 88px; }
  .hero .mascot.big .bubble { font-size: .95rem; }
  .hero .mascot.big .bubble::before { left: -10px; top: 50%; bottom: auto; transform: translateY(-50%) rotate(45deg); }
  .hero .eyebrow { display: none; }
  .hero h1 { font-size: 2.15rem; margin-bottom: .3em; }
  .hero .lead { font-size: .98rem; margin: 0; }
  .hero-actions { margin-top: 14px; }
  .hero-actions .btn-primary { flex: 1; }
  .hero-actions .btn-ghost { display: none; }
  .hero-progress { margin-top: 12px; }
  .join { margin-top: 14px; padding: 16px; gap: 12px; }
  .join h2 { font-size: 1.1rem; }
  .join p { font-size: .9rem; }
  .join-actions { flex-direction: row; }
  .join-actions .btn { padding: 10px 12px; font-size: .92rem; }
  .section { padding: 18px 0; }
  .section h2 { font-size: 1.2rem; }
  .tracks { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 0 -16px; padding: 4px 16px 10px; scrollbar-width: none; }
  .tracks::-webkit-scrollbar { display: none; }
  .track-card { flex: 0 0 72%; scroll-snap-align: start; padding: 16px; }
  .track-emoji { font-size: 1.7rem; }
  .how { display: none; }
  .nodes li { transform: translateX(calc(var(--x) * .8)); }
}
.nodes li.has-tip { margin-top: 30px; }
.lz-slide { justify-content: safe center; }

/* ================================================================
   v1.4 : icônes, pastilles 🔥 ❤️ ⭐, popover
   ================================================================ */
.ic { display: block; flex: none; }
.stat-pills { display: flex; align-items: center; gap: 2px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 40px; padding: 0 10px; border: 0; border-radius: 12px; background: none; cursor: pointer; font: 700 1.05rem var(--font-display); color: var(--muted); }
.pill:hover { background: var(--bg-soft); }
.pill b { font-weight: 700; min-width: .6em; }
#pill-streak.lit { color: #ff8a1c; }
#pill-hearts { color: #ff4b6e; }
#pill-hearts.empty { color: var(--muted); }
#pill-xp { color: #e0a800; }
.icon-btn .ic { width: 22px; height: 22px; }
.account-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); color: var(--py-blue); font: 700 .98rem var(--font-display); text-decoration: none; white-space: nowrap; }
.account-btn:hover { background: var(--surface-2); }
.account-btn.is-user { padding: 0 12px 0 4px; color: var(--ink); }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, var(--py-blue), #5aa0de); color: #fff; font: 700 1rem var(--font-display); flex: none; }
.avatar.big { width: 72px; height: 72px; border-radius: 22px; font-size: 2.2rem; box-shadow: 0 5px 0 #24557f; }

.popover { position: absolute; top: calc(100% + 6px); right: max(12px, calc((100vw - 1240px) / 2 + 16px)); width: min(340px, calc(100vw - 24px)); background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow-lg); z-index: 30; animation: popIn .18s ease; }
.popover p { margin: 10px 0 0; font-weight: 700; color: var(--ink-soft); line-height: 1.45; }
.popover .small { font-size: .86rem; }
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop-head { display: flex; align-items: center; gap: 12px; }
.pop-head strong { display: block; font: 700 1.2rem var(--font-display); color: var(--ink); }
.pop-head small { color: var(--muted); font-weight: 800; }
.pop-hearts { display: flex; gap: 4px; }
.pop-emoji { font-size: 2.2rem; }
.popover .bar { height: 14px; }
.popover .bar span { background: linear-gradient(90deg, var(--py-yellow), var(--orange)); }

/* semaine L M M J V S D */
.week { display: flex; justify-content: space-between; gap: 4px; margin-top: 14px; }
.wd { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wd i { font-style: normal; font-weight: 800; font-size: .78rem; color: var(--muted); }
.wd b { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-soft); border: 2px solid var(--line); }
.wd.on b { background: #fff1dc; border-color: #ffb45c; }
.wd.today i { color: var(--ink); }
.wd.today b { border-color: var(--py-blue); border-style: dashed; }
.wd.today.on b { border-style: solid; border-color: #ff8a1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wd.on b { background: #3b2510; } }

/* ================================================================
   Leçon : vies, révision, écran de série
   ================================================================ */
.lz-hearts { display: inline-flex; align-items: center; gap: 4px; font: 700 1.15rem var(--font-display); color: #ff4b6e; flex: none; }
.lz-hearts.lost { animation: heartLost .6s ease; }
@keyframes heartLost { 20% { transform: scale(1.35) rotate(-8deg); } 45% { transform: scale(.85) rotate(6deg); } 70% { transform: translateX(-3px); } 85% { transform: translateX(3px); } }
.lz-skiprow { display: flex; justify-content: flex-end; flex: none; }
.lz-skiprow[hidden] { display: none !important; }
.lz-skip { font-size: .85rem; padding: 2px 0 6px; }
.chip-review { display: inline-block; vertical-align: middle; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: #ffe3ea; color: #d1335a; font-size: .72rem; letter-spacing: .02em; }
.lz-icon .ic { width: 24px; height: 24px; }
.lz-close .ic { width: 26px; height: 26px; }
.sheet-life { margin: -4px 0 0; font-weight: 800; font-size: .88rem; }
.gain-heart { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font: 700 .82rem var(--font-display); color: #ff4b6e; background: #ffe3ea; border-radius: 999px; padding: 1px 10px; vertical-align: middle; }
.gain-heart .ic { display: inline-block; }
.sheet-actions .btn-go .ic { display: inline-block; margin-left: 4px; }
.sheet-actions .btn-ghost .ic { display: inline-block; }

.streak-screen { position: absolute; inset: 0; z-index: 6; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 24px 20px calc(16px + env(safe-area-inset-bottom)); text-align: center; animation: lzIn .3s ease; }
.ss-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: min(420px, 100%); }
.ss-flame { position: relative; animation: flameIn .7s cubic-bezier(.3, 1.6, .5, 1); }
.ss-flame .ic { filter: drop-shadow(0 10px 18px rgba(255, 138, 28, .35)); }
.ss-num { position: absolute; left: 0; right: 0; bottom: 12px; font: 700 3.2rem var(--font-display); color: #fff; text-shadow: 0 3px 0 #d96a00; }
.streak-screen h2 { font-size: 1.9rem; color: #ff8a1c; margin: 6px 0 4px; }
.streak-screen .week { width: 100%; background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 12px 10px; }
.streak-screen p { font-weight: 700; color: var(--ink-soft); margin-top: 14px; }
.streak-screen .btn-go { flex: none; width: min(420px, 100%); margin: 0; background: #ff8a1c; box-shadow: 0 4px 0 #c45f00; }
@keyframes flameIn { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }

/* ================================================================
   Accueil : tableau de bord
   ================================================================ */
.card { display: block; background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 16px; color: var(--ink); text-decoration: none; }
.dash { max-width: 760px; margin: 0 auto; padding: 18px 0 8px; display: flex; flex-direction: column; gap: 14px; }
.dash-hello { display: flex; align-items: center; gap: 12px; }
.dash-hello .mascot { flex: none; }
.dash-hello .mascot .bubble { display: none; }
.dash-hello .mascot.small .mascot-btn { width: 70px; }
.dash-hello .eyebrow { margin: 0; }
.dash-hello h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 2rem); line-height: 1.15; }
.next-card { display: flex; align-items: center; gap: 14px; border-color: var(--py-blue); border-bottom-width: 6px; background: linear-gradient(135deg, var(--surface), var(--surface-2)); transition: transform .1s ease; }
.next-card:hover { transform: translateY(-2px); }
.next-card:active { transform: translateY(2px); border-bottom-width: 3px; }
.nc-emoji { font-size: 2rem; width: 58px; height: 58px; display: grid; place-items: center; background: var(--bg-soft); border-radius: 16px; flex: none; }
.nc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nc-text small { color: var(--muted); font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-text strong { font: 700 1.25rem var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-go { width: 48px; height: 48px; border-radius: 50%; background: var(--py-blue); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 4px 0 #24557f; }
.nc-go .ic { margin-left: 3px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; }
.streak-card.lit { border-color: #ffb45c; background: linear-gradient(160deg, #fff6e8, var(--surface) 60%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .streak-card.lit { background: linear-gradient(160deg, #3b2510, var(--surface) 60%); } }
.sc-top { display: flex; align-items: center; gap: 10px; }
.sc-top strong { display: block; font: 700 2.2rem/1 var(--font-display); }
.sc-top small { color: var(--muted); font-weight: 800; }
.streak-card.lit .sc-top strong { color: #ff8a1c; }
.streak-card p { margin: 12px 0 0; font-weight: 700; color: var(--ink-soft); }
.mini-stats { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; }
.ms { display: grid; grid-template-columns: 34px auto 1fr; align-items: center; gap: 10px; }
.ms strong { font: 700 1.2rem var(--font-display); }
.ms small { color: var(--muted); font-weight: 700; font-size: .82rem; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-emoji { font-size: 1.6rem; text-align: center; }
.track-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 14px; }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tl-head small { color: var(--muted); font-weight: 800; }
.track-line .bar { grid-column: 1; margin: 6px 0 0; height: 12px; }
.track-line .btn { grid-column: 2; grid-row: 1 / span 2; }
.btn-sm { padding: 8px 14px; font-size: .92rem; }
.join-mini { display: flex; align-items: center; gap: 12px; border-style: dashed; }
.join-mini > span { font-size: 1.6rem; }
.join-mini p { margin: 0; flex: 1; font-size: .92rem; color: var(--ink-soft); }
.join-mini strong { color: var(--ink); }
.soon-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.soon-chip { font-weight: 800; font-size: .85rem; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); color: var(--ink-soft); }
.soon-chip small { color: var(--muted); font-weight: 700; }
@media (max-width: 640px) {
  .dash { padding-top: 10px; gap: 12px; }
  .dash-hello .mascot.small .mascot-btn { width: 56px; }
  .dash-hello h1 { font-size: 1.35rem; }
  .dash-hello .eyebrow { font-size: .95rem; }
  .sc-top strong { font-size: 1.9rem; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mini-stats { flex-direction: row; justify-content: space-between; padding: 12px; }
  .ms { grid-template-columns: auto; justify-items: center; gap: 2px; text-align: center; flex: 1; }
  .ms small { text-align: center; font-size: .74rem; max-width: 100%; }
  .ms-emoji { font-size: 1.5rem; line-height: 30px; }
  .nc-emoji { width: 50px; height: 50px; font-size: 1.7rem; }
  .nc-text strong { font-size: 1.12rem; }
  .card { padding: 14px; }
  .wd b { width: 30px; height: 30px; }
}

/* ================================================================
   Parcours : Thonk à côté de la leçon en cours, icônes
   ================================================================ */
.node .ic { color: currentColor; }
.node.done .ic { color: #7a5a00; }
.node.current .ic { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .15)); }
.node-thonk { position: absolute; top: 2px; left: calc(50% - 31px + var(--side) * 100px); width: 62px; pointer-events: none; animation: float 2.4s ease-in-out infinite; }
.node-thonk .t-shadow { display: none; }
@media (max-width: 400px) { .node-thonk { width: 52px; left: calc(50% - 26px + var(--side) * 86px); } }

/* ================================================================
   Bac à sable façon appli
   ================================================================ */
.sb { max-width: 1240px; margin: 0 auto; padding: 14px 0 0; display: flex; flex-direction: column; gap: 12px; height: calc(100dvh - 63px - 16px); min-height: 460px; }
.sb-head { display: flex; align-items: center; gap: 10px; flex: none; }
.sb-thonk .mascot { gap: 6px; }
.sb-thonk .mascot-btn { width: 52px; }
.sb-thonk .bubble { font-size: .85rem; padding: 6px 10px; max-width: 46vw; }
.sb-title { flex: 1; min-width: 0; }
.sb-title h1 { margin: 0; font-size: 1.5rem; line-height: 1.1; }
.sb-title .status { font-size: .78rem; font-weight: 800; color: var(--muted); }
.sb-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; }
.sb-editor { display: flex; flex-direction: column; min-height: 0; border: 2px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface); }
.sb-editor .editor { flex: 1; min-height: 0; }
.sb-editor .editor .CodeMirror, .sb-editor .fallback-editor { height: 100%; font-size: 15px; }
.sb-editor .keys { border-top: 2px solid var(--line); margin: 0; border-radius: 0; padding: 6px 8px; background: var(--surface-2); }
.sb-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.sb-stdin { flex: none; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 8px 12px; }
.sb-stdin summary { cursor: pointer; font-weight: 800; color: var(--ink-soft); font-size: .9rem; }
.sb-stdin textarea { width: 100%; margin-top: 8px; border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; font: .9rem var(--font-mono); background: var(--surface-2); color: var(--ink); resize: vertical; }
.sb-stdin small { color: var(--muted); font-weight: 700; }
.sb-console { flex: 1; min-height: 120px; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--console-bg); }
.sb-console .console-head { flex: none; }
.sb-console .console { flex: 1; min-height: 0; overflow-y: auto; border-radius: 0; margin: 0; max-height: none; }
.sb-foot { flex: none; display: flex; justify-content: flex-end; padding-bottom: 8px; }
.sb-foot .btn-go { flex: 0 0 260px; display: inline-flex; gap: 8px; }
.btn-block { width: 100%; }
@media (max-width: 860px) {
  .sb { height: calc(100dvh - 58px); min-height: 440px; padding-top: 8px; gap: 8px; }
  .sb-main { display: flex; flex-direction: column; gap: 8px; }
  .sb-editor { flex: 1 1 0; min-height: 150px; }
  .sb-side { flex: none; gap: 8px; }
  .sb-stdin { padding: 6px 12px; border-radius: 14px; }
  .sb-console { flex: none; height: 24dvh; min-height: 96px; }
  .sb-foot { padding-bottom: 6px; }
  .sb-foot .btn-go { flex: 1; }
  .sb-head .lz-icon { width: 44px; height: 44px; border-radius: 14px; }
  .sb-thonk .mascot-btn { width: 42px; }
  .sb-title h1 { font-size: 1.25rem; }
}
@media (max-width: 640px) { .sb { height: calc(100dvh - 56px); } }

/* ================================================================
   Compte
   ================================================================ */
.account-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 24px 0 16px; }
.account-head > div { flex: 1; min-width: 0; }
.account-head h1 { margin: 0; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { border-width: 2px; box-shadow: none; align-items: flex-start; gap: 2px; border-radius: 20px; padding: 14px 16px; }
.stat .ic, .stat span { height: 34px; font-size: 1.7rem; line-height: 34px; }
.stat strong { font-size: 1.5rem; }
.week-panel h2 { margin: 0; font-size: 1.1rem; }
.week-panel { margin-bottom: 16px; }
.week-panel p { margin: 10px 0 0; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 10px 12px; display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; align-items: center; }
  .stat > :first-child { grid-row: span 2; }
  .stat strong { font-size: 1.25rem; line-height: 1.1; }
  .stat small { font-size: .78rem; line-height: 1.2; }
  .account-head > div p { margin: 0; font-size: .85rem; }
  .account-head { padding-top: 14px; gap: 12px; }
  .account-head .avatar.big { width: 56px; height: 56px; font-size: 1.7rem; }
  .account-head h1 { font-size: 1.5rem; }
  .account-head .btn { padding: 8px 14px; font-size: .9rem; }
}

/* ================================================================
   Barre du haut et onglets (mobile)
   ================================================================ */
.tabbar .tab-ic { display: block; height: 26px; }
.tabbar .tab-ic .ic { margin: 0 auto; }
@media (max-width: 640px) {
  .tabbar a span.tab-ic { filter: none; opacity: 1; font-size: 0; }
  .tabbar a.active { background: none; }
  .tabbar a.active .tab-ic { background: color-mix(in srgb, var(--py-blue) 14%, transparent); border-radius: 10px; }
  .tabbar a .tab-ic { width: 52px; padding: 0; }
  .top-right { gap: 2px; }
  .pill { padding: 0 7px; height: 38px; font-size: 1rem; gap: 4px; }
  .icon-btn { border: 0; background: none; }
}
@media (max-width: 380px) {
  .logo-text { display: none; }
  .pill { padding: 0 5px; }
}

/* ================================================================
   Console : défilement au doigt + poignée pour l'ouvrir en grand
   ================================================================ */
.console { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent; }
.console:focus-visible { outline-offset: -3px; }
.con-box { display: flex; flex-direction: column; min-height: 0; background: var(--console-bg); border-radius: 14px; overflow: hidden; }
.con-box[hidden] { display: none !important; }
.lz-ex .con-box { flex: none; max-height: 30%; }
.con-box .console { flex: 1; min-height: 0; max-height: none; border-radius: 0; margin: 0; }
.con-box .lz-console { min-height: 44px; }
.con-head { position: relative; flex: none; display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-bottom: 1px solid rgba(255, 255, 255, .07); background: rgba(255, 255, 255, .04); color: #9fb0d8; padding: 10px 12px 6px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; text-align: left; }
.con-grip { position: absolute; left: 50%; top: 4px; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: rgba(255, 255, 255, .28); }
.con-title { font: 800 .72rem var(--font); letter-spacing: .08em; text-transform: uppercase; }
.con-count { font: 700 .74rem var(--font); color: #7f8db3; }
.con-box.can-scroll:not(.full) .con-count::after { content: " · glisse ↕"; color: #ffe08a; }
.con-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: #dbe6ff; background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 3px 10px 3px 8px; font: 700 .74rem var(--font); }
.con-toggle i { font-style: normal; }
.con-head:hover .con-toggle { background: rgba(255, 255, 255, .18); }
/* ouverte en grand */
.con-box.full { position: fixed; z-index: 60; top: max(56px, calc(env(safe-area-inset-top) + 40px)); bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; width: min(920px, calc(100% - 16px)); max-height: none !important; height: auto !important; transform: translateX(-50%); border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(8, 14, 30, .55), var(--shadow-lg); animation: conUp .26s cubic-bezier(.3, 1.2, .5, 1); }
.con-box.full .console { font-size: .92rem; padding: 12px 16px 24px; }
.con-box.full .con-head { padding: 14px 14px 10px; }
.con-box.full .con-grip { top: 6px; }
@keyframes conUp { from { transform: translate(-50%, 40px); opacity: .4; } }
body.con-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .con-box.full { animation: none; } }

/* ================================================================
   Consigne : résultat attendu dans la console + bandeau d'erreur
   ================================================================ */
.lz-task { max-height: 40%; }
.expect { margin-top: 8px; border-radius: 12px; overflow: hidden; background: var(--console-bg); }
.expect-label { display: block; padding: 5px 10px 3px; font: 800 .74rem var(--font); color: #ffe08a; letter-spacing: .02em; }
.expect-out { margin: 0; border: 0; border-radius: 0; background: none; color: var(--console-ink); padding: 2px 10px 8px; font-size: .84rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.expect-note { margin: 8px 0 0; padding: 6px 10px; border-radius: 10px; background: var(--bg-soft); font-size: .86rem; font-weight: 700; color: var(--ink-soft); }
.lz-fb { flex: none; display: flex; gap: 8px; align-items: flex-start; max-height: 4.6em; overflow-y: auto; padding: 7px 12px; border-radius: 12px; background: var(--ko-bg); color: var(--ink); border: 2px solid color-mix(in srgb, var(--ko) 45%, transparent); font-size: .88rem; font-weight: 700; line-height: 1.35; }
.lz-fb[hidden] { display: none !important; }
.lz-fb code { font-size: .85em; }
.fb-ic { flex: none; }
.lz-sheet p code { color: inherit; }
@media (max-width: 640px) {
  .lz-sheet { gap: 8px; padding-top: 12px; }
  .lz-sheet.ko .sheet-thonk { width: 46px; }
  .lz-sheet.ko .sheet-row strong { font-size: 1.15rem; }
  .lz-sheet.ko .sheet-row p { font-size: .92rem; }
  .lz-sheet.ko .sheet-actions .btn-ghost, .lz-sheet.ko .btn-go { height: 46px; }
  .lz-sheet.ko .sheet-actions .btn-ghost { padding: 0 10px; font-size: .92rem; }
  .sheet-life { font-size: .8rem; }
}

/* ================================================================
   v1.5 : menu du haut (remplace la barre d'onglets), fenêtres, finitions
   ================================================================ */
.tabbar { display: none !important; }
.menu-btn { display: none; }
.menu-btn.on { background: var(--bg-soft); }
.menu { position: absolute; top: calc(100% + 6px); right: max(12px, calc((100vw - 1240px) / 2 + 16px)); width: min(290px, calc(100vw - 24px)); z-index: 31; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface); border: 2px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); animation: popIn .16s ease; }
.menu[hidden] { display: none; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 14px; background: none; color: var(--ink); text-decoration: none; font: 700 1.02rem var(--font-display); cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--bg-soft); }
.menu a.active { background: color-mix(in srgb, var(--py-blue) 16%, transparent); color: var(--py-blue); }
.menu .tab-ic { width: 26px; height: 26px; display: grid; place-items: center; flex: none; }
.menu button { border-top: 2px solid var(--line); border-radius: 0 0 14px 14px; margin-top: 4px; color: var(--ink-soft); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu a.active { color: #8cc2f2; } }
@media (max-width: 640px) {
  .menu-btn { display: grid; border: 0; background: none; }
  #sound-btn { display: none; }
  .footer { display: none; }
  main { padding-bottom: 20px; }
}

.modal-back { position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); background: rgba(8, 14, 30, .55); backdrop-filter: blur(3px); animation: fadeIn .16s ease; }
.modal-back.out { opacity: 0; transition: opacity .15s ease; }
@media (min-width: 641px) { .modal-back { place-items: center; } }
.modal { width: min(400px, 100%); background: var(--surface); border: 2px solid var(--line); border-radius: 24px; padding: 18px 18px 16px; text-align: center; box-shadow: var(--shadow-lg); animation: sheetUp .26s cubic-bezier(.3, 1.3, .5, 1); }
.modal-thonk { width: 70px; margin: -4px auto 4px; }
.modal-thonk .t-shadow { display: none; }
.modal h2 { margin: 0 0 4px; font-size: 1.3rem; }
.modal p { margin: 0; color: var(--ink-soft); font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; height: 50px; border-radius: 16px; font-size: 1.02rem; }
.modal-actions .btn-danger { box-shadow: 0 4px 0 color-mix(in srgb, var(--ko) 60%, #000); }
@keyframes fadeIn { from { opacity: 0; } }
@media (max-width: 640px) {
  .tl-head { flex-direction: column; align-items: flex-start; gap: 0; }
  .tl-head strong { white-space: nowrap; }
}

/* ================================================================
   v1.6 : e-mail facultatif et espace admin
   ================================================================ */
.field .opt { font-style: normal; font-weight: 700; font-size: .78rem; color: var(--muted); background: var(--bg-soft); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.badge-admin { display: inline-block; vertical-align: middle; font: 700 .8rem var(--font-display); background: #fff4c2; color: #8a6a00; border-radius: 999px; padding: 2px 10px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-admin { background: #3d3410; color: #ffd43b; } }
.admin-card { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; border-color: #e0a800; border-bottom-width: 5px; }
.admin-card > span:first-child { font-size: 1.8rem; }
.admin-card > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.admin-card small { color: var(--muted); font-weight: 700; }
.admin-card .nc-go { width: 40px; height: 40px; background: #e0a800; box-shadow: 0 3px 0 #a37a00; }
.admin { max-width: 900px; margin: 0 auto; padding: 18px 0 30px; }
.admin-head h1 { margin: 0; }
.admin-head p { margin: 2px 0 14px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.admin-stats .card { padding: 12px 14px; display: flex; flex-direction: column; }
.admin-stats strong { font: 700 1.6rem/1.1 var(--font-display); }
.admin-stats small { color: var(--muted); font-weight: 800; }
.admin-search input { width: 100%; height: 46px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); padding: 0 14px; font: 600 1rem var(--font); margin-bottom: 12px; }
.admin-search input:focus { outline: none; border-color: var(--py-blue); }
.user-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.user-card { display: flex; flex-direction: column; gap: 8px; }
.uc-top { display: flex; align-items: center; gap: 10px; }
.uc-name { display: flex; flex-direction: column; min-width: 0; }
.uc-name strong { font: 700 1.1rem var(--font-display); }
.uc-name > small { color: var(--ink-soft); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.uc-stats span { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-soft); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: .84rem; }
.uc-stats .ic { display: inline-block; }
.uc-dates { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 700; }
.uc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-text { color: var(--ko) !important; }
.temp-pw { display: inline-block; margin: 8px 0; font-size: 1.3rem; letter-spacing: .08em; padding: 6px 14px !important; user-select: all; }
@media (max-width: 640px) {
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-list { grid-template-columns: minmax(0, 1fr); }
}

/* En-tête du parcours : carte arrondie, collée sous la barre du haut */
.path-head { top: 64px; display: block; padding: 10px 0 8px; background: linear-gradient(var(--bg) 75%, transparent); backdrop-filter: none; }
.ph-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.ph-emoji { flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.7rem; background: var(--bg-soft); border-radius: 14px; }
.ph-text { flex: 1; min-width: 0; }
.ph-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ph-row h1 { margin: 0; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-row small { flex: none; color: var(--muted); font-weight: 800; font-size: .85rem; }
.ph-card .bar { height: 12px; margin: 6px 0 0; }
.ph-card .bar span { background: linear-gradient(90deg, var(--py-yellow), var(--orange)); }
@media (max-width: 640px) { .path-head { top: 54px; padding-top: 8px; } }

/* ---------- v1.7 : en-tête du parcours dans le flux + bannières de chapitre collantes ---------- */
.path-head { position: static; top: auto; z-index: auto; padding: 14px 0 4px; background: none; }
.ph-card .ph-sub { display: block; margin-top: 6px; color: var(--muted); font-weight: 700; font-size: .8rem; }
.unit-banner {
  position: sticky; top: 64px; z-index: 4;
  /* 2e ombre = cache de la couleur du fond au-dessus, pour que rien ne dépasse quand la bannière colle */
}
/* collée en haut : la 2e ombre (couleur du fond) masque ce qui défile au-dessus et dans les coins */
.unit-banner.stuck { box-shadow: 0 4px 0 color-mix(in srgb, var(--u) 65%, #000), 0 -10px 0 6px var(--bg); }
@media (max-width: 640px) { .unit-banner { top: 54px; } }
/* le pingouin et la bulle « Commencer » passent sous la bannière */
.nodes li { position: relative; z-index: 1; }

/* ---------- v1.7 : pouvoirs admin ---------- */
.pill.inf b { font-size: 1.15em; line-height: 1; }
.uc-powers { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 2px dashed var(--line); }
.pw-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; text-align: left;
  font: inherit; color: var(--ink); background: var(--bg-soft); border: 2px solid var(--line); border-radius: 14px; cursor: pointer;
}
.pw-toggle.on { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.pw-ic { flex: none; width: 32px; height: 32px; display: grid; place-items: center; font-size: 1.2rem; }
.pw-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pw-txt b { font-size: .95rem; }
.pw-txt small { color: var(--muted); font-weight: 700; font-size: .78rem; }
.sw { flex: none; position: relative; width: 46px; height: 26px; border-radius: 99px; background: var(--line); transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.pw-toggle.on .sw { background: var(--ok); }
.pw-toggle.on .sw::after { transform: translateX(20px); }
.pw-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pw-btn {
  padding: 9px 8px; font: inherit; font-weight: 800; font-size: .85rem; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; cursor: pointer;
}
.pw-btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.pw-btn:disabled { opacity: .45; cursor: default; }
.pw-toggle:focus-visible, .pw-btn:focus-visible { outline: 3px solid var(--py-yellow); outline-offset: 2px; }
.modal-input {
  display: block; width: 100%; margin: 4px 0 14px; padding: 12px 14px; font: inherit; font-size: 1.3rem; font-weight: 800; text-align: center;
  color: var(--ink); background: var(--bg-soft); border: 2px solid var(--line); border-radius: 14px;
}
.modal-input:focus { outline: none; border-color: var(--py-blue); }

/* ---------- v1.8 : HTML / CSS / JavaScript ---------- */
/* Couleurs du code HTML, CSS et JS */
.cm-s-default .cm-tag { color: #c2410c; font-weight: 600; }
.cm-s-default .cm-attribute { color: #7b3fbf; }
.cm-s-default .cm-bracket { color: #8a94ad; }
.cm-s-default .cm-property { color: #1f6fb2; }
.cm-s-default .cm-atom { color: #b45309; }
.cm-s-default .cm-qualifier, .cm-s-default .cm-variable-3 { color: #0e7490; }
.cm-s-default .cm-meta { color: #8a94ad; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cm-s-default .cm-tag { color: #ff9e64; }
  :root:not([data-theme="light"]) .cm-s-default .cm-attribute { color: #c792ea; }
  :root:not([data-theme="light"]) .cm-s-default .cm-bracket { color: #8391b3; }
  :root:not([data-theme="light"]) .cm-s-default .cm-property { color: #82aaff; }
  :root:not([data-theme="light"]) .cm-s-default .cm-atom { color: #ffcb6b; }
  :root:not([data-theme="light"]) .cm-s-default .cm-qualifier,
  :root:not([data-theme="light"]) .cm-s-default .cm-variable-3 { color: #89ddff; }
}
.lang-tag { position: absolute; bottom: 6px; right: 10px; z-index: 5; font: 800 .68rem var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; pointer-events: none; opacity: .85; }
.lz-editor.lang-python .lang-tag { display: none; }

/* Aperçu de la page */
.pv-box { flex: none; display: flex; flex-direction: column; height: clamp(170px, 30%, 340px); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.pv-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--surface-2); border-bottom: 2px solid var(--line); }
.pv-dots { display: inline-flex; gap: 5px; }
.pv-dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff6b6b; }
.pv-dots i:nth-child(2) { background: #ffd43b; }
.pv-dots i:nth-child(3) { background: #4cd18f; }
.pv-url { flex: 1; min-width: 0; font: 800 .8rem var(--font); color: var(--ink-soft); background: var(--surface); border-radius: 999px; padding: 3px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-toggle { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-soft); font: 800 .78rem var(--font); cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.pv-toggle i { font-style: normal; }
.pv-toggle:hover { background: var(--bg-soft); }
.pv-frame { flex: 1; min-height: 0; width: 100%; border: 0; background: #fff; display: block; }
.pv-box.full { position: fixed; z-index: 60; top: max(56px, calc(env(safe-area-inset-top) + 40px)); bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; width: min(1000px, calc(100% - 16px)); height: auto; transform: translateX(-50%); border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(8, 14, 30, .55), var(--shadow-lg); animation: conUp .26s cubic-bezier(.3, 1.2, .5, 1); }
@media (prefers-reduced-motion: reduce) { .pv-box.full { animation: none; } }
.console .out.warn { color: #ffcb6b; }
.console .out.alert { color: #89ddff; }

/* Bac à sable : Python / Web */
.seg { flex: none; display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-soft); border: 2px solid var(--line); border-radius: 14px; }
.seg button { border: 0; background: none; font: 800 .88rem var(--font); color: var(--ink-soft); padding: 7px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 var(--line), 0 2px 6px rgba(0, 0, 0, .08); }
.sb-web .sb-preview { flex: 1 1 0; height: auto; min-height: 140px; }
.sb-web .sb-console { flex: 0 0 auto; height: 30%; min-height: 96px; }
@media (max-width: 900px) {
  .sb-web .sb-side { flex: 1 1 0; min-height: 0; }
  .sb-web .sb-editor { flex: 1.15 1 0; }
  .sb-web .sb-preview { min-height: 120px; }
  .sb-web .sb-console { height: 18dvh; min-height: 70px; }
  .seg button { padding: 6px 9px; font-size: .8rem; }
}
@media (max-width: 420px) {
  .sb-head .sb-title .status { display: none; }
  .sb-thonk .bubble { display: none; }
}

/* Accueil et liste des parcours */
.lang-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 18px; }
.lang-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: .92rem; color: var(--ink); text-decoration: none; background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 2px solid color-mix(in srgb, var(--c) 40%, transparent); }
.lang-chip:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.tracks-page .tp-head p { max-width: 70ch; }
.tp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.tp-head h1 { margin: 0 0 4px; }
.tp-head p { margin: 0; }
@media (max-width: 640px) {
  .tracks-page .tracks { display: grid; grid-template-columns: 1fr; overflow: visible; margin: 0; padding: 0; }
  .tracks-page .track-card { flex: none; }
  .tp-head { align-items: flex-start; }
  .tp-head .bubble { display: none; }
}
.track-lines h2 { margin: 0 0 6px; font-size: 1.1rem; }
.tl-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.tl-row + .tl-row { border-top: 1px solid var(--line); }
.tl-row:hover { background: var(--bg-soft); }
.tl-emoji { flex: none; width: 38px; height: 38px; display: grid; place-items: center; font-size: 1.3rem; border-radius: 12px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.tl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tl-row .tl-head { display: flex; justify-content: space-between; align-items: baseline; flex-direction: row; gap: 8px; }
.tl-row .tl-head small { color: var(--muted); font-weight: 800; }
.tl-row .bar { display: block; height: 10px; margin: 0; }
.tl-row .bar span { background: var(--c); }

.track-card .bar span { background: var(--c); }
