/* ============================================================
   AlgoLab V4 — « Le Monde ».  Design system.
   Une vraie formation : accueil, cours en couleurs, atelier,
   parcours parallèles, gamification. Clair, chaleureux, lisible.
   Tout en variables CSS — un seul endroit pour la charte.
   ============================================================ */
:root {
  /* Toile & encre */
  --bg:        #f3f1ec;
  --bg-2:      #ece8e1;
  --paper:     #ffffff;
  --ink:       #1f2533;
  --ink-2:     #424b5e;
  --ink-3:     #6b7488;
  --line:      #e3ddd3;
  --line-2:    #d3ccc0;

  /* Marque — indigo savant + dégradé héro */
  --brand:     #5b54e6;
  --brand-deep:#3a32c0;
  --brand-soft:#efeefe;
  --hero-a:    #4f46e5;
  --hero-b:    #7c3aed;
  --hero-c:    #db2777;

  /* Récompenses */
  --gold:      #f0a92e;
  --gold-deep: #d8841a;
  --gold-soft: #fdf3dd;
  --flame:     #ff6a3d;
  --xp:        #6d28d9;

  /* Couleurs pédagogiques (encadrés mémoire) */
  --def:       #2563eb;  --def-bg:   #eaf1ff;  --def-edge: #bcd3ff;
  --tip:       #d8841a;  --tip-bg:   #fff4dd;  --tip-edge: #f3d79a;
  --trap:      #dc2626;  --trap-bg:  #fdeaea;  --trap-edge:#f6c2c2;
  --key:       #047857;  --key-bg:   #e7f6ee;  --key-edge: #b6e3ca;
  --exa:       #7c3aed;  --exa-bg:   #f3ecfe;  --exa-edge: #ddc9fb;
  --voc:       #0e7490;  --voc-bg:   #e2f6fb;  --voc-edge: #b3e6f0;

  /* Verdict */
  --ok:        #047857;  --ok-bg:    #e7f6ee;
  --notyet:    #b4690e;  --notyet-bg:#fff3df;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(31,37,51,.05), 0 8px 26px rgba(31,37,51,.07);
  --shadow-lg: 0 12px 40px rgba(31,37,51,.14);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, #efe7ff 0%, rgba(239,231,255,0) 55%),
    radial-gradient(1000px 500px at -10% 0%, #ffeede 0%, rgba(255,238,222,0) 50%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-deep); text-decoration: none; }
button { font-family: inherit; }

/* ============================================================ Top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c));
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 6px 16px rgba(124,58,237,.35);
}
.brand b { font-size: 18px; letter-spacing: -.02em; }
.brand .sub { font-size: 11px; color: var(--ink-3); margin-top: -2px; }

.nav { display: flex; gap: 4px; margin-left: 6px; flex-wrap: wrap; }
.nav a {
  padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { background: var(--bg-2); }
.nav a.on { background: var(--ink); color: #fff; }
.nav a .ic { font-size: 14px; }

.topstats { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.tstat { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; }
.tstat .lab { color: var(--ink-3); font-weight: 600; font-size: 11px; }
.tstat .flame { color: var(--flame); }
.tstat .grade { color: var(--brand-deep); }
.tstat .xp { color: var(--xp); }
.engine { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.engine .dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c2b6; }
.engine .dot.warm { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.engine .dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }

/* ============================================================ Layout */
.page { max-width: 1140px; margin: 0 auto; padding: 26px 20px 80px; }
.page.wide { max-width: 1280px; }

.btn {
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink);
  padding: 10px 16px; border-radius: 11px; font-weight: 650; font-size: 14px;
  cursor: pointer; transition: transform .06s ease, box-shadow .12s ease, background .12s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.primary { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); border: none; color: #fff; box-shadow: 0 8px 20px rgba(91,84,230,.35); }
.btn.gold { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); border: none; color: #fff; box-shadow: 0 8px 20px rgba(216,132,26,.32); }
.btn.ghost { background: transparent; }
.btn.warm { background: var(--gold-soft); border-color: var(--tip-edge); color: var(--gold-deep); }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }

.kbd { color: var(--ink-3); font-size: 12px; }
.kbd kbd { background: var(--bg-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-family: var(--mono); font-size: 11px; }
.muted { color: var(--ink-3); }

/* ============================================================ ACCUEIL */
.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 34px 34px 30px; color: #fff;
  background: linear-gradient(125deg, var(--hero-a) 0%, var(--hero-b) 52%, var(--hero-c) 120%);
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(520px 280px at 88% -30%, rgba(255,255,255,.28), transparent 60%);
  pointer-events: none;
}
.hero .eyebrow { font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; opacity: .9; font-weight: 700; }
.hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 8px 0 6px; letter-spacing: -.025em; line-height: 1.08; overflow-wrap: anywhere; }
.hero p.lead { font-size: 16px; max-width: 640px; opacity: .96; margin: 0 0 20px; }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .btn.primary { background: #fff; color: var(--brand-deep); box-shadow: 0 10px 24px rgba(0,0,0,.18); }
.hero .btn.ghost { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.4); color: #fff; }

.hero-badges { display: flex; gap: 16px; margin-top: 22px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-chip { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); border-radius: 13px; padding: 10px 15px; min-width: 96px; }
.hero-chip .n { font-size: 24px; font-weight: 800; line-height: 1; }
.hero-chip .l { font-size: 11.5px; opacity: .9; margin-top: 4px; }

.grid { display: grid; gap: 18px; }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-2 { grid-template-columns: 1.5fr 1fr; }
@media (max-width: 860px) { .cards-3, .cards-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card .ttl { font-weight: 750; font-size: 14px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card .ttl .ic { font-size: 17px; }
.section-h { font-size: 19px; font-weight: 780; letter-spacing: -.02em; margin: 30px 2px 14px; display: flex; align-items: center; gap: 9px; }
.section-h .ic { font-size: 20px; }

/* Note /20 ring */
.gradebig { display: flex; align-items: center; gap: 18px; }
.ring { --p: 0; width: 96px; height: 96px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p)*1%), var(--bg-2) 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; background: var(--paper); border-radius: 50%; }
.ring .v { position: relative; font-weight: 850; font-size: 22px; color: var(--brand-deep); }
.ring .v small { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.gradebig .meta .lvl { font-weight: 800; font-size: 17px; }
.gradebig .meta .desc { color: var(--ink-3); font-size: 13px; }

.stars { color: var(--gold); letter-spacing: 2px; }
.stars .off { color: var(--line-2); }

/* Resume / continue card */
.resume { display: flex; align-items: center; gap: 16px; }
.resume .badge { width: 56px; height: 56px; border-radius: 14px; background: var(--brand-soft); display: grid; place-items: center; font-size: 26px; flex: none; }
.resume .body { flex: 1; }
.resume .body .k { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.resume .body .t { font-weight: 750; font-size: 16px; }

/* Chapter path (parcours) */
.path { position: relative; padding-left: 6px; }
.chapter-node {
  display: flex; gap: 16px; align-items: stretch; position: relative;
  padding: 4px 0;
}
.chapter-node .rail { position: relative; width: 46px; flex: none; display: flex; flex-direction: column; align-items: center; }
.chapter-node .rail .line { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--line-2); border-radius: 3px; }
.chapter-node:first-child .rail .line { top: 23px; }
.chapter-node:last-child .rail .line { bottom: calc(100% - 23px); }
.chapter-node .orb {
  position: relative; z-index: 1; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px; font-weight: 800;
  background: var(--paper); border: 3px solid var(--line-2); color: var(--ink-3);
  margin-top: 1px;
}
.chapter-node.done .orb { background: linear-gradient(135deg, var(--key), #0f9d6e); border-color: transparent; color: #fff; }
.chapter-node.active .orb { border-color: var(--brand); color: var(--brand-deep); box-shadow: 0 0 0 5px var(--brand-soft); }
.chapter-node.locked .orb { opacity: .55; }
.chapter-node .rail .line.done { background: linear-gradient(var(--key), #0f9d6e); }

.chapter-card {
  flex: 1; margin: 2px 0 14px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
  cursor: pointer; transition: transform .08s ease, box-shadow .14s ease;
}
.chapter-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.chapter-card.locked { opacity: .68; cursor: default; }
.chapter-card.locked:hover { transform: none; box-shadow: var(--shadow); }
.chapter-card .top { display: flex; align-items: center; gap: 10px; }
.chapter-card .kk { font-size: 11.5px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .08em; }
.chapter-card h3 { margin: 3px 0 4px; font-size: 17.5px; letter-spacing: -.02em; }
.chapter-card .lede { color: var(--ink-2); font-size: 13.5px; margin: 0 0 10px; }
.chapter-card .foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pill-prog { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); font-weight: 650; }
.bar { width: 130px; height: 7px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--hero-a), var(--hero-b)); }
.tagmini { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-deep); }
.tagmini.cap { background: var(--gold-soft); color: var(--gold-deep); }

/* ============================================================ COURS */
.course-head { position: relative; border-radius: 22px; padding: 26px 28px; color: #fff; margin-bottom: 22px;
  background: linear-gradient(125deg, var(--hero-a), var(--hero-b) 70%, var(--hero-c)); box-shadow: var(--shadow-lg); overflow: hidden; }
.course-head::after { content: ""; position: absolute; inset: 0; background: radial-gradient(440px 240px at 92% -40%, rgba(255,255,255,.25), transparent 60%); }
.course-head .kk { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .92; font-weight: 700; }
.course-head h1 { margin: 6px 0 8px; font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -.025em; }
.course-head p { margin: 0; max-width: 680px; opacity: .96; font-size: 15.5px; }
.course-head .obj { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 9px; position: relative; z-index: 1; }
.course-head .obj span { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3); border-radius: 99px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }

.course { max-width: 820px; margin: 0 auto; }
.course .lesson-h { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 34px 0 6px; padding-top: 8px; }
.course .lesson-h .num { color: var(--brand); margin-right: 8px; }
.course p.prose { font-size: 16px; color: var(--ink); margin: 12px 0; }
.course p.prose code, .course li code, .box code, .quiz code { font-family: var(--mono); font-size: .9em; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; color: var(--brand-deep); }
.course ul.prose { font-size: 16px; padding-left: 22px; }
.course ul.prose li { margin: 5px 0; }

/* Encadrés couleur — mémorisation */
.box { border-radius: 14px; padding: 15px 17px 15px 50px; margin: 16px 0; position: relative; border: 1px solid; font-size: 15px; }
.box .ic { position: absolute; left: 15px; top: 14px; font-size: 21px; }
.box .h { font-weight: 800; display: block; margin-bottom: 3px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.box.def  { background: var(--def-bg);  border-color: var(--def-edge);  } .box.def  .h { color: var(--def); }
.box.tip  { background: var(--tip-bg);  border-color: var(--tip-edge);  } .box.tip  .h { color: var(--tip); }
.box.trap { background: var(--trap-bg); border-color: var(--trap-edge); } .box.trap .h { color: var(--trap); }
.box.key  { background: var(--key-bg);  border-color: var(--key-edge);  } .box.key  .h { color: var(--key); }
.box.exa  { background: var(--exa-bg);  border-color: var(--exa-edge);  } .box.exa  .h { color: var(--exa); }

/* Bloc code/exemple */
.codeblock { background: #1e2230; color: #e7e9f3; border-radius: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; overflow-x: auto; margin: 14px 0; box-shadow: var(--shadow); }
.codeblock .cm { color: #8b93ab; }
.codeblock .kw { color: #c4b5fd; }
.codeblock .st { color: #fcd9a6; }
.codeblock .nb { color: #7ee0c0; }
.codeblock .rs { color: #f9a8c8; }
.codeblock .out { color: #8b93ab; }

/* Figure SVG (visuels + flèches) */
.figure { margin: 20px 0; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); text-align: center; }
.figure svg { max-width: 100%; height: auto; }
.figure .cap { font-size: 13px; color: var(--ink-3); margin-top: 10px; }
.figure .cap b { color: var(--ink-2); }

/* Vocabulaire mini-section */
.voc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
@media (max-width: 620px) { .voc-grid { grid-template-columns: 1fr; } }
.voc-item { background: var(--voc-bg); border: 1px solid var(--voc-edge); border-radius: 12px; padding: 11px 14px; }
.voc-item .term { font-weight: 800; color: var(--voc); font-size: 14.5px; }
.voc-item .def { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }

/* Points clés */
.keypoints { background: var(--key-bg); border: 1px solid var(--key-edge); border-radius: 16px; padding: 16px 18px 16px 20px; margin: 22px 0; }
.keypoints h4 { margin: 0 0 8px; color: var(--key); font-size: 14px; display: flex; align-items: center; gap: 7px; }
.keypoints ul { margin: 0; padding-left: 20px; }
.keypoints li { margin: 5px 0; font-size: 15px; }

/* Mini-quiz compréhension */
.quiz { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin: 22px 0; box-shadow: var(--shadow); }
.quiz h4 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.quiz .q { font-weight: 650; margin: 14px 0 8px; font-size: 15.5px; }
.quiz .opts { display: flex; flex-direction: column; gap: 8px; }
.quiz .opt { text-align: left; border: 1.5px solid var(--line-2); background: var(--paper); border-radius: 11px; padding: 10px 14px; cursor: pointer; font-size: 14.5px; transition: background .1s, border-color .1s; }
.quiz .opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.quiz .opt.good { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.quiz .opt.bad { border-color: var(--trap); background: var(--trap-bg); color: var(--trap); }
.quiz .why { margin-top: 8px; font-size: 13.5px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); color: var(--ink-2); display: none; }
.quiz .why.show { display: block; }

.course-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 36px 0 0; flex-wrap: wrap; padding-top: 22px; border-top: 1px solid var(--line); }
.course-foot .go-ex { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================ ATELIER (exercice) */
.lab { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .lab { grid-template-columns: 1fr; } }
.lab .col { display: flex; flex-direction: column; gap: 16px; }

.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 12px; }
.crumbs a { font-weight: 650; }
.crumbs .sep { margin: 0 7px; opacity: .6; }

.ex-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-title h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.tag { font-size: 11px; font-weight: 750; padding: 3px 10px; border-radius: 99px; }
.tag.py { background: #e2f6fb; color: var(--voc); }
.tag.n { background: var(--brand-soft); color: var(--brand-deep); }
.tag.cap { background: var(--gold-soft); color: var(--gold-deep); }
.mission { margin: 12px 0 4px; font-style: italic; color: var(--ink-2); }
.enonce h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 16px 0 4px; }
.enonce p { margin: 8px 0; font-size: 15px; }
.enonce ul { font-size: 15px; padding-left: 22px; }
.enonce code { font-family: var(--mono); font-size: .9em; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; color: var(--brand-deep); }
.pdf-note { font-size: 13px; background: var(--gold-soft); border: 1px solid var(--tip-edge); border-radius: 11px; padding: 11px 13px; margin-top: 12px; color: var(--ink-2); }

.editor-card .rung-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.rung-bar .lab { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.rung-pills { display: flex; gap: 5px; }
.rung-pills .pill { width: 22px; height: 7px; border-radius: 99px; background: var(--bg-2); }
.rung-pills .pill.on { background: linear-gradient(90deg, var(--hero-a), var(--hero-b)); }
.rung-label { font-size: 12.5px; color: var(--ink-2); }

#editorHost { border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); }
.editor-fallback {
  width: 100%; min-height: 280px; border: 0; padding: 14px 16px; resize: vertical;
  font-family: var(--mono); font-size: 14px; line-height: 1.6; color: #e7e9f3; background: #1e2230;
  tab-size: 4; outline: none; display: block;
}
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

.verdict { border-radius: 14px; padding: 16px 18px; font-size: 14.5px; border: 1px solid var(--line); background: var(--paper); }
.verdict .big { display: block; font-size: 16px; font-weight: 780; margin-bottom: 4px; }
.verdict.idle { color: var(--ink-3); }
.verdict.run { background: var(--brand-soft); border-color: #d8d6fb; }
.verdict.win { background: var(--ok-bg); border-color: var(--key-edge); color: var(--ok); }
.verdict.notyet { background: var(--notyet-bg); border-color: var(--tip-edge); color: var(--notyet); }
.verdict .diff { background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; margin: 10px 0 0; color: var(--ink); font-size: 14px; }
.verdict .got { font-family: var(--mono); color: var(--trap); font-weight: 700; }
.verdict .exp { font-family: var(--mono); color: var(--ok); font-weight: 700; }
.err-fr { background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; margin-top: 10px; color: var(--ink); }
.err-fr .ti { font-weight: 800; color: var(--trap); }
.err-fr details { margin-top: 6px; } .err-fr summary { cursor: pointer; color: var(--ink-3); font-size: 12.5px; }
.err-fr pre { background: var(--bg-2); padding: 8px 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }

/* Forge */
.forge .ing-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ingot { flex: 1; min-width: 78px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); padding: 11px 8px; text-align: center; transition: all .25s; }
.ingot .ic { font-size: 20px; color: var(--ink-3); }
.ingot .lab { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.ingot .v { font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ingot.amber { background: var(--tip-bg); border-color: var(--tip-edge); } .ingot.amber .ic { color: var(--gold-deep); }
.ingot.gold { background: linear-gradient(135deg, #fff0cf, #ffe2a0); border-color: var(--gold); box-shadow: 0 4px 12px rgba(216,132,26,.25); } .ingot.gold .ic { color: var(--gold-deep); }
.forge .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 9px; font-weight: 650; }

/* Reveal mockup */
.mockup .screen { border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); padding: 22px; text-align: center; transition: all .3s; }
.mockup .screen .eteint { color: var(--ink-3); font-size: 17px; }
.mockup .screen .allume { color: var(--ok); font-size: 20px; font-weight: 800; }
.mockup .screen.lit { background: var(--ok-bg); border-color: var(--key-edge); box-shadow: 0 6px 18px rgba(4,120,87,.18); }
.mockup .cap { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.mockup .honnete { font-size: 11.5px; color: var(--ink-3); font-style: italic; margin-top: 4px; }

/* Pyo */
.pyo { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 10px; }
.pyo .face { font-size: 26px; } .pyo .msg { font-size: 13.5px; color: var(--ink-2); }
.bug-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bug-q { background: var(--bg-2); padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.bug-code { font-family: var(--mono); font-size: 13px; }
.bug-code .ln { display: flex; cursor: pointer; }
.bug-code .ln:hover { background: var(--brand-soft); }
.bug-code .ln .n { width: 30px; text-align: right; padding: 3px 8px; color: var(--ink-3); background: var(--bg-2); user-select: none; }
.bug-code .ln .src { padding: 3px 10px; white-space: pre; }
.bug-code .ln.bad { background: var(--trap-bg); } .bug-code .ln.bad .src { color: var(--trap); }
.bug-code .ln.good { background: var(--ok-bg); } .bug-code .ln.good .src { color: var(--ok); font-weight: 700; }
.hint { border-left: 4px solid var(--def); background: var(--def-bg); border-radius: 0 10px 10px 0; padding: 11px 13px; font-size: 13.5px; margin-top: 8px; }

/* Console + viz */
.console { font-family: var(--mono); font-size: 12.5px; background: #1e2230; color: #cdd2e4; padding: 12px 14px; border-radius: 11px; white-space: pre-wrap; min-height: 36px; }
.viz-ctrl { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.viz .step { display: flex; gap: 10px; padding: 5px 8px; border-radius: 8px; font-size: 13px; }
.viz .step.cur { background: var(--brand-soft); }
.viz .vars { font-family: var(--mono); color: var(--ink-2); }
.viz .chg { font-family: var(--mono); color: var(--brand-deep); font-weight: 700; background: #e9e7fd; padding: 0 4px; border-radius: 5px; }

/* ============================================================ VOCABULAIRE */
.flash-wrap { max-width: 560px; margin: 10px auto; }
.flash { perspective: 1400px; height: 280px; margin: 18px 0; }
.flash .inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; cursor: pointer; }
.flash.flip .inner { transform: rotateY(180deg); }
.flash .side { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; padding: 26px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; box-shadow: var(--shadow-lg); }
.flash .front { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; }
.flash .front .term { font-size: 28px; font-weight: 850; letter-spacing: -.02em; }
.flash .front .hint { background: rgba(255,255,255,.16); border: 0; color: #fff; margin-top: 14px; }
.flash .back { background: var(--paper); border: 1px solid var(--line); transform: rotateY(180deg); }
.flash .back .def { font-size: 16px; color: var(--ink); }
.flash .back .ex { margin-top: 12px; font-family: var(--mono); font-size: 13px; background: var(--bg-2); padding: 8px 12px; border-radius: 9px; color: var(--brand-deep); }
.flash-nav { display: flex; align-items: center; justify-content: center; gap: 16px; }
.flash-nav .count { font-weight: 700; color: var(--ink-3); }
.deck-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.deck-tabs .dt { padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; }
.deck-tabs .dt.on { background: var(--voc); border-color: var(--voc); color: #fff; }

/* ============================================================ RAISONNEMENT */
.drill { max-width: 720px; margin: 0 auto; }
.drill-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px 24px; margin: 16px 0; }
.drill-card .qtype { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--exa); }
.drill-card .qtext { font-size: 17px; font-weight: 650; margin: 8px 0 14px; }
.order-pool, .order-chosen { display: flex; flex-direction: column; gap: 7px; min-height: 8px; }
.order-chosen { margin-bottom: 10px; padding: 8px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--bg); }
.order-block { text-align: left; font-family: var(--mono); font-size: 13.5px; border: 1.5px solid var(--line-2); background: var(--paper); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.order-block:hover { border-color: var(--exa); background: var(--exa-bg); }
.drill-feedback { margin-top: 12px; padding: 12px 14px; border-radius: 11px; font-size: 14px; display: none; }
.drill-feedback.show { display: block; }
.drill-feedback.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--key-edge); }
.drill-feedback.no { background: var(--notyet-bg); color: var(--notyet); border: 1px solid var(--tip-edge); }
.drill-course { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0 14px; }
.drill-course .course-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 850; color: var(--brand); }
.drill-course h3 { margin: 4px 0 6px; font-size: 16px; line-height: 1.25; }
.drill-course p { margin: 7px 0; font-size: 14px; color: var(--ink-2); }
.drill-course .course-objective { color: var(--ink); font-weight: 700; }
.worked-example { background: var(--def-bg); border: 1px solid var(--def-edge); border-radius: 11px; padding: 10px 12px; margin: 9px 0; }
.worked-example .ex-k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 850; color: var(--def); }
.worked-example p { margin: 5px 0; font-size: 13.5px; }
.drill-learn { background: #f8f7f4; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.drill-learn .learn-k, .drill-correction .corr-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 850; color: var(--brand); margin-bottom: 5px; }
.drill-learn .learn-main { font-weight: 780; color: var(--ink); }
.drill-learn .learn-model { color: var(--ink-2); font-size: 13.5px; margin-top: 5px; }
.drill-learn ol { margin: 8px 0 0; padding-left: 20px; }
.drill-learn li { margin: 4px 0; font-size: 13.5px; color: var(--ink-2); }
.guided-questions, .reason-checklist, .reason-trace { border-radius: 11px; padding: 10px 12px; margin: 9px 0; font-size: 13.5px; }
.guided-questions { background: var(--gold-soft); border: 1px solid var(--tip-edge); color: var(--gold-deep); }
.reason-checklist { background: var(--key-bg); border: 1px solid var(--key-edge); color: var(--key); }
.reason-trace { background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); }
.guided-questions ol, .reason-checklist ul, .reason-trace ol { margin: 6px 0 0; padding-left: 20px; }
.guided-questions li, .reason-checklist li, .reason-trace li { margin: 4px 0; }
.drill-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.drill-hint { display: none; margin-top: 10px; border-left: 4px solid var(--def); background: var(--def-bg); border-radius: 0 10px 10px 0; padding: 10px 12px; color: var(--def); font-size: 13.5px; }
.drill-hint.show { display: block; }
.drill-correction { color: var(--ink); }
.drill-correction p { margin: 7px 0; }
.drill-correction ul, .drill-correction ol { margin: 8px 0; padding-left: 20px; }
.drill-correction li { margin: 4px 0; }
.engineer-tip, .v2-tip { margin-top: 9px; border-radius: 10px; padding: 9px 11px; font-size: 13.5px; }
.engineer-tip { background: var(--key-bg); color: var(--key); border: 1px solid var(--key-edge); }
.v2-tip { background: var(--exa-bg); color: var(--exa); border: 1px solid var(--exa-edge); }

/* ============================================================ BADGES */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.badge-tile { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 18px 14px; text-align: center; position: relative; }
.badge-tile.locked { opacity: .5; filter: grayscale(.7); }
.badge-tile .em { font-size: 40px; }
.badge-tile .bt { font-weight: 800; margin-top: 6px; font-size: 14.5px; }
.badge-tile .bd { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.badge-tile .got { position: absolute; top: 10px; right: 10px; color: var(--ok); font-weight: 800; }

/* ============================================================ Toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 13px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  transition: all .3s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .vert { color: #6ee7b7; }
.toast .gold { color: var(--gold); }

/* Confetti-lite (étoiles montantes) */
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .4s ease; }

/* Level-up overlay */
.overlay { position: fixed; inset: 0; background: rgba(31,37,51,.5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 70; opacity: 0; pointer-events: none; transition: opacity .3s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay .panel { background: var(--paper); border-radius: 22px; padding: 32px 36px; text-align: center; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .45s ease; }
.overlay .panel .em { font-size: 56px; }
.overlay .panel h3 { margin: 8px 0 4px; font-size: 22px; }
.overlay .panel p { color: var(--ink-2); margin: 0 0 18px; }

/* ============================================================ V4 — coquille & compléments
   Ajouts pour app.js (barre du haut riche, overlay niveau, toasts empilés),
   views.js (blocs steps/compare/flow/table, cartes médiathèque) et lab.js. */

/* Conteneur des écrans */
.app { max-width: 1140px; margin: 0 auto; padding: 26px 20px 60px; }
.foot-min { max-width: 1140px; margin: 0 auto; padding: 22px 20px 40px; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--ink-2); border-top: 1px solid var(--line); }

/* Marque (wordmark) */
.brand .wm { font-size: 18px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); }
.brand .wm b { font-weight: 850; }

/* Barre du haut — stats vivantes */
.top-stats { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-stats .stat { display: flex; flex-direction: column; justify-content: center; }
.stat.note { align-items: baseline; flex-direction: row; gap: 2px; font-weight: 850; padding: 5px 11px; border-radius: 11px; background: var(--brand-soft); color: var(--brand-deep); line-height: 1; }
.stat.note .v { font-size: 17px; } .stat.note .u { font-size: 11px; opacity: .8; font-weight: 700; }
.stat.note.g0 { background: var(--bg-2); color: var(--ink-3); }
.stat.note.g1 { background: var(--trap-bg); color: var(--trap); }
.stat.note.g2 { background: var(--tip-bg); color: var(--gold-deep); }
.stat.note.g3 { background: var(--brand-soft); color: var(--brand-deep); }
.stat.note.g4 { background: var(--key-bg); color: var(--key); }
.stat.note.g5 { background: linear-gradient(135deg, var(--gold-soft), #ffe7b8); color: var(--gold-deep); }
.stat.lvl { min-width: 116px; gap: 4px; }
.stat.lvl .lvl-head { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 750; }
.stat.lvl .lvl-head .lv { color: var(--ink-2); } .stat.lvl .lvl-head .xp { color: var(--xp); }
.stat.lvl .xpbar { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.stat.lvl .xpbar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--xp), var(--hero-c)); transition: width .5s ease; }
.stat.streak { flex-direction: row; align-items: center; gap: 5px; font-weight: 800; font-size: 14px; color: var(--ink-3); }
.stat.streak.on { color: var(--flame); }
.stat.streak .ic { filter: grayscale(1); } .stat.streak.on .ic { filter: none; }
.engine .etxt { font-size: 11px; }
@media (max-width: 1080px) { .nav .t { display: none; } .nav a { padding: 7px 10px; } }
@media (max-width: 920px) { .engine, .stat.lvl .lvl-head .xp { display: none; } }
@media (max-width: 760px) { .top-stats .stat.lvl { display: none; } .topbar { gap: 10px; padding: 9px 14px; } }
@media (max-width: 520px) {
  .app { padding: 24px 14px 56px; }
  .hero { border-radius: 20px; padding: 30px 20px 28px; }
  .hero .eyebrow { font-size: 11.5px; letter-spacing: .12em; }
  .hero h1 { font-size: 26px; line-height: 1.13; }
  .hero p.lead { font-size: 15px; }
  .hero .cta-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .hero .cta-row .btn { width: 100%; min-width: 0; text-align: center; white-space: normal; }
  .hero-badges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .hero-chip { min-width: 0; padding: 10px 14px; }
}

/* Bloc code : titre + langue + retours à la ligne respectés */
.codeblock { white-space: pre; }
.code-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #2a2f42; color: #aeb6d0; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 12px 12px 0 0; margin: 14px 0 -14px; }
.code-title + .codeblock { border-top-left-radius: 0; border-top-right-radius: 0; }
.code-lang { background: rgba(255,255,255,.1); padding: 1px 8px; border-radius: 99px; font-size: 11px; }

/* Étapes numérotées */
.steps { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin: 16px 0; box-shadow: var(--shadow); }
.steps-h { font-weight: 800; font-size: 14px; margin-bottom: 6px; color: var(--brand-deep); }
.steps ol { margin: 0; padding-left: 22px; } .steps li { margin: 7px 0; font-size: 15px; }
.steps li b { color: var(--ink); }

/* Comparatif deux colonnes */
.compare { margin: 18px 0; }
.cmp-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .cmp-grid { grid-template-columns: 1fr; } }
.cmp-col { border-radius: 13px; padding: 13px 15px; border: 1px solid var(--line-2); background: var(--paper); }
.cmp-col .cmp-h { font-weight: 800; font-size: 13.5px; margin-bottom: 6px; }
.cmp-col ul { margin: 0; padding-left: 18px; } .cmp-col li { margin: 4px 0; font-size: 14px; }
.cmp-col.good { background: var(--key-bg); border-color: var(--key-edge); } .cmp-col.good .cmp-h { color: var(--key); }
.cmp-col.bad { background: var(--trap-bg); border-color: var(--trap-edge); } .cmp-col.bad .cmp-h { color: var(--trap); }
.cmp-col.neutral .cmp-h { color: var(--ink-2); }

/* Flux (étapes reliées par des flèches) */
.flow { margin: 18px 0; }
.flow-h { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.flow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow-node { background: var(--brand-soft); border: 1px solid #d8d6fb; color: var(--brand-deep); border-radius: 10px; padding: 8px 13px; font-weight: 650; font-size: 14px; }
.flow-arr { color: var(--ink-3); font-weight: 800; }

/* Tableau de cours */
.ftable { margin: 18px 0; overflow-x: auto; }
.ft-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.ftable table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--paper); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.ftable th { background: var(--bg-2); text-align: left; padding: 9px 13px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.ftable td { padding: 9px 13px; border-top: 1px solid var(--line); }
.ftable tr:nth-child(even) td { background: #faf8f3; }

/* Encadré « note » (le 6e ton) */
.box.note { background: var(--bg-2); border-color: var(--line-2); } .box.note .h { color: var(--ink-2); }

/* ============================================================ Médiathèque — cartes */
.monde-card { display: flex; gap: 16px; align-items: flex-start; transition: transform .08s ease, box-shadow .14s ease; }
.monde-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.monde-ic { width: 54px; height: 54px; border-radius: 15px; flex: none; display: grid; place-items: center; font-size: 28px; background: var(--brand-soft); }
.monde-body { flex: 1; min-width: 0; }
.monde-ttl { font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.monde-sub { font-size: 13px; margin: 2px 0 8px; }
.monde-meta { font-size: 12.5px; color: var(--ink-3); font-weight: 650; margin-bottom: 8px; }
.monde-card .bar { width: 100%; }

.module-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 6px 8px 8px; margin: 16px 0; }
.module-h { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; padding: 12px 12px 8px; letter-spacing: -.01em; }
.module-h .mic { font-size: 19px; }
.theme-list { display: flex; flex-direction: column; }
.theme-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; border: 1px solid transparent; }
a.theme-row { cursor: pointer; } a.theme-row:hover { background: var(--brand-soft); border-color: #e2e0fb; }
.theme-row .th-ic { font-size: 16px; width: 22px; text-align: center; flex: none; }
.theme-row .th-name { flex: 1; font-size: 14.5px; color: var(--ink); min-width: 0; }
.theme-row .th-st { font-size: 12px; font-weight: 750; padding: 3px 10px; border-radius: 99px; flex: none; }
.theme-row .th-st.ready { background: var(--brand-soft); color: var(--brand-deep); }
.theme-row .th-st.done { background: var(--key-bg); color: var(--key); }
.theme-row .th-st.soon { background: var(--bg-2); color: var(--ink-3); }
.theme-row.done .th-name { color: var(--ink-2); }
.theme-row.soon .th-name { color: var(--ink-3); }

/* Tuile d'exercice (atelier) */
.ex-tile { display: flex; flex-direction: column; transition: transform .08s ease, box-shadow .14s ease; }
.ex-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.ex-tile.done { border-color: var(--key-edge); }
.ex-tile .ttl { font-weight: 750; font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ex-tile .ttl .ic { font-size: 17px; }

/* Academy publique/adaptative */
.academy-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px 16px; margin: 0 0 14px;
}
.academy-strip span { color: var(--ink-3); margin-left: 4px; }
.mastery-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.mastery-pill { font-size: 12px; font-weight: 750; border-radius: 99px; padding: 5px 10px; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); }
.mastery-pill.mastered { background: var(--key-bg); border-color: var(--key-edge); color: var(--key); }
.mastery-pill.remediate { background: var(--trap-bg); border-color: var(--trap-edge); color: var(--trap); }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 14px 0; }
.pager > :last-child { justify-self: end; }
.coach-panel { margin-top: 12px; border-radius: 12px; padding: 12px 14px; border: 1px solid; }
.coach-panel .coach-title { font-size: 13px; font-weight: 850; margin-bottom: 4px; }
.coach-panel ul { margin: 0; padding-left: 18px; }
.coach-panel li { margin: 3px 0; font-size: 13.5px; }
.coach-panel.green { background: var(--ok-bg); border-color: var(--key-edge); color: var(--key); }
.coach-panel.red { background: var(--trap-bg); border-color: var(--trap-edge); color: var(--trap); }
.coach-panel.orange { background: var(--notyet-bg); border-color: var(--tip-edge); color: var(--notyet); }
.coach-panel.blue { background: var(--def-bg); border-color: var(--def-edge); color: var(--def); }
.coach-panel.violet { background: var(--exa-bg); border-color: var(--exa-edge); color: var(--exa); }
.mini-mastery { margin-top: 8px; color: var(--ink-3); font-size: 12.5px; }

.seg-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.seg-tabs a { border: 1px solid var(--line-2); border-radius: 99px; padding: 7px 13px; font-weight: 750; font-size: 13px; background: var(--paper); color: var(--ink-2); }
.seg-tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.project-card { display: flex; flex-direction: column; min-height: 220px; transition: transform .08s ease, box-shadow .14s ease; }
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.project-type { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 850; }
.project-title { font-size: 17px; font-weight: 850; line-height: 1.22; margin: 7px 0; color: var(--ink); }
.project-mission { font-size: 13.5px; flex: 1; }
.project-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.project-meta span { border-radius: 99px; padding: 4px 9px; font-size: 12px; background: var(--brand-soft); color: var(--brand-deep); font-weight: 750; }
.list-note { font-size: 13px; margin: 14px 2px 0; }
.project-detail { max-width: 840px; margin: 0 auto; display: grid; gap: 14px; }
.project-block { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px; }
.project-block h3 { margin: 0 0 8px; font-size: 16px; }
.project-block h4 { margin: 12px 0 6px; font-size: 14px; }
.project-block ul { margin: 0; padding-left: 20px; }
.project-block li { margin: 6px 0; }
.command-block pre { margin: 10px 0 0; white-space: pre-wrap; overflow-x: auto; background: #1e2230; color: #e7e9f3; border-radius: 11px; padding: 12px 14px; font-size: 12.5px; }
.command-block code { font-family: var(--mono); }
.file-list { display: grid; gap: 8px; }
.file-row { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #faf8f3; }
.file-row code { font-family: var(--mono); color: var(--brand-deep); font-size: 12.5px; }
.file-row span { color: var(--ink-2); font-size: 13px; }
.project-runbook { display: grid; gap: 12px; }
.run-step { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #faf8f3; }
.run-step h4 { margin: 0 0 4px; color: var(--brand-deep); }
.run-step p { margin: 0 0 10px; color: var(--ink-2); }
.run-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.run-cols b { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.run-cols ul { margin-top: 5px; }
.coach-block code { white-space: pre-wrap; color: var(--brand-deep); font-family: var(--mono); font-size: 12.5px; }
.workbench-shell { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; align-items: start; }
.workbench-side, .workbench-main, .workbench-file, .workbench-output {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.workbench-side { padding: 18px 20px; position: sticky; top: 82px; }
.workbench-side h3 { margin: 0 0 8px; font-size: 15px; }
.workbench-side h3 + ul { margin: 0 0 16px; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }
.workbench-main { padding: 14px; display: grid; gap: 12px; }
.workbench-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.workbench-file { overflow: hidden; }
.file-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; background: #faf8f3; border-bottom: 1px solid var(--line); }
.file-head code { font-family: var(--mono); color: var(--brand-deep); font-size: 12.5px; }
.file-head span { color: var(--ink-3); font-size: 12.5px; text-align: right; }
.workbench-file textarea {
  width: 100%; min-height: 190px; border: 0; resize: vertical; box-sizing: border-box;
  padding: 13px 14px; font: 12.5px/1.55 var(--mono); color: #e7e9f3; background: #1e2230;
  outline: none;
}
.workbench-file textarea:focus { box-shadow: inset 0 0 0 2px var(--brand); }
.workbench-output { padding: 16px 18px; }
.workbench-output h3 { margin: 0 0 8px; font-size: 16px; }
.academy-preview { width: 100%; min-height: 360px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-top: 10px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #faf8f3; }
.check-row b { font-size: 13.5px; }
.check-row span { color: var(--ink-2); font-size: 12.5px; }
.check-row.pass { background: var(--key-bg); border-color: var(--key-edge); }
.check-row.warn { background: var(--tip-bg); border-color: var(--tip-edge); }
.check-row.todo { background: var(--def-bg); border-color: var(--def-edge); }

@media (max-width: 760px) {
  .file-row, .run-cols, .workbench-shell { grid-template-columns: 1fr; }
  .workbench-side { position: static; }
  .file-head { align-items: flex-start; flex-direction: column; }
  .file-head span { text-align: left; }
}

@media (max-width: 680px) {
  .academy-strip { align-items: stretch; flex-direction: column; }
  .pager { grid-template-columns: 1fr; text-align: center; }
  .pager > :last-child { justify-self: stretch; }
}

/* ============================================================ Toasts empilés + overlay niveau (réécrit) */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 9px; z-index: 60; pointer-events: none; }
.toast { position: static; left: auto; bottom: auto; transform: translateY(14px); }
.toast.show { transform: translateY(0); }
.toast .bdg { font-size: 17px; margin-right: 4px; }

.levelup { position: fixed; inset: 0; background: rgba(31,37,51,.5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 70; opacity: 0; pointer-events: none; transition: opacity .3s; }
.levelup.show { opacity: 1; }
.levelup .card-lvl { position: relative; overflow: hidden; background: var(--paper); border-radius: 24px; padding: 34px 40px; text-align: center; box-shadow: var(--shadow-lg); max-width: 360px; animation: pop .5s ease; }
.levelup .lv-em { font-size: 58px; }
.levelup .lv-ttl { font-size: 24px; font-weight: 850; margin-top: 4px; }
.levelup .lv-ttl .lv-num { color: var(--brand-deep); }
.levelup .lv-sub { color: var(--ink-2); margin-top: 4px; }
.levelup .confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.levelup .confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation: fall 1.8s linear forwards; }
@keyframes fall { 0% { top: -14px; opacity: 1; } 100% { top: 110%; opacity: .2; } }

/* ============================================================ MathKit — zéro cahier, zéro stylo */
.math-page { padding: 0; }
.math-kicker {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px;
  color: var(--brand-deep); font-size: 12px; font-weight: 850; text-transform: uppercase;
}
.math-hero { margin-bottom: 18px; }
.math-hero h1 { max-width: 820px; }
.math-zero {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 10px;
}
.math-zero-item {
  display: flex; gap: 11px; align-items: flex-start; min-width: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  box-shadow: var(--shadow);
}
.math-zero-ic {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--brand-soft); font-size: 20px;
}
.math-zero-item b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.math-zero-item span { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.4; }

.math-track-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; }
.math-track-card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 238px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 17px;
  color: var(--ink); box-shadow: var(--shadow); transition: transform .08s ease, box-shadow .14s ease;
}
.math-track-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.math-track-card.def { border-color: var(--def-edge); }
.math-track-card.key { border-color: var(--key-edge); }
.math-track-card.exa { border-color: var(--exa-edge); }
.math-track-card.voc { border-color: var(--voc-edge); }
.math-track-card.tip { border-color: var(--tip-edge); }
.math-track-ic {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); font-size: 24px;
}
.math-track-title { font-weight: 850; line-height: 1.18; overflow-wrap: anywhere; }
.math-track-card p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.42; }
.math-track-goal {
  margin-top: auto; color: var(--ink-3); font-size: 12.5px; line-height: 1.35;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.math-mini-mastery { display: flex; flex-wrap: wrap; gap: 6px; }
.math-mastery {
  display: inline-flex; align-items: center; max-width: 100%; border-radius: 99px; padding: 4px 8px;
  background: var(--bg-2); color: var(--ink-3); font-size: 11.5px; font-weight: 750; overflow-wrap: anywhere;
}
.math-mastery.en-cours { background: var(--def-bg); color: var(--def); }
.math-mastery.fragile { background: var(--trap-bg); color: var(--trap); }
.math-mastery.maitrise { background: var(--key-bg); color: var(--key); }

.math-dashboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 1.35fr; gap: 12px; }
.math-dash-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 15px; min-width: 0;
}
.math-dash-card > span { display: block; color: var(--ink-3); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.math-dash-card strong { display: block; font-size: 28px; line-height: 1.1; color: var(--brand-deep); margin: 4px 0; }
.math-dash-card p { margin: 0; color: var(--ink-3); font-size: 12.5px; }
.math-dash-card b { display: block; margin-bottom: 8px; }
.math-dash-card ul { margin: 0; padding-left: 18px; }
.math-dash-card li { font-size: 12.5px; margin: 4px 0; color: var(--ink-2); }
.math-dash-card li span { color: var(--trap); font-weight: 850; }

.math-title-band, .math-lesson-head, .math-ex-head {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.math-title-band { display: flex; gap: 16px; align-items: flex-start; }
.math-title-band.def { background: linear-gradient(135deg, var(--def-bg), #fff); border-color: var(--def-edge); }
.math-title-band.key { background: linear-gradient(135deg, var(--key-bg), #fff); border-color: var(--key-edge); }
.math-title-band.exa { background: linear-gradient(135deg, var(--exa-bg), #fff); border-color: var(--exa-edge); }
.math-title-band.voc { background: linear-gradient(135deg, var(--voc-bg), #fff); border-color: var(--voc-edge); }
.math-title-band.tip { background: linear-gradient(135deg, var(--tip-bg), #fff); border-color: var(--tip-edge); }
.math-title-band h1, .math-lesson-head h1, .math-ex-head h1 { margin: 5px 0 4px; line-height: 1.14; font-size: 28px; overflow-wrap: anywhere; }
.math-title-band p, .math-lesson-head p, .math-ex-head p { margin: 0; color: var(--ink-2); max-width: 740px; }
.math-lesson-head > span, .math-ex-level {
  display: inline-flex; width: fit-content; border-radius: 99px; padding: 4px 9px;
  background: var(--brand-soft); color: var(--brand-deep); font-size: 12px; font-weight: 850;
}
.math-road { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 310px); gap: 16px; align-items: start; }
.math-road-side {
  position: sticky; top: 82px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 16px;
}
.math-road-side h3 { margin: 0 0 10px; font-size: 15px; }
.math-concept-panel { border-top: 1px solid var(--line); padding: 12px 0; }
.math-concept-panel:first-of-type { border-top: 0; padding-top: 0; }
.math-concept-panel b { display: block; margin-bottom: 7px; font-size: 13.5px; }
.math-concept-panel ul { margin: 8px 0 0; padding-left: 17px; color: var(--ink-2); font-size: 12.5px; }
.math-concept-panel li { margin: 4px 0; }
.math-lesson-tile {
  display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 14px 16px; margin-bottom: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); color: var(--ink);
}
.math-lesson-tile b { display: block; font-size: 15px; }
.math-lesson-tile span { display: block; color: var(--ink-3); font-size: 13px; }
.math-lesson-tile em { flex: none; color: var(--brand-deep); font-style: normal; font-size: 12.5px; font-weight: 850; }
.math-level-group { display: grid; gap: 12px; margin-top: 18px; }
.math-level-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow);
  padding: 13px 15px;
}
.math-level-head b { display: block; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.math-level-head span { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.math-level-head strong {
  flex: none; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep);
  padding: 6px 10px; font-size: 12px; white-space: nowrap;
}
.math-ex-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.math-ex-tile {
  display: flex; flex-direction: column; gap: 7px; min-width: 0; min-height: 165px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 15px;
  color: var(--ink);
}
.math-ex-tile:hover { box-shadow: var(--shadow-lg); }
.math-ex-tile b { line-height: 1.18; overflow-wrap: anywhere; }
.math-ex-tile p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.math-ex-tile small { margin-top: auto; color: var(--ink-3); font-weight: 700; }

.math-lesson { display: grid; gap: 12px; max-width: 850px; }
.math-block { margin: 0; }
.math-block ul { margin: 4px 0 0; padding-left: 20px; }
.math-block p { margin: 0; }
.math-block .math-visual { margin: 8px 0 10px; }
.math-block-extra { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.math-mini {
  min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.62);
  padding: 9px 10px;
}
.math-mini b {
  display: block; margin-bottom: 4px; color: var(--ink-3); font-size: 11.5px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .04em;
}
.math-mini span { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

.math-ex-head { display: flex; gap: 14px; align-items: flex-start; }
.math-ex-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); gap: 16px; align-items: start; }
.math-ex-main, .math-workbench {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 16px;
}
.math-ex-main { display: grid; gap: 13px; min-width: 0; }
.math-workbench { position: sticky; top: 82px; display: grid; gap: 12px; min-width: 0; }
.math-prompt {
  background: var(--def-bg); border: 1px solid var(--def-edge); border-radius: 13px; padding: 13px 14px;
}
.math-prompt b { display: block; color: var(--def); margin-bottom: 4px; }
.math-prompt p { margin: 0; font-size: 18px; font-weight: 750; overflow-wrap: anywhere; }
.math-toolbelt { display: flex; flex-wrap: wrap; gap: 7px; }
.math-toolbelt span {
  border-radius: 99px; padding: 5px 9px; background: var(--bg-2); color: var(--ink-2); font-size: 11.5px; font-weight: 800;
}
.math-answer { display: grid; gap: 7px; }
.math-answer span, .math-answer b { font-size: 13px; font-weight: 850; color: var(--ink-2); }
.math-answer input {
  width: 100%; min-height: 48px; border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px;
  color: var(--ink); background: #fff; font: 800 20px/1.2 var(--mono); outline: none;
}
.math-answer input:focus, .math-scratch textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.math-answer.qcm { display: grid; gap: 8px; }
.math-choice {
  width: 100%; text-align: left; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 10px 12px; font-weight: 750; cursor: pointer;
}
.math-choice.on { background: var(--brand-soft); color: var(--brand-deep); border-color: #d8d6fb; }
.math-pad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.math-pad button {
  min-height: 39px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg-2);
  color: var(--ink); font: 850 15px/1 var(--mono); cursor: pointer;
}
.math-pad button:hover { background: var(--brand-soft); color: var(--brand-deep); }
.math-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.math-actions .btn:last-child { grid-column: 1 / -1; text-align: center; }
.math-scratch { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.math-scratch-head, .math-scratch-actions {
  display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 11px; background: #faf8f3;
}
.math-scratch-head b { font-size: 13.5px; }
.math-scratch textarea {
  width: 100%; min-height: 190px; resize: vertical; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 12px; color: var(--ink); background:
    linear-gradient(#fff 31px, var(--line) 32px);
  background-size: 100% 32px; font: 14px/32px var(--sans); outline: none;
}
.math-scratch-actions span { color: var(--ink-3); font-size: 12px; }

.math-visual {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; overflow: hidden;
}
.math-visual.mini { box-shadow: none; padding: 10px; }
.math-visual > b { display: block; margin-bottom: 10px; color: var(--brand-deep); }
.visual-guide {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px;
}
.visual-guide div {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; background: #faf8f3;
}
.visual-guide b {
  display: block; margin-bottom: 4px; color: var(--brand-deep); font-size: 11px; font-weight: 950;
  letter-spacing: 0; text-transform: uppercase;
}
.visual-guide span { display: block; color: var(--ink-2); font-size: 12.5px; line-height: 1.35; }
.math-visual.mini .visual-guide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.math-visual.mini .visual-guide div { padding: 8px; }
.fraction-compare { display: grid; gap: 10px; }
.fraction-strip { display: grid; gap: 5px; }
.fraction-strip span { color: var(--ink-2); font-size: 12.5px; font-weight: 800; }
.fraction-strip div { display: grid; overflow: hidden; height: 34px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--bg-2); }
.fraction-strip i { border-left: 1px solid rgba(31,37,51,.12); background: #fff; }
.fraction-strip i:first-child { border-left: 0; }
.fraction-strip i.on { background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.math-ratio-table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px; }
.math-ratio-table th, .math-ratio-table td { border: 1px solid var(--line); padding: 10px; text-align: center; }
.math-ratio-table th { background: var(--bg-2); color: var(--ink-2); text-align: left; }
.math-ratio-table .target { background: var(--key-bg); color: var(--key); font-weight: 900; }
.math-percent {
  position: relative; height: 44px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line-2); overflow: hidden;
}
.math-percent i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--hero-c)); }
.math-percent span { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-weight: 900; }
.math-balance { display: grid; grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr); gap: 10px; align-items: end; }
.math-balance div {
  min-height: 70px; border: 2px solid var(--line-2); border-radius: 14px 14px 8px 8px;
  display: grid; place-items: center; background: var(--tip-bg);
}
.math-balance div:last-child { background: var(--key-bg); }
.math-balance span { font: 900 22px/1.1 var(--mono); overflow-wrap: anywhere; text-align: center; }
.math-balance i { height: 92px; border-left: 4px solid var(--ink-3); justify-self: center; }
.math-graph { width: 100%; height: auto; max-height: 220px; }
.math-graph .axis { fill: none; stroke: var(--ink-3); stroke-width: 3; }
.math-graph .curve { fill: none; stroke: var(--brand); stroke-width: 5; stroke-linecap: round; }
.math-graph circle { fill: var(--gold); }
.math-graph text { fill: var(--ink-2); font: 700 13px var(--sans); }
.math-decision { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.math-decision span {
  min-height: 44px; display: grid; place-items: center; text-align: center; border-radius: 11px; padding: 7px;
  font-size: 12.5px; font-weight: 850; color: var(--ink); background: var(--brand-soft); border: 1px solid #dedcfb;
}
.math-map {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: stretch;
}
.math-map strong {
  grid-column: 1 / -1; min-height: 46px; display: grid; place-items: center; border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--hero-b)); color: #fff; font-weight: 950;
}
.math-map span, .visual-flow span, .visual-transfer span, .visual-constraints span,
.visual-equation-bridge span, .visual-equation-bridge strong,
.visual-worked span, .visual-control-loop span, .visual-memory-anchor span {
  min-height: 42px; display: grid; place-items: center; text-align: center; border-radius: 11px; padding: 8px;
  background: var(--brand-soft); border: 1px solid #dedcfb; color: var(--ink); font-weight: 850; font-size: 12.5px;
}
.visual-flow, .visual-equation-bridge {
  display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 18px minmax(0, 1fr) 18px minmax(0, 1fr);
  gap: 7px; align-items: center;
}
.visual-flow i, .visual-equation-bridge i {
  height: 2px; background: var(--brand); position: relative; border-radius: 99px;
}
.visual-flow i::after, .visual-equation-bridge i::after {
  content: ""; position: absolute; right: -1px; top: -4px; width: 0; height: 0;
  border-left: 8px solid var(--brand); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.visual-equation-bridge strong { background: var(--key-bg); border-color: var(--key-edge); color: var(--key); }
.visual-worked {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.visual-worked b {
  width: 24px; height: 24px; display: inline-grid; place-items: center; margin-bottom: 4px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px;
}
.visual-control-loop {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.visual-control-loop strong {
  grid-column: 1 / -1; min-height: 44px; display: grid; place-items: center; border-radius: 12px;
  background: var(--key-bg); color: var(--key); border: 1px solid var(--key-edge); font-weight: 950;
}
.visual-memory-anchor {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.visual-memory-anchor span:nth-child(1) { background: var(--key-bg); border-color: var(--key-edge); color: var(--key); }
.visual-memory-anchor span:nth-child(3) { background: var(--trap-bg); border-color: var(--trap-edge); color: var(--trap); }
.exercise-guide { border-top: 1px dashed var(--line-2); padding-top: 12px; }
.visual-bars { display: grid; gap: 9px; }
.visual-bars span {
  --w: 50%; position: relative; min-height: 38px; display: flex; align-items: center; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 11px; background: var(--bg-2); overflow: hidden;
  color: var(--ink); font-weight: 850; font-size: 12.5px;
}
.visual-bars span::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: linear-gradient(90deg, var(--hero-c), var(--gold)); opacity: .42;
}
.visual-bars span { isolation: isolate; }
.visual-trap {
  display: grid; gap: 6px; border: 1px solid var(--trap-edge); background: var(--trap-bg);
  color: var(--trap); border-radius: 13px; padding: 12px;
}
.visual-trap strong { font-weight: 950; }
.visual-trap span { color: var(--ink-2); line-height: 1.4; }
.visual-balance-deep {
  display: grid; grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr); gap: 10px; align-items: end;
}
.visual-balance-deep span {
  min-height: 62px; border: 2px solid var(--line-2); border-radius: 14px 14px 8px 8px; display: grid; place-items: center;
  background: var(--tip-bg); color: var(--ink); font-weight: 900;
}
.visual-balance-deep span:last-child { background: var(--key-bg); }
.visual-balance-deep i { height: 84px; border-left: 4px solid var(--ink-3); justify-self: center; }
.visual-machine {
  display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.4fr) minmax(0, .75fr); gap: 10px; align-items: center;
}
.visual-machine span, .visual-machine strong {
  min-height: 54px; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--bg-2); font-weight: 950;
}
.visual-machine strong { background: linear-gradient(135deg, var(--brand-soft), #fff7df); color: var(--brand-deep); }
.visual-graph-link, .visual-blueprint, .visual-network { width: 100%; height: auto; max-height: 180px; }
.visual-graph-link path, .visual-blueprint rect, .visual-blueprint path, .visual-network path {
  fill: none; stroke: var(--brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
}
.visual-graph-link circle, .visual-network circle { fill: var(--gold); stroke: #fff; stroke-width: 3; }
.visual-graph-link text, .visual-blueprint text { fill: var(--ink-2); font: 800 12px var(--sans); }
.visual-tree {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.visual-tree span:first-child { grid-column: 1 / -1; background: var(--key-bg); color: var(--key); }
.visual-tree span {
  min-height: 42px; display: grid; place-items: center; border-radius: 11px; padding: 8px;
  background: var(--bg-2); border: 1px solid var(--line-2); text-align: center; font-weight: 850; font-size: 12.5px;
}
.visual-proof {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center;
}
.visual-proof span {
  min-height: 44px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 11px;
  background: var(--bg-2); text-align: center; font-weight: 850; font-size: 12.5px; padding: 7px;
}
.visual-proof i { color: var(--brand); font-style: normal; font-weight: 950; }
.visual-proof em {
  grid-column: 1 / -1; color: var(--ink-2); background: var(--tip-bg); border: 1px solid var(--tip-edge);
  border-radius: 11px; padding: 8px 10px; font-style: normal; font-size: 12.5px;
}
.visual-matrix {
  display: grid; grid-template-columns: repeat(2, 48px) 28px minmax(0, 1fr); gap: 7px; align-items: center;
}
.visual-matrix span {
  min-height: 42px; display: grid; place-items: center; border: 1px solid var(--line-2); background: var(--bg-2);
  font: 900 16px/1 var(--mono); border-radius: 9px;
}
.visual-matrix i { grid-row: span 2; font-style: normal; font-weight: 950; color: var(--brand); text-align: center; }
.visual-matrix strong { grid-row: span 2; padding: 12px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-deep); text-align: center; }
.visual-matrix em { grid-column: 1 / -1; font-style: normal; color: var(--ink-2); font-size: 12.5px; }
.visual-constraints {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.visual-constraints strong {
  grid-column: 1 / -1; min-height: 44px; display: grid; place-items: center; border-radius: 12px;
  background: var(--key-bg); color: var(--key); font-weight: 950;
}
.visual-decision-matrix {
  width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px;
}
.visual-decision-matrix th, .visual-decision-matrix td { border: 1px solid var(--line); padding: 9px; text-align: center; }
.visual-decision-matrix th { background: var(--bg-2); color: var(--ink-2); font-size: 12.5px; }
.visual-transfer {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px;
}

.math-feedback {
  border-radius: 14px; padding: 13px 15px; border: 1px solid var(--line); background: var(--bg-2);
}
.math-feedback b { display: block; margin-bottom: 3px; }
.math-feedback span { color: var(--ink-2); font-size: 13.5px; }
.math-feedback.win { background: var(--key-bg); border-color: var(--key-edge); color: var(--key); }
.math-feedback.work { background: var(--tip-bg); border-color: var(--tip-edge); color: var(--notyet); }
.math-correction {
  border-radius: 16px; border: 1px solid var(--line); background: var(--paper); padding: 14px; box-shadow: var(--shadow);
}
.math-correction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.math-correction-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 11px; background: #faf8f3; }
.math-label { display: block; color: var(--ink-3); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.math-correction strong { display: block; margin-top: 3px; font-size: 18px; overflow-wrap: anywhere; }
.math-correction strong.ok { color: var(--key); }
.math-correction strong.bad { color: var(--trap); }
.math-steps, .math-focus, .math-remediation { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.math-steps b, .math-focus b, .math-remediation b { display: block; margin-bottom: 6px; color: var(--brand-deep); }
.math-steps ol, .math-remediation ul { margin: 0; padding-left: 20px; }
.math-steps li, .math-remediation li { margin: 5px 0; }
.math-focus p { margin: 0 0 8px; color: var(--ink-2); }

.math-review-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.math-memory-card {
  text-align: left; min-height: 170px; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  background: var(--paper); color: var(--ink); padding: 16px; cursor: pointer;
}
.math-memory-card:hover, .math-memory-card.flip { background: var(--brand-soft); border-color: #d8d6fb; }
.math-memory-card span { display: inline-flex; border-radius: 99px; padding: 3px 8px; background: var(--bg-2); color: var(--ink-3); font-size: 11px; font-weight: 850; }
.math-memory-card b { display: block; margin: 10px 0 5px; font-size: 16px; }
.math-memory-card p { margin: 0; color: var(--ink-2); }
.math-memory-card em { display: block; margin-top: 12px; color: var(--brand-deep); font-style: normal; font-size: 12px; font-weight: 850; }

@media (max-width: 1060px) {
  .math-track-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .math-zero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .math-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .math-dash-card.wide { grid-column: 1 / -1; }
}
@media (max-width: 880px) {
  .math-road, .math-ex-shell { grid-template-columns: 1fr; }
  .math-road-side, .math-workbench { position: static; }
  .math-ex-list, .math-review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; }
  .brand { flex: 1 1 auto; min-width: 145px; }
  .brand .wm { line-height: 1.1; }
  .top-stats { margin-left: 0; gap: 7px; }
  .nav {
    order: 3; width: 100%; margin-left: 0; flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; padding: 1px 0 2px; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; padding: 7px 10px; }
  .math-title-band, .math-ex-head { flex-direction: column; }
  .math-title-band h1, .math-lesson-head h1, .math-ex-head h1 { font-size: 23px; }
  .math-track-grid, .math-zero, .math-dashboard, .math-ex-list, .math-review-grid { grid-template-columns: 1fr; }
  .math-actions, .math-correction-grid, .math-decision, .math-block-extra,
  .math-map, .visual-tree, .visual-constraints, .visual-transfer,
  .visual-guide, .visual-worked, .visual-control-loop, .visual-memory-anchor { grid-template-columns: 1fr; }
  .math-visual.mini .visual-guide { grid-template-columns: 1fr; }
  .visual-flow, .visual-equation-bridge, .visual-proof, .visual-machine, .visual-balance-deep {
    grid-template-columns: 1fr; gap: 8px;
  }
  .visual-flow i, .visual-equation-bridge i { width: 2px; height: 18px; justify-self: center; }
  .visual-flow i::after, .visual-equation-bridge i::after {
    right: -4px; top: auto; bottom: -1px; border-left: 5px solid transparent; border-right: 5px solid transparent;
    border-top: 8px solid var(--brand); border-bottom: 0;
  }
  .visual-proof i { display: none; }
  .visual-matrix { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visual-matrix i, .visual-matrix strong { grid-row: auto; }
  .math-level-head { align-items: flex-start; flex-direction: column; }
  .math-pad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .math-lesson-tile { align-items: flex-start; flex-direction: column; }
  .math-balance span { font-size: 18px; }
}
