/* ============================================================
   Cahiers de calcul — feuille de style partagée du site
   Sobre : noir / blanc / gris + un accent (indigo)
   ============================================================ */

:root {
  --encre: #1a1a1a;
  --papier: #ffffff;
  --gris-900: #1a1a1a;
  --gris-700: #444341;
  --gris-600: #5F5E5A;
  --gris-400: #9a9995;
  --gris-200: #e2e2e2;
  --gris-100: #F1EFE8;
  --gris-50:  #FAFAF7;

  --accent: #4B46C7;
  --accent-clair: #D9D9FF;
  --accent-hover: #3a36a0;

  --rouge: #E24B4A;
  --rouge-clair: #FCEBEB;

  --vert: #1D9E75;
  --vert-clair: #E1F5EE;

  --rayon: 14px;
  --rayon-sm: 8px;
  --ombre: 0 1px 2px rgba(26,26,26,0.04), 0 8px 24px rgba(26,26,26,0.05);
  --ombre-hover: 0 2px 4px rgba(26,26,26,0.06), 0 16px 32px rgba(26,26,26,0.08);
}

* { box-sizing: border-box; }
/* scrollbar-gutter:stable reserve la place de la barre de defilement en
   permanence (page courte ou longue) : evite le decalage horizontal du
   contenu quand une page passe de "pas de scroll" a "scroll" -- remarque
   sur tableau-de-bord/devoirs.html (panneau "Devoirs faits"), mais utile
   partout ou le contenu peut changer de hauteur dynamiquement. */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  color: var(--encre);
  background: var(--papier);
  margin: 0;
  line-height: 1.5;
}

a { color: inherit; }

