/* L'établi à histoires — styles.
   Pensé pour une chambre le soir : fond de nuit, texte couleur papier, la lanterne comme accent chaud.
   Pas de blanc pur ni de bleu vif, qui éblouissent dans le noir.
   Chantier 33 (13/11/2026) : ciel étoilé, cartes en léger relief, boutons qui s'enfoncent, couvertures des
   histoires, menu parent en tuiles. Tout est dans cette feuille : aucun style écrit dans la page ou par le
   code (la politique de contenu du site l'interdit). */

@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --nuit: #1B2340;
  --fond-bas: #171E38;
  --creux: rgba(17, 22, 46, 0.55);
  --velours: #262F57;
  --velours-clair: #323C6B;
  --voile: rgba(50, 60, 107, 0.45);
  --voile-plein: rgba(40, 49, 92, 0.92);
  --lisere: rgba(169, 176, 207, 0.15);
  --papier: #F3E9D2;
  --brume: #A9B0CF;
  --lanterne: #F2B544;
  --lanterne-claire: #F9D27C;
  --lanterne-ombre: #B67C1C;
  --lanterne-sombre: #3A2E12;
  --menthe: #8ED1B6;
  --menthe-ombre: #4E9A7E;
  --lilas: #B9A8F0;
  --lilas-ombre: #7B68C4;
  --alerte: #F4A3A3;
  --ombre: 0 8px 20px rgba(9, 12, 30, 0.3);
  --relief: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 3.5rem);
  --ui: "Fredoka", "Nunito", system-ui, sans-serif;
  --recit: "Literata", Georgia, "Times New Roman", serif;
  --etincelle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 -10 20 20'%3E%3Cpath fill='%23F3E9D2' d='M0-10Q0 0 10 0 0 0 0 10 0 0-10 0 0 0 0-10Z'/%3E%3C/svg%3E");
  --etincelle-or: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 -10 20 20'%3E%3Cpath fill='%23F2B544' d='M0-10Q0 0 10 0 0 0 0 10 0 0-10 0 0 0 0-10Z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* « caché » gagne toujours sur les display des composants */
html { background: var(--nuit); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--papier);
  font-family: var(--ui);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Le ciel : une lueur en haut et quelques étoiles, immobiles derrière tous les écrans.
   Les étoiles restent dans le haut de l'écran, pour ne pas passer derrière le texte qu'on lit. */
