/* ---------------------------------------------------------------------------
   Page « Planches de pictogrammes » — magicien en 4 étapes (écran).

   Contrats DOM (coquille du générateur, manipulée par planches-mots.js) :
   - affichage progressif : .mots-ui reste masqué sans JavaScript ; le JS
     ajoute la classe `js` sur <html> ou <body> (sélecteur `.js .mots-ui`) ;
   - stepper : étape active = [aria-current="step"], étape franchie = .est-fait,
     étapes à venir = état par défaut ;
   - étapes : .mots-etape[data-step], masquées par l'attribut [hidden] ;
   - planche : .mots-planche lit --cols/--rows ; cellules .mots-case
     (remplie = img + .mots-case-label ; manquante = .mots-case-manquante avec
     bouton loupe ; case de complément = .vide) ;
   - puces : .chip (mot trouvé) ou .chip-manquante, badge .chip-badge, bouton
     de retrait .chip-retirer ;
   - aperçu : .apercu-feuille (ratio 210/297) contient soit directement les
     .mots-case, soit un clone .mots-planche.
   --------------------------------------------------------------------------- */

/* Blocs d'impression : masqués à l'écran, révélés par le bloc @media print. */
.print-head,
.print-credit,
.feuille-credit {
  display: none;
}

.noscript-hint {
  width: fit-content;
  max-width: min(100% - 2.5rem, 72rem);
  margin: 0.75rem auto 0;
  padding: 0.5rem 1rem;
  border: 1.5px solid rgba(11, 48, 100, 0.1);
  border-radius: 9999px;
  background: var(--color-cream);
  color: var(--color-brown-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.mots-ui {
  display: none;
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding: 1rem 1.25rem 2rem;
}

.js .mots-ui {
  display: block;
}

/* --- Stepper -------------------------------------------------------------- */

.mots-stepper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.mots-stepper-etape {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.85rem 0.38rem 0.4rem;
  border: 1.5px solid rgba(11, 48, 100, 0.12);
  border-radius: 9999px;
  background: #fff;
  color: rgba(61, 90, 128, 0.85);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    color 0.16s ease;
}

.mots-stepper-num {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 9999px;
  background: rgba(11, 48, 100, 0.08);
  color: rgba(61, 90, 128, 0.9);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.mots-stepper-etape.est-fait {
  border-color: rgba(47, 185, 140, 0.45);
  background: #eaf8f2;
  background: color-mix(in srgb, var(--color-mint) 12%, #fff);
  color: var(--color-brown);
}

.mots-stepper-etape.est-fait .mots-stepper-num {
  background: var(--color-mint);
  color: var(--color-brown);
}

.mots-stepper-etape[aria-current="step"] {
  border-color: var(--color-sky-deep);
  background: var(--color-sky-deep);
  color: #fff;
  box-shadow: 0 3px 0 0 rgba(11, 48, 100, 0.25);
}

.mots-stepper-etape[aria-current="step"] .mots-stepper-num {
  background: #fff;
  color: var(--color-sky-deep);
}

/* --- Panneaux d'étape ------------------------------------------------------ */

.mots-etape {
  padding: clamp(1rem, 2.5vw, 1.75rem);
  border: 2px solid rgba(11, 48, 100, 0.08);
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 10px 28px rgba(11, 48, 100, 0.06);
}

.mots-etape[hidden] {
  display: none;
}

.mots-etape-titre {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-brown);
}

.mots-etape-intro {
  max-width: 46rem;
  margin: 0 0 1.25rem;
  color: var(--color-brown-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* --- Étape 1 : format ------------------------------------------------------ */

.mots-format {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.85rem;
  padding: 0.85rem 1.1rem 1rem;
  border: 1.5px solid rgba(11, 48, 100, 0.1);
  border-radius: 1rem;
  background: #f3faff;
  background: color-mix(in srgb, var(--color-sand) 45%, #fff);
}

.mots-format legend {
  padding: 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-brown-soft);
}

.mots-format label {
  color: var(--color-brown);
  font-size: 0.88rem;
  font-weight: 800;
}

.mots-format input[type="number"] {
  width: 4.25rem;
  padding: 0.45rem 0.5rem;
  border: 1.5px solid rgba(11, 48, 100, 0.18);
  border-radius: 0.8rem;
  background: #fff;
  color: var(--color-brown);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.mots-format > span {
  color: var(--color-brown-soft);
  font-size: 1rem;
  font-weight: 800;
}

.mots-capacite {
  margin: 0 0 1rem;
  color: var(--color-brown-soft);
  font-size: 0.85rem;
  font-weight: 700;
}

.apercu-format {
  --apercu-format-h: 11rem;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr));
  gap: 0.3rem;
  width: min(100%, calc(var(--apercu-format-h) * var(--cols, 3) / var(--rows, 3)));
  aspect-ratio: calc(var(--cols, 3) / var(--rows, 3));
  margin: 0 0 1.25rem;
  padding: 0.4rem;
  border: 1.5px solid rgba(11, 48, 100, 0.12);
  border-radius: 0.9rem;
  background: #fff;
}

.apercu-format > * {
  border: 1px solid rgba(11, 48, 100, 0.1);
  border-radius: 0.35rem;
  background: #eaf5fd;
  background: color-mix(in srgb, var(--color-sand) 55%, #fff);
}

/* --- Étape 2 : mots -------------------------------------------------------- */

.mots-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.65rem;
}

#mots-input {
  flex: 1 1 18rem;
  min-width: 0;
  padding: 0.55rem 1.1rem;
  border: 1.5px solid rgba(11, 48, 100, 0.14);
  border-radius: 9999px;
  background: #fff;
  color: var(--color-brown);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

#mots-input::placeholder {
  color: var(--color-brown-soft);
  opacity: 0.75;
}

.mots-compteur {
  margin: 0 0 0.85rem;
  color: var(--color-brown-soft);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

.mots-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.2rem 0.3rem 0.2rem 0.5rem;
  border: 1.5px solid rgba(47, 185, 140, 0.45);
  border-radius: 9999px;
  background: #f5fdfa;
  background: color-mix(in srgb, var(--color-mint) 7%, #fff);
  color: var(--color-brown);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.chip img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 9999px;
  background: #fff;
  object-fit: contain;
}

.chip > span:not(.chip-badge) {
  min-width: 0;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-retirer {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: rgba(11, 48, 100, 0.07);
  color: var(--color-brown-soft);
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.chip-retirer:hover {
  background: var(--color-sand);
  color: var(--color-brown);
}

.chip-manquante {
  border-color: rgba(244, 118, 31, 0.45);
  background: #fff3cc;
  background: color-mix(in srgb, var(--color-sun) 14%, #fff);
}

.chip-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 9999px;
  background: var(--color-sun);
  color: var(--color-brown);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
}

/* --- Étape 3 : planche ----------------------------------------------------- */

.mots-planche {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: clamp(0.35rem, 1.2vw, 0.6rem);
  width: min(
    100%,
    calc(var(--cols, 3) * 11rem + (var(--cols, 3) - 1) * 0.6rem)
  );
  margin: 0 auto 1.25rem;
}

.mots-case {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
  min-height: 10rem;
  padding: 0.6rem;
  border: 1.5px solid rgba(11, 48, 100, 0.12);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 1px 0 rgba(11, 48, 100, 0.04);
  overflow: hidden;
  text-align: center;
}

.mots-case img {
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: 7.5rem;
  object-fit: contain;
}

.mots-case-label {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  flex: 0 0 auto;
  width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--color-brown);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.mots-case-manquante {
  border: 2px dashed rgba(244, 118, 31, 0.65);
  background: #fff3cc;
  background: color-mix(in srgb, var(--color-sun) 14%, #fff);
}

.mots-case .btn {
  flex: 0 0 auto;
  padding: 0.28rem 0.6rem;
  font-size: 0.68rem;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.mots-case.vide {
  border-style: dashed;
  border-color: rgba(11, 48, 100, 0.14);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: none;
}

/* --- Étape 4 : aperçu des feuilles A4 -------------------------------------- */

.mots-apercu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 1.25rem;
}

.apercu-feuille {
  display: flex;
  flex-direction: column;
  width: min(100%, 24rem);
  min-height: 0;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  padding: clamp(0.4rem, 1.4vw, 0.7rem);
  border: 1.5px solid rgba(11, 48, 100, 0.12);
  border-radius: 0.6rem;
  background: #fff;
  box-shadow: 0 10px 24px rgba(11, 48, 100, 0.1);
}

.apercu-feuille .mots-planche {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr));
}

.apercu-feuille .mots-case {
  gap: 0.15rem;
  min-height: 0;
  padding: 0.25rem;
  border-radius: 0.35rem;
  box-shadow: none;
}

.apercu-feuille .mots-case img {
  max-height: 100%;
}

.apercu-feuille .mots-case-label {
  font-size: 0.5rem;
}

/* Le bouton loupe ne vit qu'à l'étape 3, jamais sur une feuille d'aperçu. */
.apercu-feuille .mots-case .btn {
  display: none;
}

/* Contrat Task 12/13 : titres de planche rendus à l'écran et à l'impression. */
.mots-planche-titre {
  flex: 0 0 auto;
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-brown-soft);
}

/* --- Barre d'actions -------------------------------------------------------- */

.mots-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1.25rem 0 0;
}

/* --- Focus visible ---------------------------------------------------------- */

.mots-stepper-etape:focus-visible,
.mots-format input:focus-visible,
#mots-input:focus-visible,
.mots-actions .btn:focus-visible,
.chip button:focus-visible,
.mots-case .btn:focus-visible,
.mots-picker-search:focus-visible,
.mots-picker-close:focus-visible,
.mots-picker-grid button:focus-visible {
  outline: 3px solid var(--color-brown);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Modale loupe (<dialog> natif) : le panneau picker existant, sans overlay
   .mots-picker ; l'état fermé (display:none) est fourni par le navigateur.
   --------------------------------------------------------------------------- */

#loupe-dialog {
  width: min(100% - 2rem, 42rem);
  max-height: min(90vh, 44rem);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-brown);
  overflow: visible;
}

#loupe-dialog::backdrop {
  background: rgba(11, 48, 100, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.mots-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  max-height: min(90vh, 44rem);
  padding: 1rem 1rem 0.9rem;
  border: 1.5px solid rgba(11, 48, 100, 0.12);
  border-radius: 1.25rem;
  background: var(--color-cream);
  box-shadow: 0 18px 50px rgba(11, 48, 100, 0.28);
}

.mots-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mots-picker-titre {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-brown);
}

.mots-picker-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1.5px solid rgba(11, 48, 100, 0.14);
  border-radius: 9999px;
  background: #fff;
  color: var(--color-brown-soft);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.mots-picker-close:hover {
  background: var(--color-sand);
  color: var(--color-brown);
}

.mots-picker-filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mots-picker-search {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.45rem 0.9rem;
  border: 1.5px solid rgba(11, 48, 100, 0.14);
  border-radius: 9999px;
  background: #fff;
  color: var(--color-brown);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.mots-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.5rem;
  min-height: 0;
  margin: 0;
  padding: 0.15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mots-picker-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.4rem 0.3rem;
  border: 1.5px solid rgba(11, 48, 100, 0.1);
  border-radius: 0.8rem;
  background: #fff;
  color: var(--color-brown);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.mots-picker-grid button:hover {
  border-color: rgba(11, 48, 100, 0.28);
  background: var(--color-sand);
}

.mots-picker-grid img {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
}

.mots-picker-grid span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* --- Petits écrans ----------------------------------------------------------- */

@media (max-width: 640px) {
  .mots-ui {
    padding: 0.75rem 1rem 1.5rem;
  }

  .mots-stepper {
    gap: 0.3rem;
  }

  .mots-stepper-etape {
    gap: 0.35rem;
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    font-size: 0.72rem;
  }

  .mots-stepper-num {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.66rem;
  }

  .mots-etape {
    padding: 1rem;
    border-radius: 1.1rem;
  }

  .mots-format {
    gap: 0.4rem 0.5rem;
    padding: 0.7rem 0.8rem 0.8rem;
  }

  .mots-format input[type="number"] {
    width: 3.6rem;
  }

  .mots-form {
    gap: 0.4rem;
  }

  #mots-input {
    flex: 1 1 100%;
    width: 100%;
  }

  .mots-chips {
    gap: 0.3rem;
  }

  .chip {
    font-size: 0.75rem;
  }

  .mots-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .mots-case {
    gap: 0.25rem;
    min-height: 5.5rem;
    padding: 0.35rem;
    border-radius: 0.7rem;
  }

  .mots-case img {
    max-height: 4.5rem;
  }

  .mots-case-label {
    font-size: 0.65rem;
  }

  .mots-case .btn {
    padding: 0.22rem 0.4rem;
    font-size: 0.6rem;
  }

  .apercu-feuille {
    width: min(100%, 18rem);
  }

  #loupe-dialog {
    width: calc(100% - 1rem);
    max-height: 92vh;
  }

  .mots-picker-panel {
    max-height: 92vh;
    padding: 0.8rem 0.8rem 0.7rem;
    border-radius: 1rem;
  }

  .mots-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.4rem;
  }
}

