/* Mise en page du site : en-tête, navigation, listes, formulaires, pied de page.
   Couleurs et polices viennent des variables de la charte des cours (/charte/institut-ihsan.css) :
   jamais de nom de police ici, pour qu'un changement de police tienne en une ligne dans la charte. */

/* ---------- Bases communes ---------- */

main a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
main a:hover {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  z-index: 1;
  padding: 0.5rem 1rem;
  background: var(--accent-strong);
  color: #ffffff;
  border-radius: 0 0 8px 8px;
}
.skip-link:focus {
  top: 0;
}

/* Bouton : action principale (import, validation, navigation vers une page clé).
   Cible tactile ≥ 44px. Le même style sert pour <a class="button"> et <button>. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-family: var(--font-title);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
main a.button {
  color: #ffffff;
}
.button:hover,
main a.button:hover {
  background: var(--accent-strong);
  color: #ffffff;
}
.button[aria-current="page"] {
  background: var(--accent-strong);
}

/* Bouton secondaire : action moins importante (télécharger, repasser en brouillon). */
.button--secondary,
main a.button--secondary {
  background: #ffffff;
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.button--secondary:hover,
main a.button--secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

@media (prefers-reduced-motion: no-preference) {
  .button,
  .nav-link,
  .course-card {
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s ease-out;
  }
  /* Retour immédiat au toucher (et pas seulement au relâchement) : le bouton s'enfonce un peu.
     Sans animation demandée par le système, seul le changement de couleur reste. */
  .button:active {
    transform: scale(0.97);
  }
}

/* ---------- Bandeau du mode développement ---------- */

.dev-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  background: var(--key-bg);
  border-bottom: 2px solid var(--key-border);
  color: var(--text);
  padding: 0.5rem 1rem;
  text-align: center;
}
/* « Voir le site comme » : libellé, liste et bouton sur une ligne, qui passe à la ligne si besoin. */
.view-as {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.6rem;
}
.view-as label {
  font-weight: bold;
}
.view-as select {
  min-height: 2.75rem;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--key-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

/* ---------- En-tête ---------- */

.site-header,
.site-footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.brand-name {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-strong);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

/* Lien de navigation en « pilule » : pas de soulignement, fond au survol.
   Page courante : fond + gras, donc repérable sans dépendre de la seule couleur. */
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  color: var(--accent-text);
  font-family: var(--font-title);
  font-weight: 600;
  text-decoration: none;
}
.nav-link:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: bold;
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

/* ---------- Titres et textes de page ---------- */

.page-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}
.lead {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
main > p {
  margin-bottom: 1rem;
}

/* ---------- Page d'un cours : lien retour et avis de brouillon ---------- */

/* Lien retour à gauche, actions à droite ; sur un écran étroit, les actions passent dessous. */
.course-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
main a.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem 0.5rem 0.75rem;
  /* Marge négative : le texte reste aligné sur le contenu, seul le fond du survol déborde. */
  margin-left: -0.75rem;
  border-radius: 999px;
  font-weight: bold;
  text-decoration: none;
}
main a.back-link:hover {
  background: var(--accent-soft);
}

.draft-notice {
  background: var(--key-bg);
  border: 1.5px solid var(--key-border);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}

/* ---------- Liste des cours ---------- */

.level + .level {
  margin-top: 2.5rem;
}
.level h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--accent-strong);
  margin-bottom: 0.9rem;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
  list-style: none;
}

/* Toute la carte est cliquable : le lien du titre s'étend sur la carte (::after).
   Un seul lien par carte, dont le nom accessible reste le titre du cours. */
.course-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}
.course-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 16%, transparent);
}
.course-card:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.course-card-title {
  background: var(--accent);
  padding: 1rem 1.2rem;
  text-align: center;
  font-size: 1.45rem;
  line-height: 1.5;
}
main .course-card-title a {
  color: #ffffff;
  text-decoration: none;
}
main .course-card-title a:hover {
  color: #ffffff;
}
.course-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
/* Le focus est montré sur la carte entière (focus-within), pas sur le seul titre. */
.course-card-title a:focus-visible {
  outline: none;
}
.course-card-body {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1.2rem 1.1rem;
}
/* Le sous-titre français sert de titre à la carte : même police que les titres */
.course-subtitle {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.35;
  color: var(--text);
}
.course-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}
.course-series {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.badge {
  background: var(--key-bg);
  color: var(--key-title);
  border: 1px solid var(--key-border);
  border-radius: 999px;
  padding: 0.05rem 0.65rem;
  font-size: 0.8rem;
  font-weight: bold;
}

.empty-state {
  border: 2px dashed var(--accent-border);
  border-radius: 12px;
  background: var(--accent-soft);
  padding: 2rem 1.5rem;
  text-align: center;
}
.empty-state p + p {
  margin-top: 1rem;
}

/* ---------- Formulaires ---------- */

.form {
  display: grid;
  gap: 1.5rem;
}
.field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  border: 0;
}
.field > label,
.field > legend {
  font-weight: bold;
}
.field > legend {
  margin-bottom: 0.5rem;
}