.enveloppe {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- En-tête du site ---------- */
.site-entete {
  border-bottom: 1.5px solid var(--gris-200);
  padding: 18px 0;
}
.site-entete .enveloppe {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--encre);
}
.site-logo .marque {
  font-size: 19px;
  font-weight: bold;
}
.site-logo .marque em {
  font-style: normal;
  color: var(--accent);
}
.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav a,
.site-nav button {
  font-size: 14px;
  text-decoration: none;
  color: var(--gris-700);
  padding: 8px 14px;
  border-radius: 20px;
  transition: background-color 0.15s, color 0.15s;
}
.site-nav button {
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.site-nav a:hover,
.site-nav button:hover { background: var(--gris-100); color: var(--encre); }
.site-nav a.nav-icone-profil,
.site-nav button.nav-icone-profil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--rayon-sm);
  border: 1.5px solid var(--gris-200);
  background: var(--papier);
  color: var(--accent);
  transition: border-color 0.15s, background-color 0.15s;
}
.site-nav a.nav-icone-profil:hover,
.site-nav button.nav-icone-profil:hover {
  border-color: var(--accent);
  background: var(--accent-clair);
  color: var(--accent);
}
.site-nav button.nav-icone-profil:disabled {
  opacity: 0.5;
  cursor: default;
}
.site-nav a.nav-vedette {
  background: #E8695E;
  color: white;
  font-size: 15.5px;
  font-weight: bold;
  padding: 9px 18px;
}
.site-nav a.nav-vedette:hover { background: var(--rouge); color: white; }
.site-nav a.nav-vedette-vert { background: #9FD3B4; color: #123D26; }
.site-nav a.nav-vedette-vert:hover { background: #8AC7A2; color: #123D26; }
.site-nav a.nav-vedette-anthracite { background: #5A6068; color: #fff; }   /* QCM Terminale : anthracite clair (25/10/2026, ex-ambre), même fond que .bento-carte--anthracite */
.site-nav a.nav-vedette-anthracite:hover { background: #4A5057; color: #fff; }
/* Sous 480px, "Accueil" + "Cahiers de calcul" + "Automatismes" + "QCM Terminale" ne tiennent pas
   sur une ligne à taille normale (~400px requis) ; on resserre pour les garder
   alignés plutôt que de les laisser passer à la ligne. */
@media (max-width: 480px) {
  .site-nav { gap: 2px; }
  /* les liens s'étirent à la hauteur de l'icône de profil (40 px) : sans centrage, le texte reste collé en haut */
  .site-nav a { font-size: 11px; padding: 5px 7px; display: inline-flex; align-items: center; }
  .site-nav a.nav-vedette { font-size: 11.5px; padding: 6px 9px; }
}
/* « QCM Terminale » (25/10/2026) est plus long que « QCM Bac » : de 481 à 720px, boutons resserrés pour garder la navigation sur une ligne */
@media (min-width: 481px) and (max-width: 720px) {
  .site-nav a { padding: 8px 10px; }
  .site-nav a.nav-vedette { padding: 9px 12px; font-size: 14.5px; }
}
/* quatre liens + icône de profil : on resserre encore sur les plus petits téléphones (QCM Terminale, ex-QCM Bac, ajouté le 18/10/2026) */
@media (max-width: 400px) {
  .site-nav { gap: 1px; }
  .site-nav a { font-size: 10.5px; padding: 5px 4px; }
  .site-nav a.nav-vedette { font-size: 10.5px; padding: 6px 6px; }
  .site-nav a.nav-icone-profil, .site-nav button.nav-icone-profil { width: 34px; height: 34px; }
}

/* ---------- Fil d'ariane ---------- */
.fil-ariane {
  font-size: 13px;
  color: var(--gris-600);
  padding: 16px 0 0;
}
.fil-ariane a { text-decoration: none; color: var(--gris-600); }
.fil-ariane a:hover { color: var(--accent); text-decoration: underline; }
.fil-ariane .separateur { margin: 0 6px; color: var(--gris-400); }
.fil-ariane .courant { color: var(--encre); font-weight: bold; }

/* ---------- Navigation entre cahiers (page sommaire d'un cahier) ---------- */
.cahier-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}
.cahier-nav-btn {
  flex: 1 1 0;
  text-align: center;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--gris-200);
  background: var(--papier);
  color: var(--accent);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.cahier-nav-btn:hover { border-color: var(--accent); background: var(--accent-clair); }
.cahier-nav-btn.cahier-nav-disabled {
  color: var(--gris-400);
  border-color: var(--gris-200);
  cursor: default;
}
.cahier-nav-btn.btn-export-cahier {
  flex: 1 1 auto;
  border-color: var(--rouge-clair);
  color: var(--rouge);
  font-family: Georgia, serif;
  font-size: 13px;
  cursor: pointer;
}
.cahier-nav-btn.btn-export-cahier:hover { background: var(--rouge-clair); border-color: var(--rouge); }
.cahier-nav-btn.btn-export-cahier:disabled { opacity: 0.6; cursor: wait; }
.icone-pdf-cahier { margin-right: 5px; vertical-align: -3px; }

/* ---------- Export PDF d'un cahier entier (fiches extraites puis assemblées dans la page) ---------- */
#export-cahier-conteneur { display: none; }
body.mode-export-cahier #export-cahier-conteneur { display: block; }
.export-cahier-fiche {
  max-width: 980px;
  margin: 0 auto;
}
#export-cahier-statut {
  max-width: 980px;
  margin: 40px auto;
  text-align: center;
  font-size: 15px;
  color: var(--gris-600);
}
/* masqué dès la préparation (pas seulement à l'impression) : une fois les styles de la fiche
   injectés dans <head>, ils s'appliquent aussi au sommaire encore visible et le désorganisent */
body.mode-export-cahier > .site-entete,
body.mode-export-cahier > .enveloppe,
body.mode-export-cahier > .site-pied {
  display: none !important;
}

/* ---------- Section héros (accueil) ---------- */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}
.hero .filet {
  height: 3px;
  background: var(--accent);
  width: 64px;
  margin: 16px auto 0;
}
.hero h1 {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 10px;
}
.hero p {
  font-size: 16px;
  color: var(--gris-600);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Titres de section génériques ---------- */
.section {
  /* padding vertical seulement : la marge latérale vient de .enveloppe, que la
     forme raccourcie « padding: 32px 0 » écrasait (cartes collées aux bords). */
  padding-top: 32px;
  padding-bottom: 32px;
}
.section-entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-entete h2 {
  font-size: 21px;
  margin: 0;
}
.section-entete .voir-tout {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.section-entete .voir-tout:hover { text-decoration: underline; }
.section-entete .voir-tout--vert { color: var(--vert); }
.section-entete .voir-tout--anthracite { color: #4A5057; }
.section-intro {
  font-size: 14.5px;
  color: var(--gris-600);
  margin: -8px 0 20px;
  max-width: 640px;
}

.groupe-niveau {
  margin-bottom: 40px;
}
.groupe-niveau-titre {
  display: inline-block;
  font-size: 32px;
  font-weight: bold;
  color: var(--accent);
  line-height: 1.15;
  margin: 0 0 8px;
  padding: 6px 22px;
  background: #F6D4D3;
  border-radius: var(--rayon);
}
.groupe-niveau-sous {
  font-size: 13px;
  color: var(--gris-600);
  margin: 0 0 16px;
}

/* ---------- Grille bento ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.bento-carte {
  grid-column: span 4;
  background: var(--papier);
  border: 1.5px solid var(--gris-200);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  text-decoration: none;
  color: var(--encre);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 148px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.bento-carte:hover {
  transform: translateY(-2px);
  box-shadow: var(--ombre-hover);
  border-color: var(--accent-clair);
}
.bento-carte:active { transform: translateY(0); }

@media (min-width: 720px) {
  .bento-carte--large   { grid-column: span 2; grid-row: span 2; min-height: 260px; }
  .bento-carte--large2  { grid-column: span 2; }
  .bento-carte--tout    { grid-column: span 4; }
}
@media (max-width: 719px) {
  .bento-carte { grid-column: span 4 !important; grid-row: auto !important; min-height: unset; }
}

.bento-etiquette {
  display: inline-flex;
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: bold;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-clair);
  border-radius: 20px;
  padding: 4px 10px;
  margin-bottom: 12px;
}
.bento-carte--sombre {
  background: var(--encre);
  color: white;
  border-color: var(--encre);
}
.bento-carte--sombre .bento-etiquette {
  background: rgba(255,255,255,0.12);
  color: white;
}
.bento-carte--sombre .bento-meta { color: rgba(255,255,255,0.65); }
.bento-carte--sombre:hover { border-color: var(--accent); }

.bento-carte--vert {
  background: #C4E4D2;
  color: #123D26;
  border-color: #9FD3B4;
}
.bento-carte--vert .bento-etiquette {
  background: rgba(18,61,38,0.14);
  color: #123D26;
}
.bento-carte--vert .bento-meta { color: #34674C; }
.bento-carte--vert:hover { border-color: var(--vert); }

.bento-carte--anthracite {
  background: #5A6068;
  color: #fff;
  border-color: #5A6068;
}
.bento-carte--anthracite .bento-etiquette {
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.bento-carte--anthracite .bento-meta { color: #E3E5E8; }
.bento-carte--anthracite:hover { border-color: #3F454B; }


.bento-carte h3 {
  font-size: 20px;
  margin: 0 0 6px;
  line-height: 1.25;
}
.bento-carte--large h3 { font-size: 25px; }

/* Cartes "niveau" (accueil) : le nom du niveau est la vedette de la carte */
.bento-carte--niveau h3 { font-size: 30px; }
.bento-carte--niveau.bento-carte--large2 h3 { font-size: 24px; }
.bento-carte p.bento-desc {
  font-size: 13.5px;
  color: var(--gris-600);
  margin: 0 0 10px;
  line-height: 1.45;
}
.bento-carte--sombre p.bento-desc { color: rgba(255,255,255,0.75); }
.bento-carte--vert p.bento-desc { color: #2A5C41; }

.bento-meta {
  font-size: 12.5px;
  color: var(--gris-400);
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
}
.bento-fleche {
  position: absolute;
  top: 20px;
  right: 20px;
  color: var(--accent);
  opacity: 0.5;
  font-size: 17px;
}
.bento-carte--sombre .bento-fleche { color: white; opacity: 0.7; }
.bento-carte--vert .bento-fleche { color: #123D26; opacity: 0.6; }
.bento-carte--anthracite p.bento-desc { color: #E3E5E8; }
.bento-carte--anthracite .bento-fleche { color: #fff; opacity: 0.7; }

/* Carte "tout voir" discrète */
.bento-carte--fantome {
  background: var(--gris-50);
  border-style: dashed;
  color: var(--gris-700);
  align-items: center;
  justify-content: center;
  text-align: center;
}
.bento-carte--fantome .bento-fleche { position: static; margin-top: 8px; }

/* Carte "à venir" (niveau/cahier pas encore publié) */
.bento-carte--a-venir {
  background: var(--gris-50);
  border-style: dashed;
  color: var(--gris-600);
  cursor: default;
}
.bento-carte--a-venir:hover {
  transform: none;
  box-shadow: var(--ombre);
  border-color: var(--gris-200);
}
.bento-carte--a-venir h3 { color: var(--gris-600); }
.bento-carte--a-venir .bento-etiquette {
  background: var(--gris-200);
  color: var(--gris-600);
}

/* ---------- Grille de fiches (page cahier) ---------- */
.theme-bloc { margin-bottom: 26px; }
.theme-titre {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent-clair);
}
.fiche-grille {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 640px) {
  .fiche-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
}
.fiche-lien {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border: 1.5px solid var(--gris-200);
  border-radius: var(--rayon-sm);
  text-decoration: none;
  color: var(--encre);
  transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
  min-height: 56px;
}
.fiche-lien:hover { border-color: var(--accent); background: var(--accent-clair); transform: translateX(2px); }
.fiche-lien:active { transform: scale(0.98); }
.fiche-badge {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: bold;
}
.fiche-nom { font-size: 14.5px; flex: 1; }
.fiche-fleche { color: var(--accent); font-size: 15px; opacity: 0.6; }

.menu-rapide {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 26px;
}
.menu-rapide a {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-clair);
  border-radius: 14px;
  padding: 6px 12px;
  text-decoration: none;
  font-family: Georgia, serif;
}
.menu-rapide a:hover { background: var(--accent); color: white; }

/* ---------- Bloc "Devoirs" (assets/js/devoirs-notification.js) : injecte
   juste apres le header pour un eleve connecte ayant une classe avec au
   moins un devoir deja attribue. Remplace le 19/09/2026 l'ancien bandeau
   pleine largeur qui listait chaque devoir ici meme -- desormais un simple
   lien permanent vers /mes-devoirs/, avec une pastille (nombre de devoirs
   A FAIRE) affichee seulement si elle est non nulle. ---------- */
.devoir-bloc-enveloppe { padding: 14px 0; }
.devoir-bloc {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--accent-clair);
  border: 1.5px solid var(--accent);
  color: var(--encre);
  text-decoration: none;
  font-weight: 600;
}
.devoir-bloc:hover { background: var(--accent); color: white; }
.devoir-bloc-icone { flex: 0 0 auto; color: var(--accent); display: inline-flex; }
.devoir-bloc:hover .devoir-bloc-icone { color: white; }
.devoir-bloc-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--rouge);
  color: white;
  font-size: 0.72rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--papier);
}

/* ---------- Page /mes-devoirs/ (assets/js/mes-devoirs.js) : trois colonnes
   "A faire"/"Enregistres"/"Faits" cote a cote a partir de 720px (meme seuil
   que .bento plus haut) -- empilees en une seule colonne en dessous, dans
   leur ordre naturel du HTML. ---------- */
.md-colonnes { display: flex; flex-direction: column; gap: 28px; }
@media (min-width: 720px) {
  .md-colonnes { flex-direction: row; align-items: flex-start; gap: 22px; }
}
.md-colonne {
  flex: 1 1 0;
  min-width: 0;
  background: var(--gris-50);
  border: 1.5px solid var(--gris-200);
  border-radius: var(--rayon);
  padding: 18px;
}
.md-colonne-titre {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2.5px solid var(--gris-200);
  font-size: 1.05rem;
}
.md-colonne-titre--afaire { color: var(--accent); border-bottom-color: var(--accent); }
.md-colonne-titre--enregistres { color: #D97706; border-bottom-color: #D97706; }
.md-colonne-titre--faits { color: var(--vert); border-bottom-color: var(--vert); }
.md-colonne-nb { font-size: 0.85rem; font-weight: normal; color: var(--gris-600); }
.md-liste { list-style: none; margin: 0; padding: 0; }
.md-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: var(--rayon-sm);
  border: 1.5px solid var(--gris-200);
  background: var(--papier);
}
a.md-item-lien { text-decoration: none; color: inherit; }
a.md-item-lien:hover { border-color: var(--accent); background: var(--accent-clair); }
.md-item-titre { font-weight: bold; color: var(--encre); }
.md-item-meta { font-size: 0.88rem; color: var(--gris-600); }
.md-item-fait { border-color: var(--gris-200); }
/* Suppression d'un devoir fait de sa liste (04/10/2026) */
.md-suppression { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; }
.md-faits-tout { margin: -4px 0 12px; }
.md-suppression-question { font-size: 0.88rem; color: var(--gris-600); flex: 1 1 100%; }
.md-supprimer {
  font: inherit; font-size: 0.85rem; padding: 4px 12px; cursor: pointer;
  background: var(--papier); color: var(--gris-600);
  border: 1.5px solid var(--gris-200); border-radius: var(--rayon-sm);
}
.md-supprimer:hover { border-color: var(--gris-400); color: var(--encre); }
.md-supprimer:disabled { opacity: 0.6; cursor: wait; }
.md-supprimer--oui { color: #B42318; border-color: #B42318; }
.md-supprimer--oui:hover { background: #FEF3F2; color: #B42318; border-color: #B42318; }

/* ---------- Pied de page ---------- */
.site-pied {
  border-top: 1.5px solid var(--gris-200);
  margin-top: 40px;
  padding: 22px 0 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--gris-400);
}
.site-pied-mention { display: block; margin-top: 6px; font-size: 11.5px; }

/* ---------- Réglages d'entrée des Automatismes et des QCM Terminale (25/10/2026, assets/reglages-entree.js) ---------- */
.comment-ca-marche { margin: 0 0 14px; font-size: 14.5px; color: var(--gris-600); max-width: 680px; }
.comment-ca-marche summary { cursor: pointer; color: var(--accent); font: 600 14.5px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 32px; display: flex; align-items: center; }
.comment-ca-marche p { margin: 6px 0 0; line-height: 1.55; }
.reglages-carte { border: 1.5px solid var(--accent-clair); border-radius: 16px; padding: 14px 16px 12px; margin: 6px 0 22px; background: #fff; max-width: 760px; }
.reglages-titre { font: 700 13px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gris-600); margin: 0 0 2px; }
.reglages-lab { display: block; font: 600 14px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--gris-600); margin: 10px 0 5px; }
.reglages-bloc[hidden] { display: none; }
.reglages-seg { display: grid; gap: 2px; background: var(--gris-100); border-radius: 14px; padding: 4px; }
.reglages-seg--2 { grid-template-columns: 1fr 1fr; }
.reglages-seg--3 { grid-template-columns: 1fr 1.5fr 1fr; }
.reglages-seg button { border: 0; background: none; min-height: 44px; border-radius: 11px; font: 600 15px Georgia, serif; color: var(--gris-600); cursor: pointer; padding: 0 6px; }
.reglages-seg button:hover { color: var(--encre); }
.reglages-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.reglages-seg button[data-mode="chrono"][aria-pressed="true"] { background: #1a1a1a; }
.reglages-indice { font: italic 14px Georgia, serif; color: var(--gris-600); margin: 6px 2px 2px; }
.reglages-duree select { width: 100%; max-width: 320px; min-height: 44px; border: 1.5px solid #ccc; border-radius: 12px; padding: 0 10px; font: 15px Georgia, serif; background: #fff; }
@media (min-width: 720px) {
  .reglages-carte { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .reglages-titre, .reglages-duree { grid-column: 1 / -1; }
}
.fiche-go { margin-left: auto; flex: none; font: 600 14px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff; background: var(--accent); border-radius: 999px; padding: 8px 16px; }

/* ============================================================
   TELEPHONE EN PORTRAIT (refonte du 25/10/2026, validée par David)
   Uniquement écran de 560 px au plus ET orientation portrait : ordinateur, tablette
   et téléphone en paysage gardent la mise en page habituelle.
   - en-tête sur une ligne (logo + icône de profil) ;
   - navigation en barre d'onglets fixée en bas (Accueil / Cahiers / Automatismes / QCM Terminale),
     construite à partir des quatre liens existants de .site-nav (aucune page à modifier) ;
     l'onglet de la section en cours reçoit aria-current (posé par assets/js/pied-droits.js) ;
   - accueil resserré, liste des cahiers en lignes compactes.
   ============================================================ */
.tel-seulement { display: none; }
@media (max-width: 560px) and (orientation: portrait) {
  .tel-seulement { display: block; }
  .pc-seulement { display: none !important; }

  body { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

  /* ----- en-tête : une seule ligne de 56 px ----- */
  .site-entete { padding: 0; }
  .site-entete .enveloppe { flex-wrap: nowrap; min-height: 56px; gap: 8px; padding: 0 12px 0 16px; }
  .site-logo { align-items: center; gap: 9px; min-width: 0; }
  .site-logo .marque { font-size: 18px; white-space: nowrap; }
  .site-logo .icone-site svg { width: 32px; height: 32px; }

  /* la nav disparait comme boite : ses liens deviennent les onglets du bas, ses boutons restent dans l'en-tete */
  .site-nav { display: contents; }
  .site-nav a.nav-icone-profil, .site-nav button.nav-icone-profil {
    flex: none; width: 44px; height: 44px; border-radius: 12px; border-width: 1px;
  }
  .site-nav a.nav-icone-profil[style*="hidden"] { display: none; }
  .site-nav button.nav-icone-profil { margin-left: auto; }
  .site-nav a.nav-icone-profil:not([style*="hidden"]) { margin-left: auto; }
  .site-nav a.nav-icone-profil:not([style*="hidden"]) + button.nav-icone-profil { margin-left: 0; }

  /* ----- barre d'onglets ----- */
  .site-entete .enveloppe::after {
    content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    height: calc(66px + env(safe-area-inset-bottom, 0px));
    background: #fff; border-top: 1px solid var(--gris-200); box-shadow: 0 -4px 14px rgba(26,26,26,0.06);
  }
  body .site-nav > a:not(.nav-icone-profil),
  body .site-nav > a:not(.nav-icone-profil):hover {
    position: fixed; bottom: env(safe-area-inset-bottom, 0px); z-index: 91; width: 25%; height: 66px; min-height: 48px;
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0 !important; border-radius: 0 !important;
    background: none !important; color: var(--gris-600) !important;
    font: 600 12px/1.15 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
    text-align: center; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  }
  @media (max-width: 380px) {
    body .site-nav > a:not(.nav-icone-profil), body .site-nav > a:not(.nav-icone-profil):hover { font-size: 11px !important; }
  }
  body .site-nav > a:nth-child(1):not(.nav-icone-profil) { left: 0; }
  body .site-nav > a:nth-child(2):not(.nav-icone-profil) { left: 25%; }
  body .site-nav > a:nth-child(3):not(.nav-icone-profil) { left: 50%; }
  body .site-nav > a:nth-child(4):not(.nav-icone-profil) { left: 75%; }
  body .site-nav > a:not(.nav-icone-profil)::before {
    content: ""; flex: none; width: 52px; height: 28px; border-radius: 14px;
    background-repeat: no-repeat; background-position: center; background-size: 22px 22px;
    transition: background-color 0.15s;
  }
  body .site-nav > a[aria-current]:not(.nav-icone-profil) { color: #111 !important; }

  body .site-nav > a:nth-child(1)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F5E5A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11l9-8 9 8M5 10v10h5v-6h4v6h5V10'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(2)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F5E5A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='4' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(3)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F5E5A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2L4 14h7l-1 8 9-12h-7z'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(4)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F5E5A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 9l10-5 10 5-10 5z'/%3E%3Cpath d='M6 11.5V16c0 1.5 3 3 6 3s6-1.5 6-3v-4.5M22 9v6'/%3E%3C/svg%3E"); }

  body .site-nav > a:nth-child(1)[aria-current]::before { background-color: #D9D9FF; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234B46C7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11l9-8 9 8M5 10v10h5v-6h4v6h5V10'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(2)[aria-current]::before { background-color: #FCD9D5; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A8352B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='4' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(3)[aria-current]::before { background-color: #D2ECDC; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23123D26' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2L4 14h7l-1 8 9-12h-7z'/%3E%3C/svg%3E"); }
  body .site-nav > a:nth-child(4)[aria-current]::before { background-color: #5A6068; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 9l10-5 10 5-10 5z'/%3E%3Cpath d='M6 11.5V16c0 1.5 3 3 6 3s6-1.5 6-3v-4.5M22 9v6'/%3E%3C/svg%3E"); }

  /* clavier ouvert : la barre disparait pour laisser la place au champ (les boutons de l'en-tete restent) */
  body:has(input:focus, textarea:focus, select:focus, math-field:focus-within) .site-entete .enveloppe::after,
  body:has(input:focus, textarea:focus, select:focus, math-field:focus-within) .site-nav > a:not(.nav-icone-profil) { display: none !important; }
  body:has(input:focus, textarea:focus, select:focus, math-field:focus-within) { padding-bottom: 0; }

  /* ----- gabarit commun des pages ----- */
  .enveloppe { padding-left: 16px; padding-right: 16px; }
  .site-entete .enveloppe { padding: 0 12px 0 16px; }
  .fil-ariane { font-size: 14px; padding-top: 12px; }
  .hero { padding: 18px 0 10px; text-align: left; }
  .hero h1 { font-size: 26px; margin-bottom: 8px; }
  .hero p { font-size: 15px; line-height: 1.45; margin: 0; max-width: none; }
  /* sommaires de cahiers et liste des cahiers : la phrase d'introduction n'apporte rien sur un petit écran */
  body:has(.cahier-nav) .hero p, .page-cahiers .hero p { display: none; }
  body:has(.cahier-nav) .hero .filet, .page-cahiers .hero .filet { display: none; }
  .hero .filet { margin: 14px 0 0; }
  .section { padding-top: 18px; padding-bottom: 14px; }
  .section-entete { margin-bottom: 12px; }
  .section-entete h2 { font-size: 20px; }
  .section-entete .voir-tout { font-size: 15px; padding: 10px 0; }
  .section-intro { font-size: 15px; }
  .site-pied { margin-top: 20px; padding: 16px 16px 24px; font-size: 13px; }
  .bento { gap: 10px; }
  .bento-carte { padding: 16px; border-radius: 16px; }
  .bento-carte h3 { font-size: 19px; }
  .bento-etiquette { font-size: 12px; margin-bottom: 8px; }
  .bento-meta { font-size: 14px; }
  .fiche-lien { min-height: 60px; }
  .fiche-nom { font-size: 16px; }
  .menu-rapide { margin-bottom: 16px; }
  .menu-rapide a { font-size: 14px; padding: 10px 14px; }
  /* barre « cahier précédent / suivant / PDF » : une ligne de cibles de 44 px (flèches seules, le texte reste lu par les lecteurs d'écran) */
  .cahier-nav { flex-wrap: nowrap; gap: 6px; margin-top: 10px; }
  .cahier-nav-btn { display: flex; align-items: center; justify-content: center; min-height: 44px; font-size: 14px; padding: 0 12px; border-radius: 12px; }
  .cahier-nav > .cahier-nav-btn:not(.btn-export-cahier) { flex: 0 0 52px; padding: 0; font-size: 0; }
  .cahier-nav > .cahier-nav-btn:not(.btn-export-cahier)::before { font-size: 30px; line-height: 1; padding-bottom: 3px; }
  .cahier-nav > :nth-child(1):not(.btn-export-cahier)::before { content: "\2039"; }
  .cahier-nav > :nth-child(2):not(.btn-export-cahier)::before { content: "\203A"; }

  /* ----- bloc « Devoirs » (élève connecté) : carte indigo pleine largeur ----- */
  .devoir-bloc-enveloppe { padding: 12px 0 0; }
  .devoir-bloc { display: flex; width: 100%; min-height: 52px; border-radius: 16px; padding: 12px 16px; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 16px; }
  .devoir-bloc-icone, .devoir-bloc:hover .devoir-bloc-icone { color: #fff; }
  .devoir-bloc:hover { background: var(--accent-hover); }
  .devoir-bloc-texte { font-size: 0; }
  .devoir-bloc-texte::after { content: "Mes devoirs"; font-size: 16px; }
  .devoir-bloc-badge { position: static; margin-left: auto; border: 0; background: #fff; color: var(--accent); min-width: 28px; height: 28px; font-size: 15px; }

  /* ----- accueil ----- */
  .page-accueil .hero { padding-top: 14px; }
  .page-accueil .hero .filet { display: none; }
  .page-accueil .hero p { display: none; }
  .page-accueil .hero p.tel-seulement { display: block; }
  .accueil-tel { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
  .grosse-carte {
    display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 16px; border-radius: 18px;
    text-decoration: none; color: inherit;
  }
  .grosse-carte:active { transform: scale(0.99); }
  .grosse-carte .pastille-ico { flex: none; width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,0.55); display: grid; place-items: center; }
  .grosse-carte .pastille-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .grosse-carte b { display: block; font-size: 20px; line-height: 1.15; }
  .grosse-carte small { display: block; font: 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; margin-top: 3px; opacity: 0.92; }
  .grosse-carte .fleche { margin-left: auto; font: 600 22px system-ui, sans-serif; opacity: 0.8; }
  .grosse-carte--corail { background: #E8695E; color: #fff; }
  .grosse-carte--vert { background: #9FD3B4; color: #123D26; }
  .grosse-carte--anthracite { background: #5A6068; color: #fff; }
  .grosse-carte--anthracite .pastille-ico { background: rgba(255,255,255,0.18); }
  .page-accueil .section-auto-qcm { display: none; }
  .page-accueil .section-vedette .bento {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px;
    margin: 0 -16px -10px; padding: 2px 16px 22px; scrollbar-width: none;
  }
  .page-accueil .section-vedette .bento::-webkit-scrollbar { display: none; }
  .page-accueil .section-vedette .bento-carte { flex: 0 0 240px; scroll-snap-align: start; min-height: 128px; }

  /* ----- liste « Tous les cahiers » : un niveau à la fois, lignes compactes ----- */
  .seg-niveaux { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--gris-100); border-radius: 14px; padding: 4px; margin: 6px 0 4px; }
  .seg-niveaux button {
    border: 0; background: none; height: 44px; border-radius: 11px; cursor: pointer;
    font: 600 16px Georgia, serif; color: var(--gris-600);
  }
  .seg-niveaux button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
  .page-cahiers .groupe-niveau.masque-tel { display: none; }
  .page-cahiers .groupe-niveau { margin-bottom: 8px; }
  .page-cahiers .groupe-niveau-titre { display: none; }
  .page-cahiers .groupe-niveau-sous { font-size: 14px; margin: 8px 0 6px; }
  .page-cahiers .bento { display: block; counter-reset: cah; }
  .page-cahiers .bento-carte {
    counter-increment: cah;
    display: grid; grid-template-columns: 40px 1fr 20px; grid-template-areas: "num titre fleche" "num meta fleche";
    align-items: center; column-gap: 14px; row-gap: 0;
    min-height: 68px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--gris-100); border-radius: 0; box-shadow: none; background: none;
  }
  .page-cahiers .bento-carte:hover { transform: none; box-shadow: none; }
  .page-cahiers .bento-carte::before {
    content: counter(cah); grid-area: num; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-clair); color: var(--accent);
    display: grid; place-items: center; font: 700 17px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  .page-cahiers .bento-etiquette { display: none; }
  .page-cahiers .bento-carte h3 { grid-area: titre; font-size: 17px; line-height: 1.2; margin: 0; }
  .page-cahiers .bento-meta { grid-area: meta; font: 14px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--gris-600); margin: 0; }
  .page-cahiers .bento-carte--a-venir::before { content: "…"; background: var(--gris-100); color: var(--gris-600); }
  .page-cahiers .bento-fleche { grid-area: fleche; position: static; opacity: 0.45; font-size: 22px; }
}
