:root {
    --bg: #0b1020; --bg2: #0f1630; --surface: #151d3a; --surface2: #1d274b; --line: #2b3765;
    --text: #edf0fb; --muted: #a3aed0; --accent: #8aa4ff; --accent-ink: #0b1020;
    --ok: #3ddc97; --ok-bg: rgba(61, 220, 151, .13); --bad: #ff8a9a; --bad-bg: rgba(255, 138, 154, .13);
    --warm: #ffb85c; --warm-bg: rgba(255, 184, 92, .12); --def-bg: rgba(138, 164, 255, .11);
    --ray: #ffd84d; --air: rgba(255, 255, 255, .03); --glass: rgba(170, 215, 255, .16);
    --spectrum: linear-gradient(90deg, #8b5cf6, #3b82f6, #06b6d4, #22c55e, #eab308, #f97316, #ef4444);
    --r: 16px; --shadow: 0 10px 30px rgba(0, 0, 0, .25);
    --fh: 'Bricolage Grotesque', 'Lexend', system-ui, sans-serif; --fb: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
[data-theme=light] {
    --bg: #f5f6fb; --bg2: #eceef7; --surface: #ffffff; --surface2: #f0f2fa; --line: #d9deee;
    --text: #17203b; --muted: #5b6685; --accent: #3654d8; --accent-ink: #ffffff;
    --ok: #0f9d64; --ok-bg: rgba(15, 157, 100, .1); --bad: #d6336c; --bad-bg: rgba(214, 51, 108, .08);
    --warm: #b45309; --warm-bg: rgba(234, 138, 0, .1); --def-bg: rgba(54, 84, 216, .07);
    --ray: #e11d48; --air: rgba(23, 32, 59, .025); --glass: rgba(60, 130, 220, .14);
    --shadow: 0 8px 24px rgba(23, 32, 59, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--fb); font-weight: 400; font-size: 16.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
sup { font-size: .68em; line-height: 0; }
h1, h2, h3, h4 { font-family: var(--fh); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.7rem, 5.5vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 26px 0 10px; }
.card > h3:first-child { margin-top: 0; }
p { margin: 10px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- barre du haut + onglets ---- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 900px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 8px; font-family: var(--fh); font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo small { font-family: var(--fb); font-weight: 500; font-size: .7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); font-weight: 500; }
#themeBtn { background: none; border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.bar { height: 3px; background: var(--line); }
.bar i { display: block; height: 100%; width: 0; background: var(--spectrum); transition: width .5s; }
.tabs { display: flex; gap: 4px; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.tabs svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--text); background: var(--surface2); }
@media (max-width: 780px) {
    .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; }
    .tabs a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; min-width: 0; }
    .tabs a.on { background: none; color: var(--accent); }
    .tabs svg { width: 23px; height: 23px; }
    main { padding-bottom: 96px !important; }
}

main { max-width: 760px; margin: 0 auto; padding: 22px 16px 60px; }
.sub { color: var(--muted); margin: 6px 0 20px; }
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.crumb a { text-decoration: none; }

