/* Ludique coloré : une couleur par matière, grandes cartes arrondies, fond lilas très clair */
:root {
  --bg: #f4f2ff; --paper: #ffffff; --ink: #221d45; --muted: #625d86; --line: #e1dcf7;
  --accent: #7c4dff; --soft: #ede6ff; --sun: #ffd23f;
  --ok: #17924f; --ok-soft: #defbe9; --ko: #d93a4a; --ko-soft: #ffe4e7;
  --b0: #3a7bf7; --b1: #f2555a; --b2: #1fae6a; --b3: #f59a1b; --b4: #d147a3;
  --m-francais: #f2555a; --m-maths: #3a7bf7; --m-histoire-geo: #f59a1b;
  --m-anglais: #12aaa0; --m-svt: #33b24a; --m-physique-chimie: #7c4dff; --m-emc: #d6409f;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@font-face { font-family: "Baloo 2"; font-weight: 400 800; font-display: swap; src: url(fonts/baloo2.woff2) format("woff2") }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(fonts/atkinson-400.woff2) format("woff2") }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/atkinson-400i.woff2) format("woff2") }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(fonts/atkinson-700.woff2) format("woff2") }
@media (prefers-color-scheme: dark) { :root {
  --bg: #15132a; --paper: #211e3d; --ink: #eeeaff; --muted: #a9a3cf; --line: #34305a;
  --accent: #a58bff; --soft: #2f2858; --sun: #ffd23f;
  --ok: #4fd68b; --ok-soft: #173b2a; --ko: #ff7a86; --ko-soft: #43202a;
  --b0: #6d9cff; --b1: #ff7a7e; --b2: #4fd68b; --b3: #ffb547; --b4: #f07cc6;
  color-scheme: dark } }

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 17px/1.55 var(--body); padding-inline: 16px; padding-block: 0 40px }
.wrap { max-width: 860px; margin: 0 auto }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0 }
h1 { font-size: 2.1rem; font-weight: 800 }
h2 { font-size: 1.5rem; font-weight: 700; color: var(--accent) }
h3 { font-size: 1.2rem; font-weight: 700 }
p { margin: 0 }
a { color: inherit }
button { font-family: inherit }
button:focus-visible, a:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px }
.muted { color: var(--muted) } .small { font-size: .9rem }
.stack { display: flex; flex-direction: column; gap: 18px }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-block: calc(12px + env(safe-area-inset-top, 0px)) 12px }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 800 1.35rem var(--display); color: #6a1fd6; text-decoration: none; margin-right: auto }
.brand img { width: 40px; height: 40px }
@media (prefers-color-scheme: dark) { .brand { color: #b48cff } }
.who { font-weight: 700; font-size: .95rem; text-decoration: none; padding: 4px 14px; border-radius: 999px; background: var(--paper); border: 2px solid var(--line); max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.streak { background: var(--sun); color: #3b2c00; font-weight: 700; padding: 4px 14px; border-radius: 999px; font-size: .95rem }
.streak:empty { display: none }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .95rem; color: var(--muted); margin-bottom: 10px }
.crumbs a { text-decoration: none; font-weight: 700; color: var(--accent) }
.crumbs .back { background: var(--accent); color: #fff; border-radius: 999px; padding: 6px 16px; margin-right: 6px; min-height: 40px; display: inline-flex; align-items: center }
.save { margin-top: 32px; font-size: .85rem; color: var(--muted); text-align: center }
h2.section { font-size: 1.25rem; color: var(--ink); margin-block: 22px 10px }
.pills { display: flex; flex-direction: column; gap: 6px; align-items: flex-end }
.pill.new { background: var(--ok); color: #fff }
@media (max-width: 520px) { .pills { flex-direction: row; align-items: center } }

/* Formulaires : connexion, profils */
.biglogo { display: block; width: min(100%, 360px); height: auto; margin: 8px auto 18px }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700 }
.field input { font: 400 1.1rem var(--body); color: var(--ink); background: var(--bg); border: 3px solid var(--line); border-radius: 14px; padding: 11px 14px; width: 100% }
.field input:focus { outline: none; border-color: var(--accent) }
.field input.code { font: 800 1.8rem var(--display); letter-spacing: .3em; max-width: 9em }
.err:empty { display: none }
.err { color: var(--ko); font-weight: 700 }
button.mcard { font: inherit; color: inherit; text-align: left; cursor: pointer }
button.mcard .ico { font: 800 1.8rem var(--display) }
.prow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-block: 8px; border-top: 2px solid var(--line) }
.rename { gap: 10px; padding-block: 8px; border-top: 2px solid var(--line) }
.addprofile { gap: 10px; margin-top: 8px; padding: 16px; border: 3px dashed var(--line); border-radius: 16px }
.addprofile h3 { margin: 0 }
.legal { gap: 10px } .legal h2 { margin-top: 10px; font-size: 1.2rem } .legal ul { margin: 0; padding-left: 1.2em }

.sheet { background: var(--paper); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 2px 0 var(--line) }
.btn { font: 700 1.05rem var(--display); border: 0; border-radius: 14px; padding: 10px 20px; cursor: pointer; background: var(--accent); color: #fff; box-shadow: 0 3px 0 rgb(0 0 0 / .18) }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgb(0 0 0 / .18) }
.btn.alt { background: var(--soft); color: var(--accent); box-shadow: none }
.btn.sun { background: var(--sun); color: #3b2c00 }
.btn.ok { background: var(--ok) } .btn.ko { background: var(--ko) }
.btn:disabled { opacity: .45; cursor: default }
.btn.big { font-size: 1.3rem; padding: 14px 30px }

/* Accueil : matières */
.hello { display: flex; flex-direction: column; gap: 6px; padding-block: 8px 18px }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 12px }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px } }
.mcard { --c: var(--accent); position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 22px; background: var(--paper); text-decoration: none; border: 3px solid transparent; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 35%, transparent); transition: transform .15s }
@media (hover: hover) { .mcard:hover { transform: translateY(-3px); border-color: var(--c) } .lcard:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent) } }
.mcard .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--c); color: #fff }
.mcard .ico svg { width: 32px; height: 32px }
.mcard h3 { font-size: 1.35rem }
@media (max-width: 520px) { .mcard { padding: 16px } .mcard h3 { font-size: 1.1rem; overflow-wrap: anywhere } .mcard .ico { width: 48px; height: 48px } }
.mcard.off { opacity: .55; box-shadow: none; pointer-events: none }
.pill { align-self: flex-start; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--accent) }
.pill.due { background: var(--sun); color: #3b2c00 }

/* Liste des leçons */
.lcard { --c: var(--accent); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 18px 20px; border-radius: 20px; background: var(--paper); text-decoration: none; border-left: 8px solid var(--c) }
.lcard .meter { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 8px; max-width: 320px }
.lcard .meter i { display: block; height: 100%; background: var(--ok) }
@media (max-width: 520px) { .lcard { grid-template-columns: 1fr } }

/* Onglets de leçon */
.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 10px; display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px }
.tabs a { flex: none; font: 700 1rem var(--display); text-decoration: none; color: var(--muted); padding: 7px 15px; border-radius: 999px; background: var(--paper) }
.tabs a[aria-current="page"] { background: var(--accent); color: #fff }

/* Séance */
.today { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center }
.today .count { font: 800 3.6rem/1 var(--display); color: var(--accent); font-variant-numeric: tabular-nums }
.tip { border-left: 5px solid var(--sun); padding: 4px 0 4px 14px }
@media (max-width: 520px) { .today { grid-template-columns: 1fr } }
.progress { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s }
.tag { align-self: flex-start; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 11px; border-radius: 99px; color: #fff; background: var(--b0) }
.question { font: 700 1.4rem/1.3 var(--display) }
.choices { display: flex; flex-direction: column; gap: 8px }
.choice { text-align: left; font-size: 1.05rem; color: var(--ink); background: var(--paper); border: 3px solid var(--line); border-radius: 14px; padding: 11px 15px; cursor: pointer }
/* Survol discret et seulement avec une souris : sur tablette, le « survol » reste collé là où on a touché et ressemble à une réponse cochée */
@media (hover: hover) { .choice:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 6%, var(--paper)) } }
.choice.good { border-color: var(--ok); background: var(--ok-soft) }
.choice.bad { border-color: var(--ko); background: var(--ko-soft) }
.choice.picked { border-color: var(--accent); background: var(--soft) }
.choice:disabled { cursor: default }
.sort { display: flex; flex-direction: column; gap: 8px }
.sort-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 12px; border-radius: 14px; border: 3px solid var(--line) }
.sort-row.good { border-color: var(--ok); background: var(--ok-soft) }
.sort-row.bad { border-color: var(--ko); background: var(--ko-soft) }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden }
.seg button { font-weight: 700; font-size: .95rem; border: 0; background: transparent; color: var(--muted); padding: 7px 13px; cursor: pointer }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff }
.seg button:disabled { cursor: default }
@media (max-width: 520px) { .sort-row { grid-template-columns: 1fr } }
.answer { background: var(--soft); border-radius: 14px; padding: 12px 16px; font-size: 1.1rem }
.feedback { position: relative; border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px }
.feedback.ok { background: var(--ok-soft); animation: pop .35s ease-out } .feedback.ko { background: var(--ko-soft) }
.feedback strong { font-family: var(--display); font-size: 1.2rem }
.feedback.ok strong { color: var(--ok) } .feedback.ko strong { color: var(--ko) }
@keyframes pop { 0% { transform: scale(.92) } 60% { transform: scale(1.03) } 100% { transform: scale(1) } }
.burst { position: absolute; left: 24px; top: 18px; width: 10px; height: 10px; border-radius: 3px; pointer-events: none; animation: fly .7s ease-out forwards }
@keyframes fly { from { transform: translate(0, 0) rotate(0); opacity: 1 } to { transform: translate(var(--x), var(--y)) rotate(200deg); opacity: 0 } }