/* Champ fichier : grande zone en pointillés ; le bouton du navigateur est mis aux couleurs du site. */
.file-input {
  width: 100%;
  padding: 1.25rem;
  border: 2px dashed var(--accent-border);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.file-input:hover {
  border-color: var(--accent);
}
.file-input::file-selector-button {
  margin-right: 1rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-family: var(--font-title);
  font-weight: 600;
  cursor: pointer;
}
.file-input[aria-invalid="true"] {
  border-color: #a1260d;
}
@media (max-width: 30rem) {
  .file-input {
    padding: 0.75rem;
  }
  .file-input::file-selector-button {
    margin-right: 0.6rem;
  }
}

/* Niveaux : un petit cadre par cycle, côte à côte sur grand écran, empilés sur mobile. */
.cycle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}
.cycle-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 1rem 0.75rem;
  min-width: 0;
}
.cycle-group > legend {
  padding: 0 0.35rem;
  margin-left: -0.35rem;
  font-size: 0.82rem;
  font-weight: bold;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  cursor: pointer;
}
.checkbox input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.help {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.field-error,
.form-alert {
  color: #a1260d; /* 7,5:1 sur blanc */
  font-weight: bold;
}
.form-alert {
  border-left: 4px solid #a1260d;
  border-radius: 0 8px 8px 0;
  background: #ffffff;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}
.form .button {
  justify-self: start;
}

/* ---------- Texte réservé aux lecteurs d'écran ---------- */

/* Invisible à l'écran, lu par les lecteurs d'écran : précise un bouton (« Monter le bloc 2… »). */
.visually-hidden,
.default-submit {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Boutons compacts (barres d'outils de l'éditeur) : cible tactile gardée à 2,75rem (44 px). */
.button--small {
  padding: 0.35rem 0.9rem;
  font-size: 0.95rem;
}
/* Supprimer : rouge, mais en contour pour ne pas crier plus fort que les actions principales. */
.button--danger,
main a.button--danger {
  background: #ffffff;
  color: #a1260d; /* 7,5:1 sur blanc */
  box-shadow: inset 0 0 0 1.5px #a1260d;
}
.button--danger:hover,
main a.button--danger:hover {
  background: #fbecea;
  color: #7d1d0a;
}
.button--danger-solid {
  background: #a1260d;
}
.button--danger-solid:hover {
  background: #7d1d0a;
}

.form-notice {
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  padding: 0.5rem 1rem;
  font-weight: bold;
}
.problem-list {
  margin: 0.5rem 0 0 1.25rem;
  font-weight: normal;
}
.problem-list li + li {
  margin-top: 0.2rem;
}

/* ---------- Éditeur de cours ---------- */

/* Champs de saisie : ceux de l'éditeur et des formulaires « Nouveau cours ». */
.editor input[type="text"],
.editor textarea,
.editor select,
.form input[type="text"],
.form input[type="email"],
.form input[type="date"],
.form select,
.form textarea,
.inline-form input[type="text"],
.inline-form input[type="email"],
.admin-list input[type="text"],
.level-add input[type="text"],
.level-add select,
.filters select,
.filters input[type="date"],
.filters input[type="search"] {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--accent-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}
.editor textarea,
.form textarea {
  resize: vertical;
  line-height: 1.5;
}
.editor input[aria-invalid="true"],
.form input[aria-invalid="true"],
.form textarea[aria-invalid="true"],
.inline-form input[aria-invalid="true"],
.admin-list input[aria-invalid="true"],
.level-add input[aria-invalid="true"],
.level-add select[aria-invalid="true"],
.filters input[aria-invalid="true"],
.form select[aria-invalid="true"] {
  border-color: #a1260d;
}
.input-arabic {
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  line-height: 2;
}

.editor-fields {
  display: grid;
  gap: 1.5rem;
}
.editor-section,
.editor-part,
.editor-block,
.editor-card {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  border-radius: 12px;
}
.editor-section,
.editor-part {
  border: 1.5px solid var(--accent-border);
  padding: 0.75rem 1.25rem 1.25rem;
}
.editor-part {
  background: #fbfdfc;
}
.editor-block {
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 0.5rem 1rem 1rem;
}
/* Un encadré contient des blocs : on décale légèrement ses éléments pour montrer l'imbrication. */
.editor-block .editor-block {
  background: var(--accent-soft);
}
.editor-card {
  border: 1px dashed var(--accent-border);
  padding: 0.5rem 1rem 1rem;
}
.editor-section > legend,
.editor-part > legend,
.editor-block > legend,
.editor-card > legend {
  padding: 0 0.4rem;
  margin-left: -0.4rem;
  font-family: var(--font-title);
  font-weight: bold;
  color: var(--accent-strong);
}
.editor-part > legend {
  font-size: 1.25rem;
}
/* Le focus peut arriver sur un cadre (après une suppression) : on le montre. */
.editor-part:focus-visible,
.editor-block:focus-visible,
.editor-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.9rem;
}
.editor-grid--card {
  grid-template-columns: minmax(6rem, 10rem) 1fr;
}
@media (max-width: 30rem) {
  .editor-grid--card {
    grid-template-columns: 1fr;
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.editor-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}
.editor-item > .field {
  flex: 1 1 16rem;
}
.editor-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}
.editor-add > .field {
  flex: 1 1 12rem;
}

/* Barre d'actions collée en bas de l'écran : « Enregistrer » reste à portée, même au milieu d'un long cours. */
.editor-bar {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 1.5rem;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1.5px solid var(--accent-border);
  background: #ffffff;
}
/* Toujours présente (jamais display: none) : une région « status » masquée puis affichée n'est pas
   annoncée par les lecteurs d'écran. */
.editor-status {
  flex: 1 1 14rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
/* Remplies par editor.js. Toujours présentes, comme .editor-status, pour être annoncées. */
.editor-dirty {
  color: var(--key-title); /* 5,4:1 sur blanc */
  font-weight: bold;
  font-size: 0.95rem;
}
.editor-error {
  flex-basis: 100%;
  color: #a1260d; /* 7,5:1 sur blanc */
  font-weight: bold;
}
.editor-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.templates {
  margin-top: 2.5rem;
}
.templates h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--accent-strong);
  margin-bottom: 0.5rem;
}
.templates ul {
  margin: 0.75rem 0 0 1.25rem;
}

.danger-zone {
  display: grid;
  gap: 1rem;
  border: 1.5px solid #a1260d;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Liste des cours : filtres ---------- */

/* Les trois filtres côte à côte sur grand écran, empilés sur mobile ; les boutons à la suite. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--accent-soft);
}
.filters > .field {
  flex: 1 1 11rem;
}
.filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Administration ---------- */

/* Accueil : une carte par rubrique ; toute la carte est le lien. */
.admin-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  list-style: none;
}
main a.admin-card {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  height: 100%;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
}
main a.admin-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
}
.admin-card-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent-strong);
}
.admin-card-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.admin-section + .admin-section {
  margin-top: 2.5rem;
}
.admin-section h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}
.admin-section > p + p,
.admin-section > ul + p {
  margin-top: 0.75rem;
}
.page-updated {
  margin-top: 2rem;
}

