@charset "utf-8";
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #14213d;
  --muted: #5c677d;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --border: #d5dcea;
  --error: #b42318;
  --ok: #067647;
  --border-strong: #7d8aa3; /* bordures des champs et boutons : 3:1 minimum (WCAG 1.4.11) */
  --hero-bg: #14213d;
  --hero-text: #ffffff;
  --hero-muted: #c9d3e8;
  --cta: #ffd24a;
  --cta-text: #14213d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1729;
    --card: #17203a;
    --text: #e8ecf6;
    --muted: #9aa6c3;
    --accent: #5b8def;
    --accent-text: #0b1020;
    --border: #2b3860;
    --error: #ff8a80;
    --ok: #6ee7b7;
    --border-strong: #6577a3;
    --hero-bg: #24356b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

#app {
  max-width: 28rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.brand h1 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; }
.tagline { margin: 0.25rem 0 1.5rem; color: var(--muted); }

section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

[hidden] { display: none !important; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tabs button {
  flex: 1;
  padding: 0.6rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }

input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

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

button.primary, button.secondary {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  font: inherit;
  font-weight: 600;
  border-radius: 0.5rem;
  cursor: pointer;
}
button.primary { color: var(--accent-text); background: var(--accent); border: 1px solid var(--accent); }
button.secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.hint { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }
.message { min-height: 1.5em; margin: 1rem 0 0; font-weight: 600; }
.message.error { color: var(--error); }
.message.ok { color: var(--ok); }
.notice { color: var(--error); }

/* ---------- Étape 4 : profils enfants ---------- */
h2 { margin: 1.25rem 0 0.5rem; font-size: 1.2rem; }
.whoami { margin: 0; color: var(--muted); }

.children { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; gap: 0.5rem; }
.child { display: flex; gap: 0.5rem; }

.child-select {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}
.child-select[aria-pressed="true"] { border-color: var(--accent); border-width: 2px; padding: calc(0.65rem - 1px) calc(0.75rem - 1px); }

.badge {
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 999px;
}

.child-delete {
  padding: 0 0.75rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}
.child-delete.danger { color: var(--error); border-color: var(--error); font-weight: 600; }

.active-child { margin: 0 0 1rem; color: var(--muted); }
.active-child strong { color: var(--text); }

.row { display: flex; gap: 0.5rem; }
.row input { flex: 1; min-width: 0; }
.row button.primary { width: auto; margin-top: 0; padding: 0.65rem 1rem; }

/* ---------- Étape 5 : listes de matière ---------- */
h3 { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
#sets-panel { margin-top: 1rem; border-top: 1px solid var(--border); }
.count { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  resize: vertical;
}
code { padding: 0.05rem 0.3rem; background: var(--bg); border-radius: 0.25rem; }

.items { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.25rem; }
.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-wrap: anywhere;
}
.item-delete {
  flex: none;
  min-width: 2.25rem;
  min-height: 2.25rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}

/* ---------- Étape 6 : quiz ---------- */
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
#quiz-form { margin-top: 1rem; }
#quiz-form h3 { margin-top: 0.5rem; }

.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.quiz-top h2 { margin: 0; overflow-wrap: anywhere; }
.quit {
  flex: none;
  padding: 0.4rem 0.75rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}
progress { display: block; width: 100%; height: 0.6rem; margin-top: 0.75rem; accent-color: var(--accent); }
/* Mode focus : barre de temps qui se vide, un peu plus épaisse, sans chiffres. */
progress.timer { height: 0.9rem; }

.prompt { margin: 0.5rem 0 1rem; font-size: 1.6rem; font-weight: 700; overflow-wrap: anywhere; }
.choices { display: grid; gap: 0.6rem; }
.choice {
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; opacity: 1; }
.choice.right { border-color: var(--ok); }
.choice.wrong { border-color: var(--error); }
.choice.right::after { content: '  \2713'; color: var(--ok); font-weight: 700; }
.choice.wrong::after { content: '  \2717'; color: var(--error); font-weight: 700; }

#quiz-feedback { margin-top: 1rem; }
.verdict { margin: 0 0 0.25rem; font-size: 1.2rem; font-weight: 700; }
.verdict.correct { color: var(--ok); }
.verdict.almost { color: var(--accent); }
.verdict.wrong { color: var(--error); }
#quiz-correct { margin: 0; overflow-wrap: anywhere; }

/* ---------- Étape 7 : maîtrise ---------- */
.summary { margin: 0.25rem 0 0.5rem; font-size: 0.9rem; color: var(--muted); }
.item-text { flex: 1; min-width: 0; }
.status {
  flex: none;
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.status.mastered { color: var(--ok); border-color: var(--ok); }
.status.difficulty { color: var(--error); border-color: var(--error); }
.status.review { color: var(--text); border-color: var(--text); }

/* ---------- Étape 8 : tableau de bord parent ---------- */
#dashboard-panel { margin-top: 1rem; border-top: 1px solid var(--border); }
.kpis { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  text-align: center;
}
.kpi-count { font-size: 1.8rem; line-height: 1.1; }
.kpi-label { font-size: 0.85rem; font-weight: 600; }
.kpi.mastered { border-color: var(--ok); }
.kpi.mastered .kpi-count { color: var(--ok); }
.kpi.review { border-color: var(--text); }
.kpi.difficulty { border-color: var(--error); }
.kpi.difficulty .kpi-count { color: var(--error); }
.week { margin: 0.5rem 0; font-weight: 600; }

.dash-sets { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.75rem; }
.dash-set { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 0.5rem; }
.dash-set strong { overflow-wrap: anywhere; }
.stack { display: flex; flex-basis: 100%; height: 0.6rem; overflow: hidden; border-radius: 999px; background: var(--border); }
.seg { min-width: 0.4rem; }
.seg.mastered { background: var(--ok); }
.seg.review { background: var(--muted); }
.seg.difficulty { background: var(--error); }
.seg.new { background: var(--border); }
.dash-counts { flex-basis: 100%; margin: 0; font-size: 0.9rem; color: var(--muted); }

/* « Par liste » : une section repliable et colorée par matière (voir aussi « Matières » plus haut) */
.dash-subject { border: 2px solid var(--edge); border-left: 0.5rem solid var(--strong); border-radius: 0.9rem; background: var(--soft); color: var(--ink); }
.dash-subject > summary { display: grid; gap: 0.35rem; padding: 0.7rem 0.9rem; cursor: pointer; list-style: none; position: relative; padding-right: 2.2rem; }
.dash-subject > summary::-webkit-details-marker { display: none; }
.dash-subject > summary::after { content: "▾"; position: absolute; right: 0.9rem; top: 0.8rem; font-size: 1.1rem; transition: none; }
.dash-subject[open] > summary::after { content: "▴"; }
.dash-subject > summary:focus-visible { outline: 3px solid var(--strong); outline-offset: 2px; border-radius: 0.6rem; }
.dash-subject-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem 0.6rem; }
.dash-subject-head .subject-icon { font-size: 1.4rem; }
.dash-subject-name { font-size: 1.05rem; }
.dash-subject-meta { font-size: 0.85rem; }
.dash-subject .dash-counts { color: var(--ink); }
.dash-alert { justify-self: start; font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.6rem; border: 1px solid var(--error); border-radius: 999px; color: var(--error); background: var(--card); }
.dash-lists { list-style: none; margin: 0; padding: 0 0.9rem 0.8rem; display: grid; gap: 0.6rem; }
.dash-lists .dash-set { padding: 0.55rem 0.7rem; background: var(--card); color: var(--text); border-radius: 0.6rem; }
.dash-lists .dash-counts { color: var(--muted); }


/* ==========================================================================
   Mise en page v2 : téléphone d'abord, puis tablette, puis grand écran
   - moins de 1100 px : une colonne, sections « Accueil / Matière »
   - 1100 px et plus  : volet « enfants » à gauche, contenu en grille à droite
   ========================================================================== */

/* Largeur de la page selon l'écran affiché */
body[data-view="home"] #app { max-width: 90rem; }
body[data-view="quiz"] #app { max-width: 42rem; }
#app { padding-inline: 1rem; }
body[data-view="home"] .brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1rem; margin-bottom: 0.75rem; }
body[data-view="home"] .brand h1 { font-size: 1.5rem; }
body[data-view="home"] .tagline { margin: 0; }
@media (max-width: 599px) { body[data-view="home"] .tagline { display: none; } }

