/* ===================================================================
   ÉducGratuite — Design system « l'école joyeuse »
   Univers : cahier d'écolier, tableau d'école, craie, gommettes.
   Fonds papier clair, couleurs crayon vives réservées aux accents.
   ------------------------------------------------------------------
   Toutes les classes existantes sont conservées.
   Les styles d'impression (@media print / .sheet) sont INCHANGÉS.
=================================================================== */

:root {
  /* --- Couleurs crayon (identité des matières) --- */
  --violet: #6247D4;   --violet-fonce: #4E37B0;
  --bleu:   #1B6FC9;   --bleu-fonce:   #155AA6;
  --vert:   #3BB273;   --vert-fonce:   #197A43;
  --jaune:  #F5B800;   --jaune-fonce:  #C88F00;
  --orange: #F0791E;   --orange-fonce: #B34B0C;
  --rose:   #E85B93;   --rose-fonce:   #C73F76;
  --teal:   #17AEBB;   --teal-fonce:   #0E8791;
  --rouge:  #E23B2E;   --rouge-fonce:  #C22A20;

  /* --- Neutres & papier --- */
  --marine: #2D3436;          /* conservé (héritage) */
  --ardoise: #33443B;         /* tableau d'école (zones sombres) */
  --encre: #2A2E45;           /* texte principal — 12:1 sur crème */
  --gris: #6E6455;            /* texte secondaire — 5.3:1 sur crème */
  --craie: #F3F5EF;           /* blanc craie (texte sur ardoise) */
  --fond: #FBF4E6;            /* papier crème */
  --fond-2: #F5EAD3;          /* crème plus soutenu (zones) */
  --carte: #FFFFFF;           /* feuille blanche */
  --carte-2: #FFFDF8;         /* feuille ivoire */
  --bordure: #E9DCC4;         /* trait crayon clair */
  --bordure-forte: #D6C4A2;   /* trait crayon marqué (champs) */

  /* --- Sémantiques (feedback bienveillant) --- */
  --succes: var(--vert-fonce);      --succes-bg: #E7F7EC;
  --erreur: var(--orange-fonce);    --erreur-bg: #FDF0E3;  /* orange doux, jamais de rouge */
  --recompense: var(--jaune);       --recompense-fonce: var(--jaune-fonce);

  /* --- Formes & profondeur --- */
  --radius: 20px;
  --radius-lg: 28px;
  --ombre: 0 6px 16px rgba(93, 74, 32, 0.10);
  --ombre-forte: 0 14px 34px rgba(93, 74, 32, 0.18);
  --ombre-bouton: inset 0 -3px 0 rgba(0, 0, 0, 0.16);

  /* --- Typographie (aucune dépendance CDN obligatoire) --- */
  --police: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --police-titre: "Baloo 2", "Fredoka", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --police-craie: "Comic Sans MS", "Marker Felt", "Segoe Print", "Bradley Hand", cursive;

  /* --- Textures (SVG/CSS pur, encodées en data-URI) --- */
  --quadrillage:
    linear-gradient(rgba(98, 71, 212, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 71, 212, 0.05) 1px, transparent 1px);
  --chalk-dust: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--police);
  color: var(--encre);
  line-height: 1.55;
  font-size: 16px;
  background-color: var(--fond);
  /* Papier quadrillé très discret en fond de page */
  background-image: var(--quadrillage);
  background-size: 26px 26px;
}
h1, h2, h3, h4 { font-family: var(--police-titre); line-height: 1.15; color: var(--encre); letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; font-weight: 800; }
h2 { font-size: 1.55rem; font-weight: 800; }
h3 { font-weight: 700; }
a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-fonce); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
button { font-family: inherit; }
img, svg { max-width: 100%; }
::selection { background: var(--jaune); color: var(--encre); }

