/* Configurateur plein écran */
body.creer { background: var(--bg); }
.cfg { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; }

/* Bannière de nuit avec le personnage */
.cfg-banner {
  position: relative; z-index: 10;
  background: radial-gradient(circle at 80% 10%, rgb(254 228 92 / .18), transparent 35%), linear-gradient(180deg, var(--night), var(--night-2));
  color: var(--on-night);
  padding-top: env(safe-area-inset-top);
  overflow: hidden;
}
.cfg-banner::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .8;
  background: radial-gradient(1.6px 1.6px at 12% 30%, var(--spark), transparent), radial-gradient(1.6px 1.6px at 38% 70%, var(--spark), transparent), radial-gradient(1.6px 1.6px at 66% 22%, var(--spark), transparent), radial-gradient(1.6px 1.6px at 90% 64%, var(--spark), transparent), radial-gradient(1.2px 1.2px at 52% 48%, #fff, transparent);
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: .8; } 50% { opacity: .35; } }
.cfg-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(760px, 100% - 24px); margin: 0 auto; min-height: 56px; position: relative; }
.cfg-logo img { height: 34px; width: auto; }
.cfg-progress { margin: 0; font-weight: 800; font-size: 15px; color: var(--on-night-muted); }
.cfg-close { width: 44px; height: 44px; display: grid; place-items: center; color: var(--white); border-radius: 50%; }
.cfg-close:hover { background: rgb(255 255 255 / .1); }
.cfg-bar { height: 5px; background: rgb(255 255 255 / .12); width: min(760px, 100% - 24px); margin: 0 auto; border-radius: 9px; overflow: hidden; position: relative; }
.cfg-bar span { display: block; height: 100%; width: 0; background: var(--spark); border-radius: 9px; transition: width .5s var(--spring); }
.cfg-stage { position: relative; height: 150px; width: min(760px, 100% - 24px); margin: 0 auto; display: flex; align-items: flex-end; justify-content: center; gap: 28px; }
@media (min-height: 760px) and (min-width: 700px) { .cfg-stage { height: 190px; } }
.cfg-stage { transition: height .45s var(--spring); }
@media (max-width: 699px) { body.compact .cfg-stage { height: 92px; } body.compact .hero-tag { display: none; } }

.hero-char { position: relative; display: grid; justify-items: center; height: 100%; }
.hero-char-img {
  width: 116px; height: 100%; border-radius: 60px 60px 0 0; overflow: hidden;
  background: rgb(255 255 255 / .08); display: grid; place-items: end center;
  transform-origin: 50% 100%;
  animation: breathe 3.2s ease-in-out infinite;
}
.hero-char-img img { width: 100%; height: 118%; object-fit: cover; object-position: 50% 18%; }
.hero-char-img .ph { width: 74%; padding-bottom: 30px; color: var(--spark); opacity: .9; }
.hero-char-img .ph svg { width: 100%; height: auto; }
.hero-char.hop .hero-char-img { animation: hop .6s var(--spring), breathe 3.2s ease-in-out .6s infinite; }
.hero-tag {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%) rotate(-3deg);
  background: var(--spark); color: var(--navy-500); font-weight: 800; font-size: 14px;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap; box-shadow: 0 3px 0 rgb(0 0 0 / .25);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025, 1.015); } }
@keyframes hop { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-16px) scale(1.04, .97); } 60% { transform: translateY(0) scale(.98, 1.03); } 100% { transform: translateY(0) scale(1); } }

.cfg-book { width: 92px; align-self: center; perspective: 600px; display: none; }
@media (min-width: 480px) { .cfg-book { display: block; } }
.cfg-book .mini { --mw: 92px; --mt: 10px; transform: rotateY(-24deg) rotateX(-6deg); }
.cfg-book .m-title { font-size: 10px; }

.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles i {
  position: absolute; left: 50%; bottom: 60px; width: 10px; height: 10px;
  background: var(--spark);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark .9s var(--ease-out) forwards;
}
@keyframes spark { 0% { transform: translate(-50%, 0) scale(.2); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1.1) rotate(90deg); opacity: 0; } }

