/* Jàngi : une page de cahier. Trait rouge de marge pour le tuteur, bulles à l'encre pour l'élève. */
:root {
  --paper: #f6f8fc; --sheet: #ffffff; --ink: #16224a; --ink-soft: #55608a; --line: #d5dcee;
  --accent: #1f47c9; --accent-ink: #ffffff; --margin: #d6324a; --ok-bg: #e2f4ea; --ok-ink: #135a3d;
  --warn-bg: #fff3d6; --warn-ink: #6b4a00; --chip: #e8edfa;
  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1424; --sheet: #171d33; --ink: #e8ecfa; --ink-soft: #9aa5cc; --line: #2c3557;
    --accent: #8aa6ff; --accent-ink: #0b1230; --margin: #ff7a8c; --ok-bg: #123a2a; --ok-ink: #9fe3c2;
    --warn-bg: #3a2f10; --warn-ink: #ffdf99; --chip: #222b4a; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
body.plein, body.plein html { height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 860px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
body.plein .app { height: 100dvh; padding-bottom: 12px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; letter-spacing: -0.02em; line-height: 1; color: var(--ink); text-decoration: none; }
.brand span { color: var(--margin); }
.sortie { margin-left: auto; }
.lien { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; padding: 0; font-size: 0.85rem; }
.pupils { display: flex; gap: 6px; flex: 1 1 auto; min-width: 0; overflow-x: auto; }
.pupil { border: 1.5px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 6px 14px; display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; color: var(--ink); white-space: nowrap; }
.pupil b { font-family: var(--font-display); font-weight: 600; }
.pupil small { color: var(--ink-soft); font-size: 0.75rem; }
.pupil[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pupil[aria-current="page"] small { color: var(--accent-ink); opacity: 0.85; }
.tools { display: flex; gap: 6px; }
.btn { border: 1.5px solid var(--line); background: var(--sheet); border-radius: 10px; padding: 7px 12px; text-decoration: none; color: var(--ink); display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn:disabled, .chip:disabled { opacity: 0.5; cursor: default; }

.subjects, .quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; border: 0; background: var(--chip); border-radius: 999px; padding: 5px 12px; font-size: 0.9rem; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 700; }
.quick .chip { background: transparent; border: 1.5px dashed var(--line); }

.page { flex: 1 1 auto; min-height: 0; overflow-y: auto; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.page.statique { border: 0; padding: 12px 0 0; overflow: visible; }
.msg { max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
.msg.tutor { border-left: 2.5px solid var(--margin); padding-left: 14px; }
.msg.tutor .who { font-family: var(--font-display); font-weight: 600; font-size: 0.8rem; color: var(--margin); text-transform: uppercase; letter-spacing: 0.06em; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; padding: 8px 12px; max-width: 85%; white-space: pre-wrap; }
.msg.me a { color: var(--accent-ink); }
.msg.note { align-self: center; color: var(--ink-soft); font-size: 0.85rem; text-align: center; }
.msg.err, .flash.error { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 8px 12px; }
.body > :first-child { margin-top: 4px; } .body > :last-child { margin-bottom: 0; }
.body p, .body ul, .body ol { margin: 0.5em 0; } .body ul, .body ol { padding-left: 1.3em; }
.body h1, .body h2, .body h3, .body h4 { font-family: var(--font-display); font-size: 1.05rem; margin: 0.8em 0 0.3em; text-wrap: balance; }
.body pre, .body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
.body pre { background: var(--chip); padding: 10px; border-radius: 8px; white-space: pre-wrap; }
.body .tw { overflow-x: auto; }
.body table { border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.body th, .body td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.plain { white-space: pre-wrap; }
.welcome h2 { font-family: var(--font-display); font-size: 1.25rem; margin: 0 0 4px; text-wrap: balance; }

.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1 1 auto; min-width: 0; resize: none; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 12px; padding: 10px 12px; min-height: 46px; max-height: 160px; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-soft); }
.foot form { margin-left: auto; }

.flashs { display: flex; flex-direction: column; gap: 6px; }
.flash { margin: 0; border-radius: 10px; padding: 8px 12px; background: var(--chip); }
.flash.success { background: var(--ok-bg); color: var(--ok-ink); }

.carte { background: var(--sheet); border: 1.5px solid var(--line); border-radius: 14px; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.carte.etroit { max-width: 460px; width: 100%; margin: 24px auto 0; }
.carte h1 { font-family: var(--font-display); font-size: 1.5rem; margin: 0; text-wrap: balance; }
.carte h1 small { font-size: 0.9rem; color: var(--ink-soft); font-weight: 600; }
.aide, .helptext { color: var(--ink-soft); margin: 0; font-size: 0.9rem; }
.formulaire { display: flex; flex-direction: column; gap: 12px; }
.formulaire.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.formulaire.grille .actions, .formulaire.grille > div:has(textarea) { grid-column: 1 / -1; }
.formulaire > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.formulaire label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-soft); }
.formulaire input, .formulaire select, .formulaire textarea { border: 1.5px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 10px; width: 100%; }
.formulaire .carnet { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.errorlist { color: var(--margin); margin: 0; padding-left: 1.1em; font-size: 0.9rem; }
.actions { display: flex; flex-direction: row !important; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.liste-eleves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.liste-eleves li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; border-top: 1.5px solid var(--line); padding-top: 10px; }
.liste-eleves .eleve { text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: 8px; }
.liste-eleves .eleve b { font-family: var(--font-display); font-size: 1.2rem; }
.liste-eleves .eleve small { color: var(--ink-soft); }
.liste-eleves .liens { grid-column: 1 / -1; font-size: 0.9rem; }
.seance-passee { border-top: 1.5px solid var(--line); padding-top: 10px; }
.seance-passee summary { cursor: pointer; font-weight: 700; }

/* Suivi */
.carte h2 { font-family: var(--font-display); font-size: 1.1rem; margin: 6px 0 0; }
.plan { margin: 4px 0; padding-left: 1.2em; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.chiffres div { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.chiffres dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); font-weight: 700; }
.chiffres dd { margin: 0; font-family: var(--font-display); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.matiere { border-top: 1.5px solid var(--line); padding-top: 8px; }
.matiere summary { cursor: pointer; font-weight: 700; }
.matiere summary .aide { font-weight: 400; margin-left: 6px; }
.tw { overflow-x: auto; }
.suivi { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-variant-numeric: tabular-nums; margin-top: 6px; }
.suivi th, .suivi td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.suivi th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
.etat { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 0.8rem; font-weight: 700; background: var(--chip); white-space: nowrap; }
.etat.acquis { background: var(--ok-bg); color: var(--ok-ink); }
.etat.fragile, .etat.a_reprendre { background: var(--warn-bg); color: var(--warn-ink); }
.etat.pas_vu { font-weight: 400; color: var(--ink-soft); background: transparent; padding-left: 0; }
.liste-eleves li > .btn { justify-self: end; }

/* Jeu : niveau, points, objectif du jour */
.jeu { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 0.85rem; color: var(--ink); text-decoration: none; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.jeu-barre { flex: 1 1 80px; min-width: 60px; height: 8px; border-radius: 999px; background: var(--chip); overflow: hidden; display: block; }
.jeu-barre i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.6s ease; }
.jeu-barre.large { height: 12px; flex: none; width: 100%; }
.jeu-points { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.jeu-objectif, .jeu-serie { background: var(--chip); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.jeu-objectif.atteint { background: var(--ok-bg); color: var(--ok-ink); font-weight: 700; }
.qcm { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.btn.choix { text-align: left; border-color: var(--accent); }
.btn.choix b { display: inline-block; min-width: 1.6em; color: var(--accent); font-family: var(--font-display); }
.btn.choix:hover { background: var(--chip); }
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 20; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 8px 18px; font-family: var(--font-display); font-weight: 600; box-shadow: 0 6px 20px rgba(10, 14, 30, 0.25); text-align: center; }
.toast.fort { background: var(--accent); color: var(--accent-ink); font-size: 1.05rem; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast 0.35s cubic-bezier(.2, 1.4, .4, 1); }
  @keyframes toast { from { transform: translateY(-16px) scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
}
.niveau { display: flex; align-items: center; gap: 14px; }
.niveau-texte { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.medaille { flex: 0 0 auto; width: 2.2em; height: 2.2em; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--chip); color: var(--ink-soft); font-family: var(--font-display); font-weight: 800; }
.medaille.grande { width: 3.4em; height: 3.4em; font-size: 1.3rem; background: var(--accent); color: var(--accent-ink); }
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.badges li { display: flex; gap: 10px; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; opacity: 0.6; }
.badges li.ok { opacity: 1; border-color: var(--accent); }
.badges li.ok .medaille { background: var(--accent); color: var(--accent-ink); }
.activite { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; height: 130px; align-items: end; }
.activite .jour { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; font-size: 0.7rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.activite i { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.carte h2 small { font-size: 0.8rem; color: var(--ink-soft); font-weight: 400; }
.liste-fiches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.liste-fiches li { border-top: 1.5px solid var(--line); padding: 8px 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.pied { color: var(--ink-soft); font-size: 0.78rem; text-align: center; margin-top: 8px; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .top, .actions, .pied, .flashs, .toasts { display: none !important; }
  .app { max-width: none; padding: 0; }
  .carte { border: 0; padding: 0; }
  details.matiere:not([open]) { display: none; }
  .badges li:not(.ok) { display: none; }
  .suivi tr, .badges li { break-inside: avoid; }
}

/* Analyse, accès élève, abonnement */
ol.plan { padding-left: 1.4em; }
.conseils { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.conseils li { border-left: 4px solid var(--line); background: var(--chip); border-radius: 6px; padding: 6px 10px; }
.conseils li.alerte { border-color: var(--margin); background: var(--warn-bg); color: var(--warn-ink); }
.conseils li.bien { border-color: var(--ok-ink); background: var(--ok-bg); color: var(--ok-ink); }
.erreurs { display: flex; flex-direction: column; gap: 6px; }
.erreurs .ligne { display: grid; grid-template-columns: 9em minmax(0, 1fr) 3.2em; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.liste-eleves .alerte, .liste-eleves .code { grid-column: 1 / -1; font-size: 0.9rem; }
.liste-eleves .alerte { background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 4px 8px; }
.liste-eleves .code b { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.12em; font-size: 1rem; }
.plein-largeur { grid-column: 1 / -1; }
.regles { white-space: pre-wrap; font-size: 0.8rem; background: var(--chip); padding: 10px; border-radius: 8px; overflow-x: auto; }