/* Page d'aide : étapes numérotées et sous-titres. */
.guide h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}
.guide ol {
  padding-left: 1.5rem;
}
.guide li + li {
  margin-top: 0.35rem;
}
.guide > ol + p,
.guide > p + ol,
.guide > p + ul {
  margin-top: 0.75rem;
}

/* Liste d'éléments (classes, comptes, niveaux) : une carte par ligne. */
.admin-list {
  display: grid;
  gap: 0.6rem;
  list-style: none;
  margin-bottom: 1rem;
}
.admin-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}
.admin-list-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: bold;
}
.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.badge--role {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
  font-family: var(--font-text);
}

/* Niveaux : le champ du nom et son bouton, puis les compteurs et les actions. */
.level-row {
  align-items: flex-end;
}
.level-rename,
.level-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  flex: 1 1 18rem;
}
.level-rename > .field,
.level-add > .field {
  flex: 1 1 12rem;
}
.level-tools {
  display: grid;
  gap: 0.4rem;
  justify-items: end;
}
@media (max-width: 30rem) {
  .level-tools {
    justify-items: start;
  }
}
.level-add {
  padding: 0.75rem 1rem;
  border: 1px dashed var(--accent-border);
  border-radius: 12px;
}
.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Élèves et présences ---------- */

/* Rubriques d'une classe : les mêmes « pilules » que la navigation du site. */
.class-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0.5rem 0 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Téléphone : les rubriques en deux colonnes égales, plutôt qu'une ligne coupée au hasard.
   Nombre impair (5 avec « Réunions ») : la dernière prend toute la largeur au lieu de rester seule à gauche. */