/* Très petits écrans : en 4 colonnes (~72 px de case), les vignettes et la
   cellule manquante doivent tenir sans rogner le bouton loupe. */
@media (max-width: 400px) {
  .mots-case {
    gap: 0.15rem;
    min-height: 4rem;
    padding: 0.25rem;
  }

  .mots-case img {
    max-height: 3.25rem;
  }

  .mots-case-manquante {
    padding: 0.3rem;
  }

  .mots-case .btn {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0.22rem 0.15rem;
    font-size: 0.62rem;
    line-height: 1.1;
    overflow-wrap: break-word;
    hyphens: auto;
  }
}

/* ---------------------------------------------------------------------------
   Impression : socle A4 (en-tête page 1, crédit répété dans chaque feuille) et
   grille paginée du magicien : une planche par page, cellules non tronquées.
   --------------------------------------------------------------------------- */

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  header,
  footer,
  .hero,
  .noscript-hint,
  .seo,
  .mots-stepper,
  .mots-etape-titre,
  .mots-etape-intro,
  .mots-format,
  .mots-capacite,
  .apercu-format,
  .mots-form,
  .mots-compteur,
  .mots-chips,
  .mots-actions,
  .mots-apercu-vide,
  #loupe-dialog {
    display: none !important;
  }

  body {
    background: #fff;
  }

  /* Les planches occupent toute la largeur imprimable (~185 mm). Le demi
     millimètre latéral évite que le trait des bordures (content-box) morde la
     marge de 12 mm ; aucun padding vertical, sinon les 2rem du bas resteraient
     dans le flux après la dernière feuille (planche unique → 2e page). */
  .mots-ui {
    padding: 0 0.75mm;
  }

  .mots-etape {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .print-head {
    display: flex !important;
    align-items: baseline;
    justify-content: space-between;
    gap: 4mm;
    margin-bottom: 3mm;
    font-size: 10pt;
    line-height: 1.2;
  }

  /* `min-h-screen` de l'écran forcerait une hauteur de page en impression. */
  #contenu {
    min-height: 0;
  }

  /* Repli (sans JavaScript ou aperçu vide) : crédit dans le flux, donc
     imprimé même si la page est défilée (contrairement à l'ancien fixed). */
  .print-credit {
    display: block !important;
    margin: 0 0 3mm;
    text-align: center;
    font-size: 7pt;
    color: #555;
  }

  /* Dès que l'aperçu porte un crédit par feuille (classe posée par le JS),
     l'exemplaire de repli est masqué pour éviter un doublon page 1. */
  html.apercu-pret .print-credit {
    display: none !important;
  }

  .feuille-credit {
    display: block !important;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    text-align: center;
    font-size: 7pt;
    line-height: 1.2;
    color: #555;
  }

  .mots-planche {
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr));
    gap: 4mm;
    width: 100%;
    aspect-ratio: 210 / 297;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .mots-planche:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  /* Feuilles A4 de l'étape 4 : une feuille = une page, sans habillage. */
  .mots-apercu {
    display: block;
    margin: 0;
  }

  .apercu-feuille {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 210 / 297;
    margin: 0;
    /* Réserves du titre (absolu, en tête) et du crédit (absolu, en pied). */
    padding: 10mm 0 5mm;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .apercu-feuille:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  /* Clone de planche imbriqué dans une feuille : remplit la hauteur restante
     (titre en tête, crédit en pied) et ne provoque pas de saut de page interne. */
  .apercu-feuille .mots-planche {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    break-after: auto;
    page-break-after: auto;
  }

  .mots-planche-titre {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    display: block;
    margin: 0;
    padding-bottom: 1.5mm;
    border-bottom: 0.5pt solid #ddd;
    color: #333;
    font-size: 9pt;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    break-after: avoid;
    page-break-after: avoid;
  }

  .mots-case,
  .mots-case-label {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .mots-case {
    gap: 2mm;
    min-height: 0;
    padding: 2mm;
    border: 1px solid #ddd;
    border-radius: 1.5mm;
    background: #fff;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .mots-case img {
    width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .mots-case-label {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    width: 100%;
    padding: 0.5mm 1mm;
    border-radius: 1mm;
    font-size: 8pt;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  /* Case manquante : mot seul + liseré pointillé discret, sans bouton loupe. */
  .mots-case-manquante {
    border: 1.5px dashed rgba(244, 118, 31, 0.65);
    background: #fff3cc;
    background: color-mix(in srgb, var(--color-sun) 14%, #fff);
  }

  .mots-case .btn {
    display: none !important;
  }

  .mots-case.vide {
    border: 1px dashed rgba(11, 48, 100, 0.14);
    background: transparent;
    box-shadow: none;
  }
}

.mots-case{position:relative}
.mots-case-effacer{position:absolute;top:.35rem;right:.35rem;width:1.7rem;height:1.7rem;border-radius:50%;border:0;background:#fff;box-shadow:0 2px 6px rgba(11,48,100,.22);color:#c0201d;font-size:1.05rem;line-height:1;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.mots-case-effacer:hover{background:#ffe8e6}

.mots-carre{display:inline-flex;align-items:center;gap:.5rem;margin-top:.75rem;font-family:Fredoka,-apple-system,'Segoe UI',sans-serif;font-weight:600;color:#0B3064;font-size:.95rem;cursor:pointer}
.mots-carre input{width:1.15rem;height:1.15rem;accent-color:#2d9cdb}

.mots-case[data-grammar="nom"]{border-color:#5dade2}
.mots-case[data-grammar="verbe"]{border-color:#ef5350}
.mots-case[data-grammar="prep"]{border-color:#ff9f43}
.mots-case[data-grammar="det"]{border-color:#f4d35e}