/* Carte mentale */
.mm { position: relative; display: flex; flex-direction: column; align-items: center; gap: 46px; padding-block: 8px }
.mm-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible }
.mm-centre { position: relative; z-index: 1; max-width: 420px; text-align: center; background: var(--accent); color: #fff; border-radius: 28px; padding: 16px 26px; display: flex; flex-direction: column; gap: 2px }
.mm-centre strong { font: 800 1.5rem/1.15 var(--display) }
.mm-centre span { font-size: .95rem; opacity: .9 }
.mm-branches { position: relative; z-index: 1; width: 100%; display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 18px; align-items: start }
.mm.stack { align-items: stretch; gap: 24px }
.mm.stack .mm-centre { align-self: flex-start; text-align: left }
.mm.stack .mm-branches { grid-template-columns: 1fr; padding-left: 48px }
.mm.stack .mm-head { align-self: flex-start }
.mm.stack .mm-branch ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) }
.mm-branch { background: var(--paper); border: 3px solid var(--c); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0 }
.mm-head { align-self: center; font: 800 1.15rem var(--display); color: #fff; background: var(--c); border-radius: 999px; padding: 4px 16px; text-align: center }
.mm-branch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px }
.mm-item { width: 100%; text-align: left; font-size: .98rem; color: var(--ink); background: color-mix(in srgb, var(--c) 10%, var(--paper)); border: 0; border-radius: 12px; padding: 7px 11px; cursor: default; transition: filter .2s }
.mm.defi .mm-item { cursor: pointer; filter: blur(6px) }
.mm.defi .mm-item.shown { filter: none }