@media (max-width: 30rem) {
  .class-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .class-tabs li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .class-tabs .nav-link {
    width: 100%;
    justify-content: center;
  }
}

/* Feuille d'appel : une carte par élève, ses trois choix à côté sur grand écran, dessous sur mobile. */
.attendance-list {
  display: grid;
  gap: 0.6rem;
  list-style: none;
  margin-bottom: 1.25rem;
}
.attendance-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  background: #ffffff;
  min-width: 0;
}
/* Une légende ne se place pas en flex par défaut : float la remet dans le flux de la carte. */
.attendance-row > legend {
  float: left;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent-strong);
  padding: 0;
}
.status-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
/* Chaque choix est une grande cible (44 px de haut au moins) : l'appel se fait souvent au téléphone.
   Le bouton radio reste visible : on voit ET on entend quel statut est choisi. */
.status-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
.status-choice input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}
/* :has() : le libellé change d'aspect quand SON bouton radio est coché. La couleur n'est jamais le
   seul repère : le bouton coché et le texte disent aussi le statut. */
.status-choice--present:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.status-choice--absent:has(input:checked) {
  background: #fdecea;
  border-color: #a1260d;
}
.status-choice--absent input {
  accent-color: #a1260d;
}
.status-choice--late:has(input:checked) {
  background: var(--key-bg);
  border-color: var(--key-border);
}
.status-choice--late input {
  accent-color: var(--key-title);
}
.status-choice:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 30rem) {
  .attendance-row > legend {
    width: 100%;
  }
  .status-choices {
    width: 100%;
  }
  .status-choice {
    flex: 1 1 auto;
    justify-content: center;
  }
}

.day-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  list-style: none;
}
.day-list a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* Récapitulatif : le tableau défile dans son cadre sur petit écran, sans élargir la page. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 0.75rem;
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
}
.summary-table caption {
  text-align: start;
  padding: 0.75rem 1rem;
  font-family: var(--font-title);
  font-weight: bold;
  color: var(--accent-strong);
}
.summary-table th,
.summary-table td {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
}
.summary-table thead th {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.9rem;
}
.summary-table td {
  font-variant-numeric: tabular-nums;
}
/* Sur téléphone, les en-têtes passent à la ligne pour que le tableau tienne sans défiler. */
@media (max-width: 30rem) {
  .summary-table th,
  .summary-table td {
    padding: 0.5rem 0.55rem;
    white-space: normal;
    font-size: 0.9rem;
  }
}

/* Avertissement d'homonyme : ce n'est pas une erreur, on demande seulement confirmation. */
.homonym-warning {
  display: grid;
  gap: 0.6rem;
  border: 1.5px solid var(--key-border);
  border-radius: 12px;
  background: var(--key-bg);
  padding: 0.9rem 1.2rem;
  margin-bottom: 1rem;
}
.homonym-warning ul {
  margin-left: 1.2rem;
}

/* ---------- Cartes d'ajout et formulaires en ligne ---------- */

/* Carte « Ajouter un élève » / « Donner un devoir » : en haut de la page, avant la liste. */
.add-card {
  margin-bottom: 2rem;
  padding: 1rem 1.2rem 1.1rem;
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  background: var(--accent-soft);
}
.add-card > h2,
.add-card > h3,
.add-card > summary {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent-strong);
}
.add-card > h2,
.add-card > h3 {
  margin-bottom: 0.75rem;
}
/* summary garde son triangle natif (display: list-item) : c'est lui qui dit « ça s'ouvre ». */
.add-card > summary {
  padding: 0.35rem 0;
  cursor: pointer;
}
.add-card > summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
.add-card[open] > summary {
  margin-bottom: 0.75rem;
}
.add-card > .help {
  margin-top: 0.6rem;
}

/* Formulaire en ligne : les champs côte à côte, les boutons à droite.
   subgrid : chaque champ (étiquette, saisie, erreur) partage les lignes de la grille du formulaire.
   Les boutons sont placés sur la ligne des saisies (grid-row: 2) : ils restent alignés sur les champs,
   même quand un message d'erreur s'affiche sous l'un d'eux. */
.inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  column-gap: 0.75rem;
  row-gap: 0.4rem;
}
.inline-form > .field {
  grid-row: span 3;
  grid-template-rows: subgrid;
}
.inline-form-actions {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
@media (max-width: 30rem) {
  .inline-form {
    grid-template-columns: minmax(0, 1fr);
  }
  .inline-form > .field {
    grid-row: auto;
    grid-template-rows: none;
  }
  .inline-form-actions {
    grid-column: 1;
    grid-row: auto;
    flex-wrap: wrap;
    margin-top: 0.4rem;
  }
}

/* ---------- Liste des élèves ---------- */

/* Une ligne par élève (hérite de .admin-list > li : centré verticalement, nom à gauche, actions à droite). */
main a.student-name {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: bold;
}
/* Les actions d'une ligne : même hauteur (celle des .button--small), même espacement, centrées. */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
/* En édition, le formulaire prend toute la largeur de la ligne. */
.student-row--edit > .inline-form {
  flex: 1 1 100%;
}
@media (max-width: 30rem) {
  /* Téléphone : le nom sur sa ligne, les boutons dessous, de largeur égale.
     « .admin-list > » : même spécificité que la règle générale des listes, qu'on remplace ici. */
  .admin-list > .student-row {
    flex-direction: column;
    align-items: stretch;
  }
  .student-row .row-actions > .button {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ---------- Devoirs ---------- */

.homework-group + .homework-group {
  margin-top: 2rem;
}
.homework-group > h2,
.homework-group > h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}
.homework-list {
  display: grid;
  gap: 0.75rem;
  list-style: none;
}
.homework-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}
.homework-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}
.homework-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--accent-strong);
}
.homework-instructions p + p {
  margin-top: 0.4rem;
}
.homework-item > .row-actions {
  margin-top: 0.25rem;
}
.target-choice .field {
  margin-top: 0.5rem;
}

/* « Fait : 2 / 5 » (onglet Devoirs du prof) : un résumé qui s'ouvre sur le détail. */
/* summary garde son triangle natif (display: list-item) : c'est lui qui dit « ça s'ouvre ». */
.homework-progress > summary {
  padding: 0.6rem 0;
  cursor: pointer;
  font-weight: bold;
  color: var(--accent-text);
}
.homework-progress ul {
  list-style: none;
  display: grid;
  gap: 0.2rem;
  padding-left: 0.25rem;
}

/* ---------- Page du parent ---------- */

/* La case « Fait » d'un devoir : grande cible, pastille qui prend la couleur du site une fois cochée
   (le texte « fait le … » à côté dit la même chose : la couleur n'est qu'un repère). */
.done-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.25rem;
}
.done-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.35rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
.done-choice input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.done-choice:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}
.done-choice:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Les totaux de présence d'un enfant : quatre cases, deux par ligne sur téléphone. */
.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.totals > div {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}
.totals dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.totals dd {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-strong);
}
@media (max-width: 30rem) {
  .totals {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Pied de page ---------- */

.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}
.site-footer .brand-name {
  font-size: 1rem;
  color: var(--accent-text);
}
.site-footer p + p {
  margin-top: 0.2rem;
}
.site-footer a {
  color: var(--accent-text);
}

/* ---------- Impression : seul le cours reste ---------- */

@media print {
  .dev-banner,
  .site-header,
  .site-footer,
  .course-nav,
  .draft-notice,
  .skip-link,
  .editor-bar {
    display: none;
  }
}

/* ---------- Connexion ---------- */

/* Nom de la personne connectée et bouton de déconnexion, côte à côte dans l'en-tête. */
.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.account-name {
  color: var(--text-muted);
  font-weight: 600;
}

/* Pages de connexion : une colonne étroite, plus facile à lire et à remplir. */
.login {
  max-width: 28rem;
}
.login p {
  margin-bottom: 1rem;
}

/* ---------- Réunions avec les parents ---------- */

/* Onglet « Réunions » du prof : le résumé d'abord, puis une carte par élève. */
.meeting-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0.75rem 0 1.25rem;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.meeting-list {
  display: grid;
  gap: 0.75rem;
  list-style: none;
}
.meeting-row {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  /* Le lien #reunion-… amène la ligne sous l'en-tête, pas collée au bord. */
  scroll-margin-top: 1rem;
}
.meeting-row--single {
  margin: 1rem 0 1.5rem;
}
.meeting-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}
.meeting-student {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--accent-strong);
}
/* L'heure est l'information principale de la ligne : chiffres alignés, heure en gras. */
.meeting-time {
  font-variant-numeric: tabular-nums;
}
.meeting-time strong {
  color: var(--accent-strong);
}
.meeting-notice {
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  padding: 0.45rem 0.85rem;
  font-weight: 600;
}
.meeting-warning {
  border-left: 4px solid var(--key-border);
  border-radius: 0 8px 8px 0;
  background: var(--key-bg);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  font-size: 0.95rem;
}