/* Bordures des champs et boutons : contraste suffisant */
input, select, textarea, button.secondary, .child-select, .child-delete, .item-delete, .quit, .choice, .tabs button {
  border-color: var(--border-strong);
}
select { min-height: 2.75rem; }
.item-delete { min-width: 2.75rem; min-height: 2.75rem; }
.quit { min-height: 2.75rem; }

/* Cartes */
.card, #sets-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1.25rem;
}
.card > h3:first-child, #sets-panel > h2:first-child { margin-top: 0; }

/* Page d'accueil : plus de grande carte unique, des cartes dans une grille */
#view-home { background: none; border: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.rail { display: contents; }
#children-box { order: 1; }
.sections { order: 2; }
.content { order: 3; }
#view-home .share-box { order: 4; margin: 0; }
.account { order: 5; }

/* Volet « Mes enfants » */
#children-box { background: var(--card); border: 1px solid var(--border); border-radius: 0.875rem; padding: 0 1.25rem; }
#children-box > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-height: 3.25rem; font-weight: 700; cursor: pointer; list-style: none;
}
#children-box > summary::-webkit-details-marker { display: none; }
#children-box > summary::after { content: '\25BE'; color: var(--muted); }
#children-box[open] > summary::after { content: '\25B4'; }
#children-box[open] > summary { border-bottom: 1px solid var(--border); }
.sum-active { margin-left: auto; color: var(--accent); }
.box-body { padding: 0.5rem 0 1.25rem; }
.box-body .children { margin-top: 0.25rem; }
.box-body label:first-child { margin-top: 0.25rem; }