/* Définitions */
.defs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px }
.def { text-align: left; border: 3px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 1rem }
.def strong { font: 800 1.15rem var(--display); color: var(--accent) }
.defs.test .def { cursor: pointer }
.defs.test .def:not(.shown) span { filter: blur(6px) }

/* Cours */
.key { color: var(--accent); font-weight: 700 }
.retenir { border: 3px dashed var(--sun); border-radius: 16px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px }
.retenir h3 { font-size: 1rem; letter-spacing: .06em; text-transform: uppercase }
.tablewrap { overflow-x: auto }
table { border-collapse: collapse; min-width: 100%; font-size: .95rem }
th, td { border: 1px solid var(--line); padding: 7px 10px; text-align: center }
th:first-child, td:first-child { text-align: left }
thead th { background: var(--soft) }
.yes { color: var(--ok); font-weight: 700 } .no { color: var(--ko); font-weight: 700 }
figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center }
figure svg { width: 100%; max-width: 420px; height: auto }
figcaption { font-size: .9rem; color: var(--muted) }

/* Progression */
.boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px }
.box { border: 3px solid var(--line); border-radius: 14px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; gap: 2px }
.box b { font: 800 1.7rem/1 var(--display); font-variant-numeric: tabular-nums }
.box span { font-size: .75rem; color: var(--muted) }
.box.b5 { border-color: var(--ok); background: var(--ok-soft) }
@media (max-width: 520px) { .boxes { grid-template-columns: repeat(3, minmax(0, 1fr)) } }
.bars { display: flex; flex-direction: column; gap: 10px }
.bar { display: grid; grid-template-columns: 10em minmax(0, 1fr) 3.2em; gap: 10px; align-items: center }
.bar .track { height: 14px; background: var(--soft); border-radius: 99px; overflow: hidden }
.bar .track i { display: block; height: 100%; background: var(--ok) }
.bar b { font-variant-numeric: tabular-nums; text-align: right }
@media (max-width: 520px) { .bar { grid-template-columns: 1fr 3.2em } .bar .track { grid-column: 1 / -1; grid-row: 2 } }

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

/* Notations mathématiques : fraction empilée, angle avec chapeau */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; font-size: .9em; margin-inline: 2px }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding-inline: 3px }
.ang { display: inline-block; border-top: 2px solid currentColor; border-radius: 50% 50% 0 0 / 7px 7px 0 0; padding: 1px 2px 0; line-height: 1.1 }
td svg { width: 100%; max-width: 160px; height: auto; display: block; margin: auto }