/* ---- boutons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 500; text-decoration: none; background: var(--surface2); color: var(--text); transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.btn.big { min-height: 54px; padding: 12px 26px; font-size: 1.05rem; }
.btn.small { min-height: 36px; font-size: .82rem; color: var(--muted); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- accueil ---- */
.hero { text-align: center; padding: 6px 0 26px; }
.hero .prism { max-width: 420px; margin: 0 auto -6px; }
.hero h1 { font-size: clamp(2.3rem, 9vw, 3.6rem); }
.grad { background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); max-width: 520px; margin: 14px auto 22px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px 16px; justify-content: center; align-items: center; }
.count { font-size: .9rem; font-weight: 500; color: var(--warm); border: 1px solid var(--warm); border-radius: 30px; padding: 6px 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tile { position: relative; overflow: hidden; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 18px 16px; text-decoration: none; color: var(--text); }
.tile::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.tile h3 { margin: 0 0 4px; font-size: 1.25rem; }
.tile p { margin: 0; color: var(--muted); font-size: .9rem; }
.tile-m { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.t1 { --c: #8b5cf6; } .t2 { --c: #06b6d4; } .t3 { --c: #22c55e; } .t4 { --c: #eab308; } .t5 { --c: #ef4444; }
.meter { flex: 1; height: 7px; border-radius: 9px; background: var(--line); overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--spectrum); border-radius: 9px; }
.meter-t { font-size: .8rem; color: var(--muted); white-space: nowrap; font-weight: 500; }

/* ---- listes ---- */
.list { display: grid; gap: 8px; margin: 14px 0; }
.row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--text); min-height: 64px; }
.row.hot { border-color: var(--warm); background: var(--warm-bg); margin-top: 14px; }
.row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-t small, summary small { color: var(--muted); font-size: .85rem; font-weight: 400; display: block; }
.row-s { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.row-m { display: flex; align-items: center; gap: 8px; width: 130px; }
.go { color: var(--muted); font-size: 1.2rem; }
.num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface2); font-family: var(--fh); font-weight: 800; font-size: .95rem; }
.pill { font-style: normal; font-size: .7rem; font-weight: 500; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

/* ---- cartes génériques ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 14px 0; }
.card.center { text-align: center; }
.card.total { display: flex; align-items: center; gap: 12px; }
.note { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }

/* ---- chapitre de cours ---- */
.chapter h1 { display: flex; align-items: center; gap: 12px; }
.chapter h1 .num { width: 42px; height: 42px; font-size: 1.1rem; background: var(--spectrum); color: #fff; }
.def, .exb, .trap { border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.def { background: var(--def-bg); border-left: 4px solid var(--accent); }
.def .eg { color: var(--muted); font-size: .93em; }
.exb { background: var(--surface); border: 1px solid var(--line); }
.exb::before { content: 'Exemple'; display: block; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.trap { background: var(--warm-bg); border: 1px solid var(--warm); }
.trap::before { content: '⚠ Piège'; display: block; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--warm); margin-bottom: 2px; }
.formula { text-align: center; font-family: var(--fh); font-weight: 800; font-size: clamp(1.25rem, 5vw, 1.6rem); padding: 16px 12px; margin: 14px 0; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.formula::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--spectrum); }
.formula small { display: block; font-family: var(--fb); font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.formula.small { font-size: 1.05rem; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.2; margin: 0 3px; }
.frac > span { padding: 0 4px; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; }
.fig { margin: 14px 0; text-align: center; }
.fig svg { width: 100%; max-width: 440px; height: auto; display: inline-block; border-radius: 12px; }
.cap { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.cap.l { text-align: left; margin-bottom: 4px; }
.tbl { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .93rem; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.tbl th { background: var(--surface2); font-weight: 500; }
.tbl.left td { text-align: left; vertical-align: top; }
.tbl.left td:first-child { white-space: nowrap; }
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.tri > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.tri span { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.tri b { font-size: 1.05rem; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duo p { font-size: .88rem; text-align: center; margin: 0; }
.duo .fig { margin: 6px 0; }
.specnames { position: relative; max-width: 440px; height: 36px; margin: 0 auto; font-size: .75rem; font-weight: 500; }
.specnames span { position: absolute; top: 0; transform: translateX(-50%); }
.specnames span:nth-child(even) { top: 16px; }
[data-theme=light] .specnames span { filter: brightness(.62) saturate(1.6); }
.spec-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.spec-card h4 { font-size: 1rem; margin-bottom: 8px; }
.spec-card svg { width: 100%; height: auto; }
.spec-card p { margin: 8px 0 0; font-size: .92rem; }
.rule { border-radius: 14px; padding: 14px; margin: 12px 0; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.rule.add { --c: #22c55e; } .rule.sub { --c: #06b6d4; } .rule.mul { --c: #f97316; }
.rule-h { font-size: .92rem; }
.rule-m { font-family: var(--fh); font-weight: 800; font-size: clamp(1.15rem, 5vw, 1.5rem); margin: 8px 0 2px; }
.rule-s { font-size: .85rem; color: var(--muted); }
.steps { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-family: var(--fh); font-weight: 600; font-size: clamp(1.05rem, 4.6vw, 1.35rem); display: grid; gap: 6px; }
.ca { color: var(--warm); } .cb { color: var(--accent); }
.c-add { color: #22c55e; font-size: 1.3rem; } .c-sub { color: #06b6d4; font-size: 1.3rem; } .c-mul { color: #f97316; font-size: 1.3rem; }
.chap-actions { margin: 20px 0 10px; }
.chap-actions .btn { width: 100%; }
.pn { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.pn .btn { flex: 1; min-width: 0; font-size: .85rem; }
.quick { border-color: var(--accent); }
.quick-h { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }

/* ---- SVG ---- */
svg text { font-family: var(--fb); fill: var(--text); }
.ray { stroke: var(--ray); stroke-width: 2.8; stroke-linecap: round; fill: none; }
.ray.head { fill: var(--ray); stroke: none; }
.ray.dim { opacity: .4; }
.cr { stroke: #ff3b3b; stroke-width: 3; } .cr.head { fill: #ff3b3b; stroke: none; }
.cg { stroke: #22c55e; stroke-width: 3; } .cg.head { fill: #22c55e; stroke: none; }
.cb.head { fill: #4f7dff; stroke: none; } line.cb { stroke: #4f7dff; stroke-width: 3; }
.normale { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 5 4; fill: none; }
.dioptre { stroke: var(--text); stroke-width: 2; }
.arc { fill: none; stroke: var(--text); stroke-width: 1.3; }
.ang { font-size: 14px; font-weight: 600; }
.med { font-size: 11px; fill: var(--muted); }
.nm { font-size: 12px; font-weight: 500; }
.dot { fill: var(--text); }
.mirror { fill: var(--muted); opacity: .55; }
.hatch { stroke: var(--muted); stroke-width: 1.2; }
.badge { fill: var(--accent); } .badget { font-size: 13px; font-weight: 600; fill: var(--accent-ink); }
.rays { background: var(--surface); border: 1px solid var(--line); }
.illu { background: var(--surface); border: 1px solid var(--line); }
.hero .illu { background: none; border: 0; }
.shadow { fill: #000; opacity: .45; }
.opaque { fill: var(--muted); }
.eye { fill: #fff; stroke: var(--text); stroke-width: 1.5; } .iris { fill: #3b82f6; }
.glass { fill: var(--glass); stroke: var(--text); stroke-width: 1.6; stroke-linejoin: round; }
.white { stroke: #fff; }
[data-theme=light] .prism { background: #10172f; }
[data-theme=light] .prism text { fill: #cfd6ee; }
[data-theme=light] .prism .glass { stroke: #fff; }
[data-theme=light] .hero .prism { border-radius: 18px; margin-bottom: 14px; }
.beam { stroke-dasharray: 130; stroke-dashoffset: 130; animation: draw .6s ease-out forwards; }
.fan { stroke-dasharray: 140; stroke-dashoffset: 140; animation: draw .7s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.tick { stroke: var(--muted); stroke-width: 1; }
.axt { font-size: 13px; fill: var(--muted); }
.specframe { fill: none; stroke: var(--line); stroke-width: 1; }
.rgbt { font-size: 11px; font-weight: 600; fill: #000; }
.rgb, .tshirt { max-width: 240px !important; border: 0; }
.tshirt { max-width: 180px !important; }

/* ---- exercices ---- */
.ex { border-left: 4px solid var(--line); }
.ex[data-st=ok] { border-left-color: var(--ok); }
.ex[data-st=retry] { border-left-color: var(--warm); }
.ex-head { display: flex; align-items: center; gap: 10px; font-size: .78rem; margin-bottom: 8px; color: var(--muted); }
.tag { background: var(--surface2); border-radius: 20px; padding: 2px 10px; font-weight: 500; }
.lvl { letter-spacing: 2px; font-size: .6rem; }
.ex-state { margin-left: auto; font-weight: 500; }
.ex[data-st=ok] .ex-state { color: var(--ok); } .ex[data-st=retry] .ex-state { color: var(--warm); }
.ex-q { font-size: 1.02rem; font-weight: 500; margin-bottom: 12px; }
.given { display: block; margin-top: 8px; font-weight: 400; font-size: .88rem; color: var(--muted); }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; background: var(--surface2); border: 1.5px solid transparent; border-radius: 12px; padding: 12px 14px; min-height: 48px; }
.opt.sel { border-color: var(--accent); background: var(--def-bg); }
.opt.good { border-color: var(--ok); background: var(--ok-bg); }
.opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.inp { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inp input { background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 150px; min-height: 48px; font-size: 1.05rem; }
.inp input:focus { border-color: var(--accent); outline: none; }
.inp.sci .in-m { width: 110px; } .inp.sci .in-e { width: 74px; align-self: flex-start; margin-top: -8px; min-height: 40px; padding: 6px 10px; font-size: .95rem; }
.x10 { font-family: var(--fh); font-weight: 800; font-size: 1.2rem; }
.unit { color: var(--muted); font-weight: 500; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.ex-fb, .ex-hint, .ex-corr { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: .95rem; }
.ex-fb.ok { background: var(--ok-bg); color: var(--ok); } .ex-fb.ok b { color: var(--ok); }
.ex-fb.ok { color: var(--text); } .ex-fb.ko { background: var(--bad-bg); }
.ex-fb.ko b { color: var(--bad); }
.ex-hint { background: var(--warm-bg); }
.ex-corr { background: var(--surface2); }
.ex-corr ol, .steps-l { margin: 6px 0 0; padding-left: 22px; }
.ex-corr li, .steps-l li { margin: 6px 0; }
[hidden] { display: none !important; }

/* ---- atelier ---- */
.ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.ctrl label, .rng { display: block; font-size: .9rem; font-weight: 500; }
.ctrl small { display: block; color: var(--muted); font-weight: 400; font-size: .75rem; }
select { width: 100%; margin-top: 6px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; min-height: 46px; }
.rng { margin-top: 16px; }
.rng b { color: var(--accent); font-size: 1.1rem; }
input[type=range] { width: 100%; margin: 10px 0 4px; accent-color: var(--accent); height: 30px; }
.readout { margin-top: 10px; }
.vals { display: flex; gap: 8px; flex-wrap: wrap; }
.vals span { background: var(--surface2); border-radius: 10px; padding: 6px 12px; font-size: .95rem; }
.calc { display: grid; gap: 12px; font-size: 1rem; overflow-x: auto; }
.hintline { color: var(--muted); font-size: .8rem; margin-left: 8px; }
.defis, .checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.defis li, .checks li { position: relative; padding-left: 32px; font-size: .95rem; }
.defis li::before, .checks li::before { content: ''; position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line); }
.defis li.ok { color: var(--ok); }
.defis li.ok::before { content: '✓'; background: var(--ok); border-color: var(--ok); color: #05130c; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 9px 6px; min-height: 42px; font-size: .9rem; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg.small { margin-top: 10px; } .seg.small button { font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chip { background: var(--surface2); border: 1.5px solid transparent; border-radius: 30px; padding: 8px 15px; min-height: 42px; font-size: .9rem; }
.chip.on { border-color: var(--accent); background: var(--def-bg); font-weight: 500; }
.chip.c-rouge.on { border-color: #ff3b3b; background: rgba(255, 59, 59, .2); }
.chip.c-vert.on { border-color: #22c55e; background: rgba(34, 197, 94, .2); }
.chip.c-bleu.on { border-color: #4f7dff; background: rgba(79, 125, 255, .25); }
.refs { display: grid; gap: 4px; margin: 6px 0 10px; }
.ref { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.ref svg { width: 100%; height: auto; display: block; }
#st-box .fig svg, #sp-fig svg { max-width: none; }
#st-box .fig { margin-left: 88px; }
#st-box .fig .cap { margin-left: 3%; }
.pw-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }
.pw-q { font-family: var(--fh); font-weight: 800; font-size: clamp(1.4rem, 6.5vw, 2rem); text-align: center; margin: 22px 0; }
.track { position: relative; height: 54px; margin: 18px 0 6px; border-bottom: 2px dashed var(--line); font-size: .78rem; color: var(--muted); }
.track .from { position: absolute; left: 0; bottom: 8px; } .track .to { position: absolute; right: 0; bottom: 8px; }
.track i { position: absolute; bottom: -8px; left: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--ray); box-shadow: 0 0 14px 4px var(--ray); }
.track i.go { animation: fly 1.6s ease-in-out forwards; }
@keyframes fly { to { left: calc(100% - 14px); } }
.big-res { text-align: center; margin: 16px 0 4px; }
.big-res b { display: block; font-family: var(--fh); font-weight: 800; font-size: clamp(1.8rem, 8vw, 2.6rem); }
.big-res span { color: var(--muted); font-size: .9rem; }

/* ---- méthodes ---- */
.aig { display: grid; gap: 6px; }
.aig-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; background: var(--surface2); border: 0; border-radius: 12px; padding: 12px 14px; min-height: 48px; font-size: .92rem; }
.aig-row b { color: var(--accent); white-space: nowrap; font-size: .82rem; }
details.rc { padding: 0; }
details.rc summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
details.rc summary::-webkit-details-marker { display: none; }
details.rc summary::after { content: '+'; margin-left: auto; font-size: 1.4rem; color: var(--muted); }
details.rc[open] summary::after { content: '−'; }
details.rc > :not(summary) { margin-left: 18px; margin-right: 18px; }
details.rc > :last-child { margin-bottom: 18px; }
details.rc .steps-l { padding-left: 40px; }
.si { color: var(--warm); font-weight: 600; }
.r-ok summary .num { background: var(--ok-bg); color: var(--ok); } .r-ko summary .num { background: var(--warm-bg); color: var(--warm); }

/* ---- avant le contrôle ---- */
.plan { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.plan label { display: flex; gap: 12px; align-items: flex-start; padding: 9px 4px; cursor: pointer; }
.plan input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.plan small { display: block; color: var(--muted); font-size: .85rem; }
.statl { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: .9rem; }
.statl > span:first-child { width: 150px; flex: none; }
.reset { text-align: center; margin-top: 26px; }
.fiche { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 16px 0; }
.fbox { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: .93rem; line-height: 1.75; }
.fbox h4 { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; font-family: var(--fb); font-weight: 600; }
.fc-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.flash { width: 100%; min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 26px 20px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-size: 1.25rem; font-weight: 500; text-align: center; line-height: 1.5; }
.flash.back { border-color: var(--accent); background: var(--def-bg); font-weight: 400; }
.flash small { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.flash em { font-style: normal; font-size: .8rem; color: var(--muted); font-weight: 400; }
.fc-act { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.note-big { font-family: var(--fh); font-weight: 800; font-size: 4rem; line-height: 1; }
.note-big small { font-size: 1.4rem; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 30px; font-size: .9rem; font-weight: 500; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; white-space: nowrap; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
    .duo { grid-template-columns: 1fr; }
    .row-m { width: 96px; }
    #st-box .fig { margin-left: 0; }
    .ref { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .beam, .fan { stroke-dashoffset: 0; } }
.tbl:not(.left) td { white-space: nowrap; }
@media (max-width: 480px) { .tbl:not(.left) th, .tbl:not(.left) td { padding: 8px 6px; font-size: .88rem; } }

/* ================= v2 : vivant, séries, récompenses ================= */
main.in { animation: pagein .26s ease-out; }
@keyframes pagein { from { opacity: .3; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.center { text-align: center; }
.ex-actions.center { justify-content: center; }
.crumb a { font-weight: 500; padding: 6px 0; }
.pulse { animation: pulse .45s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--ok); } 100% { box-shadow: 0 0 0 14px transparent; } }
.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* accueil */
.hero { padding-bottom: 18px; }
.hero h1 { font-size: clamp(2rem, 8vw, 3.2rem); }
.hello { display: flex; align-items: flex-start; gap: 12px; text-align: left; max-width: 560px; margin: 20px auto 14px; }
.lumi-w { flex: none; width: 58px; }
.lumi { width: 58px; height: 58px; overflow: visible; animation: bob 3s ease-in-out infinite; }
.lumi-rays { transform-origin: 32px 32px; animation: spin 14s linear infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.bubble { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 12px 14px; font-size: .95rem; color: var(--muted); }
.bubble b { color: var(--text); }
.next { position: relative; display: grid; grid-template-columns: 1fr auto; text-align: left; max-width: 560px; margin: 0 auto 14px; padding: 14px 18px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .1s; }
.next:active { transform: scale(.98); }
.next small { grid-column: 1; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.next b { grid-column: 1; font-family: var(--fh); font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.next span { grid-column: 1; font-size: .88rem; opacity: .85; }
.next i { grid-column: 2; grid-row: 1 / 4; align-self: center; font-style: normal; font-size: 1.6rem; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(5px); } }
.chips-info { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.count { text-decoration: none; font-size: .82rem; padding: 5px 12px; }
.count.c2 { color: var(--ok); border-color: var(--ok); } .count.c3 { color: var(--accent); border-color: var(--accent); } .count.c4 { color: var(--muted); border-color: var(--line); }
.t6 { --c: #f97316; }
.strip { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.strip-ic { flex: 1; text-align: right; font-size: 1.1rem; color: var(--muted); white-space: nowrap; overflow: hidden; }
.strip i { font-style: normal; color: var(--muted); }
.share-line { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; }
.row.hot2 { border-color: var(--accent); background: var(--def-bg); margin-top: 14px; }

/* récompenses */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.badge-c { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 12px; text-align: center; opacity: .55; }
.badge-c.on { opacity: 1; border-color: var(--warm); background: var(--warm-bg); }
.badge-c.mega-b.on { border-image: var(--spectrum) 1; border-radius: 0; }
.badge-c b { display: block; font-size: .92rem; line-height: 1.25; }
.badge-c small { display: block; color: var(--muted); font-size: .76rem; margin-top: 4px; line-height: 1.35; }
.b-ic { font-size: 2rem; line-height: 1.2; margin-bottom: 6px; filter: grayscale(1); }
.badge-c.on .b-ic { filter: none; }
#reward { position: fixed; left: 50%; top: 70px; z-index: 60; width: min(440px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--warm); box-shadow: var(--shadow); transform: translate(-50%, -160%); opacity: 0; transition: transform .45s cubic-bezier(.2, 1.3, .4, 1), opacity .3s; pointer-events: none; }
#reward.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.rw-ic { font-size: 2.2rem; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } }
.rw-t { flex: 1; min-width: 0; color: var(--text); text-decoration: none; display: flex; flex-direction: column; line-height: 1.3; }
.rw-t small { font-size: .65rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--warm); }
.rw-t span { font-size: .8rem; color: var(--muted); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; width: 9px; height: 13px; border-radius: 2px; }
.mega { position: fixed; inset: 0; z-index: 65; background: rgba(5, 8, 20, .93); display: grid; place-items: center; padding: 20px; animation: pagein .4s; }
.mega-in { max-width: 460px; text-align: center; color: #edf0fb; }
.mega-in .illu { background: none; border: 0; max-width: 340px; width: 100%; }
.mega-ic { font-size: 4rem; animation: pop .8s cubic-bezier(.2, 1.6, .4, 1); }
.mega h2 { font-size: 2.4rem; font-weight: 800; }

/* séries */
.rq-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.dots { display: inline-flex; gap: 5px; align-items: center; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dots i.ok { background: var(--ok); } .dots i.ko { background: var(--warm); } .dots i.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.ord-ans { list-style: decimal; padding-left: 26px; margin: 0 0 10px; display: grid; gap: 6px; min-height: 52px; }
.ord-ans .opt { width: 100%; }
.ord-empty { list-style: none; margin-left: -26px; color: var(--muted); font-size: .88rem; border: 1.5px dashed var(--line); border-radius: 12px; padding: 12px; }
.ord-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.ord-pool .chip { text-align: left; border-radius: 12px; height: auto; }

/* cours */
.keep { border: 1px solid var(--ok); background: var(--ok-bg); border-radius: 14px; padding: 12px 16px; margin: 18px 0 14px; }
.keep-h { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); }
.keep ul { margin: 6px 0 0; padding-left: 20px; } .keep li { margin: 4px 0; }
.fx { margin-top: 8px; }
.chapter .fig .rng { text-align: left; max-width: 440px; margin: 10px auto 0; }
.swatch { height: 64px; border-radius: 14px; display: grid; place-items: center; font-family: var(--fh); font-weight: 800; font-size: 1.3rem; margin-top: 8px; transition: background .15s; }
.photon { fill: #fff; stroke: var(--ray); stroke-width: 2; }
.sun { fill: #ffc933; transition: fill .5s; } .moonb { fill: #cfd6e4; transition: fill .5s; } .crat { fill: #aab3c5; transition: fill .5s; }
.sunlight { transition: opacity .5s; }
.src.off .sunlight { opacity: 0; } .src.off .sun { fill: #3a3523; } .src.off .moonb { fill: #1c2238; } .src.off .crat { fill: #1c2238; }
.hit { stroke: transparent; stroke-width: 28; fill: transparent; cursor: pointer; stroke-linecap: round; }
.hit.found { stroke: var(--ok); stroke-opacity: .28; fill: var(--ok); fill-opacity: .28; pointer-events: none; }
.hit.miss { stroke: var(--bad); stroke-opacity: .35; fill: var(--bad); fill-opacity: .35; }
.sc-ask { text-align: center; font-size: 1.1rem; min-height: 56px; }
.sc-ask small { display: block; color: var(--muted); font-size: .78rem; }
.sc-ask b { color: var(--accent); }
.gd-steps { padding-left: 24px; display: grid; gap: 10px; }
.gd-steps li.ok { color: var(--ok); } .gd-steps li.cur { font-weight: 500; }
.gd-steps .chips { margin-top: 8px; } .gd-steps .inp { margin-top: 8px; } .gd-steps .ex-fb { font-weight: 400; }
.date { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.date label { font-weight: 500; }
.date input { background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 12px; min-height: 46px; color-scheme: dark; }
[data-theme=light] .date input { color-scheme: light; }

/* cartes mémoire : retournement */
.flash3d { display: block; width: 100%; min-height: 270px; padding: 0; border: 0; background: none; perspective: 1200px; text-align: center; }
.f-in { position: relative; display: block; width: 100%; min-height: 270px; transition: transform .55s cubic-bezier(.3, 1.2, .5, 1); transform-style: preserve-3d; }
.flash3d.flip .f-in { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 26px 20px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-size: 1.2rem; font-weight: 500; line-height: 1.5; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); border-color: var(--accent); background: var(--surface2); font-weight: 400; }
.face small { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.face em { font-style: normal; font-size: .8rem; color: var(--muted); font-weight: 400; }

/* grand écran */
@media (min-width: 781px) {
    main { max-width: 860px; padding-top: 30px; }
    .tiles { grid-template-columns: repeat(3, 1fr); }
    #reward { top: 84px; }
}
@media (min-width: 1000px) {
    .lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
    .lab-grid .card { margin: 0 0 14px; }
    .row:hover, .tile:hover, .strip:hover { border-color: var(--accent); }
    .opt:hover, .chip:hover { border-color: var(--line); }
}
@media (max-width: 780px) { #toast { bottom: 150px; } }

/* ---- indices repliables ---- */
.hintd { margin: 10px 0 2px; font-size: .92rem; }
.hintd summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; color: var(--warm); font-weight: 500; border: 1px solid var(--warm); border-radius: 30px; padding: 5px 14px; min-height: 36px; }
.hintd summary::-webkit-details-marker { display: none; }
.hintd summary::before { content: '?'; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--warm); color: var(--bg); font-size: .75rem; font-weight: 700; }
.hintd p { background: var(--warm-bg); border-radius: 12px; padding: 10px 14px; margin: 8px 0 0; }
.sc-ask .hintd { font-weight: 400; }
.solo { color: var(--warm); font-weight: 600; font-size: .85rem; white-space: nowrap; }

@media (max-width: 780px) { main { padding-bottom: 160px !important; } }

/* ---- v3 : calculatrice dans la barre d'onglets, chapitre complément ---- */
#calcFab { display: none !important; }
.tabs button { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; color: var(--muted); background: none; border: 0; font-size: .9rem; font-weight: 500; }
.compl { border: 1px dashed var(--muted); border-radius: 12px; padding: 10px 14px; margin: 12px 0; font-size: .9rem; color: var(--muted); }
@media (max-width: 780px) {
    .tabs button { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; min-width: 0; }
    main { padding-bottom: 104px !important; }
}
@media (max-width: 420px) {
    .tbl { font-size: .82rem; }
    .tbl th, .tbl td, .tbl:not(.left) th, .tbl:not(.left) td { padding: 6px 3px; font-size: .8rem; }
    .tbl.left td { overflow-wrap: anywhere; }
    .tbl.left td:first-child { white-space: normal; }
}

/* Problèmes guidés : les 5 étapes */
.pb-steps li.todo { color: var(--muted); }
.pb-steps li.ok { color: var(--text); }
.pb-t { font-family: var(--fh); font-weight: 800; display: block; }
.pb-steps li.ok .pb-t { color: var(--ok); }
.pb-ok { font-weight: 400; margin-top: 4px; }
.pb-q { margin-top: 8px; font-weight: 500; }
.pb-modele::before { content: 'Sur ta copie'; }