/* ===== Barre du haut (bandeau papier + trait crayon) ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--bordure);
  box-shadow: 0 2px 0 rgba(93, 74, 32, 0.04);
}
.logo { display: inline-flex; align-items: center; gap: 8px; font-family: var(--police-titre); font-size: 1.3rem; color: var(--encre); font-weight: 800; white-space: nowrap; }
.logo b { color: var(--violet); }
.logo-emoji { font-size: 1.6rem; }
.mainnav {
  display: flex; gap: 4px; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  padding: 10px 14px; border-radius: 999px; min-height: 44px;
  display: inline-flex; align-items: center;
  color: var(--gris); font-weight: 800; white-space: nowrap; font-size: .95rem;
  transition: background-color .15s ease, color .15s ease;
}
.mainnav a:hover { background: var(--fond-2); color: var(--encre); text-decoration: none; }
.mainnav a.active { background: var(--violet); color: #fff; box-shadow: var(--ombre-bouton); }
.profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 999px; min-height: 44px;
  background: var(--carte); border: 2.5px solid var(--bordure-forte);
  font-weight: 800; color: var(--encre); white-space: nowrap;
  transition: border-color .15s ease, transform .15s ease;
}
.profile-chip:hover { border-color: var(--violet); transform: translateY(-1px); text-decoration: none; }
.profile-chip .xp { color: var(--violet); font-size: .85rem; font-weight: 900; }

/* ===== Mise en page ===== */
.page { max-width: 1100px; margin: 0 auto; padding: 26px 18px 60px; min-height: 65vh; }
.section { margin: 36px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
/* Titre de section = étiquette de cahier soulignée au crayon */
.section-head h2 { position: relative; display: inline-block; padding-bottom: 6px; }
.section-head h2::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 5px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--jaune) 0 14px, var(--orange) 14px 28px);
  opacity: .85;
}
.section-head p { color: var(--gris); margin: 4px 0 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ===== Cartes (feuilles avec coin & ombre douce) ===== */
.card {
  background: var(--carte); border-radius: var(--radius);
  box-shadow: var(--ombre); padding: 20px;
  border: 2px solid var(--bordure);
  position: relative;
}
.card.clickable { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; display: block; color: var(--encre); }
.card.clickable:hover { transform: translateY(-5px) rotate(-.4deg); box-shadow: var(--ombre-forte); border-color: var(--bordure-forte); text-decoration: none; }
.card.clickable:active { transform: translateY(-1px); }
.card .emoji-big { font-size: 2.8rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.card h3 { margin: 12px 0 4px; font-size: 1.15rem; }
.card p { color: var(--gris); margin: 0; font-size: .95rem; }
/* Bordure haute couleur matière (couleur posée en inline par le JS) */
.card-top { height: 8px; border-radius: 999px; margin: -20px -20px 16px; }

/* ===== Héros (papier réglé Seyès, texte encre, gommettes) ===== */
.hero {
  background-color: var(--carte-2);
  background-image:
    linear-gradient(rgba(27, 111, 201, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 91, 147, 0.35) 2px, transparent 2px);
  background-size: 100% 30px, 40px 100%;
  background-position: 0 22px, 34px 0;
  border: 3px solid var(--bordure-forte);
  border-radius: var(--radius-lg); color: var(--encre);
  padding: 44px 34px; margin-top: 8px;
  position: relative; overflow: hidden;
  box-shadow: var(--ombre);
}
.hero h1 { color: var(--encre); margin: 0 0 10px; font-size: 2.5rem; }
.hero p { font-size: 1.15rem; max-width: 560px; margin: 0 0 22px; color: var(--gris); }
.hero .hero-emojis { position: absolute; right: 26px; top: 20px; font-size: 3.2rem; opacity: 1; transform: rotate(-6deg); filter: drop-shadow(0 3px 3px rgba(0,0,0,.14)); }
.badge-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.badge-pill {
  background: var(--carte); border: 2px solid var(--bordure-forte); color: var(--encre);
  border-radius: 999px; padding: 6px 15px; font-size: .85rem; font-weight: 800;
  box-shadow: var(--ombre);
}

/* ===== Boutons « boudins » (pilules épaisses, relief craie) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; cursor: pointer;
  padding: 13px 26px; min-height: 48px; font-size: 1rem; font-weight: 800;
  font-family: var(--police-titre); letter-spacing: .01em;
  background: var(--violet); color: #fff;
  box-shadow: var(--ombre-bouton), 0 4px 10px rgba(93, 74, 32, .16);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-2px); box-shadow: var(--ombre-bouton), 0 8px 18px rgba(93, 74, 32, .22); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: var(--ombre-bouton); }
.btn:focus-visible { outline: 3px dashed var(--encre); outline-offset: 3px; }
.btn.secondary { background: var(--carte); color: var(--violet); border: 2.5px solid var(--violet); box-shadow: 0 4px 10px rgba(93, 74, 32, .12); }
.btn.ghost { background: var(--carte); color: var(--violet); border: 2.5px dashed var(--violet); box-shadow: none; }
.btn.vert { background: var(--vert-fonce); }
.btn.orange { background: var(--orange-fonce); }
.btn.small { padding: 9px 18px; min-height: 40px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }

/* ===== Sélecteurs / formulaires ===== */
select, input[type="text"], input[type="number"], textarea {
  font-family: inherit; font-size: 1rem;
  padding: 11px 14px; border-radius: 14px; min-height: 48px;
  border: 2.5px solid var(--bordure-forte); background: var(--carte); color: var(--encre);
  outline: none; max-width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 90px; }
select:focus, input:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(98, 71, 212, .16); }
label.field { display: block; font-family: var(--police-titre); font-weight: 700; font-size: .92rem; margin: 10px 0 4px; color: var(--gris); }

/* ===== Quiz ===== */
.quiz-wrap { max-width: 680px; margin: 0 auto; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.quiz-progress { flex: 1; height: 14px; background: var(--fond-2); border: 1px solid var(--bordure); border-radius: 999px; overflow: hidden; min-width: 120px; }
.quiz-progress > div { height: 100%; background: linear-gradient(90deg, var(--vert), var(--teal)); border-radius: 999px; transition: width .3s ease; }
.quiz-streak { font-family: var(--police-titre); font-weight: 800; color: var(--orange-fonce); }
.quiz-question {
  font-family: var(--police-titre);
  font-size: 1.5rem; font-weight: 800; text-align: center;
  padding: 28px 20px; background: var(--carte); border-radius: var(--radius);
  box-shadow: var(--ombre); margin-bottom: 18px; border: 2px solid var(--bordure);
}
.quiz-question .qcontext { display: block; font-family: var(--police); font-size: .95rem; font-weight: 600; color: var(--gris); margin-bottom: 8px; }
.quiz-choices { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.quiz-choices button {
  padding: 18px 14px; min-height: 60px; font-size: 1.15rem; font-weight: 800;
  font-family: var(--police-titre);
  border-radius: var(--radius); border: 3px solid var(--bordure-forte);
  background: var(--carte); cursor: pointer; color: var(--encre);
  transition: transform .12s ease, border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.quiz-choices button:hover { border-color: var(--violet); transform: translateY(-3px); box-shadow: var(--ombre); }
.quiz-choices button:focus-visible { outline: 3px dashed var(--violet); outline-offset: 2px; }
/* Bonne réponse : vert + étoile de récompense */
.quiz-choices button.correct { background: var(--succes-bg); border-color: var(--vert); color: var(--vert-fonce); }
.quiz-choices button.correct::after { content: " ⭐"; }
/* Erreur : orange doux, bienveillant — jamais rouge agressif */
.quiz-choices button.wrong { background: var(--erreur-bg); border-color: var(--orange); color: var(--orange-fonce); }
.quiz-choices button:disabled { cursor: default; }
.quiz-feedback { text-align: center; margin-top: 16px; font-family: var(--police-titre); font-weight: 800; min-height: 54px; }
.quiz-feedback .explain { display: block; font-family: var(--police); font-weight: 600; color: var(--gris); font-size: .95rem; }
.quiz-input-row { display: flex; gap: 10px; justify-content: center; }
.quiz-input-row input { font-size: 1.4rem; width: 140px; text-align: center; font-weight: 900; }
.quiz-end { text-align: center; padding: 30px 20px; }
.quiz-end .score-big { font-family: var(--police-titre); font-size: 3.4rem; font-weight: 800; color: var(--violet); }
.stars { font-size: 2rem; letter-spacing: 4px; }

/* ===== Barres de progression matières ===== */
.mastery { margin: 12px 0; }
.mastery .m-label { display: flex; justify-content: space-between; font-family: var(--police-titre); font-weight: 700; font-size: .92rem; margin-bottom: 5px; }
.mastery .m-bar { height: 14px; border-radius: 999px; background: var(--fond-2); border: 1px solid var(--bordure); overflow: hidden; }
.mastery .m-bar > div { height: 100%; border-radius: 999px; transition: width .4s ease; }

/* ===== Chat assistant « Léo » ===== */
.chat-box { display: flex; flex-direction: column; height: 62vh; min-height: 420px; background: var(--carte); border-radius: var(--radius-lg); box-shadow: var(--ombre); border: 2px solid var(--bordure); overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background-color: var(--carte-2); background-image: var(--quadrillage); background-size: 24px 24px; }
.chat-msg { max-width: 82%; padding: 13px 17px; border-radius: 20px; font-size: .98rem; box-shadow: var(--ombre); }
.chat-msg.bot { background: var(--carte); border: 2px solid var(--bordure); border-bottom-left-radius: 6px; align-self: flex-start; }
.chat-msg.user { background: var(--violet); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.chat-msg h4 { margin: 0 0 6px; }
.chat-msg ul, .chat-msg ol { margin: 6px 0; padding-left: 20px; }
.chat-msg .reveal { margin-top: 8px; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 2px solid var(--bordure); background: var(--carte); }
.chat-input input { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip {
  border: 2.5px solid var(--bordure-forte); background: var(--carte); border-radius: 999px;
  padding: 8px 15px; min-height: 40px; font-size: .85rem; font-weight: 800; cursor: pointer; color: var(--encre);
  transition: border-color .12s ease, color .12s ease, transform .12s ease;
}
.chip:hover { border-color: var(--violet); color: var(--violet); transform: translateY(-2px); }

/* ===== Tableaux (registre sobre pour Parents/Classement) ===== */
table.tbl { width: 100%; border-collapse: collapse; background: var(--carte); border-radius: var(--radius); overflow: hidden; box-shadow: var(--ombre); border: 2px solid var(--bordure); }
table.tbl th, table.tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--bordure); }
table.tbl th { background: var(--fond-2); font-family: var(--police-titre); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gris); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--carte-2); }

/* ===== Modales ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(42, 46, 69, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--carte); border-radius: var(--radius-lg); padding: 28px;
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--ombre-forte); border: 2px solid var(--bordure);
}
.modal h2 { margin-top: 0; }
.modal-close { float: right; border: 2px solid var(--bordure-forte); background: var(--fond); border-radius: 50%; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; color: var(--encre); transition: background-color .12s ease, transform .12s ease; }
.modal-close:hover { background: var(--fond-2); transform: rotate(90deg); }
.avatar-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-picker button { font-size: 1.8rem; padding: 10px; min-width: 56px; min-height: 56px; border-radius: 16px; border: 3px solid var(--bordure-forte); background: var(--carte); cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.avatar-picker button:hover { transform: translateY(-3px) rotate(-3deg); }
.avatar-picker button.sel { border-color: var(--violet); background: #F1EEFF; }

/* ===== Badges & récompenses (gommettes, léger décalage fait-main) ===== */
.badges-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.badge-item { text-align: center; width: 96px; padding: 12px 6px; border-radius: 16px; background: var(--carte); border: 2px solid var(--bordure); box-shadow: var(--ombre); transition: transform .15s ease; }
.badge-item:nth-child(odd) { transform: rotate(-1.2deg); }
.badge-item:nth-child(even) { transform: rotate(1.2deg); }
.badge-item:hover { transform: rotate(0deg) translateY(-3px); }
.badge-item .b-emoji { font-size: 2rem; filter: drop-shadow(0 2px 2px rgba(0,0,0,.14)); }
.badge-item .b-name { font-family: var(--police-titre); font-size: .74rem; font-weight: 700; color: var(--gris); margin-top: 4px; }
.badge-item.locked { opacity: .4; filter: grayscale(1); }

/* ===== Aventure (tableau d'école — la seule zone sombre) ===== */
.adventure-scene {
  background-color: var(--ardoise);
  background-image: var(--chalk-dust), radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.06), transparent 60%);
  color: var(--craie); border-radius: var(--radius-lg); padding: 36px 30px;
  box-shadow: var(--ombre-forte); border: 8px solid #6b4a2f; /* cadre bois du tableau */
}
.adventure-scene h2, .adventure-scene h3 { color: var(--craie); font-family: var(--police-craie); font-weight: 400; }
.adventure-scene .narrative { font-size: 1.12rem; color: #E8ECE4; }
.adventure-scene .quiz-question { background: rgba(255, 255, 255, .06); color: var(--craie); border-color: rgba(255,255,255,.18); box-shadow: none; }
.adventure-scene .quiz-choices button { background: rgba(255, 255, 255, .08); color: var(--craie); border-color: rgba(255, 255, 255, .3); }
.adventure-scene .quiz-choices button:hover { border-color: #fff; background: rgba(255,255,255,.14); }
.adventure-scene .quiz-choices button.correct { background: rgba(59, 178, 115, .32); border-color: var(--vert); color: #fff; }
.adventure-scene .quiz-choices button.wrong { background: rgba(240, 121, 30, .3); border-color: var(--orange); color: #fff; }
.adventure-progress { display: flex; gap: 6px; margin: 16px 0; }
.adventure-progress span { flex: 1; height: 12px; border-radius: 99px; background: rgba(255, 255, 255, .2); }
.adventure-progress span.done { background: var(--jaune); }
.inventory { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inventory .item { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255,255,255,.2); padding: 6px 14px; border-radius: 999px; font-size: .9rem; }

/* ===== Blog / articles (scotch en haut de la feuille) ===== */
.article { background: var(--carte); border-radius: var(--radius); box-shadow: var(--ombre); padding: 36px; max-width: 780px; margin: 0 auto; border: 2px solid var(--bordure); position: relative; }
.article::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 120px; height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(245, 184, 0, .35); border: 1px solid rgba(200, 143, 0, .35);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.article h1 { margin-top: 0; }
.article .meta { color: var(--gris); font-size: .9rem; margin-bottom: 18px; }
.tag { display: inline-block; background: var(--fond-2); color: var(--violet-fonce); border-radius: 999px; padding: 4px 12px; font-size: .78rem; font-weight: 800; margin-right: 6px; }

/* ===== Bons plans ===== */
.deal-card .deal-note { font-size: .8rem; color: var(--gris); font-style: italic; margin-top: 8px; }
.disclosure {
  background: var(--erreur-bg); border: 2px solid #F0C98C; border-radius: var(--radius);
  padding: 14px 18px; font-size: .92rem; margin-bottom: 22px; color: var(--encre);
}

/* ===== Pied de page (tableau d'école) ===== */
.footer { background-color: var(--ardoise); background-image: var(--chalk-dust); color: #D7DED2; padding: 42px 18px 26px; margin-top: 44px; border-top: 8px solid #6b4a2f; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.footer .logo { color: #fff; }
.footer .logo b { color: var(--jaune); }
.footer h4 { color: #fff; font-family: var(--police-craie); font-weight: 400; font-size: 1.15rem; margin: 0 0 10px; }
.footer a { display: block; color: #D7DED2; padding: 4px 0; }
.footer a:hover { color: #fff; }
.footer-note { max-width: 1100px; margin: 26px auto 0; font-size: .8rem; opacity: .75; border-top: 1px solid rgba(255, 255, 255, .18); padding-top: 16px; }

/* ===== Divers ===== */
.pill-level { display: inline-block; background: var(--fond-2); border: 1.5px solid var(--bordure-forte); border-radius: 999px; padding: 3px 12px; font-size: .78rem; font-weight: 800; color: var(--gris); }
.empty-note { text-align: center; color: var(--gris); padding: 40px 0; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.reveal-box { background: var(--fond-2); border: 1px solid var(--bordure); border-radius: 14px; padding: 12px 16px; margin-top: 8px; }
details.correction summary { cursor: pointer; font-family: var(--police-titre); font-weight: 700; color: var(--violet); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--encre); color: #fff; padding: 13px 24px; border-radius: 999px;
  font-family: var(--police-titre); font-weight: 800; z-index: 200; box-shadow: var(--ombre-forte);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.confetti { position: fixed; font-size: 1.6rem; z-index: 300; pointer-events: none; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(360deg); opacity: 0; } }

/* ===== Onglets (intercalaires de cahier) ===== */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs button {
  border: 2.5px solid var(--bordure-forte); background: var(--carte);
  padding: 10px 20px; min-height: 44px; border-radius: 999px; font-family: var(--police-titre); font-weight: 700; cursor: pointer; color: var(--gris); font-size: .95rem;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.tabs button:hover { border-color: var(--violet); color: var(--violet); }
.tabs button.active { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: var(--ombre-bouton); }

/* ===== Mini-jeux ===== */
.game-timer { flex: 1; height: 14px; background: var(--fond-2); border: 1px solid var(--bordure); border-radius: 999px; overflow: hidden; min-width: 100px; }
.game-timer > div { height: 100%; background: linear-gradient(90deg, var(--jaune), var(--orange)); border-radius: 999px; transition: width 1s linear; }
.mem-grid { display: grid; gap: 10px; }
.mem-card {
  aspect-ratio: 1; min-height: 64px; border: 3px solid var(--bordure-forte); border-radius: 16px;
  background: var(--carte); cursor: pointer; font-family: var(--police-titre);
  font-size: 1.15rem; font-weight: 700; color: var(--encre); padding: 4px;
  transition: transform .12s ease, border-color .12s ease, background-color .12s ease;
}
.mem-card:hover { transform: translateY(-2px); border-color: var(--violet); }
.mem-card.flipped { border-color: var(--violet); background: #F1EEFF; }
.mem-card.matched { border-color: var(--vert); background: var(--succes-bg); cursor: default; transform: none; }
.letter-kbd { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.letter-kbd button {
  min-width: 42px; min-height: 46px; border: 2.5px solid var(--bordure-forte); border-radius: 12px;
  background: var(--carte); font-family: var(--police-titre); font-weight: 700; font-size: 1.05rem;
  color: var(--encre); cursor: pointer;
}
.letter-kbd button:hover:not(:disabled) { border-color: var(--violet); color: var(--violet); }
.letter-kbd button:disabled { opacity: .3; cursor: default; }
.word-slots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; font-family: var(--police-titre); font-size: 1.9rem; }
.word-slots span { border-bottom: 4px solid var(--encre); min-width: 34px; text-align: center; line-height: 1.3; }
.petals { font-size: 1.15rem; letter-spacing: 2px; }
.tile-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.tile {
  padding: 16px 20px; min-height: 56px; font-size: 1.15rem; font-weight: 800;
  font-family: var(--police-titre); border-radius: var(--radius); border: 3px solid var(--bordure-forte);
  background: var(--carte); cursor: pointer; color: var(--encre);
  transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { border-color: var(--violet); transform: translateY(-2px); }
.tile.placed { background: var(--succes-bg); border-color: var(--vert); color: var(--vert-fonce); cursor: default; transform: none; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
.shake { animation: shake .3s ease; }

/* ===== PWA : bouton d'installation & guide iOS ===== */
.pwa-install {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  border: none; border-radius: 999px; cursor: pointer;
  padding: 13px 22px; min-height: 48px; font-size: .95rem; font-weight: 800;
  font-family: var(--police-titre);
  background: var(--vert-fonce); color: #fff;
  box-shadow: var(--ombre-bouton), var(--ombre-forte);
  animation: toast-in .3s ease;
}
.pwa-install:hover { filter: brightness(1.08); transform: translateY(-2px); }
.ios-hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 90; max-width: min(480px, calc(100vw - 24px));
  background: var(--carte); color: var(--encre);
  border: 2.5px solid var(--bordure-forte); border-radius: var(--radius);
  box-shadow: var(--ombre-forte); padding: 13px 44px 13px 17px;
  font-size: .92rem; animation: toast-in .3s ease;
}
.ios-hint button {
  position: absolute; right: 8px; top: 8px;
  border: none; background: var(--fond-2); color: var(--encre);
  border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-weight: 800;
}

/* ===== Accessibilité : mouvement réduit ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .card.clickable:hover, .badge-item, .badge-item:hover, .avatar-picker button:hover, .hero .hero-emojis { transform: none !important; }
}

/* ===== Impression ===== */
#print-area { display: none; }
.sheet {
  background: #fff; width: 210mm; min-height: 285mm; padding: 14mm;
  margin: 0 auto 16px; box-shadow: var(--ombre);
  page-break-after: always; break-after: page;
  color: #222; font-size: 12pt;
}
.sheet h1 { font-size: 20pt; margin: 0 0 4mm; }
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #333; padding-bottom: 3mm; margin-bottom: 6mm; }
.sheet .sheet-head .brand { font-size: 9pt; color: #888; }
.sheet .ops-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm 6mm; font-size: 15pt; }
.sheet .ops-grid.big { font-size: 19pt; grid-template-columns: repeat(2, 1fr); }
.sheet .op-line { border-bottom: 1.5px dotted #999; padding-bottom: 2mm; }
.sheet table { border-collapse: collapse; }
.sheet .sudoku td {
  width: 11mm; height: 11mm; border: 1px solid #999; text-align: center;
  font-size: 15pt; font-weight: 700;
}
.sheet .sudoku.s4 td { width: 16mm; height: 16mm; font-size: 20pt; }
.sheet .sudoku td.bt { border-top: 2.5px solid #000; }
.sheet .sudoku td.bl { border-left: 2.5px solid #000; }
.sheet .sudoku tr td:last-child { border-right: 2.5px solid #000; }
.sheet .sudoku tr:last-child td { border-bottom: 2.5px solid #000; }
.sheet .ws-grid td { width: 9mm; height: 9mm; border: 1px solid #ccc; text-align: center; font-size: 13pt; font-weight: 700; text-transform: uppercase; }
.sheet .word-list { columns: 3; font-weight: 700; margin-top: 6mm; }
.sheet .memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.sheet .memory-grid div { border: 2px dashed #888; text-align: center; font-size: 34pt; padding: 8mm 0; }
.sheet .writing-line { border-bottom: 1px solid #90b8e0; height: 13mm; position: relative; margin-bottom: 6mm; overflow: hidden; }
.sheet .writing-line::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed #c8dcf0; }
.sheet .writing-line .model { position: absolute; bottom: 0; left: 2mm; font-size: 30pt; color: #b9c7d8; font-family: "Comic Sans MS", "Marker Felt", cursive; line-height: 13mm; letter-spacing: 14mm; white-space: nowrap; }
.sheet .alpha-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm; text-align: center; }
.sheet .alpha-grid .a-cell { border: 1.5px solid #ddd; border-radius: 4mm; padding: 3mm 1mm; }
.sheet .alpha-grid .a-cell .a-letter { font-size: 19pt; font-weight: 900; }
.sheet .alpha-grid .a-cell .a-word { font-size: 9pt; color: #555; }
.sheet .tables-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4mm; font-size: 9.5pt; }
.sheet .tables-grid .t-block { border: 1.5px solid #ccc; border-radius: 3mm; padding: 2.5mm; }
.sheet .tables-grid .t-block h3 { margin: 0 0 1.5mm; font-size: 11pt; text-align: center; }
.sheet .magic-grid td { width: 17mm; height: 12mm; border: 1px solid #aaa; text-align: center; font-size: 9pt; }
.sheet .legend { display: flex; gap: 6mm; margin: 4mm 0; font-size: 10pt; flex-wrap: wrap; }
.sheet .legend span { display: inline-flex; align-items: center; gap: 2mm; }
.sheet .legend i { width: 6mm; height: 6mm; border: 1px solid #888; display: inline-block; }
.sheet .dictee-lines div { border-bottom: 1.5px solid #bbb; height: 11mm; }
.sheet .flash-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.sheet .flash-grid div { border: 2px dashed #888; text-align: center; padding: 9mm 2mm; font-size: 16pt; font-weight: 800; }
.sheet .fiche-body h2 { font-size: 14pt; margin: 5mm 0 2mm; border-left: 4mm solid var(--violet); padding-left: 3mm; }
.sheet .fiche-body p, .sheet .fiche-body li { font-size: 11pt; }
.sheet .diff-pair { display: flex; gap: 6mm; justify-content: center; }
.sheet .diff-grid { border-collapse: collapse; }
.sheet .diff-grid td { width: 12mm; height: 12mm; border: 1px solid #ddd; text-align: center; font-size: 17pt; }
.sheet .footer-line { margin-top: 8mm; font-size: 8pt; color: #999; text-align: center; }

@media print {
  body > #app, .toast, .modal-backdrop { display: none !important; }
  body { background: #fff; }
  #print-area { display: block; }
  .sheet { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 0; }
  @page { margin: 12mm; }
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .mainnav { order: 3; width: 100%; }
  .hero { padding: 30px 22px; }
  .hero h1 { font-size: 1.9rem; }
  .hero .hero-emojis { display: none; }
  .quiz-choices { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .sheet { width: 100%; min-height: auto; padding: 8mm; }
}