body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
body::before {
  background:
    radial-gradient(ellipse 95% 42% at 72% 0%, rgba(96, 88, 176, 0.32), transparent 72%),
    linear-gradient(180deg, var(--nuit) 0%, var(--nuit) 55%, var(--fond-bas) 100%);
}
body::after {
  background:
    radial-gradient(circle at 7% 5%, rgba(243, 233, 210, 0.85) 0 1px, transparent 1.7px),
    radial-gradient(circle at 19% 13%, rgba(243, 233, 210, 0.5) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 31% 4%, rgba(243, 233, 210, 0.7) 0 0.9px, transparent 1.6px),
    radial-gradient(circle at 44% 17%, rgba(243, 233, 210, 0.45) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 58% 7%, rgba(243, 233, 210, 0.8) 0 1px, transparent 1.7px),
    radial-gradient(circle at 69% 21%, rgba(243, 233, 210, 0.4) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 81% 11%, rgba(243, 233, 210, 0.7) 0 0.9px, transparent 1.6px),
    radial-gradient(circle at 93% 3%, rgba(243, 233, 210, 0.55) 0 0.9px, transparent 1.6px),
    radial-gradient(circle at 12% 27%, rgba(243, 233, 210, 0.4) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 37% 31%, rgba(243, 233, 210, 0.3) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 63% 34%, rgba(243, 233, 210, 0.35) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 88% 29%, rgba(243, 233, 210, 0.45) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 25% 41%, rgba(243, 233, 210, 0.22) 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 76% 44%, rgba(243, 233, 210, 0.2) 0 0.8px, transparent 1.5px);
}
@media (prefers-reduced-motion: no-preference) {
  body::after { animation: scintillement 5s ease-in-out infinite alternate; }
  .ecran:not([hidden]) { animation: apparition 0.22s ease-out; }
}
@keyframes scintillement { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes apparition { from { opacity: 0; } }
@keyframes respire { 50% { transform: scale(1.04); opacity: 0.85; } }

/* ---------- Écrans */
.ecran {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.ecran[hidden] { display: none; }
.ecran-centre { justify-content: center; align-items: center; text-align: center; }

.entete { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; min-height: 3rem; }

h2 { margin: 0; font-weight: 600; font-size: 1.25rem; }
h3 { margin: 0; font-weight: 600; font-size: 1.1rem; }
.question { font-size: 1.5rem; margin-top: 0.25rem; }
.discret { color: var(--brume); margin: 0; font-size: 0.95rem; }
.erreur { color: var(--alerte); margin: 0; }
.merci { margin: 0; color: var(--menthe); }

.icone { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.reserve { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Surfaces : tout ce qui est une « carte » posée sur la nuit */
.bloc-retours, .apercu, .groupe, .carte-reprise, .carte-scene, .bloc-source, .carte-tirage, .tuile, .ligne-histoire,
.liste-personnages button, .vignettes button, .durees button, .avis button, .puce-personnage, .pave button {
  background: var(--relief), var(--velours);
  border: 1px solid var(--lisere);
  box-shadow: var(--ombre);
}

/* ---------- Boutons : la hiérarchie se lit à la forme */
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--menthe); outline-offset: 3px; }

.bouton-principal {
  background: linear-gradient(180deg, var(--lanterne-claire) 0%, var(--lanterne) 55%, #EDA63B 100%);
  color: var(--nuit);
  font-weight: 600;
  font-size: 1.25rem;
  min-height: 4rem;
  padding: 0.75rem 1.5rem;
  border-radius: 2rem;
  width: 100%;
  box-shadow: 0 4px 0 var(--lanterne-ombre), 0 12px 22px rgba(242, 181, 68, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.bouton-principal:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--lanterne-ombre); }
.bouton-principal:disabled { background: var(--velours-clair); color: var(--brume); box-shadow: none; }

.bouton-secondaire {
  background: var(--voile);
  border: 2px solid var(--velours-clair);
  color: var(--papier);
  min-height: 3.25rem;
  padding: 0.5rem 1.25rem;
  border-radius: 1.625rem;
}
.bouton-secondaire:active:not(:disabled) { background: var(--velours-clair); }
.bouton-secondaire:disabled { opacity: 0.5; }
.bouton-retour { background: none; color: var(--brume); padding: 0.75rem 0.25rem; min-height: 3rem; }
/* Le bouton Retour d'un écran : une pastille avec son chevron. */
.entete .bouton-retour {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--voile-plein);
  color: var(--papier);
  border: 1px solid var(--lisere);
  border-radius: 999px;
  padding: 0.35rem 1rem 0.35rem 0.85rem;
  min-height: 2.75rem;
}
.entete .bouton-retour::before { content: ""; width: 0.5rem; height: 0.5rem; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.entete .bouton-retour:disabled { opacity: 0.4; }
.bouton-icone { background: var(--voile-plein); border: 1px solid var(--lisere); color: var(--brume); width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 50%; flex-shrink: 0; }
.bouton-principal[hidden], .bouton-secondaire[hidden], .bouton-retour[hidden] { display: none; }
.bouton-supprimer { background: none; border: 2px solid var(--alerte); color: var(--alerte); border-radius: 1.4rem; padding: 0.4rem 0.9rem; min-height: 2.75rem; flex-shrink: 0; }
.bouton-fichier { display: grid; place-items: center; text-align: center; }
.bouton-fichier input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* Le bouton d'un long écran reste en bas pendant qu'on fait défiler (création, réglages, profil, fiches). */
.barre-action {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: auto -1.25rem calc(-1 * max(1.5rem, env(safe-area-inset-bottom)));
  padding: 1.5rem 1.25rem calc(max(1rem, env(safe-area-inset-bottom)) + 4px);
  background: linear-gradient(rgba(23, 30, 56, 0), var(--fond-bas) 42%);
}

/* ---------- Champs */
input, textarea {
  font: inherit;
  color: var(--papier);
  background: var(--creux);
  border: 2px solid var(--velours-clair);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  width: 100%;
  min-height: 3.25rem;
}
textarea { resize: vertical; }
::placeholder { color: var(--brume); opacity: 0.6; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 0.5rem; }
.puces { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.puce {
  background: var(--voile);
  border: 2px solid var(--velours-clair);
  border-radius: 1.4rem;
  padding: 0.45rem 0.9rem;
  min-height: 2.75rem;
}
.puce[aria-pressed="true"], .puce[aria-checked="true"] { background: var(--menthe); border-color: var(--menthe); color: var(--nuit); font-weight: 600; }

/* ---------- Accueil */
#ecran-accueil { gap: 1.1rem; }
.entete-accueil { justify-content: flex-start; gap: 0.6rem; position: relative; z-index: 1; }
.logo { width: 3.1rem; height: 3.1rem; flex-shrink: 0; filter: drop-shadow(0 0 14px rgba(242, 181, 68, 0.35)); }
.titre-app {
  margin: 0 auto 0 0;
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--lanterne);
}
.decor-accueil { display: block; width: calc(100% + 2.5rem); height: 5.25rem; margin: -2rem -1.25rem -0.5rem; pointer-events: none; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.bouton-mode {
  position: relative;
  overflow: hidden;
  min-height: 7.25rem;
  padding: 0.75rem 0.5rem;
  border-radius: 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-align: center;
  color: var(--nuit);
  background: linear-gradient(160deg, var(--lanterne-claire), var(--lanterne) 60%, #EDA63B);
  box-shadow: 0 5px 0 var(--lanterne-ombre), 0 14px 24px rgba(9, 12, 30, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.bouton-mode::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 22% 12%, rgba(255, 255, 255, 0.5), transparent 55%); pointer-events: none; }
.bouton-mode > * { position: relative; }
.bouton-mode .emoji { font-size: 2.4rem; line-height: 1; filter: drop-shadow(0 3px 4px rgba(27, 35, 64, 0.25)); }
.bouton-mode .texte { display: flex; flex-direction: column; }
.bouton-mode strong { font-weight: 600; font-size: 1.15rem; line-height: 1.2; }
.bouton-mode small { font-size: 0.82rem; opacity: 0.72; }
.bouton-mode:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--lanterne-ombre); }
.mode-libre { background: linear-gradient(160deg, #D9CEFB, var(--lilas) 60%, #A292E6); box-shadow: 0 5px 0 var(--lilas-ombre), 0 14px 24px rgba(9, 12, 30, 0.35); }
.mode-libre:active { box-shadow: 0 1px 0 var(--lilas-ombre); }
.modes .bouton-surprise, .modes .bouton-avent { grid-column: 1 / -1; min-height: 4.5rem; flex-direction: row; justify-content: flex-start; gap: 0.9rem; padding: 0.6rem 1.25rem; text-align: left; }
.bouton-surprise { background: linear-gradient(160deg, #BDEEDB, var(--menthe) 60%, #72C3A4); box-shadow: 0 5px 0 var(--menthe-ombre), 0 14px 24px rgba(9, 12, 30, 0.35); }
.bouton-surprise:active { box-shadow: 0 1px 0 var(--menthe-ombre); }
.bouton-avent { background: linear-gradient(160deg, #2E8E6D, #1F6B52); color: var(--papier); box-shadow: 0 5px 0 #124434, 0 14px 24px rgba(9, 12, 30, 0.35); }
.bouton-avent:active { box-shadow: 0 1px 0 #124434; }
.bouton-avent::before { background: radial-gradient(circle at 22% 12%, rgba(255, 255, 255, 0.2), transparent 55%); }

.carte-reprise {
  width: 100%;
  text-align: left;
  border-radius: 1.1rem;
  padding: 0.6rem 1rem 0.6rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-left: 4px solid var(--menthe);
}
.carte-reprise .texte { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.carte-reprise strong { font-weight: 600; font-size: 1.05rem; line-height: 1.25; }
.carte-reprise small { color: var(--brume); font-size: 0.9rem; }

/* Couverture d'une histoire : sa première image, sinon un carton de couleur avec un dessin. */
.couverture { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 5; border-radius: 0.9rem; overflow: hidden; flex-shrink: 0; }
.couverture::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09); pointer-events: none; }
.couverture::before { content: ""; position: absolute; inset: 0; background:
  var(--etincelle) 18% 14% / 0.9rem no-repeat, var(--etincelle) 82% 80% / 0.6rem no-repeat, var(--etincelle-or) 80% 20% / 0.55rem no-repeat,
  radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.16), transparent 58%); opacity: 0.85; }
.couverture .emoji { position: relative; font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 4px 6px rgba(9, 12, 30, 0.4)); }
.couverture.petite::before { background: radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.16), transparent 58%); }
.couverture img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; }
.couverture.petite { width: 3.4rem; border-radius: 0.6rem; }
.couverture.petite .emoji { font-size: 1.6rem; }
.teinte-0 { background: linear-gradient(155deg, #41529A, #2A3466); }
.teinte-1 { background: linear-gradient(155deg, #63519E, #372F60); }
.teinte-2 { background: linear-gradient(155deg, #33746F, #23474F); }
.teinte-3 { background: linear-gradient(155deg, #86633E, #4A3A2C); }
.teinte-4 { background: linear-gradient(155deg, #875178, #472E4B); }
.teinte-5 { background: linear-gradient(155deg, #45679B, #293D63); }

.bibliotheque { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 0.4rem; }
.bibliotheque h2 { display: flex; align-items: baseline; gap: 0.5rem; }
.bibliotheque h2 small { color: var(--brume); font-size: 0.95rem; font-weight: 500; }
.rayon-histoires { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 0.85rem; }
@media (min-width: 30rem) { .rayon-histoires { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.carte-histoire { width: 100%; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 0.35rem; }
.carte-histoire .couverture { box-shadow: var(--ombre); transition: transform 0.08s ease; }
.carte-histoire:active .couverture { transform: scale(0.97); }
.carte-histoire .titre { font-weight: 600; font-size: 0.98rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.carte-histoire .date { color: var(--brume); font-size: 0.82rem; }
.vide { border: 2px dashed var(--velours-clair); border-radius: 1rem; padding: 1.5rem 1rem; text-align: center; }

/* ---------- Création */
.mots-choisis { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 2.75rem; }
.mots-choisis button {
  background: var(--menthe);
  color: var(--nuit);
  border-radius: 1.4rem;
  padding: 0.5rem 0.9rem;
  min-height: 2.75rem;
  font-weight: 600;
}
.mots-choisis button::after { content: " ×"; }

.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.7rem, 1fr)); gap: 0.6rem; }
.vignettes button {
  border-radius: 1rem;
  padding: 0.6rem 0.2rem 0.5rem;
  min-height: 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}
.vignettes .emoji { font-size: 2rem; line-height: 1; }
.vignettes button[aria-pressed="true"], .durees button[aria-checked="true"], .puce-personnage[aria-pressed="true"],
.avis button[aria-pressed="true"], .retour .vignettes button[aria-pressed="true"] {
  background: var(--lanterne-sombre);
  border-color: var(--lanterne);
  box-shadow: 0 0 0 1px var(--lanterne), 0 0 18px rgba(242, 181, 68, 0.22);
}

.ajout-mot { display: flex; gap: 0.5rem; }
.ajout-mot input { flex: 1; }

.durees { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.durees button {
  border-radius: 1rem;
  padding: 0.75rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-weight: 600;
}
.durees .emoji { font-size: 1.75rem; }
.durees small { color: var(--brume); font-weight: 500; }

.bloc-qui { display: flex; flex-direction: column; gap: 0.75rem; }
.choix-personnages { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.puce-personnage {
  border-radius: 1rem;
  padding: 0.5rem;
  width: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.95rem;
}
.puce-personnage img, .puce-personnage .sans-image { width: 3.5rem; height: 3.5rem; border-radius: 50%; object-fit: cover; }
.puce-personnage:disabled { cursor: default; opacity: 1; }
.sans-image { display: grid; place-items: center; background: var(--velours-clair); color: var(--lanterne); font-size: 1.4rem; }

.bloc-idee { display: flex; flex-direction: column; gap: 0.75rem; }
.bouton-micro {
  background: var(--voile);
  border: 2px solid var(--menthe);
  border-radius: 2rem;
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1.2rem;
}
.bouton-micro .emoji { font-size: 1.8rem; }
.bouton-micro.ecoute { background: var(--menthe); color: var(--nuit); }
@media (prefers-reduced-motion: no-preference) {
  .bouton-micro.ecoute { animation: respire 1.6s ease-in-out infinite; }
}

/* ---------- Fabrication : la lune se remplit pendant que l'histoire se fabrique */
.ciel-lune { position: relative; display: grid; place-items: center; padding: 1.5rem 2.5rem; }
.lune { width: min(60vw, 14rem); height: auto; filter: drop-shadow(0 0 28px rgba(242, 181, 68, 0.28)); }
.lune-fond { fill: var(--velours); }
.lune-lumiere { fill: var(--lanterne); transition: d 1.2s ease; }
.scintille { position: absolute; fill: var(--papier); stroke: none; width: 1.1rem; height: 1.1rem; opacity: 0.8; }
.scintille.s1 { top: 0.4rem; left: 1rem; }
.scintille.s2 { top: 2.2rem; right: 0.4rem; width: 0.8rem; height: 0.8rem; }
.scintille.s3 { bottom: 1.2rem; left: 0.2rem; width: 0.7rem; height: 0.7rem; }
.scintille.s4 { bottom: 0.2rem; right: 1.6rem; fill: var(--lanterne); }
.etape-texte { font-size: 1.4rem; font-weight: 600; margin: 0.5rem 0 0; max-width: 20rem; }
.bloc-erreur { display: flex; flex-direction: column; gap: 0.75rem; width: 100%; }
.bloc-erreur[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .attente .lune { animation: respire 3.5s ease-in-out infinite; }
  .attente .scintille { animation: scintillement 1.8s ease-in-out infinite alternate; }
  .attente .scintille.s2 { animation-delay: 0.5s; }
  .attente .scintille.s3 { animation-delay: 0.9s; }
  .attente .scintille.s4 { animation-delay: 1.3s; }
}

/* ---------- Lecture */
.progression { color: var(--brume); font-size: 0.95rem; }
#ecran-lecture .entete { gap: 0.5rem; }
progress { appearance: none; -webkit-appearance: none; border: 0; }
.fil-lecture { display: block; width: 100%; height: 4px; margin: -0.5rem 0 0; border-radius: 2px; overflow: hidden; background: var(--velours-clair); }
.fil-lecture::-webkit-progress-bar { background: var(--velours-clair); }
.fil-lecture::-webkit-progress-value { background: var(--lanterne); border-radius: 2px; transition: width 0.3s ease; }
.fil-lecture::-moz-progress-bar { background: var(--lanterne); }
.avertissement {
  margin: 0;
  background: var(--velours);
  border-left: 4px solid var(--alerte);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}
.page { flex: 1; }
.page h2 { font-family: var(--ui); font-size: 1.1rem; color: var(--lanterne); margin-bottom: 1rem; }
.page .titre-histoire { font-size: 1.85rem; line-height: 1.2; color: var(--papier); margin-bottom: 0.9rem; }
.page p {
  font-family: var(--recit);
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.75;
  margin: 0 0 1.1em;
  max-width: 34em;
}
.page .fin { font-family: var(--recit); font-style: italic; font-size: 1.9rem; text-align: center; color: var(--lanterne); margin-top: 2rem; }
.page .fin::before, .page .fin::after { content: ""; display: inline-block; width: 0.9rem; height: 0.9rem; margin: 0 1rem; vertical-align: middle; background: var(--etincelle-or) center / contain no-repeat; opacity: 0.8; }
.page .episode { margin: 1rem 0 0.25rem; text-align: left; color: var(--lanterne); font-family: var(--ui); font-size: 0.95rem; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; }
.page .etiquettes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; font-family: var(--ui); font-size: 0.88rem; line-height: 1.3; max-width: none; }
.etiquettes span { background: var(--voile); border: 1px solid var(--lisere); border-radius: 999px; padding: 0.25rem 0.75rem; color: var(--brume); }
.illustration { margin: 0 0 1.25rem; cursor: zoom-in; }
.illustration img { width: 100%; max-height: 75vh; object-fit: contain; border-radius: 1.1rem; display: block; background: var(--velours); box-shadow: var(--ombre); }
/* Page de titre : l'image en couverture, recadrée (elle se voit en entier quand on la touche). */
.couverture-titre img { max-height: 44vh; object-fit: cover; object-position: 50% 35%; }
.navigation {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 0.75rem;
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 -1.25rem calc(-1 * max(1.5rem, env(safe-area-inset-bottom)));
  padding: 1.5rem 1.25rem calc(max(1rem, env(safe-area-inset-bottom)) + 4px);
  background: linear-gradient(rgba(23, 30, 56, 0), var(--fond-bas) 42%);
}
.navigation .bouton-secondaire { min-height: 4rem; }

/* Bouton du parent sur la page de titre et la page « Fin » : droit aux images et à la voix de l'histoire. */
.bouton-atelier {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  margin-top: 1.6rem;
  padding: 0.7rem 1rem;
  text-align: left;
  background: var(--voile);
  border: 1.5px dashed var(--velours-clair);
  border-radius: 1rem;
}
.bouton-atelier .emoji { font-size: 1.7rem; line-height: 1; }
.bouton-atelier > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.bouton-atelier strong { font-weight: 600; }
.bouton-atelier small { color: var(--brume); font-size: 0.82rem; }

/* Page « Fin » : le retour de l'enfant (chantier 3) */
.retour { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; text-align: center; }
.retour h3 { margin: 0; font-weight: 600; font-size: 1.3rem; }
.avis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.avis button {
  border-radius: 1rem;
  padding: 0.75rem 0.25rem;
  min-height: 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}
.avis .emoji { font-size: 2.6rem; line-height: 1; }
.prefere { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.prefere[hidden] { display: none; }

/* La suite de… (chantier 13) */
.bouton-suite {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; min-height: 4rem; margin-top: 1.75rem; padding: 0.75rem 1.25rem;
  background: var(--velours); border: 2px solid var(--lanterne); border-radius: 2rem;
  color: var(--papier); font-weight: 600; font-size: 1.15rem;
}
.bouton-suite .emoji { font-size: 1.5rem; }
.bandeau-suite { display: flex; flex-direction: column; gap: 0.25rem; background: var(--velours); border-left: 4px solid var(--lanterne); border-radius: 0.5rem; padding: 0.75rem 1rem; }
.bandeau-suite[hidden] { display: none; }
.bandeau-suite p { margin: 0; }
.bandeau-suite .bouton-retour { align-self: flex-start; padding-left: 0; }

/* Lecture à voix haute (chantier 12) ; le même bouton sert à « Lire » sur l'écran « Images et voix ». */
.bouton-ecouter { background: var(--voile-plein); border: 2px solid var(--velours-clair); border-radius: 1.4rem; padding: 0.4rem 0.9rem; min-height: 2.75rem; }
.bouton-ecouter[aria-pressed="true"] { background: var(--menthe); border-color: var(--menthe); color: var(--nuit); font-weight: 600; }
.bouton-ecouter:disabled { opacity: 0.4; }

/* Une image vue en grand : on la touche pour la refermer. */
.visionneuse {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(11, 14, 32, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: zoom-out;
}
.visionneuse img { max-width: 100%; max-height: calc(100dvh - 5rem); border-radius: 1rem; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }

/* ---------- Formulaires (réglages, profil, fiches) */
.reglages { display: flex; flex-direction: column; gap: 1.1rem; }
.reglages label { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; }
.reglages small { color: var(--brume); font-weight: 500; font-size: 0.875rem; }
.groupe { display: flex; flex-direction: column; gap: 1rem; border-radius: 1.1rem; padding: 1rem 1.1rem 1.15rem; }
.groupe h3 { color: var(--lanterne); }

/* ---------- Verrou parent (chantier 2) */
.verrou { display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.verrou-points { display: flex; gap: 1rem; margin: 0.5rem 0; }
.verrou-points span { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--brume); }
.verrou-points span.plein { background: var(--lanterne); border-color: var(--lanterne); box-shadow: 0 0 12px rgba(242, 181, 68, 0.5); }
.pave { display: grid; grid-template-columns: repeat(3, 4.5rem); gap: 0.9rem; }
.pave button { height: 4.5rem; border-radius: 50%; font-size: 1.6rem; font-weight: 600; }
.pave button:active { background: var(--velours-clair); }
.verrou form { width: 100%; }

/* ---------- Espace parent : des tuiles rangées par usage, le tout sur un écran */
.menu-parent { display: flex; flex-direction: column; gap: 0.55rem; }
.menu-parent h3 { font-size: 0.8rem; font-weight: 600; color: var(--brume); text-transform: uppercase; letter-spacing: 0.09em; margin-top: 0.4rem; }
.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.tuile {
  position: relative;
  min-width: 0;
  min-height: 3.75rem;
  padding: 0.6rem 0.7rem;
  border-radius: 1.05rem;
  text-align: left;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.6rem;
  align-content: center;
  align-items: center;
}
.tuile .icone { grid-row: 1 / span 3; width: 2.3rem; height: 2.3rem; padding: 0.5rem; border-radius: 0.75rem; background: rgba(242, 181, 68, 0.14); color: var(--lanterne); }
.tuile strong { grid-column: 2; font-weight: 600; font-size: 1rem; line-height: 1.2; }
.tuile span { grid-column: 2; color: var(--brume); font-size: 0.8rem; line-height: 1.3; }
@media (max-width: 23.5rem) { /* petits téléphones : le dessin prend moins de place, le texte ne se coupe pas */
  .tuile { padding: 0.55rem 0.55rem; column-gap: 0.45rem; }
  .tuile .icone { width: 2rem; height: 2rem; padding: 0.42rem; }
}
.tuile span:empty { display: none; }
.tuile.large { grid-column: 1 / -1; }
.tuile:active { background: var(--velours-clair); }
.menu-parent > div:nth-of-type(2) .icone { background: rgba(142, 209, 182, 0.14); color: var(--menthe); }
.menu-parent > div:nth-of-type(3) .icone { background: rgba(185, 168, 240, 0.16); color: var(--lilas); }
/* Un point de lanterne : quelque chose attend le parent (souvenirs à revoir, sauvegarde à faire). */
.tuile[data-alerte] span { color: var(--lanterne); }
.tuile[data-alerte] span::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.35rem; border-radius: 50%; background: var(--lanterne); box-shadow: 0 0 8px rgba(242, 181, 68, 0.7); }

.bloc-retours, .apercu { display: flex; flex-direction: column; gap: 0.5rem; border-radius: 1rem; padding: 1rem 1.1rem; }
.retours-resume { margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.retours-suggestions { display: flex; flex-direction: column; gap: 0.5rem; }
.retours-suggestions:empty { display: none; }
.bloc-retours .bouton-retour { align-self: flex-start; padding-left: 0; text-align: left; }
.bloc-retours .bouton-retour[hidden] { display: none; }
#ecran-sauvegarde p { margin: 0; }

.liste-gestion { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.liste-gestion li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.85rem 0; border-bottom: 1px solid var(--velours-clair); }
.liste-gestion li:last-child { border-bottom: 0; }
.liste-gestion li > span { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.liste-gestion small { color: var(--brume); font-size: 0.875rem; }
.liste-gestion .actions { display: flex; flex-direction: column; gap: 0.4rem; flex-shrink: 0; }
.liste-gestion .actions .bouton-secondaire { min-height: 2.75rem; padding: 0.4rem 0.9rem; }
.liste-gestion .montant { font-weight: 600; white-space: nowrap; flex-shrink: 0; }

/* Nos histoires (espace parent) : une ligne par histoire, avec sa couverture ; la corbeille à côté. */
.liste-histoires-parent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.liste-histoires-parent li { display: flex; align-items: stretch; gap: 0.5rem; }
.ligne-histoire { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.8rem; text-align: left; border-radius: 1rem; padding: 0.5rem 0.8rem 0.5rem 0.5rem; }
.ligne-histoire:active { background: var(--velours-clair); }
.ligne-histoire .texte { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.ligne-histoire strong { font-weight: 600; line-height: 1.25; }
.ligne-histoire small { color: var(--brume); font-size: 0.82rem; line-height: 1.3; }
.ligne-histoire .etat-histoire.commence { color: var(--menthe); }
.bouton-corbeille { flex-shrink: 0; align-self: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: rgba(244, 163, 163, 0.07); border: 1px solid rgba(244, 163, 163, 0.35); color: var(--alerte); display: grid; place-items: center; }
.bouton-corbeille .icone { width: 1.3rem; height: 1.3rem; }

/* ---------- Personnages et lieux */
.liste-personnages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.liste-personnages button {
  width: 100%;
  text-align: left;
  border-radius: 1rem;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.liste-personnages img, .liste-personnages .sans-image { width: 3.5rem; height: 3.5rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.liste-personnages strong { display: block; font-weight: 600; }
.liste-personnages small { color: var(--brume); }
.vignettes-images { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.image-ref { position: relative; }
.image-ref img, .image-ref .vignette { width: 6rem; height: 6rem; object-fit: cover; border-radius: 0.75rem; display: block; }
.image-ref > button:not(.choisir-version) {
  position: absolute;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--nuit);
  color: var(--papier);
  top: 0.25rem;
}
.image-ref [data-principale] { left: 0.25rem; color: var(--brume); }
.image-ref [data-principale][aria-pressed="true"] { color: var(--lanterne); }
.image-ref [data-retirer-ref], .image-ref [data-retirer-version] { right: 0.25rem; }
.choisir-version { padding: 0; background: none; border-radius: 0.75rem; }
.choisir-version[aria-pressed="true"] img { outline: 3px solid var(--lanterne); outline-offset: 2px; }
#ecran-personnage h3, #ecran-lieu h3, #ecran-memoire h3 { margin-top: 0.75rem; color: var(--lanterne); }
#ecran-personnage .bouton-supprimer, #ecran-lieu .bouton-supprimer { align-self: flex-start; }
.bloc-source { display: flex; flex-direction: column; gap: 0.6rem; border-radius: 1rem; padding: 0.9rem; }

/* ---------- Images et voix d'une histoire */
.carte-preparer { gap: 0.65rem; border-color: rgba(242, 181, 68, 0.35); }
.ligne-etat { margin: 0; display: flex; align-items: baseline; gap: 0.6rem; }
.ligne-etat .emoji { flex-shrink: 0; }
.carte-preparer .bouton-principal { font-size: 1.1rem; min-height: 3.6rem; padding: 0.6rem 1.1rem; margin-bottom: 4px; }
.carte-preparer .bouton-secondaire { width: 100%; }
.avancement { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.25rem 0; }
.carte-preparer .avancement .bouton-secondaire { align-self: flex-start; width: auto; min-height: 2.6rem; padding: 0.3rem 1rem; font-size: 0.95rem; }
#jauge-atelier { display: block; width: 100%; height: 0.75rem; border-radius: 999px; overflow: hidden; background: var(--nuit); }
#jauge-atelier::-webkit-progress-bar { background: var(--nuit); }
#jauge-atelier::-webkit-progress-value { background: linear-gradient(90deg, var(--lanterne), var(--lanterne-claire)); border-radius: 999px; transition: width 0.4s ease; }
#jauge-atelier::-moz-progress-bar { background: var(--lanterne); }

/* Blocs repliables : le titre se touche pour ouvrir. */
.repli { display: block; }
.repli > * + * { margin-top: 0.7rem; }
.repli > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 0.6rem; font-weight: 600; }
.repli > summary::-webkit-details-marker { display: none; }
.repli > summary span { grid-column: 1; }
.repli > summary small { grid-column: 1; color: var(--brume); font-weight: 500; font-size: 0.85rem; }
.repli > summary::after { content: ""; grid-column: 2; grid-row: 1 / span 2; width: 0.5rem; height: 0.5rem; margin: 0 0.25rem 0.2rem; border-right: 2px solid var(--brume); border-bottom: 2px solid var(--brume); transform: rotate(45deg); transition: transform 0.15s ease; }
.repli[open] > summary::after { transform: rotate(-135deg); margin-bottom: -0.2rem; }

.titre-section { margin-top: 0.4rem; }
.liste-illustrer { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.carte-scene { border-radius: 1rem; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.scene-atelier { flex-direction: row; align-items: flex-start; gap: 0.85rem; padding: 0.7rem; }
.vue-scene { flex-shrink: 0; width: 4.75rem; aspect-ratio: 3 / 4; padding: 0; border-radius: 0.7rem; overflow: hidden; background: var(--creux); display: grid; place-items: center; }
.vue-scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vue-scene.sans-illustration { border: 2px dashed var(--velours-clair); color: var(--brume); font-weight: 600; font-size: 1.4rem; }
@media (prefers-reduced-motion: no-preference) {
  .scene-atelier[data-encours] .vue-scene { border-color: var(--lanterne); color: var(--lanterne); animation: respire 1.6s ease-in-out infinite; }
}
/* Le bouton et « Plus » côte à côte ; déplié, « Plus » prend toute la largeur. */
.corps-scene { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.corps-scene h3 { flex-basis: 100%; font-size: 1rem; line-height: 1.25; }
.corps-scene .erreur, .corps-scene details[open] { flex-basis: 100%; }
.corps-scene h3 small { display: block; color: var(--lanterne); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; }
.bouton-dessiner { align-self: flex-start; min-height: 2.75rem; padding: 0.4rem 0.95rem; font-size: 0.95rem; text-align: left; }
.carte-scene summary { cursor: pointer; color: var(--brume); font-size: 0.9rem; }
.carte-scene details[open] > *:not(summary) { margin-top: 0.6rem; }
.prompt { white-space: pre-wrap; font-size: 0.9rem; background: var(--nuit); padding: 0.75rem; border-radius: 0.5rem; margin: 0.5rem 0 0; user-select: all; overflow-wrap: anywhere; }
.refs-flow { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ref-flow { background: none; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; font-size: 0.85rem; }
.ref-flow img { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: 0.5rem; }
/* Images de référence dans le style de l'histoire (chantier 20 ter) */
.liste-ancres { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.75rem; }
.carte-ancre { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; font-size: 0.9rem; text-align: center; }
.carte-ancre img, .carte-ancre .sans-image { width: 6rem; height: 6rem; object-fit: cover; border-radius: 0.75rem; display: block; }
.vue-ancre { padding: 0; background: none; border-radius: 0.75rem; }
.carte-ancre .bouton-secondaire { min-height: 2.5rem; padding: 0.3rem 0.8rem; }
.carte-ancre .erreur { margin: 0; font-size: 0.8rem; }
#bloc-garder .puces:empty { display: none; }

/* ---------- Surprise (chantier 10) */
.liste-tirage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.carte-tirage { display: flex; align-items: center; gap: 0.8rem; border-radius: 0.9rem; padding: 0.45rem 0.8rem; }
.carte-tirage img, .carte-tirage .emoji { width: 2.6rem; height: 2.6rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: grid; place-items: center; font-size: 1.6rem; }
.carte-tirage small { display: block; color: var(--brume); font-size: 0.85rem; }
.carte-tirage strong { font-weight: 600; font-size: 1.1rem; }
#ecran-surprise .navigation { margin-top: auto; }
#ecran-surprise { gap: 0.9rem; }

/* ---------- Mémoire (chantier 9) */
.fait-propose { display: flex; gap: 0.6rem; align-items: flex-start; }
.fait-propose input { width: 1.6rem; height: 1.6rem; min-height: 0; margin-top: 0.9rem; flex-shrink: 0; accent-color: var(--menthe); }
.liste-memoire { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.liste-memoire li { display: flex; flex-direction: column; gap: 0.35rem; }
.liste-memoire .bouton-supprimer { align-self: flex-start; }

/* ---------- Livres (chantier 11) */
.liste-histoires-livre { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.choix-histoire { display: flex !important; flex-direction: row !important; align-items: center; gap: 0.8rem; padding: 0.6rem 0; border-bottom: 1px solid var(--velours-clair); font-weight: 500 !important; }
.choix-histoire input { width: 1.6rem; height: 1.6rem; min-height: 0; flex-shrink: 0; accent-color: var(--menthe); }
.choix-histoire span { display: flex; flex-direction: column; }
.choix-histoire small { color: var(--brume); }
.groupe .choix-histoire { border-bottom: 0; padding: 0; }

/* Pages du livre : invisibles à l'écran, seules visibles à l'impression. */
#livre { display: none; }
.page-livre {
  width: 148mm; height: 210mm; box-sizing: border-box; position: relative; overflow: hidden;
  padding: 14mm 14mm 17mm; display: flex; flex-direction: column;
  font-family: var(--recit); color: #2b2b2b; background: #fffaf0; flex-shrink: 0;
}
/* Livret (chantier 15) : une face de feuille A4 paysage = deux pages A5 côte à côte. */
.feuille { width: 297mm; height: 210mm; display: flex; overflow: hidden; break-after: page; page-break-after: always; }
.feuille:last-child { break-after: auto; page-break-after: auto; }
.numero-page { position: absolute; bottom: 7mm; left: 0; right: 0; text-align: center; font: 500 9pt var(--ui); color: #8a8a8a; }
/* Marge plus large côté pli (même largeur de texte qu'en A5 : 28 mm au total), numéros côté extérieur. */
.page-livre.page-gauche { padding-left: 11mm; padding-right: 17mm; }
.page-livre.page-droite { padding-left: 17mm; padding-right: 11mm; }
.page-gauche .numero-page { left: 11mm; right: auto; }
.page-droite .numero-page { right: 11mm; left: auto; }
.page-dessin { align-items: center; text-align: center; }
.dessin-titre { margin: 0 0 2mm; font: 600 14pt var(--ui); color: #c98a12; }
.cadre-dessin { flex: 1; align-self: stretch; margin-top: 5mm; border: 0.6mm dashed #d9c9a3; border-radius: 5mm; }
.page-ornement { justify-content: center; align-items: center; text-align: center; }
.ornement { margin: 0 0 4mm; font-size: 20pt; letter-spacing: 3mm; color: #c98a12; }
.page-dos { padding: 16mm 14mm 14mm; background: #1B2340; color: #F3E9D2; align-items: center; text-align: center; }
.page-dos img { width: 62%; max-height: 80mm; object-fit: cover; border-radius: 4mm; margin-bottom: 8mm; }
.dos-titre { margin: 0 0 3mm; font: 600 13pt var(--ui); color: #F2B544; }
.page-dos ul { list-style: none; margin: 0; padding: 0; font-size: 10.5pt; line-height: 1.6; }
.dos-signature { margin: auto 0 0; font: 500 9.5pt var(--ui); color: #A9B0CF; }
.page-couverture { padding: 0; background: #1B2340; }
.page-couverture img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.couverture-texte { position: absolute; left: 0; right: 0; bottom: 0; padding: 30mm 12mm 14mm; background: linear-gradient(transparent, rgba(27, 35, 64, 0.92) 45%); }
.couverture-texte h1 { margin: 0; font: 600 23pt/1.15 var(--ui); color: #F2B544; }
.couverture-texte p { margin: 3mm 0 0; font: 500 13pt var(--ui); color: #F3E9D2; }
.page-garde, .page-titre-histoire, .page-fin { justify-content: center; align-items: center; text-align: center; }
.appartient { margin: 0; font-style: italic; font-size: 13pt; }
.page-garde .nom { margin: 5mm 0; font: 600 26pt var(--ui); color: #c98a12; }
.discret-livre { margin: 0; font-size: 10pt; color: #777; }
.page-sommaire h2 { margin: 0 0 7mm; font: 600 18pt var(--ui); color: #c98a12; }
.page-sommaire ol { margin: 0; padding-left: 7mm; font-size: 11pt; line-height: 1.9; }
.page-sommaire li { position: relative; padding-right: 8mm; }
.page-sommaire li span:last-child { position: absolute; right: 0; top: 0; }
.page-titre-histoire h2 { margin: 0 0 6mm; font: 600 21pt/1.2 var(--ui); color: #c98a12; }
.page-image { padding: 10mm 10mm 16mm; justify-content: center; align-items: center; }
.page-image img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 3mm; }
.page-texte h3 { margin: 0 0 5mm; font: 600 13pt var(--ui); color: #c98a12; }
.page-texte p { margin: 0 0 3mm; font-size: 12pt; line-height: 1.55; }
.page-texte.texte-long p { font-size: 10.5pt; line-height: 1.45; }
.page-texte.texte-tres-long p { font-size: 9.5pt; line-height: 1.4; margin-bottom: 2mm; }
.fin-livre { margin: 0 0 4mm; font-style: italic; font-size: 26pt; color: #c98a12; }

@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff !important; min-height: 0; }
  body.impression-livre > *:not(#livre) { display: none !important; }
  body.impression-livre #livre { display: block; }
  .page-livre, .feuille { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Dépenses (chantier 14) */
.total-depenses { text-align: center; }
.montant-principal { margin: 0; font-size: 2.2rem; font-weight: 600; color: var(--lanterne); }
#bloc-depenses-anciens[hidden] { display: none; }
.aide-livret { display: flex; flex-direction: column; gap: 0.4rem; }
.aide-livret p { margin: 0; }
.feuille.tete-beche { transform: rotate(180deg); } /* versos d'une imprimante qui reprend la pile à l'envers (chantier 15 bis) */
#bloc-impression .bouton-principal, #bloc-impression .bouton-secondaire { width: 100%; }
#bloc-impression .bouton-principal { margin-bottom: 4px; }

/* ---------- Calendrier de l'Avent (chantier 26) */
.cases-avent { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.case-avent {
  width: 100%; aspect-ratio: 1; border-radius: 0.9rem; background: var(--velours); color: var(--brume);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  font-weight: 600; border: 2px dashed var(--velours-clair);
}
.case-avent .numero { font-size: 1.3rem; line-height: 1; }
.case-avent .emoji { font-size: 1.4rem; line-height: 1; min-height: 1.4rem; }
.case-avent[data-etat="ouverte"] { background: linear-gradient(160deg, #2E8E6D, #1F6B52); color: var(--papier); border: 2px solid transparent; box-shadow: 0 4px 0 #124434; }
.case-avent[data-etat="faite"] { background: var(--lanterne-sombre); color: var(--lanterne); border: 2px solid var(--lanterne); }
.case-avent[data-etat="fermee"] { opacity: 0.6; }
.case-avent[aria-current="date"] { outline: 3px solid var(--lanterne); outline-offset: 2px; }
#avent-case { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
#avent-case[hidden] { display: none; }
#avent-titre { margin: 0; }

/* ---------- Étoiles (chantier 28) */
.pastille-etoiles { background: var(--velours-clair); color: var(--lanterne); font-weight: 600;
  border-radius: 999px; padding: 0.35rem 0.85rem; min-height: 2.5rem; white-space: nowrap; }
.solde-etoiles { font-family: var(--ui); font-weight: 600; font-size: 3rem; color: var(--lanterne); margin: 0.2rem 0; text-align: center; text-shadow: 0 0 24px rgba(242, 181, 68, 0.35); }
.bouton-aide { font-family: var(--ui); font-weight: 600; font-size: 1.3rem; }
.textes-legaux p { margin: 0.2rem 0; line-height: 1.5; font-size: 0.95rem; }
#ecran-aide details p { margin: 0.5rem 0 0; line-height: 1.5; }
#bienvenue-pret { display: flex; flex-direction: column; gap: 1rem; }
.sacs-etoiles { display: flex; flex-direction: column; gap: 0.6rem; }
.sacs-etoiles:empty { display: none; }
.code-famille { display: block; background: var(--nuit); border-radius: 0.6rem; padding: 0.7rem; word-break: break-all; font-size: 0.95rem; user-select: all; }

@media print {
  body::before, body::after, .visionneuse { display: none !important; }
}