/* État d'une réunion : le mot porte le sens ; symbole et couleur ne font que le répéter. */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem; /* un espace en fin de span disparaît dans un flex : l'écart vient d'ici */
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  background: #f6f7f6;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-chip--yes {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}
.status-chip--no {
  background: #fbecea;
  border-color: #eab3a8;
  color: #a1260d; /* 6,9:1 sur ce fond */
}
.status-chip--warn {
  background: var(--key-bg);
  border-color: var(--key-border);
  color: var(--key-title);
}

/* Frères et sœurs : un encadré à part, en pointillés, parce que ce sont des élèves d'autres classes. */
.siblings {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--accent-border);
  border-radius: 10px;
  background: #fbfdfc;
}
.siblings-title {
  font-family: var(--font-text);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.siblings-list {
  display: grid;
  gap: 0.35rem;
  list-style: none;
}
.siblings-list li {
  display: grid;
  gap: 0.05rem;
}
.sibling-name {
  font-weight: 600;
}
.sibling-time {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.meeting-alert {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--key-border);
  border-radius: 10px;
  background: var(--key-bg);
  color: var(--key-title);
}
.meeting-alert-icon {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--key-title);
  color: #ffffff;
  font-weight: bold;
  font-size: 0.85rem;
  line-height: 1;
}

/* Formulaire d'une ligne : jour et heure côte à côte. */
.meeting-form {
  display: grid;
  gap: 0.6rem;
}
.meeting-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 0.75rem;
  max-width: 36rem; /* sur grand écran, des champs à la taille de ce qu'on y tape */
}
.meeting-fields .field {
  margin: 0;
}
.meeting-fields input {
  width: 100%;
  min-height: 2.75rem;
}

/* Page du parent : « Mes enfants » montre la prochaine réunion sous le nom. */
.next-meeting {
  margin-top: 0.15rem;
  color: var(--accent-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Carte d'une réunion (page d'un enfant) : le jour, puis l'heure en grand, c'est ce qu'on retient. */
.meeting-cards {
  display: grid;
  gap: 0.75rem;
  list-style: none;
}
.meeting-card {
  display: grid;
  gap: 0.4rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  background: var(--accent-soft);
}
.meeting-card-day {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--accent-strong);
}
.meeting-card-hour {
  font-family: var(--font-title);
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: -0.02em; /* les grands caractères se resserrent */
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

/* Réponse : un contrôle segmenté (deux boutons radio côte à côte), cibles de 3 rem. */
.answer-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.answer-choice {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.answer-choice legend {
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}
.segment {
  position: relative;
  cursor: pointer;
}
/* Le vrai bouton radio reste dans la page (clavier, lecteurs d'écran), posé sous le libellé visible. */
.segment input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.segment > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 3rem;
  padding: 0.4rem 0.6rem;
  border: 1.5px solid #b5c8c2;
  border-radius: 12px;
  background: #ffffff;
  font-weight: 600;
  text-align: center;
}
.segment input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}
.segment--no input:checked + span {
  border-color: #a1260d;
  background: #a1260d;
}
.segment input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  .segment > span {
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s ease-out;
  }
  .segment:active > span {
    transform: scale(0.98);
  }
}

/* « Tes autres enfants » : une ligne par enfant, son prénom et ses heures. */
.others-title {
  margin-top: 1.25rem;
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--accent-strong);
}
.others-list {
  display: grid;
  gap: 0.35rem;
  list-style: none;
  margin-top: 0.4rem;
}
.others-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.15rem 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

@media (prefers-contrast: more) {
  .segment > span,
  .status-chip,
  .siblings {
    border-width: 2px;
    border-style: solid;
  }
}

/* « Jamais connecté » à côté du nom d'un parent (fiche d'un élève). */
.admin-list-title .status-chip {
  margin-left: 0.5rem;
  vertical-align: middle;
}