/* Étapes */
.cfg-main { width: min(760px, 100% - 32px); margin: 0 auto; padding: 28px 0 120px; outline: none; }
.cfg-main h1 { font-size: clamp(28px, 6.5vw, 40px); margin-bottom: 8px; }
.cfg-main .lead { color: var(--muted); margin: 0 0 22px; font-size: 17px; }
.step-in { animation: step-in .45s var(--ease-out) both; }
@keyframes step-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.field { display: grid; gap: 6px; margin-bottom: 18px; align-content: start; }
.field > label, .field > .label { font-weight: 800; }
.field .hint { color: var(--muted); font-size: 14px; margin: 0; }
.input, .select, .textarea {
  font: 400 18px var(--font); color: var(--text);
  min-height: 54px; padding: 0 16px; width: 100%;
  border: var(--stroke) solid var(--field-line); border-radius: var(--radius-wobble-2);
  background: var(--surface);
}
.textarea { padding: 14px 16px; min-height: 130px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--navy-500); box-shadow: 0 0 0 4px var(--spark); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.error { color: var(--danger); font-weight: 700; font-size: 15px; margin: 0; }
.row2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 18px;
  border: var(--stroke) solid var(--line); border-radius: 999px; background: var(--surface);
  font-weight: 700; cursor: pointer; transition: transform .15s var(--spring);
}
.choice input:checked + span { background: var(--navy-500); color: var(--white); border-color: var(--navy-500); }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.choice span:active { transform: scale(.96); }

