/* ---------- thème (clair par défaut, sombre selon le réglage de l'appareil) ---------- */
:root {
  --bg: #f5f6fb; --card: #fff; --ink: #232a3d; --muted: #626c8c; --line: #e3e6ef; --line-2: #c9cee0; --def: #4b5470;
  --accent: #4255ff; --accent-2: #3346e6; --accent-bg: #eef0ff; --on-accent: #fff;
  --good: #18a35e; --good-bg: #e8f7ef; --bad: #e5484d; --bad-bg: #fff0f0; --gold: #ffb020; --gold-bg: #fff6e0; --gold-ink: #8a5a00; --mid-ink: #a86b00;
  --top: rgba(255, 255, 255, .92); --quote-bg: #f3f4ff;
  --radius: 16px; --shadow: 0 1px 3px rgba(40, 46, 62, .06), 0 6px 18px rgba(40, 46, 62, .06);
  --head: 57px; /* hauteur de l'en-tête */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1322; --card: #181d30; --ink: #e6e9f5; --muted: #9aa3c3; --line: #2a3150; --line-2: #3a4366; --def: #c0c6dc;
    --accent: #7b8bff; --accent-2: #95a2ff; --accent-bg: #232a52; --on-accent: #0d1024;
    --good: #3fcf86; --good-bg: #15342a; --bad: #ff6b70; --bad-bg: #3a1d24; --gold-bg: #3a3018; --gold-ink: #ffd27a; --mid-ink: #ffc35a;
    --top: rgba(21, 26, 43, .92); --quote-bg: #1e2440;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; margin: .2em 0; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
h3 { margin: 0 0 .3em; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; justify-content: center; }
s { color: var(--bad); }
.ico { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.2em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button, input { color: inherit; }

/* ---------- en-tête et navigation ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--top); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px)); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: #4255ff; color: #fff; display: grid; place-items: center; font-size: 1rem; }
.nav { display: flex; gap: 4px; }
.nav a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; color: var(--ink); font-weight: 600; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--accent-bg); color: var(--accent); }

#app { max-width: 900px; margin: 0 auto; padding: 20px 16px 40px; }
body.is-wide #app { max-width: 1200px; }
.foot { max-width: 900px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: .78rem; border-top: 1px solid var(--line); }
body.is-wide .foot { max-width: 1200px; }
.foot summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

/* téléphone : onglets en bas d'écran, à portée de pouce */
@media (max-width: 640px) {
  /* pas de flou sur l'en-tête : il piégerait la barre d'onglets fixe (contexte de positionnement) */
  .top { padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-bottom: 8px; --head: 49px; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--card); }
  .nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; background: var(--top); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 12px; font-size: .72rem; color: var(--muted); }
  .nav a .ico { width: 24px; height: 24px; }
  .nav a.on { background: none; color: var(--accent); }
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
  /* en plein jeu : ni en-tête ni onglets, tout l'écran pour le cerveau (la croix ramène au paquet) */
  body.is-play .top, body.is-play .nav, body.is-play .foot { display: none; }
  body.is-play { padding-bottom: env(safe-area-inset-bottom, 0px); }
  body.is-play #app { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  #app { padding: 16px 14px 28px; }
}

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 0; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 650; cursor: pointer; background: var(--accent); color: var(--on-accent); transition: background .15s, transform .1s, box-shadow .15s; }
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 2px var(--line-2); }
.btn.good { background: var(--good); color: #fff; } .btn.bad { background: var(--bad); color: #fff; }
.btn.sm { padding: 6px 14px; min-height: 40px; font-size: .92rem; }
.btn.close { width: 42px; height: 42px; padding: 0; flex: none; }
.btn.wide { width: 100%; margin-top: 14px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--bad); font-weight: 650; }
.icon { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; display: grid; place-items: center; }
.icon:hover { background: rgba(255,255,255,.24); }
.icon .ico { width: 20px; height: 20px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
.chk { display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-size: .9rem; }
.chk input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
kbd { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 6px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); font: 600 .8rem system-ui; color: var(--muted); }
.kbd-hint { font-weight: 500; opacity: .75; }
/* écran tactile sans clavier : les raccourcis ne servent à rien */
@media (hover: none) and (pointer: coarse) { kbd, .kbd-hint { display: none !important; } }