.account { display: flex; flex-direction: column; gap: 0.5rem; }
.account .whoami { font-size: 0.9rem; overflow-wrap: anywhere; }
#logout { margin-top: 0; }

/* Sections Accueil / Matière (téléphone et tablette) */
.sections {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  position: sticky; top: 0; z-index: 5; padding: 0.5rem 0; background: var(--bg);
}
.sections button {
  min-height: 3rem; font: inherit; font-weight: 700; color: var(--muted);
  background: var(--card); border: 2px solid var(--border-strong); border-radius: 0.75rem; cursor: pointer;
}
.sections button[aria-current="page"] { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

.content { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
@media (max-width: 1099px) {
  #view-home[data-tab="home"] #sets-panel { display: none; }
  #view-home[data-tab="matiere"] #quiz-hero,
  #view-home[data-tab="matiere"] #dashboard-panel { display: none; }
}

/* Bandeau « Réviser » */
.hero {
  background: var(--hero-bg); color: var(--hero-text); border: 0; border-radius: 1rem;
  padding: 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem;
}
.hero-text { flex: 1 1 18rem; min-width: 0; }
.hero h2 { margin: 0; font-size: 1.4rem; line-height: 1.25; letter-spacing: -0.01em; }
.hero p { margin: 0.5rem 0 0; color: var(--hero-muted); }
.hero-form { flex: 1 1 24rem; display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.hero-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; }
.hero label { margin: 0 0 0.25rem; font-size: 0.85rem; color: var(--hero-text); }
.hero select { border-color: transparent; background: var(--card); color: var(--text); }
.quiz-options > summary {
  display: flex; align-items: center; min-height: 2.75rem; font-weight: 600; cursor: pointer; color: var(--hero-text);
}
.quiz-options[open] > summary { margin-bottom: 0.25rem; }
.cta {
  min-height: 3.25rem; font: inherit; font-size: 1.1rem; font-weight: 800;
  color: var(--cta-text); background: var(--cta); border: 0; border-radius: 0.75rem; cursor: pointer;
}
.cta:focus-visible { outline-color: var(--hero-text); }

/* Tableau de bord : cartes qui s'adaptent à la largeur disponible */
#dashboard-panel { margin: 0; border: 0; }
#dashboard-heading { margin: 0 0 0.75rem; }
/* Cartes rangées en colonnes qui se remplissent de haut en bas : pas de trou quand une carte
   (ex. « Par liste ») est beaucoup plus haute que sa voisine. L'ordre du HTML = ordre de lecture. */
.widgets { columns: 17rem 2; column-gap: 1rem; }
.widgets > section { margin: 0 0 1rem; break-inside: avoid; }
.widgets h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.widgets-notes { column-span: all; }
.widgets-notes .hint { margin: 0.25rem 0 0; }
.rate { margin: 0; font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.week { margin: 0.5rem 0 0; font-weight: 400; color: var(--muted); }
.widgets .dash-sets { margin: 0; }
.item .status:last-of-type { margin-left: auto; }

/* Grand écran : volet à gauche, contenu en deux colonnes */
@media (min-width: 1100px) {
  #app { padding-inline: 1.5rem; }
  #view-home { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
  .rail { display: flex; flex-direction: column; gap: 1rem; grid-column: 1; grid-row: 1; position: sticky; top: 1rem; }
  .content { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
  .sections { display: none; }
  #children-box > summary { pointer-events: none; cursor: default; }
  #children-box > summary::after, .sum-active { display: none; }
  .quiz-options > summary { display: none; }
  #quiz-hero { grid-column: 1 / -1; }
  #dashboard-panel { grid-column: 1; grid-row: 2; }
  #sets-panel { grid-column: 2; grid-row: 2; }
  .hero h2 { font-size: 1.6rem; }
}

/* Retouches après revue visuelle */
#dashboard-message:empty { display: none; }
#dashboard-panel > .hint[hidden] { display: none; }
.quiz-options .hero-fields > .field:first-child { grid-column: 1 / -1; } /* « Niveau » a des libellés longs */
.quiz-options > summary::after { content: '\25BE'; margin-left: 0.5rem; }
.quiz-options[open] > summary::after { content: '\25B4'; }
@media (min-width: 1100px) {
  #dashboard-heading { margin-top: 1.25rem; }
  #sets-panel { margin-top: 0; }
}

/* Email de confirmation : bloc « Renvoyer » sous le message du formulaire */
.confirm-box { margin-top: 0.75rem; padding: 0.75rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; }
.confirm-box p { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.95rem; }
.confirm-box button { margin-top: 0; }

/* Suppression de compte : discrète tant qu'on ne la demande pas */
.link-danger {
  align-self: flex-start; margin: 0; min-height: 2.75rem; padding: 0 0.25rem;
  font: inherit; font-size: 0.9rem; color: var(--error); background: none; border: 0;
  text-decoration: underline; cursor: pointer;
}
.delete-panel { padding: 0.75rem 1rem; background: var(--card); border: 1px solid var(--error); border-radius: 0.75rem; }
.delete-panel p { margin: 0 0 0.5rem; }
.delete-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.delete-actions button { flex: 1 1 10rem; margin-top: 0; min-height: 2.75rem; }
.delete-actions button.danger { color: #fff; background: var(--error); border: 1px solid var(--error); font-weight: 700; border-radius: 0.5rem; cursor: pointer; font: inherit; font-weight: 700; padding: 0.65rem 1rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .delete-actions button.danger { color: #14213d; } }

/* Pied de page et page « Vie privée » */
.site-footer { margin-top: 1.5rem; padding: 1rem 0 1.5rem; text-align: center; font-size: 0.9rem; }
.site-footer a, .legal a { color: var(--muted); }
body[data-view="quiz"] .site-footer { display: none; }
#app.legal { max-width: 44rem; padding-inline: 1rem; }
.legal-card { margin-bottom: 1rem; }
.legal-card h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.legal-card p, .legal-card li { line-height: 1.55; }
.legal-card ul { padding-left: 1.25rem; margin: 0.5rem 0; }

/* Mot de passe oublié */
.auth-links { margin: 0.5rem 0 0; }
button.link {
  margin: 0; min-height: 2.75rem; padding: 0 0.25rem; font: inherit; font-size: 0.95rem;
  color: var(--accent); background: none; border: 0; text-decoration: underline; cursor: pointer;
}
#view-recovery h2 { margin-top: 0; }

/* Phrases à compléter : le trou bien visible dans la question */
.blank {
  display: inline-block; min-width: 3.5ch; margin-inline: 0.15em; padding: 0 0.4em;
  text-align: center; color: var(--accent); border-bottom: 3px solid var(--accent); letter-spacing: 0.1em;
}

/* Série de jours */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.25rem; list-style: none; margin: 0.75rem 0 0; padding: 0; }
.dot { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; min-width: 0; font-size: 0.8rem; color: var(--muted); }
/* Le cercle suit la largeur de sa colonne (max 2,25 rem) : il ne peut plus dépasser de la carte. */
.dot-mark {
  display: grid; place-items: center; width: 100%; max-width: 2.25rem; aspect-ratio: 1; border-radius: 50%;
  border: 2px solid var(--border-strong); font-weight: 800; color: var(--accent-text);
}
.dot.done .dot-mark { background: var(--ok); border-color: var(--ok); }
.streak-note { margin: 0.75rem 0; padding: 0.6rem 0.9rem; font-weight: 700; color: var(--ok); background: var(--card); border: 2px solid var(--ok); border-radius: 0.75rem; }

/* ==========================================================================
   Espace parent / mode enfant (voir js/parentLock.js)
   Verrouillé : seul ce qui sert à l'enfant reste visible (profils, « Réviser », série).
   Tout ce qui porte data-parent-only disparaît (et sort aussi de la navigation au clavier).
   ========================================================================== */
body[data-lock="locked"] [data-parent-only] { display: none !important; }
.lockbar {
  order: 0; display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 0.875rem; padding: 0.75rem 1.25rem;
}
.lock-status { margin: 0; font-weight: 700; }
.lockbar .message { margin: 0; }
body[data-lock="unlocked"] .lock-status { color: var(--ok); }
.lockbar .message:empty { display: none; }

/* Étape 13 : consigne, indice, import */
.instruction { margin: 0.5rem 0 0; padding: 0.5rem 0.75rem; border-left: 4px solid var(--accent, #4f46e5); background: var(--surface-2, rgba(127,127,127,.12)); border-radius: 0.4rem; font-weight: 600; }
.sub-label { display: block; margin-top: 0.6rem; font-size: 0.9rem; }
.import-box { margin-top: 1rem; border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.5rem 0.75rem; }
.import-box > summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; min-height: 2.75rem; }
.import-box textarea { width: 100%; }
#instruction-form { margin: 0.4rem 0; }
#instruction-form button { width: auto; margin-top: 0; white-space: nowrap; }

/* CAPTCHA : la case n'apparaît que si Cloudflare demande une vérification */
.captcha-box { position: fixed; inset: auto 0 1rem 0; z-index: 50; display: flex; justify-content: center; pointer-events: none; }
.captcha-box > * { pointer-events: auto; }
.captcha-box:empty { display: none; }

/* Sciences exactes : énoncés à plusieurs lignes, touches de symboles, méthode pas à pas */
.prompt.multiline { white-space: pre-line; font-size: 1.3rem; line-height: 1.4; }
.symbols { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.symbols[hidden] { display: none; }
.symbol {
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.75rem;
  font: inherit; font-size: 1.2rem; font-weight: 700;
  color: var(--text); background: var(--bg);
  border: 2px solid var(--border-strong); border-radius: 0.6rem; cursor: pointer;
}
.symbol:hover { border-color: var(--accent); }
.help { margin: 0.5rem 0 1rem; padding: 0.6rem 0.8rem; border-left: 4px solid var(--accent); background: var(--card); border-radius: 0.3rem; }
#quiz-help-btn { margin: 0 0 0.75rem; }
.method { margin: 0.75rem 0; padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--card); }
.method > summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.method ol { margin: 0.25rem 0 0.5rem; padding-left: 1.4rem; line-height: 1.5; overflow-wrap: anywhere; }
.method li { margin-bottom: 0.35rem; }
.method > summary::before { content: '\25B8'; margin-right: 0.5rem; }
.method[open] > summary::before { content: '\25BE'; }

/* ---------- Matières : une couleur par matière, tuiles puis listes ---------- */
/* Chaque matière définit une teinte (--h). Les autres couleurs en sont déduites, en clair comme en sombre.
   La matière est toujours écrite en toutes lettres : la couleur ne porte jamais seule l'information. */
.subj {
  --h: 215; --sat: 85%; --sat2: 65%;
  --soft: hsl(var(--h) var(--sat) 94%);
  --edge: hsl(var(--h) var(--sat2) 72%);
  --strong: hsl(var(--h) var(--sat2) 38%);
  --ink: hsl(var(--h) 70% 20%);
}
@media (prefers-color-scheme: dark) {
  .subj {
    --sat: 38%; --sat2: 75%;
    --soft: hsl(var(--h) var(--sat) 22%);
    --edge: hsl(var(--h) 40% 40%);
    --strong: hsl(var(--h) var(--sat2) 72%);
    --ink: hsl(var(--h) 80% 93%);
  }
}
.subj-maths { --h: 225; }
.subj-physique { --h: 255; }
.subj-chimie { --h: 170; }
.subj-biologie { --h: 125; }
.subj-francais { --h: 350; }
.subj-neerlandais { --h: 25; }
.subj-anglais { --h: 335; }
.subj-histoire { --h: 270; }
.subj-geographie { --h: 85; }
.subj-religion { --h: 45; }
.subj-informatique { --h: 200; }
.subj-latin { --h: 10; --sat: 60%; --sat2: 45%; }
.subj-arts { --h: 300; }
.subj-custom { --h: 215; }
.subj-autre { --h: 215; --sat: 12%; --sat2: 14%; }

.subject-grid { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; }

.subject-tile {
  width: 100%; min-height: 7.5rem; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 0.35rem;
  padding: 0.9rem; font: inherit; text-align: left; color: var(--ink); background: var(--soft);
  border: 2px solid var(--edge); border-radius: 1rem; cursor: pointer;
}
.subject-tile.empty { border-style: dashed; }
.subject-tile:hover { border-color: var(--strong); }
.subject-tile:focus-visible, .back:focus-visible { outline: 3px solid var(--strong); outline-offset: 2px; }
.subject-icon { font-size: 1.9rem; line-height: 1; }
.subject-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.subject-meta { font-size: 0.85rem; }

.back {
  display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.75rem; padding: 0.4rem 1rem; margin-bottom: 0.75rem;
  font: inherit; font-weight: 600; color: var(--text); background: transparent;
  border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer;
}
.back:hover { border-color: var(--strong); }

.subject-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; padding: 0.8rem 1rem; margin-bottom: 0.5rem;
  color: var(--ink); background: var(--soft); border: 2px solid var(--edge); border-left: 0.6rem solid var(--strong); border-radius: 1rem;
}
.subject-banner h3 { margin: 0; font-size: 1.25rem; }
.subject-banner h3:focus { outline: none; }
.subject-count { margin-left: auto; font-size: 0.85rem; }
#subject-view .child-select[aria-pressed="true"] { border-color: var(--strong); }
.subject-move { align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.subject-move .sub-label { margin: 0; }
.subject-move select { flex: 1; min-width: 10rem; }

@media (prefers-reduced-motion: no-preference) {
  .subject-tile { transition: transform 0.15s, border-color 0.15s; }
  .subject-tile:hover { transform: translateY(-2px); }
  #subject-view:not([hidden]), #subjects-home:not([hidden]) { animation: subject-in 0.2s ease-out; }
  @keyframes subject-in { from { opacity: 0; transform: translateY(6px); } }
}

button.secondary.danger { color: var(--error); border-color: var(--error); font-weight: 700; }

/* Champ mot de passe avec « œil » */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3rem; }
.pw-toggle { position: absolute; top: 0; right: 0; width: 2.75rem; height: 100%; min-height: 2.75rem; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 0 0.5rem 0.5rem 0; cursor: pointer; }
.pw-toggle:hover { color: var(--text); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); }

/* Ajout d'une matière */
.subject-tile.subject-add { color: var(--text); background: transparent; border-style: dashed; border-color: var(--border-strong); align-items: center; justify-content: center; text-align: center; }
.subject-add .subject-icon { font-size: 1.6rem; }
.pick-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.pick { min-width: 2.75rem; min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: 1.3rem; background: var(--card); border: 2px solid var(--border); border-radius: 0.6rem; cursor: pointer; }
.pick[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pick.hue { width: 2.75rem; padding: 0; background: hsl(var(--h) 70% 55%); }
.pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Formulaire d'avis (avis.html) */
.fb-group { margin: 1.25rem 0 0; padding: 0; border: 0; min-width: 0; }
.fb-group legend { padding: 0; margin-bottom: 0.5rem; font-weight: 600; }
.fb-group legend .hint { font-weight: 400; }
.fb-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fb-pill { position: relative; margin: 0; font-weight: 500; }
.fb-pill input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.fb-pill span { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0.4rem 0.9rem; background: var(--card); border: 2px solid var(--border-strong); border-radius: 0.6rem; }
.fb-pill input:checked + span { color: var(--accent-text); background: var(--accent); border-color: var(--accent); font-weight: 700; }
.fb-pill input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.legal-card .fb-title { margin: 2rem 0 0; font-size: 1.15rem; }
.fb-checks { margin-top: 1.5rem; }
.fb-check { display: flex; align-items: flex-start; gap: 0.6rem; margin: 0.5rem 0; font-weight: 500; }
.fb-check input { width: 1.25rem; height: 1.25rem; margin: 0.15rem 0 0; flex: none; }

/* Invitation à un autre parent */
.share-box { margin: 1.5rem 0; padding: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; }
.legal-card .share-box { background: var(--bg); }
.share-box h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.share-box textarea { margin-top: 0.5rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.share-actions button { flex: 1; min-width: 9rem; }
.share-actions button[hidden] { display: none; }