/* Choix du livre */
.pick-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pick { position: relative; display: grid; gap: 6px; cursor: pointer; }
.pick input { position: absolute; opacity: 0; }
.pick img { aspect-ratio: 1; object-fit: cover; width: 100%; border: var(--stroke) solid var(--line); border-radius: var(--radius-wobble-2); transition: transform .2s var(--spring); }
.pick span { font-weight: 800; font-size: 15px; line-height: 1.25; }
.pick input:checked + img { border-color: var(--navy-500); box-shadow: 0 0 0 4px var(--spark); transform: rotate(-1.5deg) translateY(-3px); }
.pick input:focus-visible + img { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Personnage */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 20px; position: relative; }
.seg button { min-height: 48px; border: 0; background: none; font: 800 16px var(--font); color: var(--navy-500); border-radius: 999px; cursor: pointer; position: relative; z-index: 1; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 2px 0 var(--line); }
.drop {
  display: grid; place-items: center; gap: 10px; text-align: center;
  border: var(--stroke) dashed var(--field-line); border-radius: var(--radius-wobble);
  background: var(--surface); padding: 28px 18px; cursor: pointer; min-height: 200px;
}
.drop:hover, .drop.over { border-color: var(--navy-500); background: var(--spark-soft); }
.drop img { max-height: 220px; border-radius: 14px; }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; font-size: 14px; color: var(--muted); }
.tips div { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; cursor: pointer; }
.check input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--navy-500); flex: none; }
.persos { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 640px) { .persos { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.perso { position: relative; cursor: pointer; }
.perso input { position: absolute; opacity: 0; }
.perso img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border: var(--stroke) solid var(--line); border-radius: var(--radius-wobble-2); background: var(--surface-2); transition: transform .2s var(--spring); }
.perso input:checked + img { border-color: var(--navy-500); box-shadow: 0 0 0 4px var(--spark); transform: translateY(-3px); }
.perso input:focus-visible + img { outline: 3px solid var(--accent); outline-offset: 3px; }
.note { background: var(--spark-soft); border: 2px solid var(--navy-500); border-radius: var(--radius-wobble-2); padding: 12px 14px; font-size: 15px; }

/* Ton : pastilles animées */
.tones { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tone { position: relative; cursor: pointer; }
.tone input { position: absolute; opacity: 0; }
.tone-card {
  position: relative; overflow: hidden; display: grid; align-content: end; gap: 2px;
  aspect-ratio: 3 / 4; padding: 16px; color: var(--white);
  min-height: 0;
  border-radius: 80px 80px var(--radius-m) var(--radius-m);
  border: var(--stroke) solid transparent;
  background: linear-gradient(170deg, var(--t1), var(--t2));
  transition: transform .3s var(--spring), box-shadow .3s;
}
.tone-card b { font-family: var(--font-display); font-weight: 400; font-size: 26px; position: relative; z-index: 1; }
.tone-card small { font-size: 14px; position: relative; z-index: 1; opacity: .95; }
.tone input:checked + .tone-card { border-color: var(--navy-500); box-shadow: 0 0 0 4px var(--spark), 0 10px 0 rgb(15 20 80 / .2); transform: translateY(-6px) rotate(-1deg); }
@media (max-width: 699px) { .tone-card { aspect-ratio: 1 / 1; border-radius: 60px 60px var(--radius-m) var(--radius-m); } .tone-card b { font-size: 23px; } }
.tone input:focus-visible + .tone-card { outline: 3px solid var(--accent); outline-offset: 3px; }
.fx { position: absolute; inset: 0; pointer-events: none; }
.fx i { position: absolute; display: block; }
.tone:not(:has(input:checked)) .fx i { animation-play-state: paused; }
.fx-tendre i { width: 14px; height: 14px; background: #ffd1e3; border-radius: 70% 0; top: -10%; animation: fall 4s linear infinite; opacity: .9; }
.fx-aventure i { height: 2px; width: 40%; background: rgb(255 255 255 / .7); border-radius: 2px; left: -40%; animation: wind 2.4s linear infinite; }
.fx-drole i { width: 8px; height: 12px; top: -10%; animation: fall 2.6s linear infinite; }
.fx-magique i { width: 10px; height: 10px; background: #fff6c2; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: shine 2s ease-in-out infinite; }
@keyframes fall { to { transform: translateY(420px) rotate(320deg); } }
@keyframes wind { to { transform: translateX(380%); } }
@keyframes shine { 0%, 100% { transform: scale(.4); opacity: .3; } 50% { transform: scale(1.3); opacity: 1; } }

/* Souvenir */
.mic {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  background: var(--night); color: var(--on-night); border-radius: var(--radius-wobble); padding: 22px 18px;
}
.mic-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 4px solid var(--spark);
  background: var(--navy-500); color: var(--spark); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 0 rgb(0 0 0 / .3); transition: transform .15s var(--spring);
}
.mic-btn:active { transform: scale(.95); }
.mic-btn.rec { background: #d64545; color: var(--white); border-color: var(--white); animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(214 69 69 / .6); } 50% { box-shadow: 0 0 0 16px rgb(214 69 69 / 0); } }
.mic p { margin: 0; color: var(--on-night-muted); font-size: 15px; }
.mic .timer { font-family: var(--font-display); font-size: 26px; color: var(--spark); }
.mic audio { width: 100%; max-width: 360px; }
.guide { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.guide li { background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 16px; }
.or { text-align: center; color: var(--muted); font-weight: 800; margin: 18px 0; }

/* Aperçu : livre qu'on feuillette */
.demo-flag { background: var(--spark); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: 13px; display: inline-block; vertical-align: 1px; margin-right: 4px; color: var(--navy-500); }
.flip { position: relative; perspective: 1600px; width: min(100%, 460px, 44svh); margin: 0 auto; aspect-ratio: 1; user-select: none; touch-action: pan-y; }
.flip-page, .flip-leaf { position: absolute; inset: 0; border-radius: 6px 14px 14px 6px; overflow: hidden; background: #fffdf6; box-shadow: 0 12px 0 rgb(15 20 80 / .14), inset 6px 0 10px -6px rgb(0 0 0 / .4); }
.flip-leaf { transform-origin: left center; transform-style: preserve-3d; transition: transform .7s var(--ease-out); z-index: 2; background: none; box-shadow: none; }
.flip-leaf .side { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fffdf6; border-radius: 6px 14px 14px 6px; overflow: hidden; }
.flip-leaf .side.b { transform: rotateY(180deg); background: #f3efe2; }
.flip-leaf.turn { transform: rotateY(-178deg); }
.flip-leaf.back { transform: rotateY(-178deg); transition: none; }
.flip-leaf.back.unturn { transform: rotateY(0); transition: transform .7s var(--ease-out); }
.pg { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; }
.pg img { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.pg p { margin: 0; padding: 12px 16px 14px; font-size: 16px; line-height: 1.4; background: #fffdf6; }
.pg.portrait img { object-fit: contain; object-position: 50% 100%; background: linear-gradient(180deg, #9db3fb, #b3c6fe 55%, #d4dcff); }
.pg.cover { background: var(--navy-500); }
.pg.cover p { display: none; }
.pg .cover-title { position: absolute; left: 7%; right: 7%; top: 6%; font-family: var(--font-display); color: var(--spark); font-size: clamp(26px, 7vw, 38px); line-height: 1.02; text-shadow: 0 2px 0 var(--navy-700), 0 0 18px rgb(15 20 80 / .8); }
.pg.blur img { filter: blur(10px) saturate(.6); }
.pg.blur::after { content: attr(data-msg); position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20%; font-weight: 800; color: var(--navy-500); background: rgb(255 253 246 / .6); }
.flip-nav { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 14px; }
.flip-nav .round { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: var(--stroke) solid var(--navy-500); color: var(--navy-500); cursor: pointer; }
.flip-nav .round:disabled { opacity: .35; cursor: default; }
.flip-count { font-weight: 800; min-width: 80px; text-align: center; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.page-actions button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--navy-500); background: var(--surface); font: 700 15px var(--font); color: var(--navy-500); cursor: pointer; }
.page-actions button:hover { background: var(--spark); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; justify-content: center; }
.pills span { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-size: 14px; font-weight: 700; }
.pills span.ok { border-color: var(--navy-500); }
.pills span.ok::before { content: "✓"; color: var(--ok); font-weight: 800; }
.loading { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 30px 0; }
.loading .book-fill { width: 120px; height: 120px; border: 4px solid var(--navy-500); border-radius: 8px 16px 16px 8px; position: relative; overflow: hidden; background: #fffdf6; }
.loading .book-fill::after { content: ""; position: absolute; inset: auto 0 0 0; height: 0; background: linear-gradient(0deg, var(--navy-500), #2a33a8); animation: fill 2.2s var(--ease-out) forwards; }
@keyframes fill { to { height: 100%; } }

/* Commande */
.formats-pick { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .formats-pick { grid-template-columns: 1fr 1fr; } }
.fmt { position: relative; cursor: pointer; }
.fmt input { position: absolute; opacity: 0; }
.fmt-card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 14px; background: var(--surface); border: var(--stroke) solid var(--line); border-radius: var(--radius-wobble-2); }
.fmt-card .stage { perspective: 600px; display: grid; place-items: center; height: 96px; }
.fmt-card .mini { --mw: 72px; --mt: 9px; transform: rotateY(-30deg) rotateX(-8deg); }
.fmt-card .mini.souple { --mt: 4px; }
.fmt-card b { display: block; font-size: 17px; }
.fmt-card .p { font-family: var(--font-display); font-size: 24px; }
.fmt-card small { color: var(--muted); }
.fmt input:checked + .fmt-card { border-color: var(--navy-500); box-shadow: 0 0 0 4px var(--spark); }
.fmt input:focus-visible + .fmt-card { outline: 3px solid var(--accent); outline-offset: 3px; }
.qty { justify-self: start; display: inline-flex; align-items: center; gap: 0; border: var(--stroke) solid var(--navy-500); border-radius: 999px; overflow: hidden; }
.qty button { width: 48px; height: 48px; border: 0; background: var(--surface); font: 800 22px var(--font); color: var(--navy-500); cursor: pointer; }
.qty output { min-width: 44px; text-align: center; font-weight: 800; font-size: 18px; }
.summary { background: var(--surface); border: var(--stroke) solid var(--navy-500); border-radius: var(--radius-wobble); padding: 18px; margin: 18px 0; }
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 0; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 800; text-align: right; padding-left: 12px; }
.summary .total { font-family: var(--font-display); font-size: 26px; border-top: 2px solid var(--line); padding-top: 10px; margin-top: 4px; }
.fine { font-size: 14px; color: var(--muted); }

/* Barre du bas */
.cfg-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  display: flex; gap: 10px; justify-content: space-between;
  padding: 12px max(16px, calc((100% - 760px) / 2)) max(12px, env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 2px solid var(--line);
}
.cfg-actions .btn { flex: 1; max-width: 360px; }
.cfg-actions #back { flex: 0 0 auto; }
.cfg-actions #back[hidden] { display: none; }
.cfg-actions #next { margin-left: auto; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