/* ---------- accueil ---------- */
.hero { padding: 6px 0 4px; }
.hero p { color: var(--muted); max-width: 60ch; margin: .3em 0; }
.steps { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.steps li { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; }
.steps b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); font-size: .85rem; }
.resume { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 14px 18px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); transition: transform .15s; }
.resume:hover { transform: translateY(-2px); }
.resume-ico { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.resume-ico .ico { width: 22px; height: 22px; }
.resume-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.resume-txt small { opacity: .85; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.deck { position: relative; display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--ink); border-bottom: 4px solid transparent; transition: border-color .15s, transform .15s; }
.deck:hover { border-bottom-color: var(--accent); transform: translateY(-2px); }
.deck p { color: var(--muted); font-size: .9rem; margin: 0 0 12px; flex: 1; }
.deck-all { background: linear-gradient(135deg, #4255ff, #6b4bff); color: #fff; }
.deck-all p, .deck-all .muted { color: rgba(255,255,255,.85); }
.deck-all .pill { background: rgba(255,255,255,.2); color: #fff; }
.deck-all .bar { background: rgba(255,255,255,.25); }
.deck-3d { background: radial-gradient(120% 120% at 80% 20%, #2c3760 0%, #141a2c 70%); color: #fff; }
.deck-3d p { color: rgba(220,228,255,.8); padding-right: 50px; }
.deck-3d .mode-ico { position: absolute; right: 16px; bottom: 16px; background: rgba(255,255,255,.14); color: #fff; }
.deck-foot { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.pill { background: var(--accent-bg); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-weight: 650; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--good); border-radius: 99px; transition: width .3s; }
.bar.big { height: 8px; margin: 10px 0 16px; }

/* recherche, raccourcis et sauts de section de l'accueil */
.find-box { position: relative; max-width: 560px; margin-top: 14px; }
.find { width: 100%; font: inherit; font-size: 1.02rem; padding: 12px 16px 12px 44px; border: 2px solid var(--line); border-radius: 14px; outline: none; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23838aa6' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat 14px center / 20px; color: var(--ink); box-shadow: var(--shadow); }
.find:focus { border-color: var(--accent); }
.find-res { position: absolute; z-index: 6; left: 0; right: 0; top: calc(100% + 6px); background: var(--card); border-radius: 14px; box-shadow: 0 10px 30px rgba(20, 26, 44, .18); padding: 6px; border: 1px solid var(--line); }
.find-res a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; padding: 10px 12px; border-radius: 10px; color: var(--ink); }
.find-res a:hover, .find-res a:focus-visible { background: var(--accent-bg); }
.find-res small { flex-basis: 100%; color: var(--muted); }
.find-res p { margin: 8px 12px; }
.quicks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.quick { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); color: var(--ink); border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.quick:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick small { color: var(--muted); }
.quick.q-all { background: linear-gradient(135deg, #4255ff, #6b4bff); color: #fff; }
.quick.q-all small { color: rgba(255,255,255,.85); }
.quick.q-all .mode-ico { background: rgba(255,255,255,.18); color: #fff; }
.jump { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 0; }
.jump .chip { background: var(--accent-bg); color: var(--accent); }
.deck-group { scroll-margin-top: calc(var(--head) + 10px); }
body.is-wide .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 760px) { .quicks { grid-template-columns: 1fr; gap: 8px; } }
/* téléphone : tuiles compactes sur deux colonnes, la description est sur la page du paquet */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  body.is-wide .grid { grid-template-columns: 1fr 1fr; }
  .deck { padding: 12px; border-radius: 14px; }
  .deck h3 { font-size: .95rem; line-height: 1.25; flex: 1; }
  .deck p { display: none; }
  .deck-foot { flex-direction: column; align-items: flex-start; gap: 4px; font-size: .78rem; margin-top: 8px; }
  .quick { padding: 10px 12px; }
}

/* ---------- page paquet ---------- */
.crumbs { margin-bottom: 6px; font-weight: 600; }
.crumbs a { display: inline-flex; align-items: center; gap: 2px; min-height: 36px; }
.set-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.set-head p { margin: 0; }
.set-head .btn { flex: none; margin-top: 6px; }
.mode { background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); color: var(--ink); display: flex; align-items: center; gap: 12px; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.mode:hover { border-color: var(--accent); }
.mode-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.mode small { color: var(--muted); }
.mode-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-bg); color: var(--accent); }
.mode-ico .ico { width: 22px; height: 22px; }
.mode.main { background: var(--accent); color: var(--on-accent); padding: 16px 18px; }
.mode.main:hover { border-color: transparent; transform: translateY(-2px); }
.mode.main small { color: inherit; opacity: .85; }
.mode.main b { font-size: 1.1rem; }
.mode.main .mode-ico { background: rgba(255,255,255,.18); color: inherit; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0 8px; }
.set-preview { min-width: 0; }
.preview-cap { text-align: center; color: var(--muted); font-size: .9rem; margin-top: -4px; min-height: 1.5em; }
.preview-cap b { color: var(--ink); }
@media (min-width: 1000px) {
  .set-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .set-preview { position: sticky; top: calc(var(--head) + 14px); margin-top: 14px; }
  .set-preview .slot.preview { aspect-ratio: auto; height: min(calc(100vh - 170px), 600px); max-height: none; }
}

.terms { display: grid; gap: 8px; }
.term { display: grid; grid-template-columns: minmax(150px, 1fr) 2fr; gap: 14px; text-align: left; background: var(--card); border: 0; border-radius: 12px; padding: 14px 16px; font: inherit; color: inherit; cursor: pointer; box-shadow: var(--shadow); border-left: 4px solid transparent; transition: border-color .15s; }
.term:hover, .term.on { border-left-color: var(--gold); }
.term.on { background: var(--gold-bg); }
.term-name { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.term-name small { color: var(--muted); }
.term-def { color: var(--def); font-size: .92rem; }
.term.r-ok { border-left-color: var(--good); } .term.r-ko { border-left-color: var(--bad); }
.tag { font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--bad-bg); color: var(--bad); }
.tag.ok { background: var(--good-bg); color: var(--good); }
@media (min-width: 1000px) { .set-body .term { grid-template-columns: 1fr; gap: 4px; } }
@media (max-width: 640px) { .term { grid-template-columns: 1fr; gap: 4px; } .set-head h1 { font-size: 1.45rem; } }

/* ---------- scène 3D ---------- */
.slot { position: relative; aspect-ratio: 16 / 10; max-height: 62vh; width: 100%; margin: 14px 0; }
.slot.preview { aspect-ratio: 16 / 9; }
@media (max-width: 640px) { .slot, .slot.preview { aspect-ratio: 1 / 1; max-height: 52vh; } }
.stage { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; background: radial-gradient(120% 90% at 50% 35%, #26304d 0%, #141a2c 55%, #0c1020 100%); box-shadow: var(--shadow); }
.stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.stage-load { position: absolute; inset: 0; display: grid; place-items: center; color: #c9d1ef; font-weight: 600; pointer-events: none; padding: 16px; text-align: center; }
.stage.ready .stage-load { display: none; }
.stage-tools { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; }
.stage-hint { position: absolute; left: 50px; right: 50px; bottom: 8px; text-align: center; color: rgba(220,228,255,.6); font-size: .75rem; pointer-events: none; line-height: 1.3; }

/* ---------- écrans de jeu ---------- */
.mode-head { display: flex; align-items: center; gap: 12px; }
.mode-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mode-title .muted { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play { display: flex; flex-direction: column; }
/* le cerveau tient dans l'écran avec la question : pas de défilement pendant le jeu */
.play > .slot { aspect-ratio: auto; max-height: none; height: clamp(240px, 44vh, 520px); margin: 12px 0 0; }
@supports (height: 1dvh) { .play > .slot { height: clamp(240px, 44dvh, 520px); } }
@media (min-width: 1000px) {
  .play.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; column-gap: 22px; row-gap: 0; align-items: start; margin-top: 14px; }
  .play.split > .slot { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - var(--head) - 165px); min-height: 380px; margin: 0; }
  .play.split > :not(.slot) { grid-column: 2; }
  .play.split > :not(.slot) + :not(.slot) { margin-top: 12px; }
  .play.split > .panel, .play.split > .flip { margin-top: 0; }
}
@media (max-width: 999px) and (orientation: landscape) and (max-height: 520px) {
  .play.split, .ou.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 42%); column-gap: 14px; row-gap: 0; align-items: start; }
  .play.split > .slot { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - 90px); min-height: 220px; margin: 0; }
  .play.split > :not(.slot) { grid-column: 2; }
  .play.split > .panel, .play.split > .flip { margin-top: 0; }
  .ou.split > .ou-schema { grid-column: 1; grid-row: 1; }
  .ou.split > .ou-side { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 10px; }
  .ou.split .slot.ou-stage { height: calc(100vh - 90px); min-height: 220px; }
  .panel { padding: 14px; }
  body.is-play .top, body.is-play .foot { display: none; }
  body.is-play #app { padding-top: 8px; }
}
@supports (height: 1dvh) { @media (min-width: 1000px) { .play.split > .slot { height: calc(100dvh - var(--head) - 165px); } } }
.panel { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-top: 14px; }
.flip { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 140px; display: grid; place-items: center; text-align: center; padding: 18px; cursor: pointer; user-select: none; -webkit-user-select: none; transition: transform .25s; margin-top: 12px; }
.flip.turn { transform: rotateX(90deg); transition: none; }
.face .def { max-width: 60ch; margin: 10px auto 0; }
.rate .btn { flex: 1; max-width: 200px; }
.big { font-size: clamp(1.35rem, 4vw, 1.8rem); font-weight: 750; line-height: 1.2; }
.big.q { font-size: 1.15rem; font-weight: 650; }
.def { color: var(--def); }
.prompt { font-size: 1.08rem; font-weight: 600; margin-bottom: 12px; }
.target { color: var(--accent); font-size: 1.2rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.play.split .choices { grid-template-columns: 1fr; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; gap: 8px; } }
.choice { display: flex; align-items: center; gap: 10px; min-height: 50px; text-align: left; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--accent); }
.choice:active { background: var(--accent-bg); }
.write { display: flex; gap: 8px; margin-bottom: 10px; }
.write input { flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; outline: none; background: var(--card); color: var(--ink); }
.write input:focus { border-color: var(--accent); }
.fb { border-radius: 12px; padding: 12px 16px; animation: pop .18s ease-out; }
.fb.good { background: var(--good-bg); } .fb.good > b { color: var(--good); }
.fb.bad { background: var(--bad-bg); } .fb.bad > b { color: var(--bad); }
.fb .big { margin-top: 6px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.mini { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.mini li { padding: 4px 10px; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.mini .ok { background: var(--good-bg); color: var(--good); } .mini .mid { background: var(--gold-bg); color: var(--mid-ink); } .mini .ko { background: var(--bad-bg); color: var(--bad); }
.field { margin: 16px 0; }
.score { font-size: 3.2rem; font-weight: 800; }
.score.good { color: var(--good); } .score.bad { color: var(--bad); }
.quote { margin: 0 0 14px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--quote-bg); border-radius: 8px; color: var(--def); }
.confirm { display: inline; }

/* ---------- explorateur ---------- */
body.is-explorer #app { max-width: 1400px; padding-top: 12px; }
body.is-explorer .foot { max-width: 1400px; }
.ex { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ex-main { position: relative; position: sticky; top: calc(var(--head) + 8px); }
.slot.ex-stage { aspect-ratio: auto; height: calc(100vh - var(--head) - 44px); max-height: none; margin: 0; }
.ex-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ex-search { width: 100%; font: inherit; padding: 11px 14px; border: 2px solid var(--line); border-radius: 12px; outline: none; background: var(--card); color: var(--ink); }
.ex-search:focus { border-color: var(--accent); }
.fiche, .ex-box, .ex-list { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; }
.fiche .big { font-size: 1.35rem; margin-top: 4px; }
.fiche .def { font-size: .92rem; margin: 8px 0; }
.fiche-cat { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fiche-cat i, .layer i, .ex-item i { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 0; background: var(--gold-bg); color: var(--gold-ink); border-radius: 99px; padding: 6px 12px; font: inherit; font-weight: 650; cursor: pointer; }
.ex-box summary, .ex-list summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.ex-box input[type=range] { width: 100%; accent-color: var(--accent); margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--bg); border-radius: 99px; padding: 3px; margin: 4px 0 10px; box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; min-height: 36px; padding: 6px 14px; border-radius: 99px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 650; }
.layers { display: grid; gap: 2px; margin: 4px 0 6px; }
.layer { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; padding: 5px 0; }
.layer input { accent-color: var(--accent); }
.ex-list { max-height: 60vh; overflow: auto; padding: 8px 10px; }
.ex-list details + details { border-top: 1px solid var(--line); }
.ex-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink); }
.ex-item span { flex: 1; }
.ex-item small { color: var(--muted); }
.ex-item:hover { background: var(--bg); }
.ex-item.on { background: var(--gold-bg); font-weight: 650; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: rgba(12, 16, 32, .9); color: #fff; padding: 4px 10px; border-radius: 8px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
@media (max-width: 800px) {
  .ex { grid-template-columns: 1fr; }
  .ex-main { position: relative; top: 0; }
  .slot.ex-stage { height: 56vh; }
  .ex-list { max-height: none; }
}

/* plan B sans 3D : image fixe de la carte */
.stage.dead { background-size: cover; background-position: center; }
.stage.dead .stage-load { display: block; position: absolute; inset: auto 0 0 0; padding: 6px 12px; font-size: .75rem; font-weight: 500; background: rgba(12,16,32,.75); text-align: center; }
.stage.dead .stage-hint, .stage.dead .stage-tools { display: none; }
/* page de rendu des images */
body.render .top, body.render .foot, body.render .nav { display: none; }
body.render { padding: 0; }
body.render #app { padding: 0; max-width: none; }
.render-slot { position: relative; width: 960px; height: 600px; }
.render-slot .stage { border-radius: 0; box-shadow: none; }
body.render .stage-hint, body.render .stage-tools { display: none; }

/* ---------- schémas du cours (dessins 2D, toujours sur fond « papier ») ---------- */
.schema { width: 100%; height: auto; display: block; user-select: none; -webkit-user-select: none; }
.schema .outline { fill: #f3e9e4; stroke: #6b5a53; stroke-width: 2; }
.schema .deco { fill: #e4d9d2; stroke: #8a7a73; stroke-width: 1.5; }
.schema .deco.cb { fill: #e8d6cf; } .schema .deco.bs { fill: #eadfd2; }
.schema .deco.sulc { fill: none; stroke: #5b4a44; stroke-width: 3; stroke-linecap: round; }
.schema .deco.tract { fill: none; stroke: #e2c24a; stroke-width: 5; stroke-linecap: round; }
.schema .deco.olive2, .schema .deco.pyr2 { fill: #dfe7f1; }
.schema .zarea .fill { fill: #dde6f3; stroke: #7d8aa3; stroke-width: 1.2; transition: fill .15s; }
.schema .zline .stroke { fill: none; stroke: #2c2f3a; stroke-width: 4; stroke-linecap: round; transition: stroke .15s; }
.schema .zline .hit { fill: none; stroke: transparent; stroke-width: 26; stroke-linecap: round; }
.schema .znerve .stroke { stroke: #d9a521; stroke-width: 5; }
.schema .zlabel { font: 700 14px system-ui, sans-serif; fill: #1d2433; text-anchor: middle; dominant-baseline: middle; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; }
.schema .zone { cursor: pointer; }
@media (hover: hover) { .ou-schema .schema .zarea:hover .fill { fill: #c3d2f5; } .ou-schema .schema .zline:hover .stroke { stroke: #4255ff; } }
.schema .zone.found .fill { fill: #d3f0df !important; } .schema .zone.found .stroke { stroke: #18a35e !important; }
.schema .zone.hl .fill { fill: #ffd36b !important; } .schema .zone.hl .stroke { stroke: #f0a400 !important; stroke-width: 6; }
.schema .zone.good .fill { fill: #5fd394 !important; } .schema .zone.good .stroke { stroke: #18a35e !important; stroke-width: 6; }
.schema .zone.bad .fill { fill: #f59a9d !important; } .schema .zone.bad .stroke { stroke: #e5484d !important; stroke-width: 6; }
.schema .zone.dim { opacity: .35; }
/* schéma dans la scène (cartes sans 3D) */
.schema-layer { position: absolute; inset: 0; display: none; background: #fbf8f6; padding: 10px; align-items: center; justify-content: center; }
.stage.show-schema .schema-layer { display: flex; }
.stage.show-schema canvas, .stage.show-schema .stage-hint, .stage.show-schema .stage-tools, .stage.show-schema .stage-load { display: none !important; }
.schema-layer .schema { max-height: 100%; width: auto; max-width: 100%; }

/* ---------- jeu « Où est … ? » ---------- */
.ou { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ou-side { display: contents; }
.ou-prompt { order: 1; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; font-size: 1.15rem; font-weight: 600; }
.ou-prompt .ou-where { font-size: .78rem; font-weight: 500; display: block; color: var(--muted); }
.ou-prompt .ou-how { font-size: .82rem; font-weight: 500; display: block; color: var(--muted); margin-top: 2px; }
.ou > .ou-schema { order: 2; }
.ou-foot { order: 3; min-height: 44px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ou-foot .fb { width: 100%; }
.ou-foot .btn.wide { margin-top: 0; }
.ou-tools { order: 4; margin-top: 0; justify-content: center; }
.ou-tools .seg { margin: 0; }
.ou-side > p { order: 5; margin: 0; text-align: center; }
.ou-schema { background: #fbf8f6; border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.ou-schema.is3d { padding: 0; background: none; box-shadow: none; }
.ou-schema .schema { max-height: 68vh; width: auto; max-width: 100%; margin: 0 auto; }
.slot.ou-stage { margin: 0; aspect-ratio: auto; max-height: none; height: clamp(280px, calc(100vh - 290px), 760px); }
@supports (height: 1dvh) { .slot.ou-stage { height: clamp(280px, calc(100dvh - 290px), 760px); } }
@media (min-width: 1000px) {
  .ou.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; margin-top: 14px; }
  .ou.split > .ou-schema { grid-column: 1; grid-row: 1; }
  .ou.split > .ou-side { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 12px; position: sticky; top: calc(var(--head) + 14px); }
  .ou.split .ou-tools { justify-content: flex-start; }
  .ou.split .ou-side > p { text-align: left; }
  .ou.split .slot.ou-stage { height: calc(100vh - var(--head) - 165px); }
  .ou.split .ou-schema .schema { max-height: calc(100vh - var(--head) - 185px); }
}
@supports (height: 1dvh) { @media (min-width: 1000px) { .ou.split .slot.ou-stage { height: calc(100dvh - var(--head) - 165px); } } }
.thumb { background: #fbf8f6; border-radius: 10px; padding: 6px; margin-bottom: 10px; pointer-events: none; }
.thumb .zlabel { display: none; }
.fiche-schema { margin-top: 12px; }
/* page d'étude d'un schéma : cerveau + fiche à gauche, légende à droite */
.set-preview .ex-main { position: relative; top: auto; margin-top: 14px; }
.set-preview .slot.ou-stage { height: clamp(300px, 56vh, 560px); }

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